new Exam(storeopt)
Keeps track of all info we need to know while exam is running.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
store |
Numbas.storage.BlankStorage |
<optional> |
the storage engine to use |
- Source:
Members
currentQuestionNumber :number
Number of the current question.
Type:
displayDuration :string
Exam duration in h:m:s
format.
Type:
entry :string
How was the exam started?
One of: ab-initio
, resume
, or review
Type:
inProgress :boolean
Is the exam in progress?
false
before starting, when paused, and after ending.
Type:
mark :number
Total marks available in the exam.
Type:
mode :string
Can be:
"normal"
- Student is currently sitting the exam."review"
- Student is reviewing a completed exam.
Type:
passed :boolean
Did the student pass the exam?
Type:
percentScore :number
Student's score as a percentage.
Type:
questionGroupOrder :Array.<number>
The order in which the question groups are displayed
Type:
questionList :Array.<Numbas.Question>
Question objects, in the order the student will see them.
Type:
questionSubset :Array.<number>
Which questions are used?
Type:
revealed :boolean
Have the correct answers been revealed?
Type:
scope :Numbas.jme.Scope
JME evaluation environment.
Contains variables, rulesets and functions defined by the exam and by extensions.
Inherited by each Numbas.Question
's scope.
Type:
settings
Settings for the exam object.
Properties:
Name | Type | Description |
---|---|---|
name |
string | Title of exam |
percentPass |
number | Percentage of max. score student must achieve to pass |
allowPrinting |
boolean | Allow the student to print an exam transcript? If not, the theme should hide everything in print media and not show any buttons to print. |
shuffleQuestions |
boolean | should the questions be shuffled? |
shuffleQuestionGroups |
boolean | randomize question group order? |
numQuestions |
number | number of questions in this sitting |
preventLeave |
boolean | prevent the browser from leaving the page while the exam is running? |
typeendtoleave |
boolean | require written confirmation before leaving the exam? |
startPassword |
string | password the student must enter before beginning the exam |
allowRegen |
boolean | can student re-randomise a question? |
allowAttemptDownload |
boolean | Can the student download their results as a CSV? |
downloadEncryptionKey |
string | key for encryption student data? |
autoSubmit |
boolean | Automatically submit parts after entering an answer? If false, then the student must click the "Save answer" button. |
navigateMode |
string | how is the exam navigated? Either |
navigateReverse |
boolean | can student navigate to previous question? |
navigateBrowse |
boolean | can student jump to any question they like? |
allowSteps |
boolean | are steps enabled? |
showFrontPage |
boolean | show the frontpage before starting the exam? |
enterReviewModeImmediately |
boolean | Should the exam go into review mode immediately after ending, or only when re-entering in review mode? |
navigationEvents |
Array.<Object.<Numbas.ExamEvent>> | checks to perform when doing certain navigation action |
timerEvents |
Array.<Object.<Numbas.ExamEvent>> | Events based on timing. |
duration |
number | The time allowed for the exam, in seconds. |
duration_extension |
number | A number of seconds to add to the duration. |
initial_duration |
number | The duration without any extension applied. |
allowPause |
boolean | Can the student suspend the timer with the pause button or by leaving? |
showActualMark |
string | When should the current score be shown? |
showTotalMark |
string | When should total marks in the exam be shown? |
showAnswerState |
string | When to tell the student if answer is correct/wrong/partial? |
showPartFeedbackMessages |
string | When to show part feedback messages? |
allowRevealAnswer |
boolean | Allow 'reveal answer' button? |
showQuestionGroupNames |
boolean | Show the names of question groups? |
revealAdvice |
string | When should question advice be shown? |
revealExpectedAnswers |
string | When should expected answers be shown? |
resultsprintquestions |
boolean | Show questions in printed results? |
resultsprintadvice |
boolean | Show advice in printed results? |
stopwatch
Stopwatch object - updates the timer every second.
Properties:
Name | Type | Description |
---|---|---|
start |
Date | |
end |
Date | |
oldTimeSpent |
number | The value of |
id |
number | The id of the |
timeRemaining :number
Seconds until the end of the exam.
Type:
timeSpent :number
Seconds the exam has been in progress.
Type:
Methods
acceptPassword(password) → {boolean}
Accept the given password to begin the exam?
Parameters:
Name | Type | Description |
---|---|---|
password |
string |
Returns:
Type | Description |
---|---|
boolean |
begin()
Begin the exam - start timing, go to the first question.
Fires:
- Numbas.Exam#event:begin
calculateScore()
Calculate the student's score.
Fires:
- Numbas.Exam#event:calculateScore
changeDuration(duration)
Set the duration of the exam.
Parameters:
Name | Type | Description |
---|---|---|
duration |
number |
changeQuestion(i)
Change the current question. Student's can't trigger this without going through Numbas.Exam#tryChangeQuestion
.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Number of the question to move to |
Fires:
- Numbas.Exam#event:changeQuestion
chooseQuestionSubset()
Decide which questions to use and in what order.
Fires:
- Numbas.Exam#event:chooseQuestionSubset
countDown()
Calculate time remaining and end the exam when timer reaches zero.
Fires:
- Numbas.Exam#event:countDown
- Numbas.Exam#event:alert
diagnostic_actions() → {object}
Get the prompt text and list of action options when the student asks to move on.
Returns:
Type | Description |
---|---|
object |
end(save)
End the exam. The student can't directly trigger this without going through Numbas.Exam#tryEnd
.
Parameters:
Name | Type | Description |
---|---|---|
save |
boolean | should the end time be saved? See |
Fires:
- Numbas.Exam#event:end
- Numbas.Exam#event:showInfoPage
endTiming()
Stop the stopwatch.
Fires:
- Numbas.Exam#event:endTiming
finaliseLoad(makeDisplayopt)
Perform any tidying up or processing that needs to happen once the exam's definition has been loaded.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
makeDisplay |
boolean |
<optional> |
true | Should this exam make a |
Fires:
- Numbas.Exam#event:diagnostic_controller_initialised
init()
Stuff to do when starting exam afresh, before showing the front page.
Fires:
- Numbas.Exam#event:ready
- Numbas.Exam#event:display_ready
load()
Restore previously started exam from storage.
Fires:
Listens to Events:
loadFromXML(xml)
Load the exam's settings from an XML
Parameters:
Name | Type | Description |
---|---|---|
xml |
Element |
- Source:
makeQuestionList(loading)
Having chosen which questions to use, make question list and create question objects.
If loading, need to restore randomised variables instead of generating anew.
Parameters:
Name | Type | Description |
---|---|---|
loading |
boolean |
Fires:
- Numbas.Exam#event:question_list_initialised
- Numbas.Exam#event:display_question_list_initialised
Listens to Events:
next_diagnostic_question(data)
Show the next question, drawn from the given topic.
Parameters:
Name | Type | Description |
---|---|---|
data |
object |
Fires:
- Numbas.Exam#event:initQuestion
- Numbas.Exam#event:showQuestion
pause()
Pause the exam, and show the suspend
page.
Fires:
- Numbas.Exam#event:pause
- Numbas.Exam#event:showInfoPage
regenQuestion() → {Promise}
Regenerate the current question.
Fires:
- Numbas.Exam#event:startRegen
- Numbas.Exam#event:endRegen
Listens to Events:
Returns:
Type | Description |
---|---|
Promise |
|
resume()
Resume the exam.
Fires:
- Numbas.Exam#event:resume
- Numbas.Exam#event:showInfoPage
revealAnswers()
Reveal the answers to every question in the exam.
Fires:
- Numbas.Exam#event:revealAnswers
reviewQuestion(i)
Show a question in review mode.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Number of the question to show |
Fires:
- Numbas.Exam#event:reviewQuestion
showInfoPage(page)
Show the given info page.
Parameters:
Name | Type | Description |
---|---|---|
page |
string | The name of the page to show. |
showMenu()
Show the question menu.
Fires:
- Numbas.Exam#event:showInfoPage
startTiming()
Set the stopwatch going.
Fires:
- Numbas.Exam#event:startTiming
- Numbas.Exam#event:hideTiming
- Numbas.Exam#event:showTiming
tryChangeQuestion(i)
Call this when student wants to move between questions.
Will check move is allowed and if so change question and update display.
Parameters:
Name | Type | Description |
---|---|---|
i |
number | Number of the question to move to |
Fires:
- Numbas.Exam#event:tryChangeQuestion
- Numbas.Exam#event:showDiagnosticActions
tryEnd()
Try to end the exam - shows confirmation dialog, and checks that all answers have been submitted.
Fires:
- Numbas.Exam#event:tryEnd
- Source:
- See:
updateDisplayDuration()
Update the timing display.
Fires:
- Numbas.Exam#event:updateDisplayDuration
updateDurationExtension()
Get any duration extension from the storage.
updateScore()
Recalculate and display the student's total score.
Fires:
- Numbas.Exam#event:updateScore
Events
question_list_initialised
The question list has been initialised - every question is loaded and ready to use.
Listeners of This Event:
- Source:
ready
The exam is ready for the student to start interacting with it.
- Source: