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