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

This commit is contained in:
Nathan Leniz
2015-02-04 21:28:10 -05:00
parent 70d704d975
commit 9246d7f663
5 changed files with 49 additions and 9 deletions

View File

@@ -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);

View File

@@ -37,11 +37,18 @@ var libraryIncludes = "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3
"<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css'/>" +
"<style>body { padding: 0px 3px 0px 3px; }</style>";
var allTests = '';
(function() {
tests.forEach(function(elem) {
allTests += elem + ' ';
});
})();
var coursewareTests = "<script>" +
"var allTestsGood = true;" +
"var expect = chai.expect; " +
"try {" +
tests[0] +
allTests +
"} catch (err) {" +
"allTestsGood = false;" +
"}" +

View File

@@ -68,6 +68,23 @@ $(document).ready(function() {
});
$('.next-courseware-button').on('click', function() {
if ($('.signup-btn-nav').length < 1) {
$.post(
'/completed-courseware',
{
coursewareInfo: {
coursewareHash: passedCoursewareHash
}
},
function(res) {
if (res) {
window.location.href = '/coursewares'
}
})
}
})
$('.all-challenges').on('click', function() {
$('#all-challenges-dialog').modal('show');
});

View File

@@ -5,7 +5,7 @@
"difficulty": "0",
"description": [
"Welcome to the FCC courseware! You can click on the button below for more information",
"Courseware comes loaded with Bootstrap, Jquery, and Angular. You can include more libraries by finding a cdn and including them in your html",
"Courseware comes loaded with Bootstrap, Animate, Lodash, Jquery, and Angular. You can include more libraries by finding a cdn and including them in your html",
"We hope you have fun learning!",
"To advance to the next exercise, change the h1 tag's text to say hello world"
],
@@ -13,5 +13,19 @@
"expect($('h1')).to.have.text('hello world');"
],
"challengeSeed": "<h1>hello you</h1>"
},
{
"_id" : "bad87fee1348bd9aedf0887a",
"name": "Centering Text",
"difficulty" : "0",
"description": [
"Your job is to center the h1 element using a built in bootstrap class and change the text to hello world.",
"If you need help, you can refer to the bootstrap documentation, something you should get in the habit of!"
],
"tests": [
"expect($('h1')).to.have.class('text-center');",
"expect($('h1')).to.have.text('hello world');"
],
"challengeSeed": "<h1>hello you</h1>"
}
]

View File

@@ -76,13 +76,13 @@ block content
.animated.zoomInDown.delay-half
span.completion-icon.ion-checkmark-circled.text-primary
- if (cc)
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-courseware-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge
- if (points && points > 2)
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank")
i.fa.fa-twitter &nbsp;
= phrase
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank")
i.fa.fa-twitter &nbsp;
= phrase
- else
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress