From 38594fd274a4bebee75ae71dbed457b39d253cae Mon Sep 17 00:00:00 2001 From: HumairAK Date: Tue, 26 Jul 2016 20:18:22 -0400 Subject: fixed false exam path search for solutions, minor change to db function --- routes/index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index f8292fc..219b7b7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -232,12 +232,17 @@ router.get('/questions/:exam_id', function (req,res) { router.get('/solutions/:exam_id/:q_num', function (req, res) { var examID = req.params.exam_id; var qID = req.params.q_num; - dbFile.get_all_solutions(examID, qID, function (solutions) { - solutions.forEach(function(soln){ - soln.commentCount = soln.comments.length; - }); - res.render('user_solutions', {query: solutions, examID: examID, qID: qID, csrfToken: req.csrfToken()}); - req.session.messages = null; + dbFile.get_all_solutions(examID, qID, function (success, failure, message, solutions) { + if(success){ + solutions.forEach(function(soln){ + soln.commentCount = soln.comments.length; + }); + res.render('user_solutions', {query: solutions, examID: examID, qID: qID, csrfToken: req.csrfToken()}); + req.session.messages = null; + } else{ + res.render('error', {error : message}); + } + }); }); -- cgit v1.2.3