diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/index.js | 2 | ||||
| -rw-r--r-- | routes/user.js | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/routes/index.js b/routes/index.js index d8cfd36..23cd7c3 100644 --- a/routes/index.js +++ b/routes/index.js @@ -182,9 +182,11 @@ router.get('/questions/:exam_id', function (req,res) { */ router.get('/solutions/:exam_id/:q_num', function (req, res) { + console.log("index.js::Getting solutions"); var examID = req.params.exam_id; var qID = req.params.q_num; dbFile.get_all_solutions(examID, qID, function (solutions) { + console.log("index.js::GOT solutions"); solutions.forEach(function(soln){ soln.commentCount = soln.comments.length; }); diff --git a/routes/user.js b/routes/user.js index c466e3c..f5dab0c 100644 --- a/routes/user.js +++ b/routes/user.js @@ -257,10 +257,27 @@ router.post('/comment/submit/:examID/:qID/:solID', function(req, res, next){ } }); +router.post('/solution/vote/:examID/:qID/:solID', function(req, res, next){ + var vote = req.body.vote; + var examID = req.params.examID; + var qID = req.params.qID; + var solutionID = req.params.solID; + dbFile.vote_solution(solutionID, vote, function(voteCounted, statusMsg){ + if(voteCounted){ + console.log("Success!"); + }else{ + console.log("Action failed!"); + } + console.log(statusMsg); // Change to display message above + res.redirect('/solutions/' + examID + '/' + qID); + }); + + +}); + module.exports = router; /************** Route protection ********************/ - function loggedIn(req, res, next) { if (req.isAuthenticated()) { return next(); |
