aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node_simple.js4
-rw-r--r--routes/index.js13
-rw-r--r--views/exams.hbs2
-rw-r--r--views/questions.hbs68
4 files changed, 18 insertions, 69 deletions
diff --git a/node_simple.js b/node_simple.js
index b611302..1542b83 100644
--- a/node_simple.js
+++ b/node_simple.js
@@ -54,8 +54,8 @@ var mongoFactory = require('mongo-factory');
var ObjectId = require('mongodb').ObjectID;
// Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname
-//var uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo';
-var uri = 'mongodb://localhost:27017/db';
+var uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo';
+//var uri = 'mongodb://localhost:27017/db';
//***********************PRELIMINARY TESTING******************************************|
diff --git a/routes/index.js b/routes/index.js
index 52a0ca6..708e532 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -86,14 +86,6 @@ router.get('/search', function(req, res, next) {
res.redirect('/exams/' + courseName);
});
-
-/* REDIRECT - exam -> questions page*/
-router.get('/exam_click',function (req,res) {
- //TODO:get needs to have exam_id attached
- var examId = req.query.exam_id;
- res.redirect('/questions/'+examId);
-});
-
/*EXAMPLE DATA GIVEN BELOW:
* questions = [{id,count,comments},{id,count,comments}] --> array of "question" objects
*
@@ -101,9 +93,10 @@ router.get('/exam_click',function (req,res) {
* count= number of solutions
* comments = number of comments*/
router.get('/questions/:exam_id', function (req,res) {
+ console.log(req.params.exam_id);
dbFile.get_exam_info_by_ID(req.params.exam_id, function (questions) {
-
res.render('questions', {query: questions});
+ console.log(questions);
});
});
@@ -148,7 +141,6 @@ app.get('/exams.html', function (req,res) {
res.sendFile(__dirname+'/exams.html');
});*/
-
function getExamsForCourseCode(courseCode) {
dbFile.get_all_exams(courseCode, function (exams) {
if (exams.length == 0){
@@ -160,7 +152,6 @@ function getExamsForCourseCode(courseCode) {
});
}
-
module.exports = router;
function toProperCase(string) {
diff --git a/views/exams.hbs b/views/exams.hbs
index 5a5955c..d7697c3 100644
--- a/views/exams.hbs
+++ b/views/exams.hbs
@@ -2,7 +2,7 @@
<div class = 'search container' id = 'solutions-div'>
<h4 class='search-head'>Search results for "{{query}}"</h4>
{{# each result}}
- <a href="/questions">
+ <a href="/questions/{{this.id}}">
<section class = 'solutions-card'>
<h3 class = 'solutions-title'>{{this.title}}</h3>
<p class = 'solutions-time' ><em>Term: </em>{{this.term}} {{this.year}}</p>
diff --git a/views/questions.hbs b/views/questions.hbs
index 8b69f8f..ff9b3b2 100644
--- a/views/questions.hbs
+++ b/views/questions.hbs
@@ -17,65 +17,23 @@
<!-- QUESTION LISTINGS -->
- <a href="/user_solutions">
- <section class = 'solutions-card row'>
- <div class='pull-left col-sm-8 col-md-8'>
- <h3 class = 'questions-number'>Question 1</h3>
- <p><span class='questions-sol-num'>2 solutions, </span> <span class = 'questions-comment'>6 comments</span></p>
- </div>
- <div class='pull-right right-arrow'>
- <img class='rounded' src="assets/images/right-arrow.png">
- </div>
- </section>
- </a>
+ {{#each query}}
- <a href="/user_solutions">
- <section class = 'solutions-card row'>
- <div class='pull-left col-sm-8 col-md-8'>
- <h3 class = 'questions-number'>Question 2</h3>
- <p><span class='questions-sol-num'>1 solution, </span> <span class = 'questions-comment'>2 comments</span></p>
- </div>
- <div class='pull-right right-arrow'>
- <img class='rounded' src="assets/images/right-arrow.png">
- </div>
- </section>
- </a>
+ <a href="/user_solutions">
+ <section class = 'solutions-card row'>
+ <div class='pull-left col-sm-8 col-md-8'>
+ <h3 class = 'questions-number'>Question {{this.id}}</h3>
+ <p><span class='questions-sol-num'>{{this.count}} solutions, </span> <span class = 'questions-comment'>{{this.comments}} comments</span></p>
+ </div>
+ <div class='pull-right right-arrow'>
+ <img class='rounded' src="/assets/images/right-arrow.png">
+ </div>
+ </section>
+ </a>
- <a href="/user_solutions">
- <section class = 'solutions-card row'>
- <div class='pull-left col-sm-8 col-md-8'>
- <h3 class = 'questions-number'>Question 3</h3>
- <p><span class='questions-sol-num'>1 solution, </span> <span class = 'questions-comment'>2 comments</span></p>
- </div>
- <div class='pull-right right-arrow'>
- <img class='rounded' src="assets/images/right-arrow.png">
- </div>
+ {{/each}}
- </section>
- </a>
- <a href="/user_solutions">
- <section class = 'solutions-card row'>
- <div class='pull-left col-sm-8 col-md-8'>
- <h3 class = 'questions-number'>Question 4</h3>
- <p><span class='questions-sol-num'>3 solutions, </span> <span class = 'questions-comment'>2 comments</span></p>
- </div>
- <div class='pull-right right-arrow'>
- <img class='rounded' src="assets/images/right-arrow.png">
- </div>
- </section>
- </a>
- <a href="/user_solutions">
- <section class = 'solutions-card row'>
- <div class='pull-left col-sm-8 col-md-8'>
- <h3 class = 'questions-number'>Question 5</h3>
- <p><span class='questions-sol-num'>0 solutions </span> <span class = 'questions-comment'></span></p>
- </div>
- <div class='pull-right right-arrow'>
- <img class='rounded' src="assets/images/right-arrow.png">
- </div>
- </section>
- </a>
</div>
</main>