Widget:ExamObjDefinition: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
var exam = { | var exam = { | ||
this.countdownTimer = null; | |||
this.countdownCurrent = null; | |||
this.id = id; | |||
this.timestamp = null; | |||
this.username = mw.user.name(); | |||
this.questions = null; | |||
this.isPatientHistory = null; | |||
this.examType = null; | |||
setCountdown : function(time){ | |||
this.countdownCurrent = parseInt(time) * 6000 | |||
} | |||
isPatientHistory : function(isPatientHistory){ | |||
this.isPatientHistory = isPatientHistory; | |||
} | |||
setExamType : function(examType){ | |||
this.examType = examType; | |||
} | |||
questionAdd : function(question) { | |||
this.questions[] = question; | |||
} | |||
questionCache : function (questions) { | |||
$.each(questions, function (index, value) { | $.each(questions, function (index, value) { | ||
this.questions[value.pagename] = getQuestionMembers(value.pagename); | this.questions[value.pagename] = getQuestionMembers(value.pagename); | ||
//can define other question array member properties as null here as needed. | //can define other question array member properties as null here as needed. | ||
}); | }); | ||
} | |||
} | |||
timerOn : function(duration) { | |||
$.getScript("http://wikidoc.org/includes/jquery.timer.js", function () { | $.getScript("http://wikidoc.org/includes/jquery.timer.js", function () { | ||
countdownTimer = $.timer(function () { | this.countdownTimer = $.timer(function () { | ||
var min = parseInt(countdownCurrent / 6000); | var min = parseInt(this.countdownCurrent / 6000); | ||
var sec = parseInt(countdownCurrent / 100) - (min * 60); | var sec = parseInt(this.countdownCurrent / 100) - (min * 60); | ||
var micro = pad(countdownCurrent - (sec * 100) - (min * 6000), 2); | var micro = pad(this.countdownCurrent - (sec * 100) - (min * 6000), 2); | ||
var output = "00"; | var output = "00"; | ||
if (min > 0) { | if (min > 0) { | ||
output = pad(min, 2); | output = pad(min, 2); | ||
} | } | ||
$ | $interface.updateClock(output + ":" + pad(sec, 2)); | ||
if (countdownCurrent == 0) { | if (this.countdownCurrent == 0) { | ||
countdownTimer.stop(); | this.countdownTimer.stop(); | ||
endExam(); | endExam(); | ||
} else { | } else { | ||
countdownCurrent -= 7; | this.countdownCurrent -= 7; | ||
if (countdownCurrent < 0) { | if (this.countdownCurrent < 0) { | ||
countdownCurrent = 0; | this.countdownCurrent = 0; | ||
} | } | ||
} | } | ||
}, 70, false); | }, 70, false); | ||
} | |||
} | } | ||
Line 49: | Line 67: | ||
stepTwo : function (){ | stepTwo : function (){ | ||
$.("#wbrcontent").html(" "); | $.("#wbrcontent").html(" "); | ||
var examPicker = " | var examPicker = " | ||
} | } | ||
} | } | ||
var question = { | |||
//Define all question members in here. Shouldn't be too many member methods. | |||
} | |||
function getQuestionMembers(pagename) { | function getQuestionMembers(pagename) { | ||
var result = null; | var result = null; |