Jump to navigation

Class: Exam

Numbas.Exam

new Exam(storeopt)

Keeps track of all info we need to know while exam is running.

Loads XML from Numbas.xml.examXML

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:

inProgress :Boolean

Is the exam in progress?

false before starting, when paused, and after ending.

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:

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:

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 Description
name String

Title of exam

percentPass Number

Percentage of max. score student must achieve to pass

shuffleQuestions Boolean

should the questions be shuffled?

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?

navigateReverse Boolean

can student navigate to previous question?

navigateBrowse Boolean

can student jump to any question they like?

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

how long is exam? (seconds)

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?

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

timeSpent when the stopwatch was last updated

id Number

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:

exit()

Exit the exam - show the exit page

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:

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:

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:

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: