From 42d17334a8915bb8f5e7c605a38dac56462499b1 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Fri, 22 Jul 2016 16:58:59 -0400 Subject: solutions given the exam_id and the questions number --- routes/index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index a0a66d0..1b00f41 100644 --- a/routes/index.js +++ b/routes/index.js @@ -145,7 +145,33 @@ router.get('/questions/:exam_id', function (req,res) { }); }); - +/*GET the solutions for a given exam given the question number and the exam_id*/ +/*EXPECTED DATA GIVEN BELOW: +array of solutions: +* solutions = [ { + * _id: "354ff71ed078933079d6467e" + * exam_id: "578a44ff71ed097fc3079d6e" + * q_id: 1 (int) + * text: "answer" + * votes: 1 (int) + * comments: [{}.{}] (just going to be string for now i think) + * } + * { + * _id: ... + * exam_id: .. + * q_id: ... + * text: .. + * votes: .. + * comments: .. + * + * } + * ]*/ +router.get('/solutions/:exam_id/:q_num', function (req, res) { + dbFile.get_all_solutions(req.params.exam_id,req.params.q_num,function (solutions) { + res.render('solutions', {query: solutions}); + console.log(solutions); + }); +}); /**** Helpers ****/ -- cgit v1.2.3 From 1da28e930df1438fee1528c4dbb2c024fc3824e7 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Fri, 22 Jul 2016 17:41:07 -0400 Subject: add solutions --- routes/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routes/index.js b/routes/index.js index 1b00f41..97291a7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -173,6 +173,14 @@ router.get('/solutions/:exam_id/:q_num', function (req, res) { }); }); +router.get('/add_solution',function (req, res) { + redirect('/add_solutions_page'); +}); + + +router.post('/add_solutions/submit', function (req, res) { + //TODO: get the form information for the solutions +}) /**** Helpers ****/ function getExamsForCourseCode(courseCode) { -- cgit v1.2.3