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

Commit

Permalink
[#840]:Changes Made
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0chin committed Jun 5, 2017
1 parent 6bf8c55 commit d79ab6c
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 21 deletions.
29 changes: 29 additions & 0 deletions app/MyApp/app/collections/CourseCareerPath
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$(function() {

App.Collections.CourseCareerPath = Backbone.Collection.extend({

url: function() {
if (this.CoursePathName != "" && this.MemberID != "") {
return App.Server + '/coursecareerpath/_design/bell/_view/GetCourseCareerByLevelNameMemberIds/?key=["' +this.CoursePathName + '","' +this.MemberID+ '"]&include_docs=true'
} else {
return App.Server + '/coursecareerpath/_all_docs?include_docs=true'
}
},

parse: function(response) {
var models = []
_.each(response.rows, function(row) {
models.push(row.doc)
});
return models
},

comparator: function(model) {
var type = model.get('Type')
if (type) return type.toLowerCase()
},

model: App.Models.CourseacreerPath
})

})
5 changes: 3 additions & 2 deletions app/MyApp/app/models/CoursecareerPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ $(function() {
},
schema: {
Level_Name: 'Text',
Course_Title: 'Text',
CoursePathName:'Text',
Courselist: 'Text',
CourseIds:[],//Array:Multiple Courses
CourseCareer: []//Array:Arranging the Courses
MemberID:'Text'
},
})
})
43 changes: 27 additions & 16 deletions app/MyApp/app/views/AddCourseCareer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $(function() {
vars: {},
events: {
"click #AddCareerPath": function() {
this.saveCareerPath();
this.saveCareerPath();
},
"click #CancelCOursePath": function(e) {
this.saveCareerPath();
Expand All @@ -17,43 +17,54 @@ $(function() {
},

saveCareerPath: function(){
var levelname = $('#level').val()
var levelname = $('#levelSelect').val()
var coursecareerpath = $('#careerPath').val()
var res = $('input:checked[name="multiselect_LCourse"]').val()
/* if ($("input[name = 'LCourse[]']").val() != undefined) {
var res = [];
$("input[name = 'LCourse[]']:checked").each(function(index) {
if($(this).is(':checked')==true){
res.push(decodeURI($(this).val()));
}
});
}
console.log(res)*/
var coursetitle = $('#LCourse').val()
var arrcourseId = []
for(var i = 0; i <this.collection.models.length; i++){
if(coursetitle === this.collection.models[i].attributes.CourseTitle){
var courseid = this.collection.models[i].attributes._id
arrcourseId.push(courseid)
}
for(var i = 0; i <this.collection.models.length; i++){
if(coursetitle === this.collection.models[i].attributes.CourseTitle){
var courseid = this.collection.models[i].attributes._id
arrcourseId.push(courseid)
}
}
var savecoursecareer = new App.Models.CoursecareerPath()
savecoursecareer.set('Level_Name',levelname);
savecoursecareer.set('Courses',coursetitle);
savecoursecareer.set('CoursePathName',coursecareerpath);
savecoursecareer.set('Courselist',res);
savecoursecareer.set('CourseIds',arrcourseId);
savecoursecareer.set('MemberID',$.cookie('Member._id'));
savecoursecareer.save(null, {
error: function() {
console.log("Not Saved")
}
});
location.reload();

location.reload();
var Collection = new App.Collections.CourseCareerPath()
Collection.Level_Name=this.levelname
},

render: function() {
console.log(this.collection.models)
render: function() {
var arrcourses = []
for(var i = 0; i <this.collection.models.length; i++){
for(var i = 0; i <this.collection.models.length-1; i++){
var courseslist = this.collection.models[i].attributes.CourseTitle
console.log(courseslist)
arrcourses.push(courseslist)
}
this.$el.find('.multipleCourse').append('<div class="btn btn-info" id="finishPressed">'+App.languageDict.attributes.Finish+'</div>&nbsp&nbsp');
this.vars.Courselist = arrcourses
this.vars.Course_Length = this.collection.models.length
this.vars.Course_Length = this.collection.models.length-1
this.$el.html(_.template(this.template,this.vars))
},


})

})
1 change: 1 addition & 0 deletions app/MyApp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<script src="app/collections/AdminMembers.js"></script> <!-- app/collections.js -->
<script src="app/collections/CourseStepQuestions.js"></script> <!-- app/collections.js -->
<script src="app/collections/CourseAnswer.js"></script> <!-- app/collections.js -->
<script src="app/collections/CourseCareerPath.js"></script> <!-- app/collections.js -->

<!-- app-Views -->
<script src="app/views/ConfigurationView.js"></script> <!-- app/views.js -->
Expand Down
6 changes: 3 additions & 3 deletions databases/coursecareerpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ ddoc.views = {
}
}
},
GetCourseCareerByMember: {
GetCourseCareerByLevelNameMemberIds: {
map: function(doc) {
if (this.MemberID != "") {
emit([doc.MemberID], doc);
if (this.CoursePathName!= "" && this.MemberID != "" ) {
emit([doc.CoursePathName,doc.MemberID], doc);
}
}
},
Expand Down

0 comments on commit d79ab6c

Please sign in to comment.