Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Explore/elr/Science/S0501/shared/scripts/csl_randomassmt.js
diff options
context:
space:
mode:
Diffstat (limited to 'Explore/elr/Science/S0501/shared/scripts/csl_randomassmt.js')
-rwxr-xr-xExplore/elr/Science/S0501/shared/scripts/csl_randomassmt.js2973
1 files changed, 0 insertions, 2973 deletions
diff --git a/Explore/elr/Science/S0501/shared/scripts/csl_randomassmt.js b/Explore/elr/Science/S0501/shared/scripts/csl_randomassmt.js
deleted file mode 100755
index 1538995..0000000
--- a/Explore/elr/Science/S0501/shared/scripts/csl_randomassmt.js
+++ /dev/null
@@ -1,2973 +0,0 @@
-
-
-
-// version --- CSL_1.3.0.0
-
-
-
-var passThreshold;
-
-
-
-var retainOrder = false;
-
-
-
-var isSingleQuestionPerPage=false;
-
-
-
-var isRandomized = true;
-
-var showPercentage = false;
-
-var repeatAcrossAttempts = true;
-
-
-
-var doAttemptAllAnswers = true;
-
-var resumeAssessment = false;
-
-
-
-
-
-
-var flashWidth=250;
-
-
-
-var flashHeight=250;
-
-
-function Answer(pText,pTrue){
- this.text = pText;
- this.correct = pTrue;
-}
-
-
-
-
-function Question(pId,pText,pType,pImageSRC){
-
- this.launchURL = "";
- this.id = pId;
-
- this.index = 0;
-
- this.questionIdCache = new Object();
-
- this.text = pText;
- this.type = pType;
- this.image = pImageSRC;
-
- this.correctFeedbackText = "";
- this.incorrectFeedbackText = "";
- this.mandatory = false;
- this.leafQuestion = true;
- this.mandatoryChildren = new Array();
- this.randomChildren = new Array();
- this.numberOfQuestionsToReturn = 0;
-
- this.answers = new Array();
- this.addAnswer = addAnswer;
- this.isAdded = false;
- this.userResponse = false;
-
- this.toString = questionToString;
-
- this.setCorrectFeedback = setCorrectFeedback;
- this.setIncorrectFeedback = setIncorrectFeedback;
- this.setLaunchURL = setLaunchURL;
- this.getLaunchURL = getLaunchURL;
-
- this.setId = setId;
- this.getId = getId;
-
- this.setMandatory = setMandatory;
- this.getMandatory = getMandatory;
-
- this.isLeafQuestion = isLeafQuestion;
-
- this.setNumberOfQuestionsToReturn = setNumberOfQuestionsToReturn;
- this.getNumberOfQuestionsToReturn = getNumberOfQuestionsToReturn;
-
- this.getTotalNumberOfQuestions = getTotalNumberOfQuestions;
- this.getNumberOfRandomQuestions = getNumberOfRandomQuestions;
- this.getNumberOfMandatoryQuestions= getNumberOfMandatoryQuestions;
-
- this.addQuestion = addQuestion;
- this.addMandatoryQuestions = addMandatoryQuestions;
- this.getRandomQuestion = getRandomQuestion;
- this.getMandatoryQuestion = getMandatoryQuestion;
- this.getRandomizedQuestions = getRandomizedQuestions;
-
- this.getDifferentRandomQuestions = _getDifferentRandomQuestions;
- this.getNumberOfPreviousQuestions = _getNumberOfPreviousQuestions;
-
- this.getQuestionById = getQuestionById;
- this.containsQuestion = containsQuestion;
-
- this.threshold = 0; // field is valid only for pool question objects.
- this.setThreshold = _setThreshold;
- this.getThreshold = _getThreshold;
-
- this.rolledUpStatus = false; // if the number of questions passed are more than threshold , value will be true.
- this.getRolledUpStatus = _getRolledUpStatus;
-
- this.instructionText = "";
-
- this.setInstructionText = _setInstructionText;
- this.getInstructionText = _getInstructionText;
-
-
- //Added to suit the render functionality
- this.questionRenderer = _defaultQuestionRenderer;
- this.resultRenderer = _defaultResultRenderer;
- this.choiceRenderer = _defaultChoiceRenderer;
- this.resultChoiceRenderer = _defaultResultChoiceRenderer;
- this.defaultSummaryCorrectRenderer = _defaultSummaryCorrectRenderer;
- this.defaultSummaryInCorrectRenderer=_defaultSummaryInCorrectRenderer;
- this.defaultSummaryNotAttemptedRenderer= _defaultSummaryNotAttemptedRenderer;
- this.getRenderer = _getRenderer;
- this.getResultRenderer = _getResultRenderer;
- this.getChoiceRenderer = _getChoiceRenderer;
- this.getResultChoiceRenderer = _getResultChoiceRenderer;
- this.InstructionTextRenderer=_defaultInstructionTextRenderer;
- this.instantCorrectFeedbackRenderer=_defaultInstantCorrectFeedbackRenderer;
- this.instantInCorrectFeedbackRenderer=_defaultInstantInCorrectFeedbackRenderer;
-
-
-}
-
-function getLaunchURL(){
- return this.launchURL;
-}
-function setLaunchURL(pURL){
- this.launchURL = pURL;
-}
-function setId(pId){
- this.id = pId;
-}
-function getId(){
- return this.id;
-}
-
-
-
-
-function _setInstructionText(pText){
- this.instructionText = pText;
-}
-
-function _getInstructionText(){
- return this.instructionText;
-}
-
-
-
-function setMandatory(pBoolean){
- this.mandatory = pBoolean;
-}
-
-
-
-function setCorrectFeedback(pFeedback){
- this.correctFeedbackText = pFeedback;
-}
-
-
-
-function setIncorrectFeedback(pFeedback){
- this.incorrectFeedbackText = pFeedback;
-}
-
-
-function getMandatory(){
- return this.mandatory;
-}
-
-function isLeafQuestion(){
- return this.leafQuestion;
-}
-
-
-
-function addQuestion(pQuestion){
- if(pQuestion.getMandatory()){
- this.mandatoryChildren[this.mandatoryChildren.length]= pQuestion;
- }else{
- this.randomChildren[this.randomChildren.length] = pQuestion;
- }
- this.leafQuestion = false;
- this.questionIdCache[pQuestion.getId()] = true;
-}
-
-
-
-
-function addAnswer(pIndex , pAnswer){
- this.answers[pIndex] = pAnswer;
-}
-function getTotalNumberOfQuestions(){
- return this.randomChildren.length + this.mandatoryChildren.length;
-}
-function getNumberOfRandomQuestions(){
- return this.randomChildren.length;
-}
-function getNumberOfMandatoryQuestions(){
- return this.mandatoryChildren.length;
-}
-
-
-
-function setNumberOfQuestionsToReturn(pNumber){
- var tNum = parseInt(pNumber);
-
- if(tNum >= 0 ){
- if(tNum < this.mandatoryChildren.length || tNum > (this.mandatoryChildren.length + this.randomChildren.length))
- {
- var message = "The Number Of Mandatory Questions are more than the number of questions you have asked"
- message += " or the total number of questions are less";
- alert(message);
- }
- else
- {
- this.numberOfQuestionsToReturn = tNum;
- }
- }else{
- alert("Enter a positive number for setNumberOfQuestionsToReturn");
- }
-}
-
-function getNumberOfQuestionsToReturn(){
- return this.numberOfQuestionsToReturn;
-}
-
-
-function getRandomQuestion(pIndex){
- var retValue = null;
- if(pIndex < this.randomChildren.length && pIndex >= 0){
- retValue = this.randomChildren[pIndex];
- }
-return retValue;
-}
-
-function getMandatoryQuestion(pIndex){
- var retValue = null;
- if(pIndex < this.mandatoryChildren.length && pIndex >= 0){
- retValue = this.mandatoryChildren[pIndex];
- }
-return retValue;
-}
-
-
-var tPoolQuestionOrder = "";
-
-function getRandomizedQuestions(pOrder,pArray , pIdCache){
-
- var numOfMandatory = this.getNumberOfMandatoryQuestions();
- var numOfRandomQuestions = this.getNumberOfRandomQuestions() - 1;
- var totalQuestions = this.getNumberOfQuestionsToReturn();
-
- var numberToRandomize = totalQuestions - numOfMandatory;
-
- var tQuestion = this.getRandomQuestion(0);
-
- if( !tQuestion ){
- tQuestion = this.getMandatoryQuestion(0);
- }
- // randomize the 'normal' way only if repeatAcrossAttempts is true OR repeatAcrossAttempts is false AND child questions are pools.
- // the repeatAcrossAttempts logic is NOT applied to child pool questions.
-
- if( (!retainOrder && repeatAcrossAttempts) || (!retainOrder && !repeatAcrossAttempts && !tQuestion.isLeafQuestion()) ){
- if(numberToRandomize >= 0 ){
-
- tPoolQuestionOrder = "";
- this.addMandatoryQuestions(pOrder,pArray , pIdCache);
-
- var randomIndex = null;
- var previousIndexCache = new Object();
-
- var iterator = 0;
- var tQuestion = null;
-
- while(iterator < numberToRandomize){
- if( isRandomized ){
- randomIndex = Math.round(Math.random()*numOfRandomQuestions);
- }
- else{
- randomIndex = iterator;
- }
- // The following line is added to avoid an error thrown in Solaris/mozilla.
- randomIndex = parseInt( randomIndex );
- if(!previousIndexCache[randomIndex]){
- tQuestion = this.getRandomQuestion(randomIndex);
- if(tQuestion.isLeafQuestion()){
- pArray[pArray.length] = tQuestion;
-
- // Added by Jayaprakash A
- tQuestion.index = pArray.length -1;
-
- pOrder[ORDER] += tQuestion.getId() + ",";
- tPoolQuestionOrder += tQuestion.getId() + ",";
- }
- else{
- //debugger;
- tQuestion.getRandomizedQuestions(pOrder,pArray,pIdCache);
- }
- previousIndexCache[randomIndex] = true;
- ++iterator;
- }
- }
- }
- }else{
- this.getDifferentRandomQuestions(pOrder , pArray , pIdCache);
- }
- //addToSuspendData( this.id + "_pool" , tPoolQuestionOrder );
- tPoolQuestionOrder = "";
- return pArray;
-}
-
-function _getDifferentRandomQuestions(pOrder , pArray , pPreviousQuestionsCache){
- var numOfMandatory = this.getNumberOfMandatoryQuestions();
- var numOfRandomQuestions = this.getNumberOfRandomQuestions() - 1;
- var totalQuestions = this.getNumberOfQuestionsToReturn();
-
- var numberToRandomize = totalQuestions - numOfMandatory;
-
- //debugger;
- var numberOfPreviousQuestions = this.getNumberOfPreviousQuestions(pPreviousQuestionsCache);
- //alert("numberOfPreviousQuestions== "+numberOfPreviousQuestions);
- //alert("this.getTotalNumberOfQuestions()== "+this.getTotalNumberOfQuestions());
- if( numberOfPreviousQuestions < this.getTotalNumberOfQuestions() ){
- if(numberToRandomize >= 0 ){
-
- tPoolQuestionOrder = "";
- this.addMandatoryQuestions(pOrder,pArray , pPreviousQuestionsCache);
-
- var randomIndex = null;
- var previousIndexCache = new Object();
-
- var iterator = 0;
- var tQuestion = null;
-
- while(iterator < numberToRandomize){
- if( isRandomized ){
- randomIndex = Math.round(Math.random()*numOfRandomQuestions);
- }
- else{
- randomIndex = iterator;
- }
- // The following line is added to avoid an error thrown in Solaris/mozilla.
- randomIndex = parseInt( randomIndex );
- if(!previousIndexCache[randomIndex]){
- tQuestion = this.getRandomQuestion(randomIndex);
- if( !pPreviousQuestionsCache[tQuestion.getId()] ){
-
- if(tQuestion.isLeafQuestion()){
- pArray[pArray.length] = tQuestion;
-
- // Added by Jayaprakash A
- tQuestion.index = pArray.length -1;
-
- pOrder[ORDER] += tQuestion.getId() + ",";
- tPoolQuestionOrder += tQuestion.getId() + ",";
- }
- // this should never be the case , since this pool contains only leaf child questions.
- else{
- tQuestion.getDifferentRandomQuestions(pOrder,pArray , pPreviousQuestionsCache) ;
- }
- previousIndexCache[randomIndex] = true;
- ++iterator;
- }
- }
- }
- }
- }else{
- alert("Cannot Randomize , all the questions have been exhausted !");
- return pArray;
- }
- //addToSuspendData( this.id + "_pool" , tPoolQuestionOrder );
- tPoolQuestionOrder = "";
- return pArray;
-}
-
-function _getNumberOfPreviousQuestions(pIdCache){
- var count = 0;
- for(var id in pIdCache){
- if( this.containsQuestion(id) ){
- count++;
- }
- }
- return count;
-}
-
-function addMandatoryQuestions(pOrder,pArray , pIdCache){
- var index = this.mandatoryChildren.length;
- for(var i = 0 ; i < index ; i ++){
- if(this.mandatoryChildren[i].isLeafQuestion()){
- pArray[pArray.length] = this.mandatoryChildren[i];
-
- // Added by Jayaprakash A
- this.mandatoryChildren[i].index = pArray.length -1;
-
- pOrder[ORDER] += this.mandatoryChildren[i].getId() + ",";
- tPoolQuestionOrder += this.mandatoryChildren[i].getId() + ",";
- }
- else{
- this.mandatoryChildren[i].getRandomizedQuestions(pOrder,pArray , pIdCache);
- }
- }
-}
-
-function containsQuestion(pId){
- var retValue = this.questionIdCache[pId];
- if(!retValue){
- retValue = false;
- }
-return retValue;
-}
-
-function getQuestionById(pId){
- var tQuestion = null;
- var size = this.randomChildren.length;
- for(var i = 0 ; i < size ; i ++){
- if(pId == this.randomChildren[i].getId()){
- tQuestion = this.randomChildren[i];
- break;
- }
- }
- if(null == tQuestion){
- size = this.mandatoryChildren.length;
- for(var i = 0 ; i < size ; i ++){
- if(pId == this.mandatoryChildren[i].getId()){
- tQuestion = this.mandatoryChildren[i];
- break;
- }
- }
- }
-return tQuestion;
-}
-
-function _getThreshold(){
- return this.threshold;
-}
-
-function _setThreshold(pThreshold){
- if(!isNaN(pThreshold)){
- if(pThreshold <= this.getNumberOfQuestionsToReturn()){
- this.threshold = pThreshold;
- }else{
- alert("Threshold is greater than numberOfQuestionsToReturn for pool : " + this.id + " !");
- }
- }
-}
-
-function _getRolledUpStatus(pQuestions){
- //debugger;
- var status = false;
-
- var tQuestion = this.getRandomQuestion(0);
- if(!tQuestion)
- {
- tQuestion= this.getMandatoryQuestion(0);
- }
-
- if(tQuestion)
- {
- if(tQuestion.isLeafQuestion())
- {
- var counter = 0;
- var size = pQuestions.length;
- var tQuestion = null;
- var numOfCorrect= 0;
-
- while(counter < size)
- {
- tQuestion = pQuestions[counter];
- if(this.containsQuestion(tQuestion.id))
- {
- if(tQuestion.userResponse)
- {
- numOfCorrect++;
- }
- }
- counter++;
- }
-
- if(numOfCorrect >= this.threshold)
- {
- status = true;
- }
- }else
- {
- var counter = 0;
- var size = this.mandatoryChildren.length;
- var tQuestion = null;
- var numOfCorrect= 0;
-
- while(counter < size)
- {
- tQuestion = this.mandatoryChildren[counter];
- if(tQuestion.getRolledUpStatus(pQuestions))
- {
- numOfCorrect++;
- }
- counter++;
- }
-
- counter = 0;
- size = this.randomChildren.length;
- tQuestion = null;
- numOfCorrect = 0;
-
- while(counter < size)
- {
- tQuestion = this.randomChildren[counter];
- if(tQuestion.getRolledUpStatus(pQuestions))
- {
- numOfCorrect++;
- }
- counter++;
- }
-
- if(numOfCorrect >= this.threshold)
- {
- status = true;
- }
- }
- }
-
- return status;
-}
-
-/// END OF QUESTION OBJECT DEFINITION
-
-
-
-function getPoolStatus(pPoolId){
- var status = false;
-
- if(pPoolId == iQuestions.id)
- {
- status = iQuestions.getRolledUpStatus(iHeaderFrame.iFinalQuestions);
- }else{
- tQuestionPool = searchQuestionPool(iQuestions , pPoolId);
-
- if(tQuestionPool)
- {
- status = tQuestionPool.getRolledUpStatus(iHeaderFrame.iFinalQuestions);
- }
- else{
- alert("Pool with ID : " + pPoolId + " not found !");
- }
- }
- return status;
-}
-
-function searchQuestionPool(pParentQuestion , pPoolId){
- var tQuestion = null;
-
- if(pParentQuestion.containsQuestion(pPoolId))
- {
- tQuestion = pParentQuestion.getQuestionById(pPoolId);
- }else{
-
- // check if parent pool contains leaf questions....
-
- var tChildQuestion = pParentQuestion.mandatoryChildren[0];
- if(!tChildQuestion)
- {
- tChildQuestion = pParentQuestion.randomChildren[0];
- }
-
- if(!tChildQuestion || tChildQuestion.isLeafQuestion())
- {
- return tQuestion;
- }
-
- // end of check
-
- var counter = 0;
- var size = pParentQuestion.mandatoryChildren.length;
- tChildQuestion = null;
-
-
- while(counter < size && tQuestion == null)
- {
- tChildQuestion = pParentQuestion.mandatoryChildren[counter];
- if(tChildQuestion.containsQuestion(pPoolId))
- {
- return tChildQuestion.getQuestionById(pPoolId);
- }
- else
- {
- tQuestion = searchQuestionPool(tChildQuestion , pPoolId);
- }
- counter++;
- }
-
-
- if(!tQuestion){
- counter = 0;
- size = pParentQuestion.randomChildren.length;
- tChildQuestion = null;
-
-
- while(counter < size && tQuestion == null)
- {
- tChildQuestion = pParentQuestion.randomChildren[counter];
- if(tChildQuestion.containsQuestion(pPoolId))
- {
- return tChildQuestion.getQuestionById(pPoolId);
- }
- else
- {
- tQuestion = searchQuestionPool(tChildQuestion , pPoolId);
- }
- counter++;
- }
- }
- }
- return tQuestion;
-}
-
-
-
-
-function writeOutput(pContentPage){
- if( !pContentPage ){
- alert("Content document not found.");
- return;
- }
-
- iContentPage = pContentPage;
- initializeVariables();
-
- var tString = "";
- var tQuestion ;
-
- randomizeQuestions();
-
- for (i=0; i < displayQuestions ; i++){
-
- tQuestion = iFinalQuestions[i];
- if( tQuestion ){
- tString += generateQuestionHTML( tQuestion, i );
- }
- }
-
- iContentPage.document.write(tString);
- iContentPage.document.close();
-}
-
-
-
-/// This function gets the user answers from the suspend data and populates the Javascript Datamodels.
-
-
-
-
-function initializeResults(){
-
- var totalQuestions = 0;
- var tQuestionOrderString = "";
- var tUserResponse = "";
-
- tQuestionOrderString = getElementFromSuspendData("questionorder") ;
-
- var tOrderArray = tQuestionOrderString.split(',');
- var order;
- // Added by Jayaprakash A
- var tQuestion;
- if(!retainOrder && !repeatAcrossAttempts){
- for( qs=tOrderArray.length - displayQuestions; qs < tOrderArray.length ; qs++ ){
- order = parseInt( tOrderArray[qs] );
- if( !isNaN( order ) ){
- tQuestion = retrieveQuestion(order,iQuestions);
- iFinalQuestions[totalQuestions] = tQuestion;
- // Added by Jayaprakash A
- tQuestion.index = iFinalQuestions.length -1;
- totalQuestions++;
- }
- }
- }else{
- for( qs=0; qs < tOrderArray.length ; qs++ ){
- order = parseInt( tOrderArray[qs] );
- if( !isNaN( order ) ){
- tQuestion = retrieveQuestion(order,iQuestions);
- iFinalQuestions[totalQuestions] = tQuestion;
- // Added by Jayaprakash A
- tQuestion.index = iFinalQuestions.length -1;
- totalQuestions++;
- }
- }
- }
-
- retrieveUserResponse();
-}
-
-
-
-
-function gererateResultSummary(pContentPage){
- if( !pContentPage ){
- alert("Content document not found.");
- return;
- }
-
- iFinalQuestions = iHeaderFrame.iFinalQuestions;
- userSelected = iHeaderFrame.iUserAnswers;
-
- score = iHeaderFrame.score;
- iContentPage = pContentPage;
- var tString = '';
- if( showPercentage ){
- score = (score/displayQuestions) * 100;
- score = Math.round(score);
- tString += '<font face="Arial,Helvetica" size="2">You had <strong>' + score +'% </strong> out of ' + displayQuestions + ' questions.';
- }
- else{
- tString += '<font face="Arial,Helvetica" size="2">You had <strong>' + score +' correct answers</strong> out of ' + displayQuestions + ' questions.';
- }
-
- initializeVariables();
-
- var tQuestion;
- for (i=0; i < displayQuestions; i++ ){
- tQuestion = iFinalQuestions[i];
- if( tQuestion ){
- var qn = i+1;
- if( tQuestion.userResponse ){
- tString += '<hr> Question ' + qn + ' - ' + insertCommas( userSelected[i] ) + ' -- <bold>Correct</bold><p>';
- }
- else{
- if(userSelected[i]){
- tString += '<hr> Question ' + qn + ' - ' + insertCommas( userSelected[i] ) + ' -- <bold><font color="red">Incorrect</font></bold><p>';
- }
- else{
- tString += '<hr> Question ' + qn + ' - ' + insertCommas( userSelected[i] ) + ' -- <bold><font color="red">Not Attempted</font></bold><p>';
- }
-
- }
- }
- }
- tString += '<hr></font>';
- iContentPage.document.write(tString);
- iContentPage.document.close();
-}
-
-
-
-
-function generateResultExplanation(pContentPage){
- if( !pContentPage ){
- alert("Content document not found.");
- return;
- }
-
- iFinalQuestions = iHeaderFrame.iFinalQuestions;
- userSelected = iHeaderFrame.iUserAnswers;
-
-
-
- iContentPage = pContentPage;
-
- var tString = "";
- tString += '<form name="qz">';
- for (i=0; i < displayQuestions ; i++){
- tQuestion = iFinalQuestions[i];
- if( tQuestion ){
- tString += generateFeedback( tQuestion, i );
- }
- tString += "<br>";
- }
- tString += '</form>';
- iContentPage.document.write(tString);
- iContentPage.document.close();
-}
-
-
-
-
-function setQuestionsForm(pForm){
- iQuestionsForm = pForm;
-}
-
-
-
-
-function answeredAllQuestions(){
- var allAnswered = true;
- for(var i=0;i< displayQuestions;i++){
- if(!userSelected[i]){
- allAnswered = false;
- break;
- }
- }
- return allAnswered;
-}
-
-
-
-
-
-
-
-function submitAnswers(resultsPage){
- if ( !resultsPage ){
- alert("Valid Results page has to be passed");
- return;
- }
-
-
- var tAttempted = 0;
- var allAnswered = true;
- var firstUnAnswered;
- getCheckboxValue();
- setUserResponses();
-
- if(doAttemptAllAnswers){
- for(var i=0;i< displayQuestions;i++){
- if(userSelected[i]){
- if( userSelected[i].length <= 0 ){
- allAnswered = false;
- firstUnAnswered = iFinalQuestions[i].id;
- unAnsweredQuestionNumber = i+1;
- break;
- }
- }
- else{
- allAnswered = false;
- firstUnAnswered = iFinalQuestions[i].id;
- unAnsweredQuestionNumber = i+1;
- break;
- }
- }
- }
- iHeaderFrame.iFinalQuestions = iFinalQuestions;
- iHeaderFrame.iUserAnswers = userSelected;
- iHeaderFrame.iAnswersArray= iAnswersArray;
- iHeaderFrame.score = score;
-
- if (getElementFromSuspendData("lesson_status") == "attempted"){
- addToSuspendData("lesson_status" , "");
- }
- if( !allAnswered ){
- alert("You did not answer question number " + unAnsweredQuestionNumber + " !");
- tLoc = iContentPage.location.href;
- if( tLoc.indexOf("#") != -1 ){
- tLoc = tLoc.substring(0,tLoc.indexOf("#") );
- }
- tLoc += "#qs" + firstUnAnswered;
- if(document.all) {
- iContentPage.location.href = tLoc;
- }
- else if(document.layers) {
- iContentPage.document.URL = tLoc;
- }
- }
- else{
-
- saveUserAnswers();
-
- var scorePercentage = ((score/displayQuestions)*100);
- var scoreRound = Math.floor(scorePercentage);
- if( showPercentage ){
- doLMSSetValue("cmi.core.score.raw",scorePercentage);
- doLMSSetValue("cmi.core.score.max",100);
- }
- else{
- doLMSSetValue("cmi.core.score.raw",score);
- doLMSSetValue("cmi.core.score.max",iFinalQuestions.length);
- }
- if ( scoreRound >= passThreshold ) {
- doLMSSetValue("cmi.core.lesson_status","passed");
- }else{
- doLMSSetValue("cmi.core.lesson_status","failed");
- }
-
- // remove list of questions marked for review
- addToSuspendData("questionIndex" , "");
-
- addToSuspendData("QuestionId" , "");
-
- addToSuspendData("answersselected" , "");
-
- // commit answers.
- if(!resumeAssessment)
- addToSuspendData("questionorder", totalQuestionOrder );// add question order to suspend data
- doLMSCommit();
- iContentPage.location.href = resultsPage;
- }
-}
-
-
-
-
- function setHeaderFrame(pHeader){
- iHeaderFrame = pHeader;
- }
-
-
-//
-// Following variables and functions are only for internal purposes and should
-// not be used outside of this javascript file.
-//
-
-var ORDER = "ORDER";
-var qOrder = new Object();
-qOrder[ORDER] = "";
-
-
-
-var iHeaderFrame;
-
-var totalQuestions = 0;
-var currentQuestion = 0;
-var questionNumbers = 1;
-var currentIndex = 1;
-var iQuestionOrder = "";
-var iQuestions = new Question("PARENT","","");
-var iFinalQuestions = new Array();
-var iAnswersArray = new Array();
-var iRandomIndices = new Array();
-var userSelected = new Array();
-var totalQuestionOrder = "";
-var score = 0;
-
-var iContentPage;
-
-var iQuestionsForm;
-
-
-var reviewQuestions = new Array();
-var userAnswers = new Array();
-var reviewQuestionNumber = new Array(); // list of questionIds marked for review
-var reviewQuestionCache = new Object(); // for fast lookup ,
-
-
-function initializeVariables(){
-
- currentQuestion = 0;
- questionNumbers = 1;
- currentIndex = 1;
- iQuestionOrder = "";
-
-}
-
-
-function randomizeQuestions(){
-
- var tSuspendData = doLMSGetValue("cmi.suspend_data");
- if( iFinalQuestions.length > 0 ){
- return;
- }
- //debugger;
- if( tSuspendData.indexOf("questionorder") == -1 || retainOrder == false ){
- var tQuestionOrderString = getElementFromSuspendData("questionorder") ;
- var tOrderArray = tQuestionOrderString.split(',');
- var tIdCache = generatePreviousIdCache(tOrderArray);
-
- var questionOrder = "";
-
- iQuestions.getRandomizedQuestions(qOrder,iFinalQuestions , tIdCache);
- iQuestionOrder = qOrder[ORDER].substring(0,qOrder[ORDER].length - 1); // Remove the trailing comma ',' //
-
- if (tQuestionOrderString && !repeatAcrossAttempts){
- questionOrder = tQuestionOrderString + "," + iQuestionOrder ;
- }
- else{
- questionOrder = iQuestionOrder ;
- }
- totalQuestionOrder = questionOrder;
- if(resumeAssessment)
- addToSuspendData("questionorder", questionOrder ); //commented by Manu , moved to submitAnswers()
- }
- else{
- var tTotalQuestionPools = iQuestions.mandatoryChildren.length + iQuestions.randomChildren.length;
- var tQuestionPool;
- var tQuestionPoolId = "";
- var totalQuestions = 0;
- var tQuestionOrderString = "";
- var tUserResponse = "";
-
- tQuestionOrderString = getElementFromSuspendData("questionorder") ;
-
- totalQuestionOrder = tQuestionOrderString;
-
- var tOrderArray = tQuestionOrderString.split(',');
- var order;
- // Added by Jayaprakash A
- var tQuestion;
- for( qs=0; qs < tOrderArray.length ; qs++ ){
- order = parseInt( tOrderArray[qs] );
- if( !isNaN( order ) ){
- tQuestion = retrieveQuestion(order,iQuestions);
- iFinalQuestions[totalQuestions] = tQuestion;
- // Added by Jayaprakash A
- tQuestion.index = iFinalQuestions.length -1;
- totalQuestions++;
- }
- }
-
- if(resumeAssessment) {
- var isFinished = false;
- //if (getElementFromSuspendData("lesson_status") == "attempted") isFinished = true ;
- //if( isFinished ){
- currentQustionIndex = getQuestionId();
- getUserSelectedArrayInSuspendData();
- //}
-
- if(tSuspendData.indexOf("questionIndex") != -1){
- // get the list of questions marked for review.
- var marked = getElementFromSuspendData("questionIndex");
- var indices = marked.split(',');
- var length = indices.length ;
- var counter = 0;
- var questionId = "";
- while(counter < length){
- questionId = indices[counter];
- // remove duplicate entries if any.
- if(questionId && !reviewQuestionCache[questionId]){
- reviewQuestionNumber[reviewQuestionNumber.length] = questionId;
- reviewQuestionCache[questionId] = 1; // dummy value , just need the questionId
- }
- counter++;
- }
- }
- }
-
-
- }
-}
-
-function generatePreviousIdCache(pOrderArray){
- var size = pOrderArray.length;
- var counter = 0;
- var tString = "";
- var IdCache = new Object();
-
- while(counter < size){
- tString = pOrderArray[counter];
- IdCache[tString] = true;
- counter++;
- }
- return IdCache;
-}
-
-
-function retrieveQuestion(pId,pParentQuestion){
- var tQuestion = null;
- if( pParentQuestion.containsQuestion(pId) ){
- tQuestion = pParentQuestion.getQuestionById(pId);
- }
- else{
- tQuestion = searchInChildQuestions(pId , pParentQuestion);
- }
- return tQuestion;
-}
-
-function saveUserAnswers(){
- if( userSelected != null ){
- tString = "";
- for(i=0; i < userSelected.length; i++){
- if(userSelected[i])
- tString += userSelected[i];
- if( i < (userSelected.length - 1) ){
- tString += ";";
- }
- }
- }
- addToSuspendData("answers",tString);
-}
-
-/// This function gets the user answers from the suspend data and populates the Javascript Datamodels.
-
-function retrieveUserResponse(){
- var tString = getElementFromSuspendData("answers");
- if( tString ){
- var tArray = tString.split(";");
- }
- for( i=0; i < tArray.length; i++){
-
- userSelected[i] = tArray[i];
- }
- setUserResponses();
- return userSelected;
-}
-
-
-function searchInChildQuestions(pId , pParentQuestion){
- var size = pParentQuestion.getNumberOfRandomQuestions();
- var tQuestion = null;
- var tParent = null;
-
- for(var index = 0 ; index < size ; index++){
- tParent = pParentQuestion.getRandomQuestion(index);
- if( tParent.containsQuestion(pId) ){
- tQuestion = tParent.getQuestionById(pId);
- break;
- }
- else{
- tQuestion = searchInChildQuestions(pId , tParent);
- }
- }
- if(null == tQuestion){
- size = pParentQuestion.getNumberOfMandatoryQuestions();
- for(var index = 0 ; index < size ; index++){
- tParent = pParentQuestion.getMandatoryQuestion(index);
- if( tParent.containsQuestion(pId) ){
- tQuestion = tParent.getQuestionById(pId);
- break;
- }
- else{
- tQuestion = searchInChildQuestions(pId , tParent);
- }
- }
- }
- return tQuestion;
-}
-
-
-
-
-function questionToString(){
- return generateQuestionHTML(this, this.index );
-}
-
-
-function generateQuestionHTML( pQuestion, index ){
- var tString = "";
- var tAnswers = pQuestion.answers;
- var tAnswer;
- var tType = "radio";
-
- var correctAnsString = "";
-
- if( pQuestion.type == "multiple" ){
- tType = "checkbox";
-
- tString += '<tr><td> <a name="qs' + pQuestion.id + '">&nbsp;</a></td> </tr>';
- tString += '<tr>\n <td colspan="3"> \n';
- tString += '<div class="qtext" name="qs' + pQuestion.id + 'Layer"><table cellpadding=0 cellspacing=0 border=0><tr><td valign=top align="left" width=25><span name="' + pQuestion.id + 'question" class="qtext"> \n';
- tString += (index + 1) + '. &nbsp;&nbsp;</td><td valign=top align=left class="qtext" colspan=3 width=575>' + pQuestion.text + '<br><br>';
- tString += '</span> \n';
-
- if(!pQuestion.instructionText){
- tString += '<span class="blue">Please select&nbsp;&nbsp;<b>all the correct answers</b>.</span></td></tr>\n';
- }else{
- tString += pQuestion.instructionText;
- }
- }
- else{
- tString += '<tr><td> <a name="qs' + pQuestion.id + '">&nbsp;</a></td> </tr>';
- tString += '<tr>\n <td colspan="3"> \n';
- tString += '<div class="qtext" name="qs' + pQuestion.id + 'Layer"><table cellpadding=0 cellspacing=0 border=0 width=600><tr><td valign=top width=25 align=left><span name="' + pQuestion.id + 'question" class="qtext"> \n';
- tString += (index + 1) + '. &nbsp;&nbsp;</td><td valign=top class="qtext" align=left colspan=3 width=575>' + pQuestion.text + '<br><br>';
- tString += '</span> \n';
- if(!pQuestion.instructionText){
- tString += '<span class="blue">Please select <b>the best answer</b>.</span></td></tr>\n';
- }
- else{
- tString += pQuestion.instructionText;
- }
-
- }
- var questionLetter = 1;
- if(doLMSGetValue("cmi.suspend_data").indexOf("lesson_status") != -1){
- tArray = getUserResponse();
- for( j=0; j < tAnswers.length; j++ ){
- if( tAnswers[j].correct == true ){
- if( correctAnsString.length > 0 ){
- correctAnsString += "," + (j+1)
- }
- else{
- correctAnsString += (j+1);
- }
- }
- var userclick=userAttemptedValues((index + 1),tArray,questionLetter);
-
- tString += '<tr><td width=15 align=left>&nbsp;</td><td valign=top width=15 align=left><span class="choice" name="' + pQuestion.id +'choice' + (j+1) + '">\n';
- if( pQuestion.type == 'multiple' ){
- if(userclick=="true" && resumeAssessment){
- tString += '<input name="qs' + pQuestion.id + 'choiceBtn" value="' + (j+1) + '" type="checkbox" checked onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- else{
- tString += '<input name="qs' + pQuestion.id + 'choiceBtn" value="' + (j+1) + '" type="checkbox" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- }
- else if( pQuestion.type == 'single' ){
- if(userclick=="true" && resumeAssessment){
- tString += '<input name="qs'+ pQuestion.id + 'RadioInp" type="radio" checked onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- else{
- tString += '<input name="qs'+ pQuestion.id + 'RadioInp" type="radio" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- }
-
- questionLetters = String.fromCharCode( questionLetter + 64 );
-
- tString += '</input></td><td valign=top class="qtext" align="left" width=15>' + questionLetters + '.&nbsp;&nbsp;</td><td valign=top align=left class="qtext" width=555>';
- tString += tAnswers[j].text;
- tString += '<br><br></td></tr>\n';
- questionLetter++;
- }
- }
- else{
- for( j=0; j < tAnswers.length; j++ ){
- if( tAnswers[j].correct == true ){
- if( correctAnsString.length > 0 ){
- correctAnsString += "," + (j+1);
- }
- else{
- correctAnsString += (j+1);
- }
- }
- tString += '<tr><td width=15 align=left>&nbsp;</td><td valign=top width=15 align=left><span class="choice" name="' + pQuestion.id +'choice' + (j+1) + '">\n';
- if( pQuestion.type == 'multiple' ){
- tString += '<input name="qs' + pQuestion.id + 'choiceBtn" value="' + (j+1) + '" type="checkbox" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- else if( pQuestion.type == 'single' ){
- tString += '<input name="qs'+ pQuestion.id + 'RadioInp" type="radio" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
-
- questionLetters = String.fromCharCode( questionLetter + 64 );
-
- tString += '</input></td><td valign=top class="qtext" align="left" width=15>' + questionLetters + '.&nbsp;&nbsp;</td><td valign=top align=left class="qtext" width=555>';
- tString += tAnswers[j].text;
- tString += '<br><br></td></tr>\n';
- questionLetter++;
- }
- }
- tString += '</p>\n';
- tString += '</td></tr></table></div>\n';
- tString += '</td>\n</tr>\n';
-
- questionNumbers++;
- iAnswersArray[ index ] = correctAnsString;
- return tString;
-}
-
-function checkIfSelected(userAnswer, option){
- option = new String(option);
- if( userAnswer.indexOf(option) == -1 ){
- return "";
- }
- else{
- return "checked";
- }
-}
-
-
-function generateFeedback(pQuestion, index){
-
- var tString = "";
- var tAnswers = pQuestion.answers;
- var correctAnsString = "";
-
- if( pQuestion.type == "multiple" ){
- tType = "checkbox";
-
- tString += '<table><tr>\n <td colspan="3"> \n';
- tString += '<div class="qtext" name="' + pQuestion.id + 'Layer"><table cellpadding=0 cellspacing=0 border=0><tr><td valign=top class="qtext" width=25><span name="' + pQuestion.id + 'question" class="qtext"> \n';
- tString += questionNumbers + '. &nbsp;&nbsp;</td><td valign=top class="qtext" colspan=3 width=575>' + pQuestion.text + '<br><br>';
- tString += '</span> \n';
-
-
- if(!pQuestion.instructionText){
- tString += '<span class="blue">Please select&nbsp;&nbsp; <b>all the correct answers</b>.</span></td></tr>\n';
- }else{
- tString += pQuestion.instructionText;
- }
- tString += '<br>\n';
- }
- else{
- tString += '<table><tr>\n <td colspan="3"> \n';
- tString += '<div class="qtext" name="' + pQuestion.id + 'Layer"><table cellpadding=0 cellspacing=0 border=0><tr><td valign=top class="qtext" align=left width=25><span name="' + pQuestion.id + 'question" class="qtext"> \n';
- tString += questionNumbers + '. &nbsp;&nbsp;</td><td valign=top align=left class="qtext" colspan=3 width=575>' + pQuestion.text + '<br><br>';
- tString += '</span> \n';
-
-
- if(!pQuestion.instructionText){
- tString += '<span class="blue">Please select <b>the best answer</b>.</span></td></tr>\n';
- }else{
- tString += pQuestion.instructionText;
- }
-
- }
- var questionLetter = 1;
- for( j=0; j < tAnswers.length; j++ ){
- if( tAnswers[j].correct == true ){
- if( correctAnsString.length > 0 ){
- correctAnsString += "," + (j+1);
- }
- else{
- correctAnsString += (j+1);
- }
- }
-
- tString += '<tr><td width=15>&nbsp;</td><td valign=top align=left width=15><span class="choice" name="' + pQuestion.id +'choice' + (j+1) + '">\n';
- if( pQuestion.type == 'multiple' ){
- tString += '<input disabled name="' + pQuestion.id + 'choiceBtn" value="' + (j+1) + '" type="checkbox" ' +checkIfSelected(userSelected[index],j+1) + ' >\n';
- }
- else if( pQuestion.type == 'single' ){
- tString += '<input disabled name="'+ pQuestion.id + 'RadioInp" type="radio" ' + checkIfSelected(userSelected[index],j+1) + ' >\n';
- }
- questionLetters = String.fromCharCode( questionLetter + 64 );
-
- tString += '</input></td><td valign=top width=15 align=left class="qtext">' + questionLetters + '.&nbsp;&nbsp;</td><td valign=top class="qtext" align=left width=555>';
- tString += tAnswers[j].text;
- tString += '<br><br></td></tr>\n';
- questionLetter++;
- }
-
- var tFeedback;
- if( pQuestion.userResponse ){
- tFeedback = pQuestion.correctFeedbackText;
- }
- else{
- tFeedback = pQuestion.incorrectFeedbackText;
- }
- if( tFeedback == "" ){
- tFeedback = correctAnswerString(correctAnsString);
- }
-
- tString += '</p>';
- tString += '<tr><td> </td><td colspan=3 class="qtext">' + tFeedback;
- tString += '</td></tr></table></div>\n';
- tString += '</td>\n</tr></table>\n';
-
- questionNumbers++;
- return tString;
-
-}
-
-
-function insertCommas(pString){
- var newString = "";
- var tChars = pString.split(",");
- var tNumber;
- for( chars=0; chars < tChars.length ; chars++){
-
- tNumber = tChars[chars];
- tNumber = parseInt( tNumber );
-
- if( !isNaN( tNumber ) ){
- if( tChars.length > 1 ){
- if( chars >= tChars.length -1 ){
- newString += " and ";
- }
-
- }
-
- newString += String.fromCharCode( tNumber + 64 ) ;
-
- if( tChars.length > 1 && (chars < tChars.length -2 ) ){
- newString += ",";
- }
- }
- }
- return newString;
-}
-
-
-function correctAnswerString(answers){
- var tString = "";
-
- tString += "The correct answer";
- if( answers.length == 1 ){
- tString += " is " + insertCommas(answers) + ".";
- }
- else{
- tString += "s are " + insertCommas(answers) + ".";
- }
- return tString;
-}
-
- function updateRadio(queName,value){
- //userSelected[queName] = value;
- // commented by surekha as the below function works same as above
- checkCurentQuestionOnClick(queName);
- }
-
-
- function setUserResponses(){
- score = 0;
- for(var i=0;i< iFinalQuestions.length;i++){
- generateQuestionHTML(iFinalQuestions[i],i);
- if(userSelected[i] == iAnswersArray[i]){
- iFinalQuestions[i].userResponse = true;
- score++;
- }
- }
- }
-
-
- function getCheckboxValue() {
- var tQuestion;
- for( i=0; i < displayQuestions; i++){
- tQuestion = iFinalQuestions[i];
- checkForCorrectResponse( tQuestion,i );
- }
-}
-
-//updated by Sampad in order to handle single Question per Page with resume functionality.. to get back user response
-
-function checkForCorrectResponse(pQuestion,index){
- var tStr = "";
-
- if(isSingleQuestionPerPage)
- {
- var f = parent.quizheader.iQuestionsForm;
- }
- else
- {
- var f = iQuestionsForm;
- }
-
- //var f = iQuestionsForm;//iContentPage.document.xp;
- var selCount =0;
- var button;
- var radiobutton;
-
- tStr = "";
- if( pQuestion ){
- if( pQuestion.type == 'multiple' ){
- eval('button = f.qs' + pQuestion.id + 'choiceBtn' );
- if( button ){
- for( j=0; j < button.length; j++ ){
- if( button[j].checked ){
- if( tStr.length > 0 ){
- tStr += "," + button[j].value;
- }
- else{
- tStr += button[j].value;
- }
- }
- }
- userSelected[index] = tStr;
- //alert("question" + index + "response" +tStr);
- }
- }
- else{
- var temp='radiobutton = f.qs' + pQuestion.id + 'RadioInp';
- eval(temp );
- if( radiobutton ){
- for( j=0; j < radiobutton.length; j++ ){
- if( radiobutton[j].checked ){
- tStr += j+1;
- }
- }
- userSelected[index] = tStr;
- //alert("question" + index + "response" +tStr);
- }
- }
- }
-}
-
-
-var currentQustionIndex = 0;
-
-
-
-
-function hasNextQuestion(){
- var tReturn = false;
- if( currentQustionIndex < iFinalQuestions.length ){
- tReturn = true;
- }
- return tReturn;
-}
-
-
-
-function getNextQuestion(){
- var tQuestion = iFinalQuestions[currentQustionIndex];
- addToSuspendData("QuestionId" , currentQustionIndex);
- currentQustionIndex++;
- doLMSCommit();
- return tQuestion;
-}
-
-
-
-function getNextQuestionString(){
- var tQuestion = getNextQuestion();
- var tString = "";
- if( tQuestion ){
- tString = generateQuestionHTML(tQuestion, currentQustionIndex-1 );
- }
- return tString;
-}
-
-
-
-function checkCurrentQuestion(){
- var tQuestion = iFinalQuestions[currentQustionIndex-1];
- checkForCorrectResponse( tQuestion, currentQustionIndex-1 );
-}
-
-
-
-function getFeedbackString(){
- var tQuestion = iFinalQuestions[currentQustionIndex-1];
- if(userSelected[currentQustionIndex-1] == iAnswersArray[currentQustionIndex-1]){
- return tQuestion.correctFeedbackText;
- }
- else{
- return tQuestion.incorrectFeedbackText;
- }
-}
-
-
-
-function getUserSelectedArrayInSuspendData(){
- var tString = getElementFromSuspendData("answersselected");
- if(tString.indexOf("#") !=0 ){
- var tArray = tString.split("#");
- for(var l=0; l < tArray.length; l++){
- var tIndex = tArray[l].indexOf(",");
- var tQuestionNumber = tArray[l].substring(0,tIndex);
- userSelected[tQuestionNumber] = tArray[l].substring((tIndex+1),tArray[l].length);
- }
- }
- else{
- userSelected[tString.substring(0,tString.indexOf(","))] = tString.substring(tString.indexOf(","),tString.length);
- }
-
- return userSelected;
-}
-
-function getQuestionId(){
- var tSuspendDataValue = doLMSGetValue("cmi.suspend_data");
- if(tSuspendDataValue.indexOf("QuestionId") != -1){
- userattempts = getElementFromSuspendData("QuestionId");
- if(!userattempts) userattempts = 0;
- if(userattempts > displayQuestions - 1) userattempts = 0;
- return parseInt(userattempts);
- }
- else{
- return 0;
- }
-}
-
-function getUserResponse(){
- var userSelectedAnswer = new Array();
- var tString = getElementFromSuspendData("answersselected");
- var tArray = tString.split("#");
- for(var l=0; l < tArray.length; l++){
- var tIndex = tArray[l].indexOf(",");
- var tQuestionNumber = tArray[l].substring(0,tIndex);
- userSelectedAnswer[tQuestionNumber] = tArray[l].substring(tIndex,(tArray[l].length+1))+",";
- }
- userAnswers = userSelectedAnswer;
- return userSelectedAnswer;
-}
-
-//updated by Sampad in order to handle single Question per Page with resume functionality.. to get back user response
-
-function checkCurentQuestionOnClick(pId){
- addToSuspendData("lesson_status","attempted");
- var tUserString = "";
- var tUserSelection = new Array();
- if(isSingleQuestionPerPage)
- {
- var tQuestion = parent.quizheader.iFinalQuestions[pId];
- }
- else
- {
- var tQuestion = iFinalQuestions[pId];
- }
- //alert("user Selected"+tQuestion);
- checkForCorrectResponse( tQuestion, pId );
-
- tUserSelection[pId] = userSelected[pId];
- for(i=0;i<tUserSelection.length;i++){
- if(tUserSelection[i]){
- tUserString = i+","+tUserSelection[i];
- }
- }
- var tUserSuspendValue = getElementFromSuspendData("answersselected");
- tUserSuspendValue = "#" + tUserSuspendValue;
-
- if(tUserString == ""){
- var tIndex = tUserSuspendValue.indexOf("#"+pId+",");
- tUserSuspendValue = tUserSuspendValue.substring(1,tUserSuspendValue.length);
- if(tIndex !=-1){
- var tUserArrayInSuspendData = getUserSelectedArrayInSuspendData();
- tUserArrayInSuspendData[pId] = "";
- for(var l=0;l<tUserArrayInSuspendData.length;l++){
- tUserString = tUserString + l + "," + tUserArrayInSuspendData[l] + "#";
- }
- tUserString = tUserString.substring(0,(tUserString.length-1));
- }
- }
- else{
- if(doLMSGetValue("cmi.suspend_data").indexOf("answersselected") != -1 && tUserSuspendValue != "#"){
- var tIndex = tUserString.indexOf(",");
- var toCheck = "#" + tUserString.substring(0,(tIndex+1));
- var tUserAttemptedIndex = tUserSuspendValue.indexOf(toCheck);
- tUserSuspendValue = tUserSuspendValue.substring(1,tUserSuspendValue.length);
- if(tUserAttemptedIndex == -1){
- tUserString = tUserSuspendValue + "#" + tUserString;
- }
- else{
- var tUserArrayInSuspendData = getUserSelectedArrayInSuspendData();
- tUserArrayInSuspendData[tUserString.substring(0,tIndex)] = tUserString.substring((tIndex+1),tUserString.length);
- tUserString = "";
- for(var l=0;l<tUserArrayInSuspendData.length;l++){
-
- tUserString = tUserString + l + "," + tUserArrayInSuspendData[l] + "#";
- }
- tUserString = tUserString.substring(0,(tUserString.length-1));
- }
- }
- }
- addToSuspendData("answersselected",tUserString);
-
-}
-
-
-function userAttemptedValues(pQid,pArray,pQindex){
- var temp;
- var userselectedvalues=pArray[pQid-1];
- if(userselectedvalues){
- temp=','+(pQindex)+',';
- if(userselectedvalues.indexOf(temp) >= 0){
- return "true";
- }
- else
- return "false";
- }
-}
-
-
-
-
-function markQuestion(pQuestionIndex,pReviewChecked){
- var marked = "";
- if(doLMSGetValue("cmi.suspend_data").indexOf("questionIndex") != -1){
- if(pReviewChecked=="true"){
- reviewQuestionNumber[reviewQuestionNumber.length] = pQuestionIndex;
- reviewQuestionCache[pQuestionIndex] = 1;
- marked = getElementFromSuspendData("questionIndex") + ","+pQuestionIndex;
- }
- else{
- reviewQuestionCache[pQuestionIndex] = null;
- removeIndex(pQuestionIndex);
- marked = getElementFromSuspendData("questionIndex");
- }
- }
- else{
- reviewQuestionNumber[reviewQuestionNumber.length] = pQuestionIndex;
- marked = ","+pQuestionIndex;
- }
- addToSuspendData("questionIndex" , marked);
- doLMSCommit();
-}
-
-function getIndicesOfQuestionsMarkedForReview(){
- //reviewQuestionNumber = reviewQuestionNumber.sort();
- return reviewQuestionNumber;
-}
-
-
-function selectQuestion(pIndex){
- currentQustionIndex = parseInt(pIndex);
- reviewQuestionCache[pIndex] = null;
- removeIndex(pIndex);
-}
-
-function removeIndex(pIndex){
- var counter = 0;
- var length = reviewQuestionNumber.length;
- var index = 0;
- while(counter < length){
- index = reviewQuestionNumber[counter];
- if(index == pIndex){
- reviewQuestionNumber[counter] = null;
- var marked = getElementFromSuspendData("questionIndex");
- marked = marked.substring(1,marked.length);
-
- addToSuspendData("questionIndex" , "");
- var indices = marked.split(',');
- indices[counter] = null;
- var tempMarked = "";
- for(var i=0;i<indices.length;i++){
- tempMarked = tempMarked + indices[i] + ",";
- }
-
- if(tempMarked != "")
- tempMarked = tempMarked.substring(0,(tempMarked.length-1));
-
- tempMarked = "," + tempMarked;
-
- addToSuspendData("questionIndex" , tempMarked);
- doLMSCommit();
- }
- counter++;
- }
-}
-
-function getUserSelected(){
- return userAnswers;
-}
-
-
-
-
-function hasPreviousQuestion(){
- if (currentQustionIndex > 0) return true;
- else return false;
-}
-
-
-
-function decrementCursor(){
- if (currentQustionIndex > 0) currentQustionIndex--;
- if (currentQustionIndex > 0) currentQustionIndex--;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-//Start Change of Model by Manu/Monalika/Sampad/Arijit
-
-//Base token to declare in the assessment page
-
-
-
-
-var QUESTIONS_TOKEN = "@@QUESTIONS@@";
-
-//Question numbers after randomization
-
-
-var QUESTION_ID_TOKEN = "@@QUESTION_ID@@";
-
-//Question Stem text
-
-
-
-var QUESTION_TEXT_TOKEN = "@@QUESTION_TEXT@@";
-//Image text
-
-
-
-var IMAGE_TEXT_TOKEN = "@@IMAGE_TEXT@@";
-
-
-//Instruction text
-
-var QUESTION_ITEXT_TOKEN= "@@QUESTION_ITEXT@@";
-
-//Question display number
-
-
-var QUESTION_NUMBER = "@@QUESTION_NUMBER@@";
-
-//Choices or distracters for the question
-
-
-
-var CHOICE_TOKEN = "@@CHOICE@@";
-
-
-// Feedback
-
-var FEEDBACK_TOKEN = "@@FEEDBACK@@";
-
-//Summary
-var SUMMARY_TOKEN = "@@SUMMARY@@";
-
-//Correct Summary
-
-var CORRECT_SUMMARY_TOKEN = "@@CORRECT_SUMMARY@@";
-//Incorrect Summary
-
-var INCORRECT_SUMMARY_TOKEN= "@@INCORRECT_SUMMARY@@";
-//Not Attempted Summary
-
-
-
-var NOT_ATTEMPTED_SUMMARY_TOKEN = "@@NOT_ATTEMPTED_SUMMARY@@";
-//Instruction text for each question
-
-var INSTRUCTION_TEXT_TOKEN="@@INSTRUCTION_TEXT@@";
-//Correct number of answer given by the user in percent or number
-
-
-var SCORE_TOKEN="@@SCORE@@";
-//Total number of question displayed
-
-
-var TOTAL_QUESTION_TOKEN="@@TOTAL_QUESTION@@";
-//Correct Instant feedback - Only used for single question per page type
-
-
-var CORRECT_INSTANT_FEEDBACK_TEXT_TOKEN="@@CORRECT_INSTANT_FEEDBACK_TEXT@@";
-//Incorrect Instant feedback - Only used for single question per page type
-
-
-var INCORRECT_INSTANT_FEEDBACK_TEXT_TOKEN="@@INCORRECT_INSTANT_FEEDBACK_TEXT@@";
-
-
-//Renderers
-
-//Default Renderers for Question Page
-var _defaultQuestionRenderer = new QuestionRenderer();
-
-//Choice Renderer for Question Page
-var _defaultChoiceRenderer = new ChoiceRenderer();
-
-//Default Renderers for Result Page
-var _defaultResultRenderer = new ResultRenderer();
-
-//Choice Renderer for Result Page - Choices
-var _defaultResultChoiceRenderer = new ResultChoiceRenderer();
-
-//Default Renderers for Result Summary
-var _defaultSummaryCorrectRenderer = new SummaryCorrectRenderer();
-var _defaultSummaryInCorrectRenderer = new SummaryInCorrectRenderer();
-var _defaultSummaryNotAttemptedRenderer = new SummaryNotAttemptedRenderer();
-
-//Default Renderers for Result - Scores
-var _defaultScoreRenderer=new ScoreRenderer();
-
-//Default Renderers for Result - Instruction text
-var _defaultInstructionTextRenderer = new InstructionTextRenderer();
-
-//Default Renderers forInstant Feedback in single question per page type assessments
-var _defaultInstantCorrectFeedbackRenderer=new InstantCorrectFeedbackRenderer();
-var _defaultInstantInCorrectFeedbackRenderer=new InstantInCorrectFeedbackRenderer();
-
-
-
-
-
-
-
-//Defining the html strings which will be replaced by default while rendering
-//All the methods below can be overriden in the pageLayout file to customize the assessment look and feel
-
-
-//Setting HTML Code block for Question Page
-
-_defaultQuestionRenderer.setHtmlCode('<tr><td bgcolor="yellow" width=575> <a name="qs@@QUESTION_ID@@">&nbsp;</a></td> </tr>'+
-
- '<tr>\n <td> \n'+
-
- '<table cellpadding=0 cellspacing=0 border=0><tr><td valign=top align="left" width=25>'+
-
- '<span name="@@QUESTION_ID@@question" class="qtext1"> \n'+
-
- '@@QUESTION_NUMBER@@. &nbsp;&nbsp;</td><td valign=top align=left class="qtextGreen" width=575 colspan=3>'+
-
- '@@QUESTION_TEXT@@</td></tr><tr><td colspan=4>@@IMAGE_TEXT@@<br><br></td> </tr>'+
-
- '<tr><td colspan=4>@@QUESTION_ITEXT@@</span> \n@@CHOICE@@</td></tr></table></td></tr>');
-
-
-//Setting HTML Code block for instruction text
-
-
-_defaultInstructionTextRenderer.setHtmlCode('<span class="blue">Please select&nbsp;&nbsp;<b>@@INSTRUCTION_TEXT@@</b>.</span><br><br></td></tr>\n');
-
-
-//Setting HTML Code block for Score display
-
-
-_defaultScoreRenderer.setHtmlCode("<tr><td class='blue'>You had <strong> @@SCORE@@ %</strong> out of @@TOTAL_QUESTION@@ Questions Correct.</td></tr>");
-
-
-//Setting HTML Code block for Correct Summary
-
-
-_defaultSummaryCorrectRenderer.setHtmlCode('<tr><td class="qtext">Question @@CORRECT_SUMMARY@@ -- Correct</td></tr>');
-
-
-//Setting HTML Code block for Incorrect Summary
-
-
-_defaultSummaryInCorrectRenderer.setHtmlCode('<tr><td class="qtext"> Question@@INCORRECT_SUMMARY@@ -- Incorrect</td></tr>');
-
-
-//Setting HTML Code block for Summary Not Attempted answer
-
-
-_defaultSummaryNotAttemptedRenderer.setHtmlCode('<tr><td class="qtext">Question @@NOT_ATTEMPTED_SUMMARY@@ -- Not Attempted</td></tr>');
-
-
-//Setting HTML Code block for Result Page
-
-
-_defaultResultRenderer.setHtmlCode('<tr><td bgcolor="yellow"> <a name="qs@@QUESTION_ID@@">&nbsp;</a></td> </tr>'+
-
- '<tr>\n <td> \n'+
-
- '<table cellpadding=0 cellspacing=0 border=0><tr><td valign=top align="left" width=25>'+
-
- '<span name="@@QUESTION_ID@@question" class="qtext1"> \n'+
-
- '@@QUESTION_NUMBER@@. &nbsp;&nbsp;</td><td valign=top align=left class="qtextGreen" width=575 colspan=3>'+
-
- '@@QUESTION_TEXT@@</td></tr><tr><td colspan=4>@@IMAGE_TEXT@@<br><br></td> </tr>'+
-
- '<tr><td colspan=4>@@QUESTION_ITEXT@@</span> \n@@CHOICE@@</td></tr><tr><td valign=top align=left class="qtext1" colspan=4>@@FEEDBACK@@</span></td></tr></table></td></tr>');
-
-
-
-//Setting HTML Code block for instant Correct Feedback
-
-
-_defaultInstantCorrectFeedbackRenderer.setHtmlCode('<tr><td class="green">@@CORRECT_INSTANT_FEEDBACK_TEXT@@</td></tr>');
-
-
-//Setting HTML Code block for instant Incorrect Feedback
-
-
-_defaultInstantInCorrectFeedbackRenderer.setHtmlCode('<tr><td class="red">@@INCORRECT_INSTANT_FEEDBACK_TEXT@@</td></tr>');
-
-
-//The above methods can be overridden in the pageLayout file
-
-
-
-// Methods for Question Page
-
-function _getRenderer(){
-
- return this.guestionRenderer ;
-
-}
-
-
-function _getChoiceRenderer(){
-
- return this.choiceRenderer;
-
-}
-
-//main rendering function to be called from the Assessment Page (Multi Question / Page)
-
-
-
-function AssessmentPageRenderer(pDocument){
-
- iContentPage =pDocument;// inorder to set the content page reference.
-
- this.htmlDocument = pDocument;
-
- this.defaultQuestionRenderer = _defaultQuestionRenderer;
-
- this.render = _render;
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setHtmlCode;
-
-
-}
-
-
-function _setHtmlCode(pCodeString){
-
- this.htmlCode = pCodeString;
-
-}
-
-//render() called from Assessment page
-
-
-
-
-function _render(){
-
- //debugger;
-
- if(!this.htmlDocument) {
-
- alert("please set the html document reference!");
-
- return;
-
- }
-
- var questionString = "";
-
- var length = iFinalQuestions.length;
-
- var index = 0;
-
- var question = "null";
-
- while(index < length){
-
- question = iFinalQuestions[index];
- //alert("question== "+ (question.getRenderer()));
-
- if(question.getRenderer())
-
- questionString += question.getRenderer().render(question , index);
-
- else
-
- questionString += this.defaultQuestionRenderer.render(question , index);
-
- index++;
-
- }
-
- this.htmlDocument.write(replaceToken(QUESTIONS_TOKEN,this.htmlCode , questionString));
-
- this.htmlDocument.close();
-
-}
-
-
-// Question Renderer
-function QuestionRenderer(){
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setQuestionHtmlCode;
- this.InstructionTextRenderer=_defaultInstructionTextRenderer;
- this.render = _renderQuestion;
-
- this.choiceRenderer = _defaultChoiceRenderer;
-
- this.setChoiceRenderer = _setChoiceRenderer;
-
- this.getChoiceRenderer = _getChoiceRenderer;
-
-}
-
-
-//Replacing Tokens in Assessment page with Respective Code blocks
-
-function _renderQuestion(pQuestion , pIndex){
-
- //debugger;
-
- var imageString = ""; //added to display images/swf
-
- if(pQuestion.image){
- if(pQuestion.image.substring(pQuestion.image.lastIndexOf(".")+1) == 'swf') {
-var imageString = '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"';
- imageString += 'codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/';
-imageString += 'swflash.cab#version=6,0,29,0\" width=\"'+flashWidth+'\"';
-imageString += 'height=\"'+flashHeight+'\"><param name=\"movie\"';
-imageString += 'value=\"'+pQuestion.image+'\"><param name=\"quality\"';
-imageString += 'value=\"high\">';
-imageString += '<embed src=\"'+pQuestion.image+'\" quality=\"high\"';
-imageString += 'pluginspage=\"http://www.macromedia.com/go/getflashplayer\"';
-imageString += 'type=\"application/x-shockwave-flash\" width=\"'+flashWidth+'\"'; imageString += 'height=\"'+flashHeight+'\"></embed></object>';
-
- }
- else {
-var imageString = '<img border=\"0\" src=\"' + pQuestion.image + '\"';
-imageString += 'usemap=\"#HeaderMap\" alt=\"\">';
-
- }
- }
-
-
- var questionString = "";
-
- questionString = replaceToken(QUESTION_ID_TOKEN , this.htmlCode , pQuestion.getId());
-
- questionString = replaceToken(QUESTION_TEXT_TOKEN , questionString , pQuestion.text);
-
- questionString = replaceToken(IMAGE_TEXT_TOKEN , questionString , imageString);
-
- var iText = "";
- var instructionrenderer=pQuestion.InstructionTextRenderer;
-
- if(!pQuestion.getInstructionText()){
-
- iText= instructionrenderer.render(pQuestion.type);
-
- }else {
-
- iText= pQuestion.getInstructionText();
-
- }
-
- questionString = replaceToken(QUESTION_ITEXT_TOKEN , questionString , iText);
-
- questionString = replaceToken(QUESTION_NUMBER , questionString , pIndex+1);
-
-
-
- var choiceRenderer = pQuestion.getChoiceRenderer();
-
- if(!choiceRenderer)
-
- choiceRenderer = this.choiceRenderer;
-
-//Calls the render() of QuestionRenderer for generating Choices to replace @@CHOICE@@ token
- questionString = replaceToken(CHOICE_TOKEN , questionString , choiceRenderer.render(pQuestion.answers , pQuestion , pIndex));
-
- return questionString;
-
-}
-
-
-
-function _setQuestionHtmlCode(pCode){
-
- this.htmlCode = pCode;
-
-}
-
-
-
-
-// Choice Renderer
-
-function _setChoiceRenderer(pRenderer){
-
- this.choiceRenderer = pRenderer;
-
-}
-
-
-
-function _getChoiceRenderer(){
-
- return this.choiceRenderer;
-
-}
-
-
-
-function ChoiceRenderer(){
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setChoiceHtmlCode;
-
- this.render = _renderChoice;
-
-
-
-}
-
-function _setChoiceHtmlCode(pCode){
-
- this.htmlCode = pCode;
-
-}
-
-// render() for Choices in Question page
-function _renderChoice(pAnswersArray , pQuestion , pIndex){
-
- var completeChoiceString = "";
- var tAnswers = pQuestion.answers;
- var choice = null;
-
- var numberOfChoices = pAnswersArray.length;
- var correctAnsString = "";
- var index = 0;
- var tArray=null;
-
- var questionLetter = 1;
-
- if(doLMSGetValue("cmi.suspend_data").indexOf("lesson_status") != -1){
- tArray = getUserResponse();
-
- }
- //addition
- for( j=0; j < tAnswers.length; j++ ){
- if( tAnswers[j].correct == true ){
- if( correctAnsString.length > 0 ){
- correctAnsString += "," + (j+1)
- }
- else{
- correctAnsString += (j+1);
- }
- }
- }
- iAnswersArray[ pIndex ] = correctAnsString;
-
- //end for
-
-
- while(index < numberOfChoices){
-
- choice = pAnswersArray[index];
-
- if(tArray)
- var userclick=userAttemptedValues((pIndex + 1),tArray,questionLetter);
-
- completeChoiceString += '<tr><td width=15 align=left>&nbsp;</td><td valign=top width=15 align=left><span class="choice" name="' + pQuestion.id +'choice' + (index+1) + '">\n';
-
-
- if( pQuestion.type == 'multiple' )
- {
- if(userclick=="true" && resumeAssessment){
- completeChoiceString += '<input name="qs' + pQuestion.id + 'choiceBtn" value="' + (index+1) + '" type="checkbox" checked onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')" >\n';
- }
- else
- {
- completeChoiceString += '<input name="qs' + pQuestion.id + 'choiceBtn" value="' + (index+1) + '" type="checkbox" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')" >\n';
- }
- }
-
- else if( pQuestion.type == 'single' ){
-
- if(userclick=="true" && resumeAssessment){
- completeChoiceString += '<input name="qs'+ pQuestion.id + 'RadioInp" type="radio" checked onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
-
- }
- else
- {
-
- completeChoiceString += '<input name="qs'+ pQuestion.id + 'RadioInp" type="radio" onClick="checkCurentQuestionOnClick(\'' + pQuestion.index + '\')">\n';
- }
- }
-
-
-
- questionLetters = String.fromCharCode( questionLetter + 64 );
-
-
-
- completeChoiceString += '</input></span></td><td valign=top class="qtext" align="left" width=15>' + questionLetters + '.&nbsp;&nbsp;</td><td valign=top align=left class="qtext" width=555>';
-
- completeChoiceString += choice.text;
-
- completeChoiceString += '<br><br></td></tr>\n';
-
- questionLetter++;
-
- index++;
-
- }
-
- return completeChoiceString;
-
-}
-
-function InstructionTextRenderer()
-{
-this.htmlCode=null;
-this.setHtmlCode=_setInstructionHtmlCode;
-this.render= _renderInstructionText;
-}
-
-function _setInstructionHtmlCode(pCode)
-{
- this.htmlCode=pCode;
-
-}
-
-function _renderInstructionText(pType)
-{
- var instructionText="";
- if(pType=='multiple')
- {
- instructionText+='all the correct answers.'
- }
- else
- {
- instructionText+='the best answer.'
- }
-
- var tempstring=replaceToken(INSTRUCTION_TEXT_TOKEN,this.htmlCode,instructionText);
- return tempstring;
-}
-
-
-// Result Page
-
-
-
-function _setResultChoiceRenderer(pRenderer){
-
- this.resultChoiceRenderer = pRenderer;
-
-}
-
-
-
-function _getResultChoiceRenderer(){
-
- return this.resultChoiceRenderer;
-
-}
-
-
-
-function _setResultHtmlCode(pCode){
-
- this.htmlCode = pCode;
-
-}
-
-
-
-// Results Choice Renderer
-
-
-
-function ResultChoiceRenderer(){
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setResultChoiceHtmlCode;
-
- this.render = _renderResultChoice;
-
-}
-
-
-
-function _setResultChoiceHtmlCode(pCode){
-
- this.htmlCode = pCode;
-
-}
-
-
-
-function _renderResultChoice(pAnswersArray , pQuestion , pIndex){
-
- var completeChoiceString = "";
-
- var choice = null;
-
- var numberOfChoices = pAnswersArray.length;
-
- var index = 0;
-
- var questionLetter = 1;
- var tAnswers = pAnswersArray;
- var correctAnsString = "";
-
- while(index < numberOfChoices){
-
- choice = pAnswersArray[index];
-
- if( tAnswers[index].correct == true ){
- if( correctAnsString.length > 0 ){
- correctAnsString += "," + (index+1);
- }
- else{
- correctAnsString += (index+1);
- }
- }
-
- completeChoiceString += '<tr><td width=15>&nbsp;</td><td valign=top align=left width=15><span class="choice" name="' + pQuestion.id +'choice' + (index+1) + '">\n';
- if( pQuestion.type == 'multiple' ){
- completeChoiceString += '<input disabled name="' + pQuestion.id + 'choiceBtn" value="' + (j+1) + '" type="checkbox" ' +checkIfSelected(userSelected[pIndex],index+1) + ' >\n';
- }
- else if( pQuestion.type == 'single' ){
- completeChoiceString += '<input disabled name="'+ pQuestion.id + 'RadioInp" type="radio" ' + checkIfSelected(userSelected[pIndex],index+1) + ' >\n';
- }
-
- questionLetters = String.fromCharCode( questionLetter + 64 );
-
- completeChoiceString += '</input></td><td valign=top width=15 align=left class="qtext">' + questionLetters + '.&nbsp;&nbsp;</td><td valign=top class="qtext" align=left width=555>';
- completeChoiceString += tAnswers[index].text;
- completeChoiceString += '<br><br></td></tr>\n';
- questionLetter++;
- index++;
- }
-
- return completeChoiceString;
-
-}
-
-
-//Results Renderer
-
-
-function ResultRenderer(){
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setResultHtmlCode;
-
- this.render = _renderResult;
-
- this.choiceRenderer = _defaultResultChoiceRenderer;
-
- this.setChoiceRenderer = _setResultChoiceRenderer;
-
- this.getChoiceRenderer = _getResultChoiceRenderer;
-
-}
-
-
-function _getResultRenderer(){
-
- return this.resultRenderer;
-
-}
-
-
-function ResultsPageRenderer(pDocument){
-
- iContentPage =pDocument;
-
- this.htmlDocument = pDocument;
-
- this.defaultResultRenderer = _defaultResultRenderer;
-
- this.render = _resRender;
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setHtmlCode;
-
-}
-
-//resRnder() function called from Result page
-
-
-function _resRender(){
-
- //debugger;
-
-
- userSelected = iHeaderFrame.iUserAnswers;
-
- if(!this.htmlDocument) {
-
- alert("please set the html document reference!");
-
- return;
-
- }
-
- var resultString = "";
-
- var length = iFinalQuestions.length;
-
- var index = 0;
-
- var question = "null";
-
-
-
- resultString += '<form name="qz">';
- while(index < length){
-
- question = iFinalQuestions[index];
- //alert("question== "+ (question.getRenderer()));
-
- if(question.getResultRenderer())
-
- resultString += question.getResultRenderer().render(question , index);
-
- else
-
- resultString += this.defaultResultRenderer.render(question , index);
-
- index++;
-
- }
- resultString += '</form>';
-
- this.htmlDocument.write(replaceToken(QUESTIONS_TOKEN,this.htmlCode , resultString));
-
- this.htmlDocument.close();
-
-}
-
-//Replacing Tokens in Result page with Respective Code blocks
-function _renderResult(pQuestion , pIndex){
-
- //debugger;
-
- var imageString = "";
-
- if(pQuestion.image){
- if(pQuestion.image.substring(pQuestion.image.lastIndexOf(".")+1) == 'swf') {
-var imageString = '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"';
- imageString += 'codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/';
-imageString += 'swflash.cab#version=6,0,29,0\" width=\"'+flashWidth+'\"';
-imageString += 'height=\"'+flashHeight+'\"><param name=\"movie\"';
-imageString += 'value=\"'+pQuestion.image+'\"><param name=\"quality\"';
-imageString += 'value=\"high\">';
-imageString += '<embed src=\"'+pQuestion.image+'\" quality=\"high\"';
-imageString += 'pluginspage=\"http://www.macromedia.com/go/getflashplayer\"';
-imageString += 'type=\"application/x-shockwave-flash\" width=\"'+flashWidth+'\"'; imageString += 'height=\"'+flashHeight+'\"></embed></object>';
-
- }
- else {
-var imageString = '<img border=\"0\" src=\"' + pQuestion.image + '\"';
-imageString += 'usemap=\"#HeaderMap\" alt=\"\">';
-
- }
- }
-
-
-
- var resultString = "";
-
- resultString = replaceToken(QUESTION_ID_TOKEN , this.htmlCode , pQuestion.getId());
-
- resultString = replaceToken(QUESTION_TEXT_TOKEN , resultString , pQuestion.text);
- resultString = replaceToken(IMAGE_TEXT_TOKEN , resultString , imageString);
-
- var iText = "";
- var instructionrenderer=pQuestion.InstructionTextRenderer;
- if(!pQuestion.getInstructionText()){
-
- iText= instructionrenderer.render(pQuestion.type);
-
- }else {
-
- iText= pQuestion.getInstructionText();
-
- }
- var tFeedback;
- if( pQuestion.userResponse ){
- tFeedback = pQuestion.correctFeedbackText;
- }
- else{
- tFeedback = pQuestion.incorrectFeedbackText;
- }
- if( tFeedback == "" ){
- tFeedback = correctAnswerString(correctAnsString);
- }
-
- resultString = replaceToken(QUESTION_ITEXT_TOKEN , resultString , iText);
-
- resultString = replaceToken(QUESTION_NUMBER , resultString , pIndex+1);
-
-
-
- var resultChoiceRenderer = pQuestion.getResultChoiceRenderer();
-
-
- if(!resultChoiceRenderer)
-
- resultChoiceRenderer = this.resultChoiceRenderer;
-
-//Calls the render() of Results Renderer for the generating disabled Choices to replace @@CHOICE@@ token
- resultString = replaceToken(CHOICE_TOKEN , resultString , resultChoiceRenderer.render(pQuestion.answers , pQuestion , pIndex));
- resultString = replaceToken(FEEDBACK_TOKEN , resultString , tFeedback);
- return resultString;
-
-}
-
-
-//Summary Renderer
-
-//Summary Renderer called from Result Summary page
-
-
-
-function SummaryPageRenderer(pDocument)
-{
-
-this.htmlDocument=pDocument;
-this.defaultSummaryCorrectRenderer = _defaultSummaryCorrectRenderer;
-this.defaultSummaryInCorrectRenderer = _defaultSummaryInCorrectRenderer;
-this.defaultSummaryNotAttemptedRenderer= _defaultSummaryNotAttemptedRenderer;
-this.defaultScoreRenderer= _defaultScoreRenderer;
-this.render = _summaryRender;
-this.htmlCode= null;
-this.setHtmlCode= _setSummaryHtmlCode;
-
-}
-
-
-
-
-function _setSummaryHtmlCode(pCodeString)
-{
-this.htmlCode=pCodeString;
-}
-
-
-
-
-function _summaryRender()
-{
-
- if(!this.htmlDocument)
- {
- alert("please set the html document reference!");
- return;
- }
-
- iFinalQuestions = iHeaderFrame.iFinalQuestions;
-
- userSelected = iHeaderFrame.iUserAnswers;
-
- var length = iFinalQuestions.length;
-
- var index = 0;
-
- score = iHeaderFrame.score;
-
- question = null;
-
- var tString = '';
-
- if( showPercentage ){
- score = (score/displayQuestions) * 100;
- score = Math.round(score);
- tString= this.defaultScoreRenderer.render(score,displayQuestions);
- }
- else{
- tString= this.defaultScoreRenderer.render(score,displayQuestions);
- }
- initializeVariables();
-
- var summaryString = tString;
-
- while(index < displayQuestions)
- {
- question = iFinalQuestions[index];
-
- if(question)
- {
-
- if(question.userResponse){
-
- summaryString += this.defaultSummaryCorrectRenderer.render(index+1 , userSelected[index]);
- }
-
- else
- {
- if(userSelected[index])
- {
-
- summaryString += this.defaultSummaryInCorrectRenderer.render(index+1 , userSelected[index]);
- }
- else
- {
- summaryString += this.defaultSummaryNotAttemptedRenderer.render(index+1 , userSelected[index]);
- }
- }
- }
-
- index++;
-
- }
-
- this.htmlDocument.write(replaceToken(SUMMARY_TOKEN,this.htmlCode , summaryString));
-
- this.htmlDocument.close();
- }
-
-
-
-// CorrectSummary Renderer
-function SummaryCorrectRenderer()
- {
- this.htmlCode = null;
-
- this.setHtmlCode = _setSummaryCorrectHtmlCode;
-
- this.render = _renderSummaryCorrect;
- }
-
-
-
-function _setSummaryCorrectHtmlCode(pCode)
- {
- this.htmlCode=pCode;
-
- }
-
-
-
-function _renderSummaryCorrect(index,pString)
- {
-
- var SummaryCorrectString = index.toString();
- SummaryCorrectString+= " ";
- SummaryCorrectString += insertCommas(pString);
- var tempString= replaceToken(CORRECT_SUMMARY_TOKEN, this.htmlCode, SummaryCorrectString);
- return tempString;
-
- }
-
-
-//SummaryIncorrect
-function SummaryInCorrectRenderer()
- {
- this.htmlCode = null;
-
- this.setHtmlCode = _setSummaryInCorrectHtmlCode;
-
- this.render = _renderSummaryInCorrect;
- }
-
-
-
-function _setSummaryInCorrectHtmlCode(pCode)
- {
- this.htmlCode=pCode;
-
- }
-
-
-
-function _renderSummaryInCorrect(index,pString)
- {
-
- var SummaryInCorrectString = index.toString();
- SummaryInCorrectString+= " ";
- SummaryInCorrectString += insertCommas(pString);
- var tempString= replaceToken(INCORRECT_SUMMARY_TOKEN, this.htmlCode, SummaryInCorrectString);
- return tempString;
-
- }
-
-//summary Not attempted
-function SummaryNotAttemptedRenderer()
- {
- this.htmlCode = null;
-
- this.setHtmlCode = _setSummaryNotAttemptedHtmlCode;
-
- this.render = _renderSummaryNotAttempted;
- }
-
-
-
-function _setSummaryNotAttemptedHtmlCode(pCode)
- {
- this.htmlCode=pCode;
-
- }
-
-
-
-function _renderSummaryNotAttempted(index,pString)
- {
-
- var SummaryNotAttemptedString = index.toString();
- SummaryNotAttemptedString+= " ";
- SummaryNotAttemptedString += insertCommas(pString);
- var tempString= replaceToken(NOT_ATTEMPTED_SUMMARY_TOKEN, this.htmlCode, SummaryNotAttemptedString);
- return tempString;
-
- }
-
-
-
-function ScoreRenderer()
- {
- this.htmlCode=null;
- this.setHtmlCode= _setScoreHtml;
- this.render=_renderScore;
-
- }
-
-
-
-function _setScoreHtml(pCode)
- {
- this.htmlCode=pCode;
- }
-
-
-
-function _renderScore(pScore,pDisplayQuestion)
- {
- var finalScoreText=replaceToken(SCORE_TOKEN,this.htmlCode,pScore);
- this.setHtmlCode(finalScoreText);
- finalScoreText=replaceToken(TOTAL_QUESTION_TOKEN,this.htmlCode,pDisplayQuestion);
- return finalScoreText;
- }
-
-
-
-function _setCorrectFeedbackHtmlCode(pCode)
-{
- this.htmlCode=pCode;
-}
-
-
-
-function _setInCorrectFeedbackHtmlCode(pCode)
-{
- this.htmlCode=pCode;
-}
-
-
-
-//for single question per Page type assessment.....
-
-
-function SinglePageAssessmentRenderer()
-{
-
- this.htmlDocument = null;
- this.setHtmlDocument = _setSinglePageAssessmentHtmlDocument;
- this.defaultQuestionRenderer = _defaultQuestionRenderer;
-
- this.render = _singlePageAssessmentrender;
-
- this.htmlCode = null;
-
- this.setHtmlCode = _setSinglePageAssessmentHtmlCode;
-
-
-}
-
-
-
-function _setSinglePageAssessmentHtmlCode(pCodeString){
-
- this.htmlCode = pCodeString;
-
-}
-
-
-
-function _setSinglePageAssessmentHtmlDocument(pDocument,pFormName){
-
- iContentPage =pDocument;
-
- setQuestionsForm(pFormName);
-
- this.htmlDocument = pDocument;
-
-}
-
-
-
-function _singlePageAssessmentrender()
-{
-
- if(!this.htmlDocument) {
-
- alert("please set the html document reference!");
-
- return;
-
- }
-
- var questionString = "";
-
- var questionNum = currentQustionIndex;
-
- var question = "null";
-
-
-if(hasNextQuestion() )
-{
- var question = getNextQuestion();
- if(question.getRenderer())
- questionString += question.getRenderer().render(question , questionNum);
- else
- questionString += this.defaultQuestionRenderer.render(question , questionNum);
-}
-
-this.htmlDocument.write(replaceToken(QUESTIONS_TOKEN,this.htmlCode , questionString));
-this.htmlDocument.close();
-
-}
-
-
-
-function InstantCorrectFeedbackRenderer()
-{
-this.htmlCode=null;
-this.setHtmlCode=_setCorrectFeedbackHtmlCode;
-this.render=_renderInstantCorrectFeedback;
-}
-
-
-
-function _renderInstantCorrectFeedback(pQuestion)
-{
-
-var feedbackString=replaceToken(CORRECT_INSTANT_FEEDBACK_TEXT_TOKEN,this.htmlCode,pQuestion.correctFeedbackText);
-return feedbackString;
-}
-
-
-
-function InstantInCorrectFeedbackRenderer()
-{
-this.htmlCode=null;
-this.setHtmlCode=_setInCorrectFeedbackHtmlCode;
-this.render=_renderInstantInCorrectFeedback;
-}
-
-
-
-function _renderInstantInCorrectFeedback(pQuestion)
-{
-
-var feedbackString=replaceToken(INCORRECT_INSTANT_FEEDBACK_TEXT_TOKEN,this.htmlCode,pQuestion.incorrectFeedbackText);
-return feedbackString;
-}
-
-
-// Ending Renderer
-
-
-
-
-
-
-
-// Global
-
-// replaces all occurences of the token.
-function replaceToken(pToken , pOriginalString , pStringToReplaceWith){
-
- //alert("Token" +pToken +"Original String" + pOriginalString + "ReplaceString" + pStringToReplaceWith);
-
- var index = pOriginalString.indexOf(pToken);
-
- var modifiedString = pOriginalString;
-
- if(index!=-1){
-
- var startString = pOriginalString.substring(0 , index);
-
- var endString = pOriginalString.substring(index+pToken.length);
-
- modifiedString = startString + pStringToReplaceWith + endString;
-
-
-
- if(modifiedString.indexOf(pToken) != -1)
-
- modifiedString = replaceToken(pToken , modifiedString , pStringToReplaceWith);
-
- }
-
- return modifiedString;
-
-}
-
-//used to return instant feedback string of the Question object. for Single question/page
-
-function getInstantFeedbackString(){
-
- var tQuestion = iFinalQuestions[currentQustionIndex-1];
- if(userSelected[currentQustionIndex-1] == iAnswersArray[currentQustionIndex-1]){
- return tQuestion.instantCorrectFeedbackRenderer.render(tQuestion);
- }
- else{
- return tQuestion.instantInCorrectFeedbackRenderer.render(tQuestion);
- }
-}
-
-
-//End Change of Model by Manu/Monalika/Sampad/Arijit