diff --git a/controllers/courseware.js b/controllers/courseware.js index 541586899c..82987ea7a7 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -285,20 +285,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) { } pairedWith = pairedWith.pop(); - index = pairedWith.uncompletedCoursewares.indexOf(coursewareHash); - if (index > -1) { - pairedWith.progressTimestamps.push(Date.now() || 0); - pairedWith.uncompletedCoursewares.splice(index, 1); - } - - pairedWith.completedCoursewares.push({ - _id: coursewareHash, - completedWith: req.user._id, - completedDate: isCompletedDate, - solution: solutionLink, - githubLink: githubLink - }); req.user.completedCoursewares.push({ _id: coursewareHash, @@ -312,6 +299,27 @@ exports.completedZiplineOrBasejump = function (req, res, next) { if (err) { return next(err); } + debug('this is the user object returned %s,' + + ' this is the req.user._id %s, ' + + 'this is the pairedWith._id %s', user, req.user._id, pairedWith._id); + debug(req.user._id.toString() === pairedWith._id.toString()); + if (req.user._id.toString() === pairedWith._id.toString()) { + return res.sendStatus(200); + } + index = pairedWith.uncompletedCoursewares.indexOf(coursewareHash); + if (index > -1) { + pairedWith.progressTimestamps.push(Date.now() || 0); + pairedWith.uncompletedCoursewares.splice(index, 1); + + } + + pairedWith.completedCoursewares.push({ + _id: coursewareHash, + completedWith: req.user._id, + completedDate: isCompletedDate, + solution: solutionLink, + githubLink: githubLink + }); pairedWith.save(function (err, paired) { if (err) { return next(err); diff --git a/public/js/main.js b/public/js/main.js index c422d2b732..d0f73e7732 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -164,7 +164,7 @@ $(document).ready(function() { coursewareHash: passedCoursewareHash, coursewareName: passedCoursewareName, completedWith: didCompleteWith, - publicURL: publicURl, + publicURL: publicURL, githubURL: githubURL, challengeType: challengeType }