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