Widget:ExamObjDefinition: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) Created page with "<includeonly> <script type="text/javascript"> var exam = { init: function(id, timestamp, username){ this.id = id; this.timestamp = timestamp; this.username..." |
Matt Pijoan (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
var exam = { | var exam = { | ||
init : function (id, timestamp, username, questions, isTimed) { | |||
this.id = id; | |||
this.timestamp = timestamp; | |||
this.username = username; | |||
this.questions = null; | |||
$.each(questions, function (index, value) { | |||
this.questions[value.pagename] = getQuestionMembers(value.pagename); | |||
}); | |||
if (isTimed) { | |||
this.countdownTimer = null; | |||
this.countdownCurrent = null; | |||
$.getScript("http://wikidoc.org/includes/jquery.timer.js", function () { | |||
$(document).ready(function () { | |||
countdownTimer = $.timer(function () { | |||
var min = parseInt(countdownCurrent / 6000); | |||
var sec = parseInt(countdownCurrent / 100) - (min * 60); | |||
var micro = pad(countdownCurrent - (sec * 100) - (min * 6000), 2); | |||
var output = "00"; | |||
if (min > 0) { | |||
output = pad(min, 2); | |||
} | |||
$('.countdowntime').html(output + ":" + pad(sec, 2)); | |||
if (countdownCurrent == 0) { | |||
countdownTimer.stop(); | |||
endExam(); | |||
} else { | |||
countdownCurrent -= 7; | |||
if (countdownCurrent < 0) { | |||
countdownCurrent = 0; | |||
} | |||
} | |||
}, 70, false); | |||
}); | |||
}); | |||
} | |||
} | |||
} | } | ||
function getQuestionMembers(pagename) { | |||
var result = null; | |||
$.ajaxSetup({ | |||
async : false | |||
}); | |||
var right = " "; | |||
var qs = "[[" + pagename + "]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp|?WBRImage|?WBRImageCaption|?WBRImagePlace"; | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'ask', | |||
query : qs, | |||
format : 'json' | |||
}, { | |||
ok : function (data) { | |||
result = data.value.printouts; | |||
}); | |||
return result; | |||
} | |||
</script> | </script> | ||
</includeonly> | </includeonly> |