/
quiz.rlm
339 lines (300 loc) · 12.9 KB
/
quiz.rlm
1
<PG title="Quiz" name="quiz"> <SCR name="getPageID"><![CDATA[pageIcon = icon.parentNode.clip();if (rootIcon.projMode == "dev"){ // Page Wizard pageIcon.templateData = pageIcon.extXML.toObject(); pageIcon.templateData = pageIcon.templateData.pageWizard[0]; // establish page location issues that affect navigation calls // establish container myLocXML = String(icon.parentNode.parentNode); myLocXML = myLocXML.substr(1,3); if (myLocXML == "IFC"){ container = "Interface"; } else if (myLocXML == "FW ") { container = "Framework"; } else { // unspecified container = "U"; } // establish navigationOffset to cope with effect of an entryFrame firstC = String(icon.parentNode.parentNode.firstChild); firstC = firstC.substr(1,6); if (firstC == "FW_ENT") { navigationOffset = 1; // use - navigationOffset } else { navigationOffset = 0; } } else { // Toolkits myXML = new XML(extXML.firstChild.childNodes[rootIcon.getPageIndex() - pgOffset]); pageIcon.templateData = myXML.toObject(); navigationOffset = 1; container = "Interface";} rootIcon.setTitleText(templateData.learningObject[0].name); // handle multiple page data definitions in a project if (rootIcon.projectPageIndex == undefined){ rootIcon.projectPageIndex = 0;}// check if this page has a definition for the current project index and default to 0 if notif (pageIcon.templateData.quiz[rootIcon.projectPageIndex].name == undefined){ projPI = 0;} else { projPI = rootIcon.projectPageIndex; } //make questionsif (icon.attributes.built != 'true'){ icon.parentNode.getChildByName("questions").firstChild.duplicate(pageIcon.templateData.quiz[projPI].question.length - 1); icon.attributes.built = 'true';}quizPageTracking = new Array();quizScoreTracking = new Array();align = pageIcon.templateData.quiz[projPI].align;//sequencingif (pageIcon.templateData.quiz[projPI].order == 'random'){ icon.parentNode.getChildByName("questions").attributes.branch = 'randomUnused';} else { icon.parentNode.getChildByName("questions").attributes.branch = 'sequence';}//number of questionsif (pageIcon.templateData.quiz[projPI].numQuestions == undefined || pageIcon.templateData.quiz[projPI].numQuestions.toLowerCase() == 'all'){ icon.parentNode.getChildByName("questions").attributes.repeat = 'all'; qCount = pageIcon.templateData.quiz[projPI].question.length;} else { icon.parentNode.getChildByName("questions").attributes.repeat = pageIcon.templateData.quiz[projPI].numQuestions; qCount = pageIcon.templateData.quiz[projPI].numQuestions;}panelWidth = pageIcon.templateData.quiz[projPI].panelWidth;if (panelWidth == "Small"){ panelW = 300; textW = 440;} else if (panelWidth == "Medium"){ panelW = 450; textW = 290;} else if (panelWidth == "Large"){ panelW = 600; textW = 150;} else { panelW = 760; textW = 0;}//video?if (pageIcon.templateData.quiz[projPI].video != undefined){ panelW = 450; textW = 290;}// language string set upif (pageIcon.templateData.quiz[projPI].quesCount != undefined){ quesCount = pageIcon.templateData.quiz[projPI].quesCount; feedbackLabel = pageIcon.templateData.quiz[projPI].feedbackLabel; singleRight = pageIcon.templateData.quiz[projPI].singleRight; singleWrong = pageIcon.templateData.quiz[projPI].singleWrong; multiRight = pageIcon.templateData.quiz[projPI].multiRight; multiWrong = pageIcon.templateData.quiz[projPI].multiWrong; onCompletion = pageIcon.templateData.quiz[projPI].onCompletion; scoreText = pageIcon.templateData.quiz[projPI].score; submitBtnText = pageIcon.templateData.quiz[projPI].submitBtnText; submitBtnTip = pageIcon.templateData.quiz[projPI].submitBtnTip; submitBtnWidth = pageIcon.templateData.quiz[projPI].submitBtnWidth; nextBtnText = pageIcon.templateData.quiz[projPI].nextBtnText; nextBtnTip = pageIcon.templateData.quiz[projPI].nextBtnTip; nextBtnWidth = pageIcon.templateData.quiz[projPI].nextBtnWidth; restartBtnText = pageIcon.templateData.quiz[projPI].restartBtnText; restartBtnTip = pageIcon.templateData.quiz[projPI].restartBtnTip; restartBtnWidth = pageIcon.templateData.quiz[projPI].restartBtnWidth;} else { quesCount="Question {i} of {n}"; feedbackLabel="Feedback"; singleRight="Your answer is correct"; singleWrong="Your answer is incorrect"; multiRight="You have selected all the correct answers"; multiWrong="You have not selected the correct combination of answers"; onCompletion="You have completed the exercise"; scoreText="You scored {i}/{n}"; submitBtnText="Submit"; submitBtnTip="Submit Answer"; submitBtnWidth="100"; nextBtnText="Next"; nextBtnTip="Next Question"; nextBtnWidth="100"; restartBtnText="Restart"; restartBtnTip="Restart Quiz"; restartBtnWidth="100"}if (pageIcon.templateData.quiz[projPI].narration != undefined){ narration = pageIcon.templateData.quiz[projPI].narration; rootIcon.broadcast('showAudio');}]]></SCR> <DIS tabIndex="-1" id="panel" h="474" w="panelW" name="panel" x="align == 'left' ? 20 : 780 - panelW" y="20" type="ext" url="templatePath + 'common/whitePanel.swf'"><![CDATA[]]></DIS> <INT name="loadPanel" perpetual="0"> <RES name="onLoad" type="event" eventName="onLoad" icon="panel" erase="1" exit="1"> <SCR name="calculate"><![CDATA[//ok to move on]]></SCR> </RES> </INT> <DIS id="instr" name="intructions" x="align == 'left' ? panel._x + panel._width + 20 : 20" y="20" w="textW" h="10" type="text"><![CDATA[{pageIcon.templateData.quiz[projPI].instructions}]]></DIS> <SCR name="movie"><![CDATA[if (pageIcon.templateData.quiz[projPI].video == undefined){ if (icon.built != true){ icon.nextSibling.removeNode(); icon.built = true; }}]]></SCR> <MOV w="290" name="[Untitled]" x="instr._x" y="instr._y + instr._height + 20" url="{pageIcon.templateData.quiz[projPI].video}" controls="1" play="0"><![CDATA[]]></MOV> <DEC id="quiz" name="questions" repeat="all" branch="blaH" pause="0" erase="1" eraseOnExit="0"> <PG name="protoQuestion"> <SCR name="setup"><![CDATA[if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].image != undefined){ prptWidth = (panelW / 2) - 30;} else { icon.parentNode.getChildByName("loader").removeNode(); prptWidth = panelW - 40;}quizPrompt = "<b>" + quesCount + "</b>";quizPrompt = replace(quizPrompt, "{i}", quiz.repCount);quizPrompt = replace(quizPrompt, "{n}", qCount);//if (nQValue == "n"){// quizPrompt = quizPrompt + quiz.repCount + " " + betweenQuesCount + " " + qCount + " " + afterQuesCount + "</b>";//} else {// quizPrompt = quizPrompt + qCount + " " + betweenQuesCount + " " + quiz.repCount + " " + afterQuesCount + "</b>";//} quizPrompt = quizPrompt + "<br><br>" + pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].prompt; ]]></SCR> <DIS textColour="#000000" id="prpt" name="Prompt" x="panel._x + 20" y="panel._y + 20" w="prptWidth" h="10" type="text"><![CDATA[{quizPrompt}]]></DIS> <DIS tabIndex="-1" id="image" name="image" x="prpt._x + prpt._width + 20" y="prpt._y" type="ext" url="{pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].image}"><![CDATA[]]></DIS> <INT name="loader" perpetual="0"> <RES name="onLoad" type="event" eventName="onLoad" icon="image" erase="1" exit="1"> <SCR name="resize"><![CDATA[image.constrain(prptWidth, panel._height - 40);p = image._width / image._height;image._x = panel._x + panel._width - 20 - image._width;]]></SCR> </RES> </INT> <SCR name="makeOptions"><![CDATA[ln = pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].option.length;if (ln > 2 && icon.attributes.built != 'true'){ icon.nextSibling.childNodes[1].duplicate(ln - 2); icon.attributes.built = 'true';}//multi answer?if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Multiple Answer'){ for (i = 0; i < ln; i++){ icon.nextSibling.childNodes[i].attributes.type="checkBox"; }}optionTracking = new Array();for (i = 0; i < ln; i++){ optionTracking[i] = 0; if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].option[i].correct == 'true'){ icon.nextSibling.childNodes[i].attributes.correct = 1; } else { icon.nextSibling.childNodes[i].attributes.correct = 0; }}]]></SCR> <INT id="ques" name="protoInteraction" perpetual="0"> <RES w="prptWidth" textColour="#000000" name="protoOption" type="radio" x="prpt._x" y="prpt._y + prpt._height + 20" label="{pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].option[icon.index()].text}" group="grp" erase="1" exit="0"> <SCR name="judge"><![CDATA[//track the questionif (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Single Answer'){ for (i = 0; i < ln; i++){ optionTracking[i] = 0; } optionTracking[icon.parentNode.index()] = 1;} if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Multiple Answer'){ if (icon.parentNode.clip().getValue() == true){ optionTracking[icon.parentNode.index()] = 1; } else { optionTracking[icon.parentNode.index()] = 0; }} btnSubmit.setEnabled(true);]]></SCR> </RES> <RES w="prptWidth" textColour="#000000" name="protoOption" type="radio" x="prpt._x" y="_ytile + 10" label="{pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].option[icon.index()].text}" group="grp" erase="1" exit="0"> <SCR name="judge"><![CDATA[//track the questionif (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Single Answer'){ for (i = 0; i < ln; i++){ optionTracking[i] = 0; } optionTracking[icon.parentNode.index()] = 1;} if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Multiple Answer'){ if (icon.parentNode.clip().getValue() == true){ optionTracking[icon.parentNode.index()] = 1; } else { optionTracking[icon.parentNode.index()] = 0; }} btnSubmit.setEnabled(true);]]></SCR> </RES> <RES w="submitBtnWidth" toolTip="{submitBtnTip}" swf="templatePath + 'common/button.swf'" enabled="false" rs="btnSubmit" name="submit" type="button" x="icon.previousSibling.clip()._x" y="_ytile + 10" label="{submitBtnText}" erase="1" exit="0"> <SCR name="makeFeedback"><![CDATA[//single answer feedbackfb = "";for (i = 0; i < ln; i++){ if (optionTracking[i] == 1){ fb += pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].option[i].feedback + '\r\r'; }}fb = '<b>' + feedbackLabel + '</b><br>' + fb;if (pageIcon.templateData.quiz[projPI].judge == 'true'){ if (pageIcon.templateData.quiz[projPI].question[quiz.getPageIndex()].type == 'Single Answer'){ if (ques.judge()){ fb+= singleRight ; } else { fb += singleWrong; } } else { if (ques.judge()){ fb+= multiRight; } else { fb += multiWrong; } }}//track the scorm score?if (ques.judge()){ quizScoreTracking[quiz.repCount - 1] = 1;} else { quizScoreTracking[quiz.repCount - 1] = 0;}]]></SCR> <DIS scrolling="auto" textColour="#000000" name="feedback" x="btnSubmit._x" y="btnSubmit._y + btnSubmit._height + 20" w="prptWidth" h="474 - (btnSubmit._y + btnSubmit._height) - 40" type="text"><![CDATA[{fb}]]></DIS> <SCR name="enableNext"><![CDATA[btnNext.setEnabled(true);]]></SCR> </RES> <RES w="nextBtnWidth" toolTip="{nextBtnTip}" enabled="false" rs="btnNext" swf="templatePath + 'common/button.swf'" name="next" type="button" x="icon.previousSibling.clip()._x" y="455" label="{nextBtnText}" erase="1" exit="1"> <SCR name="next"><![CDATA[//move on]]></SCR> </RES> </INT> </PG> </DEC> <SCR name="scorm"><![CDATA[score = Math.ceil(quizScoreTracking.sum() / quizScoreTracking.length * 100);if (pageIcon.templateData.quiz[projPI].scorm == 'Track Last Score'){ _level0.setValue('cmi.core.score.raw', String(score));}if (pageIcon.templateData.quiz[projPI].scorm == 'Track First Score'){ if (isNaN(_level0.getValue('cmi.core.score.raw'))){ _level0.setValue('cmi.core.score.raw', String(score)); }}fb = '<b>' + onCompletion + '</b><br><br>' + pageIcon.templateData.quiz[projPI].feedback;if (pageIcon.templateData.quiz[projPI].judge == 'true'){ s = scoreText; s = replace(s, "{i}", quizScoreTracking.sum()); s = replace(s, "{n}", quizScoreTracking.length); fb += '<br><br>' + s;}]]></SCR> <DIS id="finalScore" name="finalScore" x="panel._x + 20" y="panel._y + 20" w="400" h="10" type="text"><![CDATA[{fb}]]></DIS> <INT name="restart" perpetual="0"> <RES w="restartBtnWidth" toolTip="{restartBtnTip}" swf="templatePath + 'common/button.swf'" name="restart" type="button" x="finalScore._x" y="finalScore._y + finalScore._height + 20" label="{restartBtnText}" erase="1" exit="0"> <SCR name="restart"><![CDATA[if (container == "Framework"){ fwXML = icon.findParentByType('FW'); pageNum = fwXML.clip().currentPage; fwXML.clip().gotoPage(pageNum); }else{ // use for projects rootIcon.gotoPage(rootIcon.getPageIndex() - navigationOffset);}]]></SCR> </RES> </INT> </PG>