diff options
| author | Waref Haque <warefhaque@inside-239-60.wireless.utoronto.ca> | 2016-07-27 00:25:57 +0000 |
|---|---|---|
| committer | Waref Haque <warefhaque@inside-239-60.wireless.utoronto.ca> | 2016-07-27 00:25:57 +0000 |
| commit | 20220f9c3cf0cf8e1efbe850aba4a99f23d9a0cb (patch) | |
| tree | 0feee3c28b6b3d08668882f981542f76bc2d74b3 | |
| parent | 25706820837bd05cdc3b186eb1d5ebabf9688a61 (diff) | |
follow_exam
| -rw-r--r-- | routes/user.js | 16 | ||||
| -rw-r--r-- | views/questions.hbs | 18 |
2 files changed, 34 insertions, 0 deletions
diff --git a/routes/user.js b/routes/user.js index 5ddd4b8..22a30a4 100644 --- a/routes/user.js +++ b/routes/user.js @@ -339,6 +339,22 @@ router.post('/solution/vote/:examID/:qID/:solID', function(req, res, next){ }); +router.post('/follow_exam/:examID',function (req, res) { + + console.log("ENTERED THE FUNCTION FOLLOW EXAM!!"); + var examId = req.params.examID; + + if (req.isAuthenticated()){ + console.log("Exam Id follow exam: " + examId); + console.log("Username follow exam: " + req.user.user_name); + }else{ + var message = "Must be logged in to follow an exam!"; + req.session.messages = {error : message}; + res.redirect('/questions/' + examID); + } +}); + + module.exports = router; /************** Route protection ********************/ diff --git a/views/questions.hbs b/views/questions.hbs index 4b40d33..e5bf21d 100644 --- a/views/questions.hbs +++ b/views/questions.hbs @@ -3,6 +3,24 @@ <!-- EXAM DETAILS --> + <form action="/user/follow_exam/{{../examInfo.id}}" method = 'post'> + <input type="hidden" name="_csrf" value="{{ csrfToken }}"> + <button class="col-xs-4 col-sm-2 col-md-2 col-lg-2 + col-xs-offset-4 col-sm-offset-5 col-md-offset-2 + col-lg-offset-2 rounded" id="add-solution" type="submit"> + <h3>Follow Exam</h3> + </button> + </form> + + <!--<a href="/user/follow_exam/{{../examInfo.id}}">--> + <!--<button class="col-xs-4 col-sm-2 col-md-2 col-lg-2--> + <!--col-xs-offset-4 col-sm-offset-5 col-md-offset-2--> + <!--col-lg-offset-2 rounded" id="add-solution">--> + <!--<h3>Follow Exam</h3>--> + <!--</button>--> + <!--</a>--> + + <a href="http://www.cs.toronto.edu/~fpitt/CSC148/20131/tests/test1-0101.pdf" target='_blank'><img src="/assets/images/exam.png" class='exam-img img-responsive exam-info'></a> <section class='exam-info'> |
