diff options
| -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'> |
