From daefddd8dc45e7044e83bd40706cfdca36471fe9 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Tue, 19 Jul 2016 00:21:17 -0400 Subject: proper exams rendering --- routes/index.js | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index 457fbd1..1406143 100644 --- a/routes/index.js +++ b/routes/index.js @@ -28,9 +28,46 @@ router.get('/questions', function(req, res, next) { }); /* Render/GET exam page */ -router.get('/exams/:id', function(req, res, next) { +/* Render/GET exam page */ +//EXAMPLE EXPECTED DATA GIVEN BELOW: +/*[ { courseCode: 'CSC240', + year: 2016, + term: 'Fall', + instructors: [ 'Faith Ellen', 'Tom F.' ], + type: 'Midterm Examination', + title: 'Thry of Computation' }, + { courseCode: 'CSC240', + year: 2014, + term: 'Fall', + instructors: [ 'Faith Ellen', 'Tom F.' ], + type: 'Midterm Examination', + title: 'Thry of Computation' } ] + */ - res.render('exams', {query: req.params.id}); +router.get('/exams/:id', function(req, res, next) { + var minExamInfoArray = []; + dbFile.get_all_exams(req.params.id, function (exams) { + if (exams.length == 0){ + console.log("Nothing was found"); + } + else { + //console.log(exams); + //only pass over the information that is necessary for the exams page + for (var i = 0; i Date: Tue, 19 Jul 2016 19:21:20 -0400 Subject: added the id to exams passed --- routes/index.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index 1406143..72e6c5b 100644 --- a/routes/index.js +++ b/routes/index.js @@ -59,7 +59,8 @@ router.get('/exams/:id', function(req, res, next) { term:toProperCase(exams[i].term), instructors:exams[i].instructors, type:toProperCase(exams[i].type) + " Examination", - title:exams[i].title + title:exams[i].title, + id:exams[i]._id }; //console.log(minExamInfo); minExamInfoArray.push(minExamInfo); @@ -91,18 +92,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){ - console.log("Nothing was found"); - } - else { - console.log(exams); - } - }); -} - module.exports = router; function toProperCase(string) { -- cgit v1.2.3