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

Commit

Permalink
[#1022] Made changes for course secnario
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0chin committed Sep 15, 2017
1 parent 3b96da1 commit f288b6a
Showing 1 changed file with 140 additions and 97 deletions.
237 changes: 140 additions & 97 deletions tests/mock_data
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<res.length;i++){
course_id.push(res[i].id);
}

for(var i = 0; i < 1; i++){
var course_id = randomCourses();
defaultCoursestep.push({
"courseId": course_id,
"courseId": course_id[i],
"description": "This is course step "+ (parseInt(i)+1),
"kind": "Course Step",
"passingPercentage": "30",
Expand All @@ -103,91 +93,144 @@ function createDummyCourses() {
"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
defaultResources.push({
"kind": "Resource",
"status": "accepted",
"title": "a",
"author": "a",
"Publisher": "",
"language": "Arabic",
"Year": "a",
"linkToLicense": "",
"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": [
"Early Education",
"Lower Primary",
"Upper Primary",
"Lower Secondary",
"Upper Secondary",
"Undergraduate",
"Graduate",
"Professional"
],
"Tag": null,
"Medium": "Text",
"openWith": "Just download",
"resourceFor": "Default",
"resourceType": "Textbook",
"uploadDate": "2017-09-12T18:15:00.000Z",
"averageRating": "",
"articleDate": "2017-09-12T18:15:00.000Z",
"addedBy": "admin",
"openUrl": "",
"openWhichFile": "",
"sum": 0,
"timesRated": 0
});
}
var resources = nano.db.use('resources');
resources.bulk({"docs":defaultResources}, function(err, body) {
if (err){
return console.log(err);
}else{
defaultCoursestep[0].resourceId.push(body[0].id);
//insert into coursestep
coursestep.insert({"docs":defaultCoursestep[0]},function(err,res){
if(err){
console.log(err);
}else{
defaultCoursestep[0]._id = res.id;
defaultCoursestep[0]._rev = res.rev;
//insert into coursequestion
defaultCoursequestion.push({
"CorrectAnswer": [
"Charles Babbages",
],
"Options": [
"Sachin Maharjan",
"Rupesh Manandhar",
"Charles Babbage",
"Stefan Unchester"
],
"Statement": "What is father of computer" +" ?",
"Type": "Multiple Choice",
"courseId": course_id,
"kind": "coursequestion",
"stepId" : defaultCoursestep[0]._id,
"Marks" : 10
});
defaultCoursequestion.push({
"Statement": "What is programming language"+" ?",
"Type": "Comment/Essay Box",
"courseId": course_id,
"kind": "coursequestion",
"stepId" : defaultCoursestep[0]._id,
"Marks" : 10
});

defaultCoursequestion.push({
"Statement": "Question "+ (parseInt(i)+1) +" ?",
"Type": "Attachment",
"courseId": course_id,
"kind": "coursequestion",
"stepId" : step_id,
"Marks" : 90
});
defaultCoursequestion.push({
"Statement": "Attach Summer Project" +".",
"Type": "Attachment",
"courseId": course_id,
"kind": "coursequestion",
"stepId" : defaultCoursestep[0]._id,
"Marks" : 10
});

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){
defaultCoursequestion.push({
"Statement": "Full form of IDE" +".",
"Type": "Single Textbox",
"courseId": course_id,
"kind": "coursequestion",
"stepId" : defaultCoursestep[0]._id,
"Marks" : 10
});

question_list_id.push(res[i].id);
defaultCoursestep[0].questionslist.push(res[i].id)

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++){
defaultCoursestep[0].questionslist.push(res[i].id)
}
//update coursestep[0]
coursestep.insert(defaultCoursestep[0], function(err, res) {
if (err)
return console.log(err);
else
done();
});
}
});
}
}

});
}
var coursestep = nano.db.use('coursestep');
coursestep.bulk({"docs":defaultCoursestep}, function(err, body) {
if (err)
return console.log(err);
else{
done();
}
});
}
});
});
}
});
}
Expand Down

0 comments on commit f288b6a

Please sign in to comment.