Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add: function (req, res) {
- var id = req.session.Student.id;
- Student.findOne({id: id}).exec(function(err, thisStudent) {
- Course.findOne({unit_code: req.param('unit_code')}).exec(function(err, thisCourse) {
- var creditPoints = thisCourse.credit_points;
- for (i = 0; i < thisStudent.courses.length; i++) {
- creditPoints = creditPoints + parseInt(thisStudent.courses[i].credit_points)
- console.log("in for loop cp is " + creditPoints);
- }
- if (creditPoints > 12) {
- res.redirect('/exceeded_credit_points');
- }
- else {
- console.log("credit points is " + creditPoints);
- thisStudent.courses.add(thisCourse);
- thisStudent.save(function(err, newStudent){});
- res.view({
- course: thisCourse
- });
- }
- });
- });
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement