Jump to navigation

Class: Exam

Numbas.Exam

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

currentQuestion :Numbas.Question

Object representing the current question.

Type:
Source:

currentQuestionNumber :number

Number of the current question.

Type:
Source:

displayDuration :string

Exam duration in h:m:s format.

Type:
Source:

endTime :Date

Time that the exam should stop.

Type:
Source:

entry :string

How was the exam started?

One of: ab-initio, resume, or review

Type:
Source:

inProgress :boolean

Is the exam in progress?

false before starting, when paused, and after ending.

Type:
Source:

json :object

Definition of the exam

Type:
Source:

mark :number

Total marks available in the exam.

Type:
Source:

mode :string

Can be:

  • "normal" - Student is currently sitting the exam.
  • "review" - Student is reviewing a completed exam.
Type:
Source:

passed :boolean

Did the student pass the exam?

Type:
Source:

percentScore :number

Student's score as a percentage.

Type:
Source:

questionGroupOrder :Array.<number>

The order in which the question groups are displayed

Type:
Source:

questionList :Array.<Numbas.Question>

Question objects, in the order the student will see them.

Type:
Source:

questionSubset :Array.<number>

Which questions are used?

Type:
Source:

question_groups :Array.<Numbas.QuestionGroup>

Groups of questions in the exam.

Type:
Source:

revealed :boolean

Have the correct answers been revealed?

Type:
Source:

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:
Source:

score :number

Student's current score.

Type:
Source:

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 "sequence", "menu" or "diagnostic"

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?

Source:

signals :Numbas.schedule.SignalBox

Signals produced while loading this exam.

Type:
Source:

start :Date

Time the exam started.

Type:
Source:

stop :null|Date

Time the exam finished.

Type:
Source:

stopwatch

Stopwatch object - updates the timer every second.

Properties:
Name Type Description
start Date
end Date
oldTimeSpent number

The value of timeSpent when the stopwatch was last updated.

id number

The id of the Interval which calls Numbas.Exam#countDown.

Source:

student_id :string

Student's ID.

Type:
Source:

student_name :string

Student's name.

Type:
Source:

timeRemaining :number

Seconds until the end of the exam.

Type:
Source:

timeSpent :number

Seconds the exam has been in progress.

Type:
Source:

xml :Element

Base node of exam XML

Type:
Source:

Methods

acceptPassword(password) → {boolean}

Accept the given password to begin the exam?

Parameters:
Name Type Description
password string
Returns:
Type Description
boolean
Source:

begin()

Begin the exam - start timing, go to the first question.

Fires:
  • Numbas.Exam#event:begin
Source:

calculateScore()

Calculate the student's score.

Fires:
  • Numbas.Exam#event:calculateScore
Source:

changeDuration(duration)

Set the duration of the exam.

Parameters:
Name Type Description
duration number
Source:

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
Source:

chooseQuestionSubset()

Decide which questions to use and in what order.

Fires:
  • Numbas.Exam#event:chooseQuestionSubset
Source:
See:

countDown()

Calculate time remaining and end the exam when timer reaches zero.

Fires:
  • Numbas.Exam#event:countDown
  • Numbas.Exam#event:alert
Source:

diagnostic_actions() → {object}

Get the prompt text and list of action options when the student asks to move on.

Returns:
Type Description
object
Source:

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 Numbas.storage.BlankStorage#end

Fires:
  • Numbas.Exam#event:end
  • Numbas.Exam#event:showInfoPage
Source:

endTiming()

Stop the stopwatch.

Fires:
  • Numbas.Exam#event:endTiming
Source:

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 Numbas.display.ExamDisplay object?

Fires:
  • Numbas.Exam#event:diagnostic_controller_initialised
Source:

init()

Stuff to do when starting exam afresh, before showing the front page.

Fires:
Source:

load()

Restore previously started exam from storage.

Fires:
Listens to Events:
Source:

loadFromXML(xml)

Load the exam's settings from an XML node.

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:
Listens to Events:
Source:

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
Source:

pause()

Pause the exam, and show the suspend page.

Fires:
  • Numbas.Exam#event:pause
  • Numbas.Exam#event:showInfoPage
Source:

regenQuestion() → {Promise}

Regenerate the current question.

Fires:
  • Numbas.Exam#event:startRegen
  • Numbas.Exam#event:endRegen
Listens to Events:
Returns:
Type Description
Promise
  • Resolves when the new question is ready.
Source:

resume()

Resume the exam.

Fires:
  • Numbas.Exam#event:resume
  • Numbas.Exam#event:showInfoPage
Source:

revealAnswers()

Reveal the answers to every question in the exam.

Fires:
  • Numbas.Exam#event:revealAnswers
Source:

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
Source:

set_exam_variables()

Set exam-level variables.

Source:

showInfoPage(page)

Show the given info page.

Parameters:
Name Type Description
page string

The name of the page to show.

Source:

showMenu()

Show the question menu.

Fires:
  • Numbas.Exam#event:showInfoPage
Source:

startTiming()

Set the stopwatch going.

Fires:
  • Numbas.Exam#event:startTiming
  • Numbas.Exam#event:hideTiming
  • Numbas.Exam#event:showTiming
Source:

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
Source:
See:

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
Source:

updateDurationExtension()

Get any duration extension from the storage.

Source:

updateScore()

Recalculate and display the student's total score.

Fires:
  • Numbas.Exam#event:updateScore
Source:
See:

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: