From fdecd784f939c683f52b154d4ac32e73fc048bba Mon Sep 17 00:00:00 2001 From: pr0chin Date: Tue, 3 Oct 2017 17:11:01 +0545 Subject: [PATCH] [#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