From 5770ccaa18dfe8a48c7cfeaceadd34de36b6efc5 Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Mon, 31 Jul 2017 11:53:36 +0545 Subject: [PATCH 01/12] [#952] CourseMem Filter by community added --- app/MyApp/app/Home-Urdu.css | 5 ++ app/MyApp/app/Home.css | 7 +- app/MyApp/app/Router.js | 27 +++++++- app/MyApp/app/views/CourseMembers.js | 98 +++++++++++++++++++++++++-- app/MyApp/app/views/listSyncDbView.js | 30 +++++++- init_docs/Text.json | 3 +- 6 files changed, 158 insertions(+), 12 deletions(-) diff --git a/app/MyApp/app/Home-Urdu.css b/app/MyApp/app/Home-Urdu.css index 381c46631..8597c893e 100644 --- a/app/MyApp/app/Home-Urdu.css +++ b/app/MyApp/app/Home-Urdu.css @@ -1252,3 +1252,8 @@ form > fieldset > ul > li.bbf-field.field-selectLanguage { #addIndividualResource{ width:110px; } +.DropDownOptn{ + float: left; + margin-left: 20px; + position: relative; +} diff --git a/app/MyApp/app/Home.css b/app/MyApp/app/Home.css index 385c154ab..7b942a955 100644 --- a/app/MyApp/app/Home.css +++ b/app/MyApp/app/Home.css @@ -1059,4 +1059,9 @@ form > fieldset > ul > li.bbf-field.field-selectLanguage { .courseInfo{ width:97%; margin-left:20px; -} \ No newline at end of file +} +.DropDownOptn{ + float: right; + margin-right: 20px; + position: relative; +} diff --git a/app/MyApp/app/Router.js b/app/MyApp/app/Router.js index 23dc620f1..fae81b932 100644 --- a/app/MyApp/app/Router.js +++ b/app/MyApp/app/Router.js @@ -2978,10 +2978,33 @@ $(function() { CourseMembers: function(cId) { var courseMembers = new App.Views.CourseMembers() courseMembers.courseId = cId; - App.$el.children('.body').empty(); + App.$el.children('.body').html('') App.$el.children('.body').append('
'); courseMembers.render(); - $('.courseEditStep').append(courseMembers.el); + var CoursecommunityList = ""; + if(App.configuration.get('type') == 'nation'){ + $.ajax({ + url: '/community/_design/bell/_view/getCommunityByCode', + type: 'GET', + dataType: "jsonp", + async: false, + success: function(json){ + CoursecommunityList = ''; + CoursecommunityList += ''; + $.each(json.rows, function(rec, index) { + CoursecommunityList += ''; + }) + CoursecommunityList = ''; + $('.DropDownOptn').append(CoursecommunityList); + } + }); + } + $('#CommunitySelect').change(function(){ + var selectedvalue = $('#CommunitySelect').val(); + var courseMembers = new App.Views.CourseMembers() + courseMembers.courseId = cId; + courseMembers.randerTable(selectedvalue); + }); var directionOfLang = App.languageDict.get('directionOfLang'); if(directionOfLang.toLowerCase()==="right") { $('.courseEditStep').find('h3').css('margin-right','5%'); diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index eab70e1e5..1ee0f7e2c 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -2,7 +2,6 @@ $(function () { App.Views.CourseMembers = Backbone.View.extend({ vars: {}, - initialize: function () {}, removeMember:function(e){ @@ -12,7 +11,7 @@ $(function () { _id: this.courseId }) courseModel.fetch({ - success:function(result){ + success:function(result){ var members = result.get('members') members.splice(members.indexOf(memberId),1) result.set('members',members) @@ -24,11 +23,11 @@ $(function () { async:false }) while (model = memberCoursePro.first()) { - model.destroy(); - } + model.destroy(); + } that.render() alert(App.languageDict.attributes.Member_Removed_From_Course) - } + } }) }, @@ -47,12 +46,13 @@ $(function () { config.fetch({ async: false }) + var currentConfig = config.first().toJSON() var code = currentConfig.rows[0].doc.code var na = currentConfig.rows[0].doc.nationName.substring(3,5); $('.courseEditStep').empty(); $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') - var viewtext = '' + var viewtext = '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' for (var i = 0; i < memberList.length; i++) { var mem = new App.Models.Member({ _id: memberList[i] @@ -94,9 +94,93 @@ $(function () { 'onclick=showComposePopupMultiple("' + mail + '") id="sendMailButton">' +App.languageDict.attributes.Send_Email+'' + ''; + +App.languageDict.attributes.Back+''; viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
'; $('.courseEditStep').append(viewtext) + }, + randerTable: function(selectedvalue){ + $('#Table1').remove() + var courseModel = new App.Models.Course({ + _id: this.courseId + }) + courseModel.fetch({ + async: false + }) + var memberList = courseModel.get('members') + var configurations = Backbone.Collection.extend({ + url: App.Server + '/configurations/_all_docs?include_docs=true' + }) + var config = new configurations() + config.fetch({ + async: false + }) + var currentConfig = config.first().toJSON() + var code = currentConfig.rows[0].doc.code + var na = currentConfig.rows[0].doc.nationName.substring(3,5); + $('.courseEditStep').empty(); + $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') + var viewtext = '' + var newMemberList = []; + for (var i = 0; i < memberList.length; i++) { + var mem = new App.Models.Member({ + _id: memberList[i] + }) + mem.fetch({ + async: false + }) + if(mem.attributes.community == selectedvalue){ + newMemberList.push(memberList[i]); + } + } + if(newMemberList.length > 0){ + for (var i = 0; i < newMemberList.length; i++) { + var mem = new App.Models.Member({ + _id: newMemberList[i] + }) + mem.fetch({ + async: false + }) + var roleOfMem; + if(courseModel.get('courseLeader').indexOf(mem.get('_id')) > -1) { + roleOfMem=App.languageDict.attributes.Leader + } else { + roleOfMem=App.languageDict.attributes.Learner + } + var mail = mem.get('login') + '.' + code +na+ '@olebell.org' + var src = "img/default.jpg" + var attchmentURL = '/members/' + mem.id + '/' + if (typeof mem.get('_attachments') !== 'undefined') { + attchmentURL = attchmentURL + _.keys(mem.get('_attachments'))[0] + src = attchmentURL + } + viewtext += '' + var loggedIn = new App.Models.Member({ + "_id": $.cookie('Member._id') + }) + loggedIn.fetch({ + async: false + }) + var roles = loggedIn.get("roles") + if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { + var memId=mem.get('_id')+','+this.courseId; + viewtext+='' + } + viewtext+='' + } + viewtext += ''; + viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + mem.get('firstName') + ' ' + mem.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'
' + + '' + + '' + + '
'; + $('.courseEditStep').append(viewtext) + } else { + viewtext += ''; + $('.courseEditStep').append(viewtext) + } } }) }) \ No newline at end of file diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index d5918a9c3..ecf649c30 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -17,7 +17,7 @@ $(function() { }, 1000); }, render: function() { - var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
'); + var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
' + App.languageDict.get('Courses') + '
'); this.$el.append($button); this.$el.append(''); this.$el.append(''); @@ -70,6 +70,8 @@ $(function() { context.syncCourseProgress(); } else if ($(this).val() == 'CourseAnswers') { context.syncCourseAnswers(); + } else if ($(this).val() == 'Courses') { + context.syncCourses(); } if ($(this).val() == 'Application') { context.checkAvailableUpdates() @@ -155,6 +157,32 @@ $(function() { async: false }) }, + + syncCourses: function() { + $.ajax({ + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8' + }, + type: 'POST', + url: '/_replicate', + dataType: 'json', + data: JSON.stringify({ + "source": "courses", + "target": 'http://' + App.configuration.get('nationUrl') + '/courses', + }), + success: function(response) { + alert(App.languageDict.attributes.Courses_Replicated) + if (isActivityLogChecked == false) { + App.stopActivityIndicator(); + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + alert(App.languageDict.attributes.TryLater_Error) + } + }) + }, + syncReports: function() { $.ajax({ diff --git a/init_docs/Text.json b/init_docs/Text.json index 39685daf5..1685a86f8 100644 --- a/init_docs/Text.json +++ b/init_docs/Text.json @@ -936,5 +936,6 @@ "Markdown": "Markdown", "Rich_Text": "Rich Text", "Course_Answers":"Course Answers", - "Course_Answers_Replicated":"Course Answers Replicated" + "Course_Answers_Replicated":"Course Answers Replicated", + "Courses_Replicated": "Courses Replicated" } From c3004f40526570a1e584294c186db152b4d0b207 Mon Sep 17 00:00:00 2001 From: razu9861 Date: Thu, 3 Aug 2017 09:39:45 +0545 Subject: [PATCH 02/12] Update Router.js --- app/MyApp/app/Router.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/MyApp/app/Router.js b/app/MyApp/app/Router.js index fae81b932..b70b8302e 100644 --- a/app/MyApp/app/Router.js +++ b/app/MyApp/app/Router.js @@ -2981,6 +2981,7 @@ $(function() { App.$el.children('.body').html('') App.$el.children('.body').append('
'); courseMembers.render(); + $('.courseEditStep').append(courseMembers.el); var CoursecommunityList = ""; if(App.configuration.get('type') == 'nation'){ $.ajax({ From 4ceddccd2c70174db1018ad5c7acde6bd373c292 Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Mon, 7 Aug 2017 15:32:34 +0545 Subject: [PATCH 03/12] [#952] fetch course member --- .../app/collections/membercourseprogresses.js | 5 +- app/MyApp/app/views/CourseMembers.js | 297 ++++++++++-------- app/MyApp/app/views/listSyncDbView.js | 29 +- databases/membercourseprogress.js | 7 + databases/members.js | 7 + 5 files changed, 185 insertions(+), 160 deletions(-) diff --git a/app/MyApp/app/collections/membercourseprogresses.js b/app/MyApp/app/collections/membercourseprogresses.js index d36279256..550eca09e 100644 --- a/app/MyApp/app/collections/membercourseprogresses.js +++ b/app/MyApp/app/collections/membercourseprogresses.js @@ -4,7 +4,10 @@ $(function() { url: function() { - var url = App.Server + '/membercourseprogress/_design/bell/_view/GetMemberCourseResult?key=["' + this.memberId + '","' + this.courseId + '"]&include_docs=true' + if(this.memberId && this.courseId) + var url = App.Server + '/membercourseprogress/_design/bell/_view/GetMemberCourseResult?key=["' + this.memberId + '","' + this.courseId + '"]&include_docs=true' + else if(this.courseId) + var url = App.Server + '/membercourseprogress/_design/bell/_view/GetMemberByCourseID?key="'+ this.courseId +'"&include_docs=true' return url }, diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index 1ee0f7e2c..145b05c0f 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -32,155 +32,190 @@ $(function () { }, render: function () { + //MCP courseId fetch var courseModel = new App.Models.Course({ _id: this.courseId }) courseModel.fetch({ async: false }) - var memberList = courseModel.get('members') - var configurations = Backbone.Collection.extend({ - url: App.Server + '/configurations/_all_docs?include_docs=true' - }) - var config = new configurations() - config.fetch({ - async: false - }) + var memberProgress = new App.Collections.membercourseprogresses() + memberProgress.courseId = this.courseId + memberProgress.fetch({ + async: false, + success: function(res){ + member_list = [] + if(res.length > 0){ + for(var i = 0; i < res.length; i++){ + member_list.push(res.models[i].attributes.memberId) + } + if(member_list.length > 0){ + var configurations = Backbone.Collection.extend({ + url: App.Server + '/configurations/_all_docs?include_docs=true' + }) + var config = new configurations() + config.fetch({ + async: false + }) - var currentConfig = config.first().toJSON() - var code = currentConfig.rows[0].doc.code - var na = currentConfig.rows[0].doc.nationName.substring(3,5); - $('.courseEditStep').empty(); - $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') - var viewtext = '' - for (var i = 0; i < memberList.length; i++) { - var mem = new App.Models.Member({ - _id: memberList[i] - }) - mem.fetch({ - async: false - }) - var roleOfMem; - if(courseModel.get('courseLeader').indexOf(mem.get('_id')) > -1) { - roleOfMem=App.languageDict.attributes.Leader - } else { - roleOfMem=App.languageDict.attributes.Learner - } - var mail = mem.get('login') + '.' + code +na+ '@olebell.org' - var src = "img/default.jpg" - var attchmentURL = '/members/' + mem.id + '/' - if (typeof mem.get('_attachments') !== 'undefined') { - attchmentURL = attchmentURL + _.keys(mem.get('_attachments'))[0] - src = attchmentURL - } - viewtext += '' - var loggedIn = new App.Models.Member({ - "_id": $.cookie('Member._id') - }) - loggedIn.fetch({ - async: false - }) - var roles = loggedIn.get("roles") - if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { - var memId=mem.get('_id')+','+this.courseId; - viewtext+='' + var currentConfig = config.first().toJSON() + var code = currentConfig.rows[0].doc.code + var na = currentConfig.rows[0].doc.nationName.substring(3,5); + $('.courseEditStep').empty(); + $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') + var viewtext = '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + mem.get('firstName') + ' ' + mem.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'
' + for (var i = 0; i < member_list.length; i++) { + var mems = new App.Models.Member({ + _id: member_list[i] + }) + mems.fetch({ + async: false, + }) + var roleOfMem; + if(courseModel.get('courseLeader').indexOf(mems.get('_id')) > -1) { + roleOfMem=App.languageDict.attributes.Leader + } else { + roleOfMem=App.languageDict.attributes.Learner + } + var mail = mems.get('login') + '.' + code +na+ '@olebell.org' + var src = "img/default.jpg" + var attchmentURL = '/members/' + mems.id + '/' + if (typeof mems.get('_attachments') !== 'undefined') { + attchmentURL = attchmentURL + _.keys(mems.get('_attachments'))[0] + src = attchmentURL + } + viewtext += '' + var loggedIn = new App.Models.Member({ + "_id": $.cookie('Member._id') + }) + loggedIn.fetch({ + async: false + }) + var roles = loggedIn.get("roles") + if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { + var memId=mems.get('_id')+','+this.courseId; + viewtext+='' + } + viewtext+='' + } + viewtext += ''; + viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + mems.get('firstName') + ' ' + mems.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'
' + + '' + + '' + + '
'; + $('.courseEditStep').append(viewtext) + } + } + }, + error: function(status){ + console.log("error :" + status) } - viewtext+='' - } - viewtext += '' + - '' + - '' + - ''; - viewtext += ''; - $('.courseEditStep').append(viewtext) + }) }, randerTable: function(selectedvalue){ $('#Table1').remove() - var courseModel = new App.Models.Course({ + var courseModel = new App.Models.Course({ _id: this.courseId }) courseModel.fetch({ async: false }) - var memberList = courseModel.get('members') - var configurations = Backbone.Collection.extend({ - url: App.Server + '/configurations/_all_docs?include_docs=true' - }) - var config = new configurations() - config.fetch({ - async: false - }) - var currentConfig = config.first().toJSON() - var code = currentConfig.rows[0].doc.code - var na = currentConfig.rows[0].doc.nationName.substring(3,5); - $('.courseEditStep').empty(); - $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') - var viewtext = '' - var newMemberList = []; - for (var i = 0; i < memberList.length; i++) { - var mem = new App.Models.Member({ - _id: memberList[i] - }) - mem.fetch({ - async: false - }) - if(mem.attributes.community == selectedvalue){ - newMemberList.push(memberList[i]); - } - } - if(newMemberList.length > 0){ - for (var i = 0; i < newMemberList.length; i++) { - var mem = new App.Models.Member({ - _id: newMemberList[i] - }) - mem.fetch({ - async: false - }) - var roleOfMem; - if(courseModel.get('courseLeader').indexOf(mem.get('_id')) > -1) { - roleOfMem=App.languageDict.attributes.Leader - } else { - roleOfMem=App.languageDict.attributes.Learner - } - var mail = mem.get('login') + '.' + code +na+ '@olebell.org' - var src = "img/default.jpg" - var attchmentURL = '/members/' + mem.id + '/' - if (typeof mem.get('_attachments') !== 'undefined') { - attchmentURL = attchmentURL + _.keys(mem.get('_attachments'))[0] - src = attchmentURL + var memberProgress = new App.Collections.membercourseprogresses() + memberProgress.courseId = this.courseId + memberProgress.fetch({ + async: false, + success: function(res){ + member_list = [] + if(res.length > 0){ + for(var i = 0; i < res.length; i++){ + member_list.push(res.models[i].attributes.memberId) + } + if(member_list.length > 0){ + var configurations = Backbone.Collection.extend({ + url: App.Server + '/configurations/_all_docs?include_docs=true' + }) + var config = new configurations() + config.fetch({ + async: false + }) + var currentConfig = config.first().toJSON() + var code = currentConfig.rows[0].doc.code + var na = currentConfig.rows[0].doc.nationName.substring(3,5); + $('.courseEditStep').empty(); + $('.courseEditStep').append('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') + var viewtext = '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + var newMember_list = [] + for (var i = 0; i < member_list.length; i++) { + var mems = new App.Models.Member({ + _id: member_list[i] + }) + mems.fetch({ + async: false, + }) + if(mems.attributes.community == selectedvalue){ + newMember_list.push(member_list[i]) + } + } + if(newMember_list.length > 0){ + for (var i = 0; i < newMember_list.length; i++){ + var mems = new App.Models.Member({ + _id:newMember_list[i] + }) + mems.fetch({ + async: false + }) + var roleOfMem; + if(courseModel.get('courseLeader').indexOf(mems.get('_id')) > -1) { + roleOfMem=App.languageDict.attributes.Leader + } else { + roleOfMem=App.languageDict.attributes.Learner + } + var mail = mems.get('login') + '.' + code +na+ '@olebell.org' + var src = "img/default.jpg" + var attchmentURL = '/members/' + mems.id + '/' + if (typeof mems.get('_attachments') !== 'undefined') { + attchmentURL = attchmentURL + _.keys(mems.get('_attachments'))[0] + src = attchmentURL + } + viewtext += '' + var loggedIn = new App.Models.Member({ + "_id": $.cookie('Member._id') + }) + loggedIn.fetch({ + async: false + }) + var roles = loggedIn.get("roles") + if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { + var memId=mems.get('_id')+','+this.courseId; + viewtext+='' + } + viewtext+='' + } + viewtext += ''; + viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + mems.get('firstName') + ' ' + mems.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'
' + + '' + + '' + + '
'; + $('.courseEditStep').append(viewtext) + } else { + viewtext += ''; + $('.courseEditStep').append(viewtext) + } + } } - viewtext += '' + mem.get('firstName') + ' ' + mem.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'' - var loggedIn = new App.Models.Member({ - "_id": $.cookie('Member._id') - }) - loggedIn.fetch({ - async: false - }) - var roles = loggedIn.get("roles") - if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { - var memId=mem.get('_id')+','+this.courseId; - viewtext+='' - } - viewtext+='' + }, + error: function(status){ + console.log("error :" + status) } - viewtext += '' + - '' + - '' + - ''; - viewtext += ''; - $('.courseEditStep').append(viewtext) - } else { - viewtext += ''; - $('.courseEditStep').append(viewtext) - } + }) } }) }) \ No newline at end of file diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index ecf649c30..8edff471a 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -17,7 +17,7 @@ $(function() { }, 1000); }, render: function() { - var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
' + App.languageDict.get('Courses') + '
'); + var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+'

'); this.$el.append($button); this.$el.append(''); this.$el.append(''); @@ -70,8 +70,6 @@ $(function() { context.syncCourseProgress(); } else if ($(this).val() == 'CourseAnswers') { context.syncCourseAnswers(); - } else if ($(this).val() == 'Courses') { - context.syncCourses(); } if ($(this).val() == 'Application') { context.checkAvailableUpdates() @@ -158,31 +156,6 @@ $(function() { }) }, - syncCourses: function() { - $.ajax({ - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8' - }, - type: 'POST', - url: '/_replicate', - dataType: 'json', - data: JSON.stringify({ - "source": "courses", - "target": 'http://' + App.configuration.get('nationUrl') + '/courses', - }), - success: function(response) { - alert(App.languageDict.attributes.Courses_Replicated) - if (isActivityLogChecked == false) { - App.stopActivityIndicator(); - } - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - alert(App.languageDict.attributes.TryLater_Error) - } - }) - }, - syncReports: function() { $.ajax({ diff --git a/databases/membercourseprogress.js b/databases/membercourseprogress.js index 3f16d4ccf..0945ea6fd 100644 --- a/databases/membercourseprogress.js +++ b/databases/membercourseprogress.js @@ -26,6 +26,13 @@ ddoc.views = { emit(doc.memberId, true) } } + }, + GetMemberByCourseID: { + map: function(doc) { + if (doc.courseId) { + emit(doc.courseId, doc.memberId) + } + } }, GetMemberCourseResult: { map: function(doc) { diff --git a/databases/members.js b/databases/members.js index 8bfa79d9b..01a2b01be 100644 --- a/databases/members.js +++ b/databases/members.js @@ -100,6 +100,13 @@ ddoc.views = { } } }, + FilterByCommunity: { + map: function(doc) { + if (doc._id && doc.community) { + emit(doc._id, doc.community) + } + } + }, allMembers: { map: function(doc) { if (doc && doc.kind == 'Member') { From 95d5af071e016c98bcba6227059879f9446e849b Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Tue, 8 Aug 2017 10:08:55 +0545 Subject: [PATCH 04/12] [#950] view Course member by community --- app/MyApp/app/Router.js | 2 +- app/MyApp/app/views/CourseMembers.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/MyApp/app/Router.js b/app/MyApp/app/Router.js index b70b8302e..0cd5dc064 100644 --- a/app/MyApp/app/Router.js +++ b/app/MyApp/app/Router.js @@ -2981,7 +2981,7 @@ $(function() { App.$el.children('.body').html('') App.$el.children('.body').append('
'); courseMembers.render(); - $('.courseEditStep').append(courseMembers.el); + $('.courseEditStep').append(courseMembers.el); var CoursecommunityList = ""; if(App.configuration.get('type') == 'nation'){ $.ajax({ diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index 145b05c0f..370b14941 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -3,15 +3,17 @@ $(function () { App.Views.CourseMembers = Backbone.View.extend({ vars: {}, initialize: function () {}, - removeMember:function(e){ var memberId = e.currentTarget.value + console.log(memberId) var that = this var courseModel = new App.Models.Course({ _id: this.courseId }) courseModel.fetch({ success:function(result){ + console.log("this Courser" + result) + return false var members = result.get('members') members.splice(members.indexOf(memberId),1) result.set('members',members) @@ -44,6 +46,7 @@ $(function () { memberProgress.fetch({ async: false, success: function(res){ + console.log(res) member_list = [] if(res.length > 0){ for(var i = 0; i < res.length; i++){ @@ -93,7 +96,7 @@ $(function () { }) var roles = loggedIn.get("roles") if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) { - var memId=mems.get('_id')+','+this.courseId; + var memId=mems.get('_id')+','+res.models[i].attributes.courseId; viewtext+='' } viewtext+='' From 35b4dd56f8e231f77210656e067aec810b0965f5 Mon Sep 17 00:00:00 2001 From: razu9861 Date: Thu, 17 Aug 2017 14:39:13 +0545 Subject: [PATCH 05/12] Update CourseMembers.js --- app/MyApp/app/views/CourseMembers.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index 370b14941..05357e368 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -5,15 +5,12 @@ $(function () { initialize: function () {}, removeMember:function(e){ var memberId = e.currentTarget.value - console.log(memberId) var that = this var courseModel = new App.Models.Course({ _id: this.courseId }) courseModel.fetch({ success:function(result){ - console.log("this Courser" + result) - return false var members = result.get('members') members.splice(members.indexOf(memberId),1) result.set('members',members) @@ -221,4 +218,4 @@ $(function () { }) } }) -}) \ No newline at end of file +}) From 1dd26955243c0910c24af7652e7a701f58137a05 Mon Sep 17 00:00:00 2001 From: razu9861 Date: Fri, 18 Aug 2017 10:37:31 +0545 Subject: [PATCH 06/12] Update Router.js --- app/MyApp/app/Router.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/MyApp/app/Router.js b/app/MyApp/app/Router.js index 0cd5dc064..d26de1775 100644 --- a/app/MyApp/app/Router.js +++ b/app/MyApp/app/Router.js @@ -3001,10 +3001,14 @@ $(function() { }); } $('#CommunitySelect').change(function(){ - var selectedvalue = $('#CommunitySelect').val(); - var courseMembers = new App.Views.CourseMembers() - courseMembers.courseId = cId; - courseMembers.randerTable(selectedvalue); + var selectedvalue = $('#CommunitySelect').val(); + var courseMembers = new App.Views.CourseMembers() + courseMembers.courseId = cId; + courseMembers.randerTable(selectedvalue); + if(selectedvalue == "" || selectedvalue == undefined){ + courseMembers.render(); + } + }); var directionOfLang = App.languageDict.get('directionOfLang'); if(directionOfLang.toLowerCase()==="right") { From 0ce6d08e73435f09f978438956453acf5b0450de Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Wed, 13 Sep 2017 10:45:33 +0545 Subject: [PATCH 07/12] [#952] resolved conflicts --- app/MyApp/app/views/listSyncDbView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index 8edff471a..b1f3b22d3 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -17,7 +17,7 @@ $(function() { }, 1000); }, render: function() { - var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+'

'); + var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+'
'); this.$el.append($button); this.$el.append(''); this.$el.append(''); @@ -155,7 +155,6 @@ $(function() { async: false }) }, - syncReports: function() { $.ajax({ From 4a6cc6ea7c208d59ad3e9a4f8a2839913585d9c6 Mon Sep 17 00:00:00 2001 From: razu9861 Date: Wed, 13 Sep 2017 10:47:52 +0545 Subject: [PATCH 08/12] Update listSyncDbView.js --- app/MyApp/app/views/listSyncDbView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index b1f3b22d3..e177e26f4 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -17,7 +17,7 @@ $(function() { }, 1000); }, render: function() { - var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+'
'); + var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
'); this.$el.append($button); this.$el.append(''); this.$el.append(''); @@ -818,4 +818,4 @@ $(function() { } }) -}) \ No newline at end of file +}) From a2a81cff9503f0433506f13738a639a4e47bbf11 Mon Sep 17 00:00:00 2001 From: razu9861 Date: Wed, 13 Sep 2017 10:48:44 +0545 Subject: [PATCH 09/12] Update listSyncDbView.js --- app/MyApp/app/views/listSyncDbView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index e177e26f4..08d3efba0 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -817,5 +817,4 @@ $(function() { } }) - }) From c95acea7ce0aff17e3ba3953850f518b85410f2f Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Wed, 13 Sep 2017 10:51:48 +0545 Subject: [PATCH 10/12] [#952] unwanted line removed --- app/MyApp/app/views/listSyncDbView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index 08d3efba0..d5918a9c3 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -817,4 +817,5 @@ $(function() { } }) -}) + +}) \ No newline at end of file From 649d0f8d8f87326036dac2b57de55c11833bf75d Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Wed, 13 Sep 2017 10:57:20 +0545 Subject: [PATCH 11/12] [#952] unwanted line removed --- app/MyApp/app/views/CourseMembers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index 05357e368..6f90641f9 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -2,7 +2,9 @@ $(function () { App.Views.CourseMembers = Backbone.View.extend({ vars: {}, + initialize: function () {}, + removeMember:function(e){ var memberId = e.currentTarget.value var that = this @@ -31,7 +33,6 @@ $(function () { }, render: function () { - //MCP courseId fetch var courseModel = new App.Models.Course({ _id: this.courseId }) From 848d16acaacc87668bbebb0f2d37409053d76e77 Mon Sep 17 00:00:00 2001 From: Raju Chaudhary Date: Fri, 15 Sep 2017 11:22:05 +0545 Subject: [PATCH 12/12] [#952] console.log removed --- app/MyApp/app/views/CourseMembers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index 6f90641f9..87cab1b19 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -44,7 +44,6 @@ $(function () { memberProgress.fetch({ async: false, success: function(res){ - console.log(res) member_list = [] if(res.length > 0){ for(var i = 0; i < res.length; i++){