From 9246d7f66323ee10eed619e56d0613853f234354 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Wed, 4 Feb 2015 21:28:10 -0500 Subject: [PATCH] Hooked courseware up to mongo correctly, persisting solutions and configured controller to correctly pass user to next course or return to first if all are completed --- controllers/courseware.js | 8 +++++--- .../js/lib/coursewares/coursewaresFramework.js | 9 ++++++++- public/js/main.js | 17 +++++++++++++++++ seed_data/coursewares.json | 16 +++++++++++++++- views/coursewares/show.jade | 8 ++++---- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/controllers/courseware.js b/controllers/courseware.js index 912a12c412..76938d602b 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -37,6 +37,9 @@ exports.returnNextCourseware = function(req, res) { next(err); } courseware = courseware.pop(); + if (courseware === undefined) { + return res.redirect('../coursewares/intro'); + } nameString = courseware.name.toLowerCase().replace(/\s/g, '-'); return res.redirect('/coursewares/' + nameString); }); @@ -146,15 +149,14 @@ exports.generateChallenge = function(req, res) { }; exports.completedCourseware = function (req, res) { + debug('In post call with data from req', req); var isCompletedDate = Math.round(+new Date() / 1000); var coursewareHash = req.body.coursewareInfo.coursewareHash; req.user.completedCoursewares.push({ _id: coursewareHash, - completedWith: null, - completedDate: isCompletedDate, - solution: isSolution + completedDate: isCompletedDate }); var index = req.user.uncompletedCoursewares.indexOf(coursewareHash); diff --git a/public/js/lib/coursewares/coursewaresFramework.js b/public/js/lib/coursewares/coursewaresFramework.js index 18e4e9f53e..ba06db1afc 100644 --- a/public/js/lib/coursewares/coursewaresFramework.js +++ b/public/js/lib/coursewares/coursewaresFramework.js @@ -37,11 +37,18 @@ var libraryIncludes = "