This static class provides access to the other question bank.
More...
|
const | MAX_SUMMARY_LENGTH = 32000 |
|
|
static | ensure_fraction_options_initialised () |
|
This static class provides access to the other question bank.
It provides functions for managing question types and question definitions.
- Copyright
- 2009 The Open University
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ end_unit_test()
static question_bank::end_unit_test |
( |
| ) |
|
|
static |
◆ fraction_options()
static question_bank::fraction_options |
( |
| ) |
|
|
static |
- Return values
-
array | string => string The standard set of grade options (fractions) to use when editing questions, in the range 0 to 1 inclusive. Array keys are string becuase: a) we want grades to exactly 7 d.p., and b. you can't have float array keys in PHP. Initialised by ensure_grade_options_initialised(). |
◆ fraction_options_full()
static question_bank::fraction_options_full |
( |
| ) |
|
|
static |
- Return values
-
array | string => string The full standard set of (fractions) -1 to 1 inclusive. |
◆ get_all_qtypes()
static question_bank::get_all_qtypes |
( |
| ) |
|
|
static |
- Return values
-
array | all the installed question types. |
◆ get_all_question_types_in_categories()
static question_bank::get_all_question_types_in_categories |
( |
| $categories | ) |
|
|
static |
Return a list of the different question types present in the given categories.
- Parameters
-
array | $categories | a list of category ids |
- Return values
-
array | the list of question types in the categories |
- Since
- Moodle 3.1
◆ get_all_versions_of_question()
static question_bank::get_all_versions_of_question |
( |
int | $questionid | ) |
|
|
static |
Get all the versions of a particular question.
- Parameters
-
int | $questionid | id of the question |
- Return values
-
array | The array keys are version number, and the values are objects with three int fields version (same as array key), versionid and questionid. |
◆ get_all_versions_of_questions()
static question_bank::get_all_versions_of_questions |
( |
array | $questionids | ) |
|
|
static |
Get all the versions of questions.
- Parameters
-
array | $questionids | Array of question ids. |
- Return values
-
array | two dimensional array question_bank_entries.id => version number => question.id. Versions in descending order. |
◆ get_config()
static question_bank::get_config |
( |
| ) |
|
|
static |
Load the question configuration data from config_plugins.
- Return values
-
object | get_config('question') with caching. |
◆ get_creatable_qtypes()
static question_bank::get_creatable_qtypes |
( |
| ) |
|
|
static |
- Return values
-
array | all the question types that users are allowed to create, sorted into the preferred order set on the admin screen. |
◆ get_finder()
static question_bank::get_finder |
( |
| ) |
|
|
static |
◆ get_qtype()
static question_bank::get_qtype |
( |
| $qtypename, |
|
|
| $mustexist = true ) |
|
static |
Get the question type class for a particular question type.
- Parameters
-
string | $qtypename | the question type name. For example 'multichoice' or 'shortanswer'. |
bool | $mustexist | if false, the missing question type is returned when the requested question type is not installed. |
- Return values
-
◆ get_qtype_name()
static question_bank::get_qtype_name |
( |
| $qtypename | ) |
|
|
static |
- Parameters
-
$qtypename | the internal name of a question type, for example multichoice. |
- Return values
-
string | the human_readable name of this question type, from the language pack. |
◆ get_version_of_questions()
static question_bank::get_version_of_questions |
( |
array | $questionids | ) |
|
|
static |
Retrieves version information for a list of questions.
- Parameters
-
array | $questionids | Array of question ids. |
- Return values
-
array | An array question_bank_entries.id => version number => question.id. |
◆ is_qtype_installed()
static question_bank::is_qtype_installed |
( |
| $qtypename | ) |
|
|
static |
- Parameters
-
string | $qtypename | a question type name, e.g. 'multichoice'. |
- Return values
-
bool | whether that question type is installed in this Moodle. |
◆ is_qtype_usable()
static question_bank::is_qtype_usable |
( |
string | $qtypename | ) |
|
|
static |
Check if a given question type is one that is installed and usable.
Use this before doing things like rendering buttons/options which will only work for installed question types.
When loaded through most of the core_question areas, qtype will still be the uninstalled type, e.g. 'mytype', but when we get to the quiz pages, it will have been converted to 'missingtype'. So we need to check that as well here.
- Parameters
-
string | $qtypename | e.g. 'multichoice'. |
- Return values
-
◆ load_question()
static question_bank::load_question |
( |
| $questionid, |
|
|
| $allowshuffle = true ) |
|
static |
Load a question definition from the database.
The object returned will actually be of an appropriate question_definition subclass.
- Parameters
-
int | $questionid | the id of the question to load. |
bool | $allowshuffle | if false, then any shuffle option on the selected quetsion is disabled. |
- Return values
-
◆ load_question_data()
static question_bank::load_question_data |
( |
| $questionid | ) |
|
|
static |
Load a question definition data from the database.
The data will be returned as a plain stdClass object.
- Parameters
-
int | $questionid | the id of the question to load. |
- Return values
-
object | question definition loaded from the database. |
◆ load_question_definition_classes()
static question_bank::load_question_definition_classes |
( |
| $qtypename | ) |
|
|
static |
Load the question definition class(es) belonging to a question type.
That is, include_once('/question/type/' . $qtypename . '/question.php'), with a bit of checking.
- Parameters
-
string | $qtypename | the question type name. For example 'multichoice' or 'shortanswer'. |
◆ load_test_question_data()
To be used for unit testing only.
Will throw an exception if start_unit_test() has not been called first.
- Parameters
-
object | $questiondata | a question data object to put in the test data store. |
◆ make_question()
static question_bank::make_question |
( |
| $questiondata | ) |
|
|
static |
Convert the question information loaded with get_question_options() to a question_definintion object.
- Parameters
-
object | $questiondata | raw data loaded from the database. |
- Return values
-
◆ qtype_enabled()
static question_bank::qtype_enabled |
( |
| $qtypename | ) |
|
|
static |
- Parameters
-
string | $qtypename | the internal name of a question type. For example multichoice. |
- Return values
-
bool | whether users are allowed to create questions of this type. |
◆ qtype_exists()
static question_bank::qtype_exists |
( |
| $qtypename | ) |
|
|
static |
- Parameters
-
string | $qtypename | the internal name of a question type. For example multichoice. |
- Return values
-
bool | whether this question type exists. |
◆ render_preview_of_question()
Render a throw-away preview of a question.
If the question cannot be rendered (e.g. because it is not installed) then display a message instead.
- Parameters
-
- Return values
-
◆ sort_qtype_array()
static question_bank::sort_qtype_array |
( |
| $qtypes, |
|
|
| $config = null ) |
|
static |
Sort an array of question types according to the order the admin set up, and then alphabetically for the rest.
- Parameters
-
array | qtype->name() => qtype->local_name(). |
- Return values
-
◆ start_unit_test()
static question_bank::start_unit_test |
( |
| ) |
|
|
static |
The documentation for this class was generated from the following file: