aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authornanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-21 06:40:43 +0000
committernanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-21 06:40:43 +0000
commit39ef1b6fd37bb9b725676d3a98f13e3450798200 (patch)
treeeeec60d5b56e5c69a3ba251d98a27f4684d47066 /routes
parentee8e1a13b60a6adfdc691b2a9b57289188397641 (diff)
parent76757d227f64e35a093d47facc260d9266e2bf38 (diff)
MERGED
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/routes/index.js b/routes/index.js
index 99c73f1..52a0ca6 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -61,10 +61,11 @@ router.get('/exams/:id', function(req, res, next) {
//console.log(exams);
//only pass over the information that is necessary for the exams page
for (var i = 0; i<exams.length;i++){
+ var getInstructors = exams[i].instructors.join(", ");
var minExamInfo = { courseCode:exams[i].course_code,
year:exams[i].year,
term:toProperCase(exams[i].term),
- instructors:exams[i].instructors,
+ instructors: getInstructors,
type:toProperCase(exams[i].type) + " Examination",
title:exams[i].title,
id:exams[i]._id
@@ -74,7 +75,7 @@ router.get('/exams/:id', function(req, res, next) {
}
}
console.log(minExamInfoArray);
- res.render('exams', {query: minExamInfoArray});
+ res.render('exams', {query: req.params.id, result: minExamInfoArray});
});
});
@@ -85,6 +86,27 @@ 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
+ *
+ * id = questions number
+ * count= number of solutions
+ * comments = number of comments*/
+router.get('/questions/:exam_id', function (req,res) {
+ dbFile.get_exam_info_by_ID(req.params.exam_id, function (questions) {
+
+ res.render('questions', {query: questions});
+ });
+});
+
router.get('/signup', function(req, res, next) {
res.render('signup', {csrfToken: req.csrfToken()});
});