Members
(static) createPart
Create a new question part.
- Source:
- See:
(static) createPartFromJSON
Create a question part based on an XML definition.
- Source:
Fires:
- Numbas.Part#event:finaliseLoad
(static) custom_part_types :object
Definitions of custom part types.
Type:
- Source:
(static) extensions
Extensions should add objects to this so they can be accessed
(static) loadScript
Ask to load a javascript file. Unless noreq
is set, the file's code must be wrapped in a call to Numbas.queueScript with its filename as the first parameter.
(static) locale :object
Resources to do with localisation: preferred_locale
is the code of the locale to use, and resources
is a dictionary of localisations.
Type:
(static) marking_scripts :Object.<Numbas.marking.MarkingScript>
Marking scripts for the built-in part types.
Type:
- Object.<Numbas.marking.MarkingScript>
(static) partConstructors
Associate part type names with their object constructors.
These constructors are called by Numbas.createPart
- they should be finalised constructors with all the generic part methods implemented.
Most often, you do this by extending Numbas.parts.Part
.
- Source:
(static) raw_marking_scripts :Object.<string>
Definitions of marking scripts for the built-in part types.
Type:
(static) rawxml :Object.<string>
Raw XML of the exam definition.
Type:
- Source:
Methods
(static) activateExtension(name)
Run the extension with the given name. The extension must have already been registered with Numbas.addExtension
.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
(static) addExtension(name, deps, callback) → {Promise}
A wrapper round Numbas.queueScript
to register extensions easily.
The extension is not run immediately - call Numbas.activateExtension
to run the extension.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Unique name of the extension. |
deps |
Array.<string> | A list of other scripts which need to be run before this one can be run. |
callback |
function | Code to set up the extension. It's given the object |
Returns:
Type | Description |
---|---|
Promise |
|
(static) checkAllScriptsLoaded() → {Array.<object>}
Check all required scripts have executed - the theme should call this once the document has loaded.
Returns:
Type | Description |
---|---|
Array.<object> |
A list of files which have not loaded. |
(static) createExamFromJSON(data, storeopt, display_root, scheduler) → {Numbas.Exam}
Create a Numbas.Exam
object from a JSON definition.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
object | ||
store |
Numbas.storage.BlankStorage |
<optional> |
the storage engine to use |
display_root |
Element | The root element of the exam's display. |
|
scheduler |
Numbas.Scheduler |
Returns:
Type | Description |
---|---|
Numbas.Exam |
- Source:
(static) createExamFromXML(xml, storeopt, display_rootopt, scheduler) → {Numbas.Exam}
Create a Numbas.Exam
object from an XML definition.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
xml |
Element | ||
store |
Numbas.storage.BlankStorage |
<optional> |
The storage engine to use. |
display_root |
Element |
<optional> |
Should this exam make a |
scheduler |
Numbas.Scheduler |
Returns:
Type | Description |
---|---|
Numbas.Exam |
- Source:
(static) createPartFromXML(index, xml, pathopt, questionopt, parentPartopt, storeopt, scopeopt) → {Numbas.parts.Part}
Create a question part based on an XML definition.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
index |
number | The index of the part's definition. |
|
xml |
Element | ||
path |
Numbas.parts.partpath |
<optional> |
|
question |
Numbas.Question |
<optional> |
|
parentPart |
Numbas.parts.Part |
<optional> |
|
store |
Numbas.storage.BlankStorage |
<optional> |
The storage engine to use. |
scope |
Numbas.jme.Scope |
<optional> |
Scope in which the part should evaluate JME expressions. If not given, the question's scope or |
Fires:
- Numbas.Part#event:finaliseLoad
Throws:
-
"part.missing type attribute" if the top node in
xml
doesn't have a "type" attribute. - Type
- Numbas.Error
Returns:
Type | Description |
---|---|
Numbas.parts.Part |
- Source:
(static) createQuestionFromJSON(data, number, examopt, groupopt, scopeopt, storeopt, loading) → {Numbas.Question}
Create a Numbas.Question
object from a JSON object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
object | ||
number |
number | The number of the question in the exam. |
|
exam |
Numbas.Exam |
<optional> |
The exam this question belongs to. |
group |
Numbas.QuestionGroup |
<optional> |
The group this question belongs to. |
scope |
Numbas.jme.Scope |
<optional> |
The global JME scope. |
store |
Numbas.storage.BlankStorage |
<optional> |
The storage engine to use. |
loading |
boolean | Is this question being resumed? |
Returns:
Type | Description |
---|---|
Numbas.Question |
(static) createQuestionFromXML(xml, number, examopt, groupopt, scopeopt, storeopt, loading) → {Numbas.Question}
Create a Numbas.Question
object from an XML definition.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
xml |
Element | ||
number |
number | The number of the question in the exam. |
|
exam |
Numbas.Exam |
<optional> |
The exam this question belongs to. |
group |
Numbas.QuestionGroup |
<optional> |
The group this question belongs to. |
scope |
Numbas.jme.Scope |
<optional> |
The global JME scope. |
store |
Numbas.storage.BlankStorage |
<optional> |
The storage engine to use. |
loading |
boolean | Is this question being resumed? |
Returns:
Type | Description |
---|---|
Numbas.Question |
(static) debug(msg, noStackopt, error)
A function for displaying debug info in the console. It will try to give a reference back to the line that called it, if it can.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
msg |
string | Text to display. |
||
noStack |
boolean |
<optional> |
false | Don't show the stack trace. |
error |
Error |
(static) getStandaloneFileURL(extension, path) → {string}
Get the URL of a standalone file from an extension.
Parameters:
Name | Type | Description |
---|---|---|
extension |
string | The name of the extension. |
path |
string | The path to the script, relative to the extension's |
Returns:
Type | Description |
---|---|
string |
(static) init_exam(examXML, store, elementopt) → {Promise.<Numbas.Exam>}
Initialise the exam:
- Connect to the LMS, which might have saved student answers
- Load the exam XML and the XSL templates
- create and initialise the exam object
- display the frontpage
This function is called when all the other scripts have been loaded and executed. It uses the scheduling system to make sure the browser isn't locked up when the exam is being initialised.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
examXML |
Element | The XML definition of the exam. |
|
store |
Numbas.storage.Storage | Attempt data storage controller. |
|
element |
Element |
<optional> |
The root |
Fires:
- Numbas.signals#event:exam_ready
- Numbas.signals#event:Numbas_initialised
Returns:
Type | Description |
---|---|
Promise.<Numbas.Exam> |
(static) loadStandaloneScript(extension, path, typeopt)
Load a standalone script from an extension. Inserts a