Created
June 13, 2013 21:24
-
-
Save troscoe/5777502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var questions = Alloy.Collections.questions; | |
var exam = Alloy.createModel("exam", { | |
type: type, | |
date: moment().format('YYYY-MM-DD'), | |
length: num_questions, | |
location: 0, | |
time: time, | |
started: 0, | |
progress: 0, | |
completed: 0, | |
score: 0, | |
block_a_score: 0, | |
block_a_num: lengths["a_length"], | |
block_b_score: 0, | |
block_b_num: lengths["b_length"], | |
block_c_score: 0, | |
block_c_num: lengths["c_length"], | |
block_d_score: 0, | |
block_d_num: lengths["d_length"], | |
block_e_score: 0, | |
block_e_num: lengths["e_length"], | |
block_f_score: 0, | |
block_f_num: lengths["f_length"] | |
}); | |
for (var i=0; i < num_questions; i++) { | |
var question = addQuestion(i); | |
questions.add(question); | |
question.save(); | |
} | |
var exams = Alloy.Collections.exams; | |
exams.add(exam); | |
exam.save(); | |
function addQuestion(num) { | |
var question = Alloy.createModel('question', { | |
exam_id: Alloy.Collections.exams.length, | |
number: num + 1, | |
id: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').id, | |
question_txt: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').text, | |
option1: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').options.option[0], | |
option2: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').options.option[1], | |
option3: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').options.option[2], | |
option4: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').options.option[3], | |
answer: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').answer, | |
reference: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').reference, | |
figure: i18n.getString('root.sections.section[' + set.questions[num].s + '].questions.question[' + set.questions[num].n + ']').figure, | |
selected: 0, | |
sumbmitted: 0, | |
inReview: 0 | |
}); | |
return question; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment