From 68be8844ddc1e30e34745a0589fa3395ae6ec198 Mon Sep 17 00:00:00 2001 From: HumairAK Date: Thu, 21 Jul 2016 04:58:24 -0400 Subject: Added templating for questions, made a minor adjustments to index.js --- node_simple.js | 4 ++-- routes/index.js | 13 ++-------- views/exams.hbs | 2 +- views/questions.hbs | 68 ++++++++++------------------------------------------- 4 files changed, 18 insertions(+), 69 deletions(-) diff --git a/node_simple.js b/node_simple.js index b611302..1542b83 100644 --- a/node_simple.js +++ b/node_simple.js @@ -54,8 +54,8 @@ var mongoFactory = require('mongo-factory'); var ObjectId = require('mongodb').ObjectID; // Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname -//var uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo'; -var uri = 'mongodb://localhost:27017/db'; +var uri = 'mongodb://general:assignment4@ds057862.mlab.com:57862/solutions_repo'; +//var uri = 'mongodb://localhost:27017/db'; //***********************PRELIMINARY TESTING******************************************| diff --git a/routes/index.js b/routes/index.js index 52a0ca6..708e532 100644 --- a/routes/index.js +++ b/routes/index.js @@ -86,14 +86,6 @@ router.get('/search', function(req, res, next) { res.redirect('/exams/' + courseName); }); - -/* REDIRECT - exam -> questions page*/ -router.get('/exam_click',function (req,res) { - //TODO:get needs to have exam_id attached - var examId = req.query.exam_id; - res.redirect('/questions/'+examId); -}); - /*EXAMPLE DATA GIVEN BELOW: * questions = [{id,count,comments},{id,count,comments}] --> array of "question" objects * @@ -101,9 +93,10 @@ router.get('/exam_click',function (req,res) { * count= number of solutions * comments = number of comments*/ router.get('/questions/:exam_id', function (req,res) { + console.log(req.params.exam_id); dbFile.get_exam_info_by_ID(req.params.exam_id, function (questions) { - res.render('questions', {query: questions}); + console.log(questions); }); }); @@ -148,7 +141,6 @@ app.get('/exams.html', function (req,res) { res.sendFile(__dirname+'/exams.html'); });*/ - function getExamsForCourseCode(courseCode) { dbFile.get_all_exams(courseCode, function (exams) { if (exams.length == 0){ @@ -160,7 +152,6 @@ function getExamsForCourseCode(courseCode) { }); } - module.exports = router; function toProperCase(string) { diff --git a/views/exams.hbs b/views/exams.hbs index 5a5955c..d7697c3 100644 --- a/views/exams.hbs +++ b/views/exams.hbs @@ -2,7 +2,7 @@ -- cgit v1.2.3