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:

question_groups :Array.<Numbas.QuestionGroup>

Groups of questions in the exam.

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:

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

Properties:
Name Type Default 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?

startPassword string

password the student must enter before beginning the exam

allowRegen boolean

can student re-randomise a question?

navigateMode string "sequence"

how is the exam navigated? Either "sequence" or "menu"

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?

showResultsPage boolean

show the results page after finishing the exam?

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 boolean

show current score?

showTotalMark boolean

show total marks in exam?

showAnswerState boolean

tell student if answer is correct/wrong/partial?

allowRevealAnswer boolean

allow 'reveal answer' button?

showQuestionGroupNames boolean

show the names of question groups?

reviewShowScore boolean

show student's score in review mode?

reviewShowFeedback boolean

show part feedback messages in review mode?

reviewShowAdvice boolean

show question advice in review mode?

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.

Source:

calculateScore()

Calculate the student's score.

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

Source:

chooseQuestionSubset()

Decide which questions to use and in what order.

Source:
See:

countDown()

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

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

Source:

endTiming()

Stop the stopwatch.

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:

pause()

Pause the exam, and show the suspend page.

Source:

regenQuestion()

Regenerate the current question.

Listens to Events:
Source:

resume()

Resume the exam.

Source:

revealAnswers()

Reveal the answers to every question in the exam.

Source:

reviewQuestion(i)

Show a question in review mode.

Parameters:
Name Type Description
i number

Number of the question to show

Source:

showInfoPage(page)

Show the given info page.

Parameters:
Name Type Description
page string

Name of the page to show.

Source:

showMenu()

Show the question menu.

Source:

startTiming()

Set the stopwatch going.

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

Source:
See:

tryEnd()

Try to end the exam - shows confirmation dialog, and checks that all answers have been submitted.

Source:
See:

updateScore()

Recalculate and display the student's total score.

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: