diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-27 00:18:22 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-27 00:18:22 +0000 |
| commit | 38594fd274a4bebee75ae71dbed457b39d253cae (patch) | |
| tree | 52600020d82067ed66975f137c9ce7920a83aa90 /routes | |
| parent | b65166302f5296165da115ed96ce112433157a2d (diff) | |
fixed false exam path search for solutions, minor change to db function
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/index.js | 17 |
1 files changed, 11 insertions, 6 deletions
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}); + } + }); }); |
