Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Commit

Permalink
[#650] objective or subjective test (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupesh87 authored and lmmrssa committed Apr 17, 2017
1 parent 60e3636 commit 063a4ec
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/MyApp/app/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@ $(function() {
courseId: courseId
})
Cstep.set("totalMarks", 0);
Cstep.set("stepType", "Objective");
var lForm = new App.Views.LevelForm({
model: Cstep
})
Expand All @@ -2437,7 +2438,7 @@ $(function() {
lForm.sliders();
$("input[name='step']").attr("disabled", true);
$("input[name='passingPercentage']").attr("readonly",true);
+ $("input[name='passingPercentage']").val(10)
$("input[name='passingPercentage']").val(10)
if (totalLevels != -1) {
var tl = parseInt(totalLevels) + 1
$("input[name='step']").val(tl)
Expand Down
9 changes: 6 additions & 3 deletions app/MyApp/app/collections/CourseStepQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ $(function() {

model: App.Models.CourseQuestion,
url: function() {
if (this.keys != 'undefined')
if (this.stepId != "" && this.stepId != undefined) {
return App.Server + '/coursequestion/_design/bell/_view/questionsByCourseStepId/?key="' +this.stepId + '"&include_docs=true'
} else if (this.keys != 'undefined') {
return App.Server + '/coursequestion/_all_docs?include_docs=true&keys=[' + this.keys + ']'
else
} else {
return App.Server + '/coursequestion/_all_docs?include_docs=true'
}
},

parse: function(response) {
Expand All @@ -25,4 +28,4 @@ $(function() {

})

})
})
2 changes: 1 addition & 1 deletion app/MyApp/app/models/CourseStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $(function() {
},
passingPercentage: { //Least marks to be obtained for passing any step
type: 'Text',
},
}
},
saveAttachment: function(formEl, fileEl, revEl) {
// Work with this doc in the files database
Expand Down
31 changes: 26 additions & 5 deletions app/MyApp/app/views/CourseStepQuestionRow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function() {
$(function() {

App.Views.CourseStepQuestionRow = Backbone.View.extend({

Expand All @@ -25,17 +25,38 @@ $(function() {
CourseStepQuestionObject.set({
'questionslist': CourseStepQuestions
})
var that = this
CourseStepQuestionObject.save(null, {
success: function() {

questionModel.destroy();
var stepQuestion = new App.Collections.CourseStepQuestions();
stepQuestion.stepId = that.Id
stepQuestion.fetch({
async: false
});
var courseStep = new App.Models.CourseStep({
_id: that.Id
})
courseStep.fetch({
async: false
})
for (var i = 0; i < stepQuestion.length; i++) {
if(stepQuestion.models[i].attributes.Type != "Multiple Choice"){
break;
} else {
if (i == stepQuestion.length-1) {
courseStep.set("stepType", "Objective");
courseStep.save();
}
}
}
}
});
},
"click .edit_coursestep_question": function(event) {
var courseQuizEdit = new App.Views.TestView();
courseQuizEdit.questionModel = this.model;
courseQuizEdit.coursesavefunction(this.Id, true, this.model);
var courseQuizEdit = new App.Views.TestView();
courseQuizEdit.questionModel = this.model;
courseQuizEdit.coursesavefunction(this.Id, true, this.model);
}

},
Expand Down
41 changes: 34 additions & 7 deletions app/MyApp/app/views/TestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,44 @@ $(function() {
},
async: false
});
} else {
var courseStepModel = new App.Models.CourseStep({
if (questionObject.attributes.Type != "Multiple Choice") {
var Cstep = new App.Models.CourseStep({
_id: csId
})
courseStepModel.fetch({
Cstep.fetch({
async: false
})
var totalMarks = parseInt(courseStepModel.get('totalMarks'));
var input_marks = parseInt(questionObject.attributes.Marks);
courseStepModel.set('totalMarks', (totalMarks+input_marks));
courseStepModel.save();
if(Cstep.attributes.stepType == "Objective"){
Cstep.set("stepType", "Subjective");
Cstep.save();
}
}
} else {
var stepQuestion = new App.Collections.CourseStepQuestions();
stepQuestion.stepId = csId
stepQuestion.fetch({
async: false
});
var courseStepModel = new App.Models.CourseStep({
_id: csId
})
courseStepModel.fetch({
async: false
})
for (var i = 0; i < stepQuestion.length; i++) {
if(stepQuestion.models[i].attributes.Type != "Multiple Choice"){
courseStepModel.set("stepType", "Subjective");
break;
} else {
if (i == stepQuestion.length-1) {
courseStepModel.set("stepType", "Objective");
}
}
}
var totalMarks = parseInt(courseStepModel.get('totalMarks'));
var input_marks = parseInt(questionObject.attributes.Marks);
courseStepModel.set('totalMarks', (totalMarks+input_marks));
courseStepModel.save();
alert(App.languageDict.attributes.question_Edit);
window.location.reload();
}
Expand Down

0 comments on commit 063a4ec

Please sign in to comment.