From 508bd90bce362d87837af939240f105138f03408 Mon Sep 17 00:00:00 2001 From: pr0chin Date: Thu, 7 Sep 2017 12:18:53 +0545 Subject: [PATCH 01/15] [#1022] Mock data for course --- mock_data | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 mock_data diff --git a/mock_data b/mock_data new file mode 100644 index 000000000..6a60dcec0 --- /dev/null +++ b/mock_data @@ -0,0 +1,205 @@ +var sys = require('sys') +var fs = require('fs') +var exec = require('child_process').exec; +var program = require('commander'); +var databases = [] +program + .version('0.0.2') + .parse(process.argv); +if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') +var couchUrl = program.args[0] +var nano = require('nano')(couchUrl) + +function start() { + increaseLimits() +} + +// Increase Limits so couchapp push works correctly +function increaseLimits() { + exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() { + exec('sudo ulimit -n 150056', function doneWithUlimit() { + return createDummyCourses() + }) + }) +} + +var n_courses = 1 ; //Number of Iteration to run for courses +var defaultCourses = []; //Contains only CourseID and MemberList +var defaultCoursestep = []; +var defaultCoursequestion = []; +var dummyData = []; //For creating Steps. +var dummyData1 = []; //For creating Course Questions having different types. + +function createDummyCourses() { + var courses = nano.db.use('courses'); + for(course = 0; course < n_courses; course++){ + course_number = course + 1; + var subjectLevel; + if (course <=3){ + subjectLevel = "Amateur"; + }else if(course>=4 && course<=8){ + subjectLevel = "Mid"; + }else{ + subjectLevel = "Beginner"; + } + defaultCourses.push({ + "CourseTitle": "Course " +course_number, + "Day": "0", + "backgroundColor": "", + "courseLeader": "", + "description": "This is Course " +course_number+" .", + "endDate": "12/12/2017", + "endTime": "17:00", + "foregroundColor": "", + "gradeLevel": "1", + "kind": "Course", + "languageOfInstruction": "English", + "location": "Alberta", + "memberLimit": "20", + "members": [], + "method": "Theory and Practical", + "name": "Course " +course_number, + "startDate": "01/01/2017", + "startTime": "10:00", + "subjectLevel": subjectLevel + }); + } + + //insert into courses + courses.bulk({"docs":defaultCourses}, function(err, res) { + if (err) + return console.log(err); + else { + for(var i = 0; i< defaultCourses.length; i++){ + for(var j in defaultCourses[i].members){ + dummyData.push({ + courseID : res[i].id, + memberID : defaultCourses[i].members[j] + }); + } + } + + function randomCourses(){ + var random_number = res[Math.floor(Math.random() * res.length)]; + random = res[Math.floor(Math.random() * res.length)]; + var random_course_id = random.id; + return random_course_id; + } + + for(var i = 0; i < 1; i++){ + var course_id = randomCourses(); + defaultCoursestep.push({ + "courseId": course_id, + "description": "This is course step "+ (parseInt(i)+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":[], + "resourceId":[], + "questionslist":[], + "step": "1", + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (parseInt(i)+1), + "totalMarks": "100" + }); + } + + var coursestep = nano.db.use('coursestep'); + coursestep.bulk({"docs":defaultCoursestep}, function(err, res) { + if (err) + return console.log(err); + else { + for(var i = 0; i< 1; i++){ + dummyData1.push({ + courseID : defaultCoursestep[i].courseId, + stepID : res[i].id + }); + defaultCoursestep[i]._id = res[i].id; + defaultCoursestep[i]._rev = res[i].rev; + } + + for(var i = 0; i < 1; i++){ + var course_id = dummyData1[i].courseID; + var step_id = dummyData1[i].stepID; + defaultCoursequestion.push({ + "CorrectAnswer": [ + "A", + "B" + ], + "Options": [ + "A", + "B", + "C", + "D" + ], + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Multiple Choice", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Comment/Essay Box", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Attachment", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Single Textbox", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + } + var coursequestion = nano.db.use('coursequestion'); + coursequestion.bulk({"docs":defaultCoursequestion}, function(err, res) { + if (err) + return console.log(err); + else { + //need to update questionlist in coursestep + for(var i = 0; i < defaultCoursequestion.length; i++){ + var question_list_id = []; + for(var j in dummyData1){ + if(defaultCoursequestion[i].courseId == dummyData1[j].courseID && defaultCoursequestion[i].stepId == dummyData1[j].stepID){ + + question_list_id.push(res[i].id); + defaultCoursestep[0].questionslist.push(res[i].id) + + } + } + + } + + coursestep.bulk({"docs":defaultCoursestep}, function(err, body) { + if (err) + return console.log(err); + else{ + done(); + } + }); + } + }); + } + }); + } + }); +} +function done(){ + console.log("done"); +} +start() \ No newline at end of file From 020c07961c36396fe69aa3dbca592d3a0ef634ee Mon Sep 17 00:00:00 2001 From: pr0chin Date: Fri, 8 Sep 2017 16:46:30 +0545 Subject: [PATCH 02/15] [#1017] Updated mock_data --- mock_data | 205 ------------------------------------------------ tests/mock_data | 197 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+), 205 deletions(-) delete mode 100644 mock_data create mode 100644 tests/mock_data diff --git a/mock_data b/mock_data deleted file mode 100644 index 6a60dcec0..000000000 --- a/mock_data +++ /dev/null @@ -1,205 +0,0 @@ -var sys = require('sys') -var fs = require('fs') -var exec = require('child_process').exec; -var program = require('commander'); -var databases = [] -program - .version('0.0.2') - .parse(process.argv); -if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') -var couchUrl = program.args[0] -var nano = require('nano')(couchUrl) - -function start() { - increaseLimits() -} - -// Increase Limits so couchapp push works correctly -function increaseLimits() { - exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() { - exec('sudo ulimit -n 150056', function doneWithUlimit() { - return createDummyCourses() - }) - }) -} - -var n_courses = 1 ; //Number of Iteration to run for courses -var defaultCourses = []; //Contains only CourseID and MemberList -var defaultCoursestep = []; -var defaultCoursequestion = []; -var dummyData = []; //For creating Steps. -var dummyData1 = []; //For creating Course Questions having different types. - -function createDummyCourses() { - var courses = nano.db.use('courses'); - for(course = 0; course < n_courses; course++){ - course_number = course + 1; - var subjectLevel; - if (course <=3){ - subjectLevel = "Amateur"; - }else if(course>=4 && course<=8){ - subjectLevel = "Mid"; - }else{ - subjectLevel = "Beginner"; - } - defaultCourses.push({ - "CourseTitle": "Course " +course_number, - "Day": "0", - "backgroundColor": "", - "courseLeader": "", - "description": "This is Course " +course_number+" .", - "endDate": "12/12/2017", - "endTime": "17:00", - "foregroundColor": "", - "gradeLevel": "1", - "kind": "Course", - "languageOfInstruction": "English", - "location": "Alberta", - "memberLimit": "20", - "members": [], - "method": "Theory and Practical", - "name": "Course " +course_number, - "startDate": "01/01/2017", - "startTime": "10:00", - "subjectLevel": subjectLevel - }); - } - - //insert into courses - courses.bulk({"docs":defaultCourses}, function(err, res) { - if (err) - return console.log(err); - else { - for(var i = 0; i< defaultCourses.length; i++){ - for(var j in defaultCourses[i].members){ - dummyData.push({ - courseID : res[i].id, - memberID : defaultCourses[i].members[j] - }); - } - } - - function randomCourses(){ - var random_number = res[Math.floor(Math.random() * res.length)]; - random = res[Math.floor(Math.random() * res.length)]; - var random_course_id = random.id; - return random_course_id; - } - - for(var i = 0; i < 1; i++){ - var course_id = randomCourses(); - defaultCoursestep.push({ - "courseId": course_id, - "description": "This is course step "+ (parseInt(i)+1), - "kind": "Course Step", - "passingPercentage": "30", - "resourceTitles":[], - "resourceId":[], - "questionslist":[], - "step": "1", - "stepGoals": "Knowledge", - "stepMethod": "Theory", - "title": "Course Step "+ (parseInt(i)+1), - "totalMarks": "100" - }); - } - - var coursestep = nano.db.use('coursestep'); - coursestep.bulk({"docs":defaultCoursestep}, function(err, res) { - if (err) - return console.log(err); - else { - for(var i = 0; i< 1; i++){ - dummyData1.push({ - courseID : defaultCoursestep[i].courseId, - stepID : res[i].id - }); - defaultCoursestep[i]._id = res[i].id; - defaultCoursestep[i]._rev = res[i].rev; - } - - for(var i = 0; i < 1; i++){ - var course_id = dummyData1[i].courseID; - var step_id = dummyData1[i].stepID; - defaultCoursequestion.push({ - "CorrectAnswer": [ - "A", - "B" - ], - "Options": [ - "A", - "B", - "C", - "D" - ], - "Statement": "Question "+ (parseInt(i)+1) +" ?", - "Type": "Multiple Choice", - "courseId": course_id, - "kind": "coursequestion", - "stepId" : step_id, - "Marks" : 90 - }); - defaultCoursequestion.push({ - "Statement": "Question "+ (parseInt(i)+1) +" ?", - "Type": "Comment/Essay Box", - "courseId": course_id, - "kind": "coursequestion", - "stepId" : step_id, - "Marks" : 90 - }); - - defaultCoursequestion.push({ - "Statement": "Question "+ (parseInt(i)+1) +" ?", - "Type": "Attachment", - "courseId": course_id, - "kind": "coursequestion", - "stepId" : step_id, - "Marks" : 90 - }); - - defaultCoursequestion.push({ - "Statement": "Question "+ (parseInt(i)+1) +" ?", - "Type": "Single Textbox", - "courseId": course_id, - "kind": "coursequestion", - "stepId" : step_id, - "Marks" : 90 - }); - } - var coursequestion = nano.db.use('coursequestion'); - coursequestion.bulk({"docs":defaultCoursequestion}, function(err, res) { - if (err) - return console.log(err); - else { - //need to update questionlist in coursestep - for(var i = 0; i < defaultCoursequestion.length; i++){ - var question_list_id = []; - for(var j in dummyData1){ - if(defaultCoursequestion[i].courseId == dummyData1[j].courseID && defaultCoursequestion[i].stepId == dummyData1[j].stepID){ - - question_list_id.push(res[i].id); - defaultCoursestep[0].questionslist.push(res[i].id) - - } - } - - } - - coursestep.bulk({"docs":defaultCoursestep}, function(err, body) { - if (err) - return console.log(err); - else{ - done(); - } - }); - } - }); - } - }); - } - }); -} -function done(){ - console.log("done"); -} -start() \ No newline at end of file diff --git a/tests/mock_data b/tests/mock_data new file mode 100644 index 000000000..d0a0fdf6d --- /dev/null +++ b/tests/mock_data @@ -0,0 +1,197 @@ +var sys = require('sys') +var fs = require('fs') +var exec = require('child_process').exec; +var program = require('commander'); +var databases = [] +program + .version('0.0.2') + .parse(process.argv); +if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') +var couchUrl = program.args[0] +var nano = require('nano')(couchUrl) + +function start() { + increaseLimits() +} + +// Increase Limits so couchapp push works correctly +function increaseLimits() { + exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() { + exec('sudo ulimit -n 150056', function doneWithUlimit() { + return createDummyCourses() + }) + }) +} + +var n_courses = 1 ; //Number of Iteration to run for courses +var defaultCourses = []; //Contains only CourseID and MemberList +var defaultCoursestep = []; +var defaultCoursequestion = []; +var dummyData = []; //For creating Steps. +var dummyData1 = []; //For creating Course Questions having different types. + +function createDummyCourses() { + var courses = nano.db.use('courses'); + for(course = 0; course < n_courses; course++){ + course_number = course + 1; + var subjectLevel; + if (course <=3){ + subjectLevel = "Amateur"; + }else if(course>=4 && course<=8){ + subjectLevel = "Mid"; + }else{ + subjectLevel = "Beginner"; + } + defaultCourses.push({ + "CourseTitle": "Course " +course_number, + "Day": "0", + "backgroundColor": "", + "courseLeader": "", + "description": "This is Course " +course_number+" .", + "endDate": "12/12/2017", + "endTime": "17:00", + "foregroundColor": "", + "gradeLevel": "1", + "kind": "Course", + "languageOfInstruction": "English", + "location": "Alberta", + "memberLimit": "20", + "members": [], + "method": "Theory and Practical", + "name": "Course " +course_number, + "startDate": "01/01/2017", + "startTime": "10:00", + "subjectLevel": subjectLevel + }); + } + + //insert into courses + courses.bulk({"docs":defaultCourses}, function(err, res) { + if (err) + return console.log(err); + else { + for(var i = 0; i< defaultCourses.length; i++){ + for(var j in defaultCourses[i].members){ + dummyData.push({ + courseID : res[i].id, + memberID : defaultCourses[i].members[j] + }); + } + } + + function randomCourses(){ + var random_number = res[Math.floor(Math.random() * res.length)]; + random = res[Math.floor(Math.random() * res.length)]; + var random_course_id = random.id; + return random_course_id; + } + + for(var i = 0; i < 2; i++){ + var course_id = randomCourses(); + defaultCoursestep.push({ + "courseId": course_id, + "description": "This is course step "+ (parseInt(i)+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":[], + "resourceId":[], + "questionslist":[], + "step": i+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (parseInt(i)+1), + "totalMarks": "100" + }); + } + for(var i = 0; i< 1; i++){ + dummyData1.push({ + courseID : defaultCoursestep[i].courseId, + stepID : res[i].id + }); + defaultCoursestep[i]._id = res[i].id; + defaultCoursestep[i]._rev = res[i].rev; + } + + for(var i = 0; i < 1; i++){ + var course_id = dummyData1[i].courseID; + var step_id = dummyData1[i].stepID; + defaultCoursequestion.push({ + "CorrectAnswer": [ + "A", + "B" + ], + "Options": [ + "A", + "B", + "C", + "D" + ], + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Multiple Choice", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Comment/Essay Box", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Attachment", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + + defaultCoursequestion.push({ + "Statement": "Question "+ (parseInt(i)+1) +" ?", + "Type": "Single Textbox", + "courseId": course_id, + "kind": "coursequestion", + "stepId" : step_id, + "Marks" : 90 + }); + } + var coursequestion = nano.db.use('coursequestion'); + coursequestion.bulk({"docs":defaultCoursequestion}, function(err, res) { + if (err) + return console.log(err); + else { + //need to update questionlist in coursestep + for(var i = 0; i < defaultCoursequestion.length; i++){ + var question_list_id = []; + for(var j in dummyData1){ + if(defaultCoursequestion[i].courseId == dummyData1[j].courseID && defaultCoursequestion[i].stepId == dummyData1[j].stepID){ + + question_list_id.push(res[i].id); + defaultCoursestep[0].questionslist.push(res[i].id) + + } + } + + } + var coursestep = nano.db.use('coursestep'); + coursestep.bulk({"docs":defaultCoursestep}, function(err, body) { + if (err) + return console.log(err); + else{ + done(); + } + }); + } + }); + } + }); +} +function done(){ + console.log("done"); +} +start() \ No newline at end of file From 3b96da1a9cae380d241bffa311939d12b5f1794d Mon Sep 17 00:00:00 2001 From: pr0chin Date: Wed, 13 Sep 2017 11:44:37 +0545 Subject: [PATCH 03/15] made some changes --- tests/mock_data | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/mock_data b/tests/mock_data index d0a0fdf6d..92297065c 100644 --- a/tests/mock_data +++ b/tests/mock_data @@ -1,4 +1,4 @@ -var sys = require('sys') +var util = require('util') var fs = require('fs') var exec = require('child_process').exec; var program = require('commander'); @@ -23,7 +23,7 @@ function increaseLimits() { }) } -var n_courses = 1 ; //Number of Iteration to run for courses +var n_courses = 2 ; //Number of Iteration to run for courses var defaultCourses = []; //Contains only CourseID and MemberList var defaultCoursestep = []; var defaultCoursequestion = []; @@ -86,7 +86,7 @@ function createDummyCourses() { return random_course_id; } - for(var i = 0; i < 2; i++){ + for(var i = 0; i < 1; i++){ var course_id = randomCourses(); defaultCoursestep.push({ "courseId": course_id, From f288b6a81ee2ac08ac5fb1ad8f8e37613180bec5 Mon Sep 17 00:00:00 2001 From: pr0chin Date: Fri, 15 Sep 2017 12:23:23 +0545 Subject: [PATCH 04/15] [#1022] Made changes for course secnario --- tests/mock_data | 237 ++++++++++++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 97 deletions(-) diff --git a/tests/mock_data b/tests/mock_data index 92297065c..816dc340f 100644 --- a/tests/mock_data +++ b/tests/mock_data @@ -27,11 +27,13 @@ var n_courses = 2 ; //Number of Iteration to run for courses var defaultCourses = []; //Contains only CourseID and MemberList var defaultCoursestep = []; var defaultCoursequestion = []; -var dummyData = []; //For creating Steps. -var dummyData1 = []; //For creating Course Questions having different types. +var defaultResources = []; function createDummyCourses() { var courses = nano.db.use('courses'); + var coursestep = nano.db.use('coursestep'); + var coursequestion = nano.db.use('coursequestion'); + for(course = 0; course < n_courses; course++){ course_number = course + 1; var subjectLevel; @@ -70,26 +72,14 @@ function createDummyCourses() { if (err) return console.log(err); else { - for(var i = 0; i< defaultCourses.length; i++){ - for(var j in defaultCourses[i].members){ - dummyData.push({ - courseID : res[i].id, - memberID : defaultCourses[i].members[j] - }); - } - } - - function randomCourses(){ - var random_number = res[Math.floor(Math.random() * res.length)]; - random = res[Math.floor(Math.random() * res.length)]; - var random_course_id = random.id; - return random_course_id; + course_id = []; + console.log(res.length); + for(var i=0;i Date: Fri, 15 Sep 2017 12:47:40 +0545 Subject: [PATCH 05/15] [#1022] Changed mock_data into course_mock_data --- tests/{mock_data => course_mock_data} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{mock_data => course_mock_data} (100%) diff --git a/tests/mock_data b/tests/course_mock_data similarity index 100% rename from tests/mock_data rename to tests/course_mock_data From fdecd784f939c683f52b154d4ac32e73fc048bba Mon Sep 17 00:00:00 2001 From: pr0chin Date: Tue, 3 Oct 2017 17:11:01 +0545 Subject: [PATCH 06/15] [#1022] Dynamic mock data --- tests/course_mock_data | 320 +++++++++++++++++++---------------------- 1 file changed, 146 insertions(+), 174 deletions(-) diff --git a/tests/course_mock_data b/tests/course_mock_data index 816dc340f..60e069d0d 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -16,34 +16,82 @@ function start() { // Increase Limits so couchapp push works correctly function increaseLimits() { - exec('sudo launchctl limit maxfiles 150056 150056', function doneWithLaunchCtl() { - exec('sudo ulimit -n 150056', function doneWithUlimit() { - return createDummyCourses() - }) - }) + return createDummyCourses() + } - -var n_courses = 2 ; //Number of Iteration to run for courses +var n_members = 5; +var n_courses = 2; //Number of Iteration to run for courses +var n_steps = 5; var defaultCourses = []; //Contains only CourseID and MemberList var defaultCoursestep = []; var defaultCoursequestion = []; var defaultResources = []; +var defaultMembers = []; +var defaultCourseanswer = []; function createDummyCourses() { - var courses = nano.db.use('courses'); - var coursestep = nano.db.use('coursestep'); - var coursequestion = nano.db.use('coursequestion'); + var courses = nano.db.use('courses'); + var coursestep = nano.db.use('coursestep'); + var coursequestion = nano.db.use('coursequestion'); + var members = nano.db.use('members'); + var courseanswer = nano.db.use('courseanswer'); + + /***************Members***************/ + //First you need to create Member: - for(course = 0; course < n_courses; course++){ + for(var member = 0; member < n_members; member++){ + participation = member + 1; + if(member< parseInt(n_members/2)){ + defaultMembers.push({ + "login": "member" + participation, + "kind": "Member", + "roles": ["Manager"], + "firstName": "Member " + participation, + "lastName": "Member " + participation, + "password": "password", + "Gender": "Male", + "status": "active", + "email": "member" + participation + ".somalia@olebell.org", + "visits": 0, + "BirthDate": "01/01/1985" + }); + }else{ + defaultMembers.push({ + "login": "member" + participation, + "kind": "Member", + "roles": ["Learner"], + "firstName": "Member " + participation, + "lastName": "Member " + participation, + "password": "password", + "Gender": "Male", + "status": "active", + "email": "member" + participation + ".somalia@olebell.org", + "visits": 0, + "BirthDate": "01/01/1985" + }); + } + } + members.bulk({"docs":defaultMembers}, function(err, res) { + if (err) + return console.log(err); + else { + var memberarr = []; + for(var course = 0; course < res.length; course++){ + memberarr.push(res[course].id); course_number = course + 1; var subjectLevel; + var gradelevel; if (course <=3){ subjectLevel = "Amateur"; + gradelevel = "Higher" }else if(course>=4 && course<=8){ subjectLevel = "Mid"; + gradelevel="10" }else{ subjectLevel = "Beginner"; + gradelevel="5" } + defaultCourses.push({ "CourseTitle": "Course " +course_number, "Day": "0", @@ -53,187 +101,111 @@ function createDummyCourses() { "endDate": "12/12/2017", "endTime": "17:00", "foregroundColor": "", - "gradeLevel": "1", + "gradeLevel": gradelevel, "kind": "Course", "languageOfInstruction": "English", "location": "Alberta", "memberLimit": "20", - "members": [], + "members": memberarr, "method": "Theory and Practical", "name": "Course " +course_number, "startDate": "01/01/2017", "startTime": "10:00", "subjectLevel": subjectLevel }); - } - - //insert into courses - courses.bulk({"docs":defaultCourses}, function(err, res) { + } + //insert into courses + + courses.bulk({"docs":defaultCourses}, function(err, res) { if (err) return console.log(err); - else { - course_id = []; - console.log(res.length); - for(var i=0;i Date: Thu, 5 Oct 2017 09:47:27 +0545 Subject: [PATCH 07/15] [1022] Made some dynamic changes --- install_windows | 145 ----------------------------------------- tests/course_mock_data | 65 ++++++++++-------- 2 files changed, 38 insertions(+), 172 deletions(-) delete mode 100644 install_windows diff --git a/install_windows b/install_windows deleted file mode 100644 index f61bc331b..000000000 --- a/install_windows +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var sys = require('sys') -var fs = require('fs') -var exec = require('child_process').exec; -var program = require('commander'); -var databases = [] -program - .version('0.0.2') - .parse(process.argv); -if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') -var couchUrl = program.args[0] -var nano = require('nano')(couchUrl) - -function start() { - getListOfDatabases() -} - -function getListOfDatabases() { - fs.readdir('./databases', function doneReadDir(err, files) { - files.forEach(function addFile(element, index, array) { - databases.push(element.substr(0, element.length - 3)) - }) - installDatabases() - }) -} - -var a = 0 - -function installDatabases() { - var database = databases[a] - if (a !== databases.length) { - console.log("creating database " + database) - nano.db.create(database, function(err, body) { - if (err && err.error !== "file_exists") console.log(err) - a++ - return installDatabases() - }) - } else { - return installDesignDocs() - } -} - -var b = 0 - -function installDesignDocs() { - var database = databases[b] - if (b !== databases.length) { - if (database != "communities" && database != "languages" && database != "configurations") { - console.log("Inserting design docs for the " + database + " database"); - var docToPush = 'databases\\' + database + '.js'; - var targetDb = couchUrl + '/' + database; - exec('pushDocToDb.bat "' + docToPush + '" "' + targetDb + '"', function(error, stdout, stderr) { - if (error) console.log(error); - if (stderr) console.log(stderr); - console.log(stdout) - b++ - installDesignDocs() - }) - } else { - b++ - installDesignDocs() - } - } else { - createDefaultAdminMember() - } -} - -function createDefaultAdminMember() { - nano.db.get('members', function(err, body) { - if (err) console.log(err) - // Cancel if there are already members in the database - if (body.doc_count > 1) return done() - console.log('Creating a default admin member of admin:password') - var members = nano.db.use('members') - var defaultAdminMember = { - "login": "admin", - "kind": "Member", - "roles": ["Manager", "SuperManager"], - "firstName": "Default", - "lastName": "Admin", - "password": "password", - "Gender": "Male", - "status": "active", - "email": "admin.somalia@olebell.org", - "visits": 0 - } - members.insert(defaultAdminMember, function (err, res) { - if (err) - return console.log(err) - else { - var configurations = nano.db.use('configurations'); - var configsDocPath = 'init_docs/ConfigurationsDoc-Nation.txt'; - fs.readFile(configsDocPath, function (err, data) { - configurations.insert(data, function (err, res) { - if (err) { - console.log(err); - } else { - console.log("******************Going to insert document into languages database*******************************"); - insertLanguageDocs(); - } - done() - }) - }) - } - }); - - }); -} - -function insertLanguageDocs() { - var languages = nano.db.use('languages'); - fs.readdir('./init_docs/languages', function doneReadDir(err, files) { - files.forEach(function (element) { - var langList = ['Arabic.txt', 'English.txt', 'Nepali.txt', 'Spanish.txt', 'Urdu (Pakistan).txt']; - if (langList.indexOf(element) > -1) { - var langDocPath = './init_docs/languages/' + element; - console.log("Inserting " + element); - fs.readFile(langDocPath, function (err, data) { - languages.insert(data, function (err, res) { - if (err) { - console.log(err); - } else { - console.log(element + " doc inserted successfully."); - } - }); - }); - } - }) - }); -} - -function done() { - console.log('done!') -} - -// -// Trigger Start -// - -start(); diff --git a/tests/course_mock_data b/tests/course_mock_data index 60e069d0d..d6c2d50c2 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -120,31 +120,32 @@ function createDummyCourses() { if (err) return console.log(err); else{ - for(var steps = 0; steps < n_steps; steps++){ - for(var courselist = 0; courselist < res.length; courselist++){ + for(var steps = 0; steps < n_steps; steps++){ + for(var courselist = 0; courselist < res.length; courselist++){ - defaultCoursestep.push({ - "courseId": res[courselist].id, - "description": "This is course step "+ (steps+1), - "kind": "Course Step", - "passingPercentage": "30", - "resourceTitles":[], - "resourceId":[], - "questionslist":[], - "step": steps+1, - "stepGoals": "Knowledge", - "stepMethod": "Theory", - "title": "Course Step "+ (steps+1), - "totalMarks": "100" - }); - } - } + defaultCoursestep.push({ + "courseId": res[courselist].id, + "description": "This is course step "+ (steps+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":[], + "resourceId":[], + "questionslist":[], + "step": steps+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (steps+1), + "totalMarks": "100" + }); + } + } + //insert into coursestep - coursestep.bulk({"docs":defaultCoursestep},function(err,res){ + coursestep.bulk({"docs":defaultCoursestep},function(err,resstep){ if(err){ console.log(err); }else{ - for(var steplist = 0; steplist Date: Thu, 12 Oct 2017 14:09:34 +0545 Subject: [PATCH 08/15] [#1022] Made dyamic course scenario --- app/MyApp/indexFile.js | 2 + tests/course_mock_data | 310 +++++++++++++++++++++++++++++------------ 2 files changed, 223 insertions(+), 89 deletions(-) diff --git a/app/MyApp/indexFile.js b/app/MyApp/indexFile.js index f43cb5db5..03c9ac2fc 100644 --- a/app/MyApp/indexFile.js +++ b/app/MyApp/indexFile.js @@ -921,6 +921,8 @@ function sendAdminRequest(courseLeader, courseName, courseId) { async: false }) var num = gmodel.get("members").length + console.log("memberlength"+num) + console.log(gmodel.get("memberLimit")); if (gmodel.get("memberLimit")) { if (gmodel.get("memberLimit") < num) { alert(App.languageDict.attributes.Course_Full) diff --git a/tests/course_mock_data b/tests/course_mock_data index d6c2d50c2..90d201961 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -19,8 +19,7 @@ function increaseLimits() { return createDummyCourses() } -var n_members = 5; -var n_courses = 2; //Number of Iteration to run for courses +var n_members = 6; var n_steps = 5; var defaultCourses = []; //Contains only CourseID and MemberList var defaultCoursestep = []; @@ -28,13 +27,16 @@ var defaultCoursequestion = []; var defaultResources = []; var defaultMembers = []; var defaultCourseanswer = []; +var defaultMemberprogress = []; function createDummyCourses() { var courses = nano.db.use('courses'); + var resources = nano.db.use('resources'); var coursestep = nano.db.use('coursestep'); var coursequestion = nano.db.use('coursequestion'); var members = nano.db.use('members'); var courseanswer = nano.db.use('courseanswer'); + var membercourseprogress = nano.db.use('membercourseprogress'); /***************Members***************/ //First you need to create Member: @@ -71,20 +73,20 @@ function createDummyCourses() { }); } } - members.bulk({"docs":defaultMembers}, function(err, res) { + members.bulk({"docs":defaultMembers}, function(err, resmem) { if (err) return console.log(err); else { - var memberarr = []; - for(var course = 0; course < res.length; course++){ - memberarr.push(res[course].id); + var memberarr = []; + for(var course = 0; course < resmem.length; course++){ + memberarr.push(resmem[course].id); course_number = course + 1; var subjectLevel; var gradelevel; if (course <=3){ subjectLevel = "Amateur"; gradelevel = "Higher" - }else if(course>=4 && course<=8){ + }else if(course>=4){ subjectLevel = "Mid"; gradelevel="10" }else{ @@ -116,97 +118,228 @@ function createDummyCourses() { } //insert into courses - courses.bulk({"docs":defaultCourses}, function(err, res) { + courses.bulk({"docs":defaultCourses}, function(err, rescourse) { if (err) return console.log(err); else{ - for(var steps = 0; steps < n_steps; steps++){ - for(var courselist = 0; courselist < res.length; courselist++){ - - defaultCoursestep.push({ - "courseId": res[courselist].id, - "description": "This is course step "+ (steps+1), - "kind": "Course Step", - "passingPercentage": "30", - "resourceTitles":[], - "resourceId":[], - "questionslist":[], - "step": steps+1, - "stepGoals": "Knowledge", - "stepMethod": "Theory", - "title": "Course Step "+ (steps+1), - "totalMarks": "100" - }); - } - } - - //insert into coursestep - coursestep.bulk({"docs":defaultCoursestep},function(err,resstep){ + defaultResources.push({ + "kind": "Resource", + "status": "accepted", + "title": "Resource1", + "author": "s", + "Publisher": "ds", + "language": "English", + "Year": "s", + "linkToLicense": "dsd", + "subject": [ + "Agriculture", + "Arts", + "Business and Finance", + "Environment", + "Food and Nutrition", + "Geography", + "Health and Medicine", + "History", + "Human Development", + "Languages", + "Law", + "Learning", + "Literature", + "Math", + "Music", + "Politics and Government", + "Reference", + "Religion", + "Science", + "Social Sciences", + "Sports", + "Technology" + ], + "Level": [ + "Professional" + ], + "Tag": null, + "Medium": "Text", + "openWith": "PDF.js", + "resourceFor": "Leader", + "resourceType": "Textbook", + "uploadDate": "2017-10-10T18:15:00.000Z", + "averageRating": "", + "articleDate": "2017-10-10T18:15:00.000Z", + "addedBy": "admin", + "openUrl": "", + "openWhichFile": "", + "need_optimization": true, + "sum": 0, + "timesRated": 0 + }); + //insert into Resources + resources.bulk({"docs":defaultResources},function(err,resreso){ if(err){ console.log(err); }else{ - for(var steplist = 0; steplist Date: Thu, 12 Oct 2017 16:31:47 +0545 Subject: [PATCH 09/15] Made some changes --- app/MyApp/indexFile.js | 2 - tests/course_mock_data | 90 +++++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/app/MyApp/indexFile.js b/app/MyApp/indexFile.js index 03c9ac2fc..f43cb5db5 100644 --- a/app/MyApp/indexFile.js +++ b/app/MyApp/indexFile.js @@ -921,8 +921,6 @@ function sendAdminRequest(courseLeader, courseName, courseId) { async: false }) var num = gmodel.get("members").length - console.log("memberlength"+num) - console.log(gmodel.get("memberLimit")); if (gmodel.get("memberLimit")) { if (gmodel.get("memberLimit") < num) { alert(App.languageDict.attributes.Course_Full) diff --git a/tests/course_mock_data b/tests/course_mock_data index 90d201961..bac48f32f 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -19,7 +19,7 @@ function increaseLimits() { return createDummyCourses() } -var n_members = 6; +var n_members = 4; var n_steps = 5; var defaultCourses = []; //Contains only CourseID and MemberList var defaultCoursestep = []; @@ -108,7 +108,7 @@ function createDummyCourses() { "languageOfInstruction": "English", "location": "Alberta", "memberLimit": "20", - "members": memberarr, + "members": [memberarr[course]], "method": "Theory and Practical", "name": "Course " +course_number, "startDate": "01/01/2017", @@ -189,8 +189,8 @@ function createDummyCourses() { "description": "This is course step "+ (steps+1), "kind": "Course Step", "passingPercentage": "30", - "resourceTitles":[], - "resourceId":[], + "resourceTitles":[resreso[0].title], + "resourceId":[resreso[0].id], "questionslist":[], "step": steps+1, "stepGoals": "Knowledge", @@ -284,53 +284,51 @@ function createDummyCourses() { var n = n+5; } for (var i = 0; i < n_members; i++) { - for (var j = 0; j < rescourse.length; j++) { - defaultMemberprogress.push({ - "kind": "course-member-result", - "stepsIds": stepIdlist[j], - "memberId":resmem[j].id , - "stepsResult":[ - [ - null, - "50" - ], - [ - null, - "100" - ], - [ - null, - "0" - ], - "", - "" + defaultMemberprogress.push({ + "kind": "course-member-result", + "stepsIds": stepIdlist[i], + "memberId":resmem[i].id , + "stepsResult":[ + [ + null, + "50" ], - "stepsStatus":[ - [ - null, - 1 - ], - [ - null, - 1 - ], - [ - null, - 0 - ], - "0", + [ + null, + "100" + ], + [ + null, "0" ], - "pqAttempts":[ 1, - 1, - 1, - 0, + "", + "" + ], + "stepsStatus":[ + [ + null, + 1 + ], + [ + null, + 1 + ], + [ + null, 0 ], - "courseId": rescourse[j].id - }); - console.log(defaultMemberprogress) - } + "0", + "0" + ], + "pqAttempts":[ 1, + 1, + 1, + 0, + 0 + ], + "courseId": rescourse[i].id + }); + console.log(defaultMemberprogress) } membercourseprogress.bulk({"docs":defaultMemberprogress}, function(err, res) { if (err) From ab1150b5abe4bd875d6ffdebb13c65048e8d9e31 Mon Sep 17 00:00:00 2001 From: pr0chin Date: Thu, 12 Oct 2017 16:48:08 +0545 Subject: [PATCH 10/15] [#1022] Statement added --- tests/course_mock_data | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/course_mock_data b/tests/course_mock_data index bac48f32f..99e645ccb 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -1,3 +1,8 @@ +/*Here I have made some course test scenario where test is done automatically while it renders all data in BeLL-App UI and couchdb. +For test scenario we have got multiple members, courses, steps , resources, questions adn a membercourseprogress as we need all +these specific variables or a data that should be bulk inserted in a data base*/ +/*For running this script we have to run node [filename][url] eg:node course_mock_data http://192.168.10.111:5982 */ + var util = require('util') var fs = require('fs') var exec = require('child_process').exec; @@ -93,7 +98,7 @@ function createDummyCourses() { subjectLevel = "Beginner"; gradelevel="5" } - + //insert into courses defaultCourses.push({ "CourseTitle": "Course " +course_number, "Day": "0", @@ -116,12 +121,12 @@ function createDummyCourses() { "subjectLevel": subjectLevel }); } - //insert into courses courses.bulk({"docs":defaultCourses}, function(err, rescourse) { if (err) return console.log(err); else{ + //insert into Resources defaultResources.push({ "kind": "Resource", "status": "accepted", @@ -173,7 +178,6 @@ function createDummyCourses() { "sum": 0, "timesRated": 0 }); - //insert into Resources resources.bulk({"docs":defaultResources},function(err,resreso){ if(err){ console.log(err); @@ -284,6 +288,7 @@ function createDummyCourses() { var n = n+5; } for (var i = 0; i < n_members; i++) { + //insert into Membercourseprogress defaultMemberprogress.push({ "kind": "course-member-result", "stepsIds": stepIdlist[i], From 65b35c0483d099b41c46d0198d93e51c13e5f19e Mon Sep 17 00:00:00 2001 From: pr0chin Date: Fri, 13 Oct 2017 16:36:25 +0545 Subject: [PATCH 11/15] [#1022] Dynamic course test scenario --- tests/course_mock_data | 183 ++++++++++++++++++++++++++++++----------- 1 file changed, 133 insertions(+), 50 deletions(-) diff --git a/tests/course_mock_data b/tests/course_mock_data index 99e645ccb..a4554efe6 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -33,6 +33,8 @@ var defaultResources = []; var defaultMembers = []; var defaultCourseanswer = []; var defaultMemberprogress = []; +var c_step ={}; +var m_step = [[],[],[],[]]; function createDummyCourses() { var courses = nano.db.use('courses'); @@ -187,28 +189,101 @@ function createDummyCourses() { courseIdlist.push(rescourse[i].id) } for(var courselist = 0; courselist < rescourse.length; courselist++){ - for(var steps = 0; steps < n_steps; steps++){ - defaultCoursestep.push({ - "courseId": rescourse[courselist].id, - "description": "This is course step "+ (steps+1), - "kind": "Course Step", - "passingPercentage": "30", - "resourceTitles":[resreso[0].title], - "resourceId":[resreso[0].id], - "questionslist":[], - "step": steps+1, - "stepGoals": "Knowledge", - "stepMethod": "Theory", - "title": "Course Step "+ (steps+1), - "totalMarks": "100" - }); - } + if(courselist == 1){ + n_steps = 1 + for(var steps = 0; steps < n_steps; steps++){ + defaultCoursestep.push({ + "courseId": rescourse[courselist].id, + "description": "This is course step "+ (steps+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":["Resources"], + "resourceId":[resreso[0].id], + "questionslist":[], + "step": steps+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (steps+1), + "totalMarks": "100" + }); + } + }else if(courselist == 2){ + n_steps = 2 + for(var steps = 0; steps < n_steps; steps++){ + defaultCoursestep.push({ + "courseId": rescourse[courselist].id, + "description": "This is course step "+ (steps+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":["Resources"], + "resourceId":[resreso[0].id], + "questionslist":[], + "step": steps+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (steps+1), + "totalMarks": "100" + }); + } + }else if(courselist == 3){ + n_steps = 3 + for(var steps = 0; steps < n_steps; steps++){ + defaultCoursestep.push({ + "courseId": rescourse[courselist].id, + "description": "This is course step "+ (steps+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":["Resources"], + "resourceId":[resreso[0].id], + "questionslist":[], + "step": steps+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (steps+1), + "totalMarks": "100" + }); + } + }else{ + for(var steps = 0; steps < n_steps; steps++){ + defaultCoursestep.push({ + "courseId": rescourse[courselist].id, + "description": "This is course step "+ (steps+1), + "kind": "Course Step", + "passingPercentage": "30", + "resourceTitles":["Resources"], + "resourceId":[resreso[0].id], + "questionslist":[], + "step": steps+1, + "stepGoals": "Knowledge", + "stepMethod": "Theory", + "title": "Course Step "+ (steps+1), + "totalMarks": "100" + }); + } + } } //insert into coursestep coursestep.bulk({"docs":defaultCoursestep},function(err,resstep){ if(err){ console.log(err); }else{ + for (var i = 0; i < 5; i++) { + m_step[0].push(resstep[i].id) + } + c_step[rescourse[0].id] = m_step[0] + for (var b = 5; b <= 5; b++) { + m_step[1].push(resstep[b].id) + } + c_step[rescourse[1].id] = m_step[1] + for (var i = 6; i < 8; i++) { + m_step[2].push(resstep[i].id) + } + c_step[rescourse[2].id] = m_step[2] + for (var i = 8; i < 11; i++) { + m_step[3].push(resstep[i].id) + } + c_step[rescourse[3].id] = m_step[3] + console.log(c_step); for(var steplist = 0; steplist Date: Thu, 26 Oct 2017 15:54:16 +0545 Subject: [PATCH 12/15] [#1022] Course mock data --- tests/course_mock_data | 224 +++++++++++++++++++++++------------------ 1 file changed, 128 insertions(+), 96 deletions(-) diff --git a/tests/course_mock_data b/tests/course_mock_data index a4554efe6..f8a618538 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -33,6 +33,8 @@ var defaultResources = []; var defaultMembers = []; var defaultCourseanswer = []; var defaultMemberprogress = []; +var member_obj ={}; +var member_arr = [[],[],[],[],[]]; var c_step ={}; var m_step = [[],[],[],[]]; @@ -80,13 +82,32 @@ function createDummyCourses() { }); } } + members.bulk({"docs":defaultMembers}, function(err, resmem) { if (err) return console.log(err); else { - var memberarr = []; + for (var i = 0; i < 4; i++) { + member_arr[0].push(resmem[i].id) + } + member_obj[resmem[0].id] = member_arr[0] + for (var b = 0; b < 3; b++) { + member_arr[1].push(resmem[b].id) + } + member_obj[resmem[1].id] = member_arr[1] + for (var i = 0; i < 2; i++) { + member_arr[2].push(resmem[i].id) + } + member_obj[resmem[2].id] = member_arr[2] + for (var i = 0; i < 1; i++) { + member_arr[3].push(resmem[i].id) + } + member_obj[resmem[3].id] = member_arr[3] + for (var i = 0; i < 0; i++) { + member_arr[4].push(resmem[i].id) + } + for(var course = 0; course < resmem.length; course++){ - memberarr.push(resmem[course].id); course_number = course + 1; var subjectLevel; var gradelevel; @@ -115,7 +136,7 @@ function createDummyCourses() { "languageOfInstruction": "English", "location": "Alberta", "memberLimit": "20", - "members": [memberarr[course]], + "members": member_obj[Object.keys(member_obj)[course]], "method": "Theory and Practical", "name": "Course " +course_number, "startDate": "01/01/2017", @@ -123,7 +144,6 @@ function createDummyCourses() { "subjectLevel": subjectLevel }); } - courses.bulk({"docs":defaultCourses}, function(err, rescourse) { if (err) return console.log(err); @@ -262,6 +282,7 @@ function createDummyCourses() { } } } + //insert into coursestep coursestep.bulk({"docs":defaultCoursestep},function(err,resstep){ if(err){ @@ -333,99 +354,110 @@ function createDummyCourses() { }); } - coursequestion.bulk({"docs":defaultCoursequestion}, function(err, resquestion) { - if (err) - return console.log(err); - else { - //need to update questionlist in coursestep - var j = 0; - var k = 4; - for(var i = 0; i < defaultCoursestep.length; i++){ - if(i%2==0){ - for(j; j < k-3; j++){ - defaultCoursestep[i].questionslist.push(resquestion[j].id) - } - j = k; - k = k+4; - }else if(i%3 == 0){ - for(j; j < k-2; j++){ - defaultCoursestep[i].questionslist.push(resquestion[j].id) - } - j = k; - k = k+4; - } else{ - for(j; j < k; j++){ - defaultCoursestep[i].questionslist.push(resquestion[j].id) - } - j = k; - k = k+4; - } - coursestep.insert(defaultCoursestep[i], function(err, res) { - if (err) - return console.log(err); - }); - } - //console.log(defaultCoursestep) - } - for (var i = 0; i < n_members; i++) { - //insert into Membercourseprogress - defaultMemberprogress.push({ - "kind": "course-member-result", - "stepsIds": c_step[Object.keys(c_step)[i]], - "stepsResult":[ - [ - "100", - "50" - ], - [ - "50", - "100" - ], - [ - null, - "0" - ], - "", - "" - ], - "stepsStatus":[ - [ - 1, - 1 - ], - [ - 1, - 1 - ], - [ - 1, - 0 - ], - [ - 1, - 1 - ], - "0" - ], - "pqAttempts":[ 1, - 3, - 5, - 0, - 0 - ], - "courseId": Object.keys(c_step)[i] - }); - console.log(defaultMemberprogress) - membercourseprogress.bulk({"docs":defaultMemberprogress}, function(err, res) { - if (err) - return console.log(err); - else { - done(); + coursequestion.bulk({"docs":defaultCoursequestion}, function(err, resquestion) { + if (err) + return console.log(err); + else { + //need to update questionlist in coursestep + var j = 0; + var k = 4; + for(var i = 0; i < defaultCoursestep.length; i++){ + if(i%2==0){ + for(j; j < k-3; j++){ + defaultCoursestep[i].questionslist.push(resquestion[j].id) + } + j = k; + k = k+4; + }else if(i%3 == 0){ + for(j; j < k-2; j++){ + defaultCoursestep[i].questionslist.push(resquestion[j].id) + } + j = k; + k = k+4; + } else{ + for(j; j < k; j++){ + defaultCoursestep[i].questionslist.push(resquestion[j].id) + } + j = k; + k = k+4; } - }); + coursestep.insert(defaultCoursestep[i], function(err, res) { + if (err) + return console.log(err); + }); } - } - }); + } + + for (var i = 0; i < resmem.length; i++) { + //insert into Membercourseprogress + for (var j = 4; j > 0; j--) { + defaultMemberprogress.push({ + "kind": "course-member-result", + "memberId":resmem[i].id, + "stepsIds": c_step[Object.keys(c_step)[j]], + "stepsResult": [ + [ + null, + "100" + ], + [ + null, + "25", + "50", + "65" + ], + [ + null, + "0", + "10" + ], + [ + null, + "0" + ], + "" + ], + "stepsStatus": [ + [ + null, + "1" + ], + [ + null, + "1", + "1", + "1" + ], + [ + null, + "0", + "0" + ], + [ + null, + null + ], + "0" + ], + "pqAttempts": [ + 1, + 3, + 2, + 1, + 0 + ], + "courseId": Object.keys(c_step)[j] + }); + } + } + membercourseprogress.bulk({"docs":defaultMemberprogress}, function(err, res) { + if (err) + return console.log(err); + else{ + done(); + } + }); + }); } }); } @@ -436,6 +468,6 @@ function createDummyCourses() { }); } function done(){ - console.log("done"); + console.log("Your Course mock test is ready"); } start() \ No newline at end of file From ed34456717aa8cc2cca325d480c4f315adcdf2df Mon Sep 17 00:00:00 2001 From: pr0chin Date: Fri, 27 Oct 2017 10:37:02 +0545 Subject: [PATCH 13/15] [#1022] Added install_windows --- install_windows | 145 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 install_windows diff --git a/install_windows b/install_windows new file mode 100644 index 000000000..f61bc331b --- /dev/null +++ b/install_windows @@ -0,0 +1,145 @@ +#!/usr/bin/env node + +/** + * Module dependencies. + */ + +var sys = require('sys') +var fs = require('fs') +var exec = require('child_process').exec; +var program = require('commander'); +var databases = [] +program + .version('0.0.2') + .parse(process.argv); +if (!program.args[0]) return console.log('No CouchDB URL provided. Quiting now.') +var couchUrl = program.args[0] +var nano = require('nano')(couchUrl) + +function start() { + getListOfDatabases() +} + +function getListOfDatabases() { + fs.readdir('./databases', function doneReadDir(err, files) { + files.forEach(function addFile(element, index, array) { + databases.push(element.substr(0, element.length - 3)) + }) + installDatabases() + }) +} + +var a = 0 + +function installDatabases() { + var database = databases[a] + if (a !== databases.length) { + console.log("creating database " + database) + nano.db.create(database, function(err, body) { + if (err && err.error !== "file_exists") console.log(err) + a++ + return installDatabases() + }) + } else { + return installDesignDocs() + } +} + +var b = 0 + +function installDesignDocs() { + var database = databases[b] + if (b !== databases.length) { + if (database != "communities" && database != "languages" && database != "configurations") { + console.log("Inserting design docs for the " + database + " database"); + var docToPush = 'databases\\' + database + '.js'; + var targetDb = couchUrl + '/' + database; + exec('pushDocToDb.bat "' + docToPush + '" "' + targetDb + '"', function(error, stdout, stderr) { + if (error) console.log(error); + if (stderr) console.log(stderr); + console.log(stdout) + b++ + installDesignDocs() + }) + } else { + b++ + installDesignDocs() + } + } else { + createDefaultAdminMember() + } +} + +function createDefaultAdminMember() { + nano.db.get('members', function(err, body) { + if (err) console.log(err) + // Cancel if there are already members in the database + if (body.doc_count > 1) return done() + console.log('Creating a default admin member of admin:password') + var members = nano.db.use('members') + var defaultAdminMember = { + "login": "admin", + "kind": "Member", + "roles": ["Manager", "SuperManager"], + "firstName": "Default", + "lastName": "Admin", + "password": "password", + "Gender": "Male", + "status": "active", + "email": "admin.somalia@olebell.org", + "visits": 0 + } + members.insert(defaultAdminMember, function (err, res) { + if (err) + return console.log(err) + else { + var configurations = nano.db.use('configurations'); + var configsDocPath = 'init_docs/ConfigurationsDoc-Nation.txt'; + fs.readFile(configsDocPath, function (err, data) { + configurations.insert(data, function (err, res) { + if (err) { + console.log(err); + } else { + console.log("******************Going to insert document into languages database*******************************"); + insertLanguageDocs(); + } + done() + }) + }) + } + }); + + }); +} + +function insertLanguageDocs() { + var languages = nano.db.use('languages'); + fs.readdir('./init_docs/languages', function doneReadDir(err, files) { + files.forEach(function (element) { + var langList = ['Arabic.txt', 'English.txt', 'Nepali.txt', 'Spanish.txt', 'Urdu (Pakistan).txt']; + if (langList.indexOf(element) > -1) { + var langDocPath = './init_docs/languages/' + element; + console.log("Inserting " + element); + fs.readFile(langDocPath, function (err, data) { + languages.insert(data, function (err, res) { + if (err) { + console.log(err); + } else { + console.log(element + " doc inserted successfully."); + } + }); + }); + } + }) + }); +} + +function done() { + console.log('done!') +} + +// +// Trigger Start +// + +start(); From 32118cf2db79d43a94d2fb6cdec85e24b29fa547 Mon Sep 17 00:00:00 2001 From: pr0chin Date: Fri, 27 Oct 2017 11:13:19 +0545 Subject: [PATCH 14/15] [#1022] Travis fixed --- tests/{report_test.js => report_tset.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{report_test.js => report_tset.js} (100%) diff --git a/tests/report_test.js b/tests/report_tset.js similarity index 100% rename from tests/report_test.js rename to tests/report_tset.js From a3434b7c71e8556c07922452cdd752bbf3310d9a Mon Sep 17 00:00:00 2001 From: Rupesh Manandhar Date: Fri, 27 Oct 2017 16:15:29 +0545 Subject: [PATCH 15/15] [#1022] Increaselimits function removed --- tests/course_mock_data | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/course_mock_data b/tests/course_mock_data index f8a618538..0cb29313d 100644 --- a/tests/course_mock_data +++ b/tests/course_mock_data @@ -16,14 +16,9 @@ var couchUrl = program.args[0] var nano = require('nano')(couchUrl) function start() { - increaseLimits() -} - -// Increase Limits so couchapp push works correctly -function increaseLimits() { return createDummyCourses() - } + var n_members = 4; var n_steps = 5; var defaultCourses = []; //Contains only CourseID and MemberList