Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
qtype

Classes

class  moodle1_qtype_calculated_handler
 Calculated question type conversion handler. More...
 
class  moodle1_qtype_essay_handler
 Short answer question type conversion handler. More...
 
class  moodle1_qtype_multianswer_handler
 Multianswer (aka embedded, cloze) question type conversion handler. More...
 
class  moodle1_qtype_multichoice_handler
 Multichoice question type conversion handler. More...
 
class  moodle1_qtype_numerical_handler
 Multichoice question type conversion handler. More...
 
class  moodle1_qtype_shortanswer_handler
 Short answer question type conversion handler. More...
 
class  moodle1_qtype_truefalse_handler
 True/false question type conversion handler. More...
 
class  qtype_calculated
 The calculated question type. More...
 
class  qtype_calculated_dataset_loader
 This class is responsible for loading the dataset that a question needs from the database. More...
 
class  qtype_calculated_edit_form
 Calculated question type editing form definition. More...
 
class  qtype_calculated_question
 Represents a calculated question. More...
 
class  qtype_calculated_question_helper
 Helper class for questions that use datasets. More...
 
interface  qtype_calculated_question_with_expressions
 This interface defines the method that a quetsion type must implement if it is to work with qtype_calculated_question_helper. More...
 
class  qtype_calculated_renderer
 Generates the output for calculated questions. More...
 
class  qtype_calculated_test_dataset_loader
 Test implementation of qtype_calculated_dataset_loader. More...
 
class  qtype_calculated_test_helper
 Test helper class for the calculated question type. More...
 
class  qtype_calculated_variable_substituter
 This class holds the current values of all the variables used by a calculated question. More...
 
class  qtype_calculatedmulti
 The calculated multiple-choice question type. More...
 
class  qtype_calculatedmulti_calculate_helper
 Helper to abstract common code between qtype_calculatedmulti_single_question and qtype_calculatedmulti_multi_question. More...
 
class  qtype_calculatedmulti_edit_form
 Calculated multiple-choice question editing form. More...
 
class  qtype_calculatedmulti_multi_question
 Represents a calculated multiple-choice multiple-response question. More...
 
class  qtype_calculatedmulti_renderer
 Generates the output for calculated multiple-choice questions. More...
 
class  qtype_calculatedmulti_single_question
 Represents a calculated multiple-choice multiple-response question. More...
 
class  qtype_calculatedmulti_test_helper
 Test helper class for the calculated multiple-choice question type. More...
 
class  qtype_calculatedsimple
 The simple calculated question type. More...
 
class  qtype_calculatedsimple_edit_form
 Editing form for the calculated simplequestion type. More...
 
class  qtype_calculatedsimple_qe2_attempt_updater
 Class for converting attempt data for simple calculated questions when upgrading attempts to the new question engine. More...
 
class  qtype_calculatedsimple_question
 Represents a simple calculated question. More...
 
class  qtype_calculatedsimple_renderer
 Generates the output for simple calculated questions. More...
 
class  qtype_calculatedsimple_test_helper
 Test helper class for the simple calculated question type. More...
 
class  qtype_description
 The description 'question' type. More...
 
class  qtype_description_edit_form
 Description editing form definition. More...
 
class  qtype_description_qe2_attempt_updater
 Class for converting attempt data for description questions when upgrading attempts to the new question engine. More...
 
class  qtype_description_question
 Represents a description 'question'. More...
 
class  qtype_description_renderer
 Generates the output for description 'question's. More...
 
class  qtype_essay
 The essay question type. More...
 
class  qtype_essay_edit_form
 Essay question type editing form. More...
 
class  qtype_essay_format_editor_renderer
 An essay format renderer for essays where the student should use the HTML editor without the file picker. More...
 
class  qtype_essay_format_editorfilepicker_renderer
 An essay format renderer for essays where the student should use the HTML editor with the file picker. More...
 
class  qtype_essay_format_monospaced_renderer
 An essay format renderer for essays where the student should use a plain input box with a monospaced font. More...
 
class  qtype_essay_format_noinline_renderer
 An essay format renderer for essays where the student should not enter any inline response. More...
 
class  qtype_essay_format_plain_renderer
 An essay format renderer for essays where the student should use a plain input box, but with a normal, proportional font. More...
 
class  qtype_essay_format_renderer_base
 A base class to abstract out the differences between different type of response format. More...
 
class  qtype_essay_qe2_attempt_updater
 Class for converting attempt data for essay questions when upgrading attempts to the new question engine. More...
 
class  qtype_essay_question
 Represents an essay question. More...
 
class  qtype_essay_renderer
 Generates the output for essay questions. More...
 
class  qtype_missingtype
 Missing question type class. More...
 
class  qtype_missingtype_edit_form
 This question renderer class is used when the actual question type of this question cannot be found. More...
 
class  qtype_missingtype_question
 This question definition class is used when the actual question type of this question cannot be found. More...
 
class  qtype_missingtype_renderer
 This question renderer class is used when the actual question type of this question cannot be found. More...
 
class  qtype_multianswer
 The multi-answer question type class. More...
 
class  qtype_multianswer_edit_form
 Form for editing multi-answer questions. More...
 
class  qtype_multianswer_multichoice_horizontal_renderer
 Render an embedded multiple-choice question vertically, like for a normal multiple-choice question. More...
 
class  qtype_multianswer_multichoice_inline_renderer
 Render an embedded multiple-choice question that is displayed as a select menu. More...
 
class  qtype_multianswer_multichoice_vertical_renderer
 Render an embedded multiple-choice question vertically, like for a normal multiple-choice question. More...
 
class  qtype_multianswer_multiresponse_horizontal_renderer
 Render an embedded multiple-response question horizontally. More...
 
class  qtype_multianswer_multiresponse_vertical_renderer
 Class qtype_multianswer_multiresponse_renderer. More...
 
class  qtype_multianswer_qe2_attempt_updater
 Class for converting attempt data for multianswer questions when upgrading attempts to the new question engine. More...
 
class  qtype_multianswer_question
 Represents a multianswer question. More...
 
class  qtype_multianswer_renderer
 Base class for generating the bits of output common to multianswer (Cloze) questions. More...
 
class  qtype_multianswer_subq_renderer_base
 Subclass for generating the bits of output specific to shortanswer subquestions. More...
 
class  qtype_multianswer_textfield_renderer
 Subclass for generating the bits of output specific to shortanswer subquestions. More...
 
class  qtype_multichoice
 The multiple choice question type. More...
 
class  qtype_multichoice_base
 Base class for multiple choice questions. More...
 
class  qtype_multichoice_edit_form
 Multiple choice editing form definition. More...
 
class  qtype_multichoice_multi_question
 Represents a multiple choice question where multiple choices can be selected. More...
 
class  qtype_multichoice_multi_renderer
 Subclass for generating the bits of output specific to multiple choice multi=select questions. More...
 
class  qtype_multichoice_qe2_attempt_updater
 Class for converting attempt data for multichoice questions when upgrading attempts to the new question engine. More...
 
class  qtype_multichoice_renderer_base
 Base class for generating the bits of output common to multiple choice single and multiple questions. More...
 
class  qtype_multichoice_single_question
 Represents a multiple choice question where only one choice should be selected. More...
 
class  qtype_multichoice_single_renderer
 Subclass for generating the bits of output specific to multiple choice single questions. More...
 
class  qtype_numerical
 The numerical question type class. More...
 
class  qtype_numerical_answer
 Subclass of question_answer with the extra information required by the numerical question type. More...
 
class  qtype_numerical_answer_processor
 This class processes numbers with units. More...
 
class  qtype_numerical_edit_form
 numerical editing form definition. More...
 
class  qtype_numerical_qe2_attempt_updater
 Class for converting attempt data for numerical questions when upgrading attempts to the new question engine. More...
 
class  qtype_numerical_question
 Represents a numerical question. More...
 
class  qtype_numerical_test_helper
 Test helper class for the numerical question type. More...
 
class  qtype_random
 The random question type. More...
 
class  qtype_random_edit_form
 random editing form definition. More...
 
class  qtype_shortanswer
 The short answer question type. More...
 
class  qtype_shortanswer_edit_form
 Short answer question editing form definition. More...
 
class  qtype_shortanswer_qe2_attempt_updater
 Class for converting attempt data for shortanswer questions when upgrading attempts to the new question engine. More...
 
class  qtype_shortanswer_question
 Represents a short answer question. More...
 
class  qtype_shortanswer_renderer
 Generates the output for short answer questions. More...
 
class  qtype_truefalse
 The true-false question type class. More...
 
class  qtype_truefalse_edit_form
 True-false question editing form definition. More...
 
class  qtype_truefalse_qe2_attempt_updater
 Class for converting attempt data for truefalse questions when upgrading attempts to the new question engine. More...
 
class  qtype_truefalse_question
 Represents a true-false question. More...
 
class  qtype_truefalse_renderer
 Generates the output for true-false questions. More...
 
class  qtype_truefalse_test_helper
 Test helper class for the truefalse question type. More...
 
class  question_dataset_dependent_definitions_form
 Calculated question data set definitions editing form definition. More...
 
class  question_dataset_dependent_items_form
 Calculated question data set items editing form definition. More...
 

Functions

 qtype_calculated_calculate_answer ($formula, $individualdata, $tolerance, $tolerancetype, $answerlength, $answerformat='1', $unit='')
 
 qtype_calculated_find_formula_errors ($formula)
 Validate a forumula.
 
 qtype_calculated_find_formula_errors_in_text ($text)
 Validate all the forumulas in a bit of text.
 
 qtype_multianswer_extract_question ($text)
 
 qtype_multianswer_initialise_multichoice_subquestion ($wrapped)
 Initialise subquestion fields that are constant across all MULTICHOICE types.
 
 qtype_multianswer_validate_question (stdClass $question)
 Validate a multianswer question.
 
 xmldb_qtype_calculated_upgrade ($oldversion)
 Upgrade code for the calculated question type.
 
 xmldb_qtype_essay_upgrade ($oldversion)
 Upgrade code for the essay question type.
 
 xmldb_qtype_multianswer_upgrade ($oldversion)
 Upgrade code for the multi-answer question type.
 
 xmldb_qtype_multichoice_upgrade ($oldversion)
 Upgrade code for the multiple choice question type.
 
 xmldb_qtype_numerical_upgrade ($oldversion)
 Upgrade code for the numerical question type.
 
 xmldb_qtype_shortanswer_upgrade ($oldversion)
 Upgrade code for the essay question type.
 

Variables

global $CFG
 
global $CFG
 
global $CFG
 
global $CFG
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
 $plugin = 2024041600
 
const ANSWER_ALTERNATIVE_ANSWER_REGEX '.+?(?<!\\\\|&|&amp;)(?=[~#}]|$)'
 
const ANSWER_ALTERNATIVE_FEEDBACK_REGEX '.*?(?<!::::::::)(?=[~}]|$)'
 
const ANSWER_ALTERNATIVE_FRACTION_REGEX '=|%(-?[0-9]+(?:[.,][0-9]*)?)%'
 
const ANSWER_ALTERNATIVE_REGEX '(' . ANSWER_ALTERNATIVE_FRACTION_REGEX .')?' . '(' . ANSWER_ALTERNATIVE_ANSWER_REGEX . ')' . '(#(' . ANSWER_ALTERNATIVE_FEEDBACK_REGEX .'))?'
 
const ANSWER_ALTERNATIVE_REGEX_ANSWER 3
 
const ANSWER_ALTERNATIVE_REGEX_FEEDBACK 5
 
const ANSWER_ALTERNATIVE_REGEX_FRACTION 1
 
const ANSWER_ALTERNATIVE_REGEX_PERCENTILE_FRACTION 2
 
const ANSWER_REGEX ANSWER_START_REGEX . '(' . ANSWER_ALTERNATIVE_REGEX . '(~' . ANSWER_ALTERNATIVE_REGEX . ')*)::}'
 
const ANSWER_REGEX_ALTERNATIVES 16
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE 4
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_HORIZONTAL 6
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_HORIZONTAL_SHUFFLED 11
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_REGULAR 5
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_REGULAR_SHUFFLED 10
 
const ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE_SHUFFLED 9
 
const ANSWER_REGEX_ANSWER_TYPE_MULTIRESPONSE 12
 
const ANSWER_REGEX_ANSWER_TYPE_MULTIRESPONSE_HORIZONTAL 13
 
const ANSWER_REGEX_ANSWER_TYPE_MULTIRESPONSE_HORIZONTAL_SHUFFLED 15
 
const ANSWER_REGEX_ANSWER_TYPE_MULTIRESPONSE_SHUFFLED 14
 
const ANSWER_REGEX_ANSWER_TYPE_NUMERICAL 3
 
const ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER 7
 
const ANSWER_REGEX_ANSWER_TYPE_SHORTANSWER_C 8
 
const ANSWER_REGEX_NORM 1
 
const ANSWER_START_REGEX '\{([0-9]*):(' . ANSWER_TYPE_DEF_REGEX . '):'
 
const ANSWER_TYPE_DEF_REGEX '(NUMERICAL|NM)|(MULTICHOICE|MC)|(MULTICHOICE_V|MCV)|(MULTICHOICE_H|MCH)|' . '(SHORTANSWER|SA|MW)|(SHORTANSWER_C|SAC|MWC)|' . '(MULTICHOICE_S|MCS)|(MULTICHOICE_VS|MCVS)|(MULTICHOICE_HS|MCHS)|'. '(MULTIRESPONSE|MR)|(MULTIRESPONSE_H|MRH)|(MULTIRESPONSE_S|MRS)|(MULTIRESPONSE_HS|MRHS)'
 
$plugin component = 'qtype_calculated'
 
$plugin component = 'qtype_calculatedmulti'
 
$plugin component = 'qtype_calculatedsimple'
 
$plugin component = 'qtype_description'
 
$plugin component = 'qtype_essay'
 
$plugin component = 'qtype_missingtype'
 
$plugin component = 'qtype_multianswer'
 
$plugin component = 'qtype_multichoice'
 
$plugin component = 'qtype_numerical'
 
$plugin component = 'qtype_random'
 
$plugin component = 'qtype_shortanswer'
 
$plugin component = 'qtype_truefalse'
 
$plugin dependencies
 
$plugin dependencies
 
$plugin dependencies
 
$plugin dependencies
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
$plugin maturity = MATURITY_STABLE
 
const NUMBER_REGEX '-?(([0-9]+[.,]?[0-9]*|[.,][0-9]+)([eE][-+]?[0-9]+)?)'
 
const NUMERICAL_ABS_ERROR_MARGIN 6
 
const NUMERICAL_ALTERNATIVE_REGEX '^(' . NUMBER_REGEX . ')(:' . NUMBER_REGEX . ')?$'
 
const NUMERICAL_CORRECT_ANSWER 1
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 
$plugin version = 2024042200
 

Detailed Description

Function Documentation

◆ qtype_calculated_find_formula_errors()

qtype_calculated_find_formula_errors ( $formula)

Validate a forumula.

Parameters
string$formulathe formula to validate.
Return values
string|booleanfalse if there are no problems. Otherwise a string error message.

◆ qtype_calculated_find_formula_errors_in_text()

qtype_calculated_find_formula_errors_in_text ( $text)

Validate all the forumulas in a bit of text.

Parameters
string$textthe text in which to validate the formulas.
Return values
string|booleanfalse if there are no problems. Otherwise a string error message.

◆ qtype_multianswer_initialise_multichoice_subquestion()

qtype_multianswer_initialise_multichoice_subquestion ( $wrapped)

Initialise subquestion fields that are constant across all MULTICHOICE types.

Parameters
objet$wrappedThe subquestion to initialise

◆ qtype_multianswer_validate_question()

qtype_multianswer_validate_question ( stdClass $question)

Validate a multianswer question.

Parameters
object$questionThe multianswer question to validate as returned by qtype_multianswer_extract_question
Return values
arrayArray of error messages with questions field names as keys.

◆ xmldb_qtype_calculated_upgrade()

xmldb_qtype_calculated_upgrade ( $oldversion)

Upgrade code for the calculated question type.

Parameters
int$oldversionthe version we are upgrading from.

◆ xmldb_qtype_essay_upgrade()

xmldb_qtype_essay_upgrade ( $oldversion)

Upgrade code for the essay question type.

Parameters
int$oldversionthe version we are upgrading from.

◆ xmldb_qtype_multianswer_upgrade()

xmldb_qtype_multianswer_upgrade ( $oldversion)

Upgrade code for the multi-answer question type.

Parameters
int$oldversionthe version we are upgrading from.

◆ xmldb_qtype_multichoice_upgrade()

xmldb_qtype_multichoice_upgrade ( $oldversion)

Upgrade code for the multiple choice question type.

Parameters
int$oldversionthe version we are upgrading from.

◆ xmldb_qtype_numerical_upgrade()

xmldb_qtype_numerical_upgrade ( $oldversion)

Upgrade code for the numerical question type.

Parameters
int$oldversionthe version we are upgrading from.

◆ xmldb_qtype_shortanswer_upgrade()

xmldb_qtype_shortanswer_upgrade ( $oldversion)

Upgrade code for the essay question type.

Parameters
int$oldversionthe version we are upgrading from.

Variable Documentation

◆ dependencies [1/4]

$plugin dependencies
Initial value:
= [
'qtype_numerical' => 2024041600,
]

◆ dependencies [2/4]

$plugin dependencies
Initial value:
= [
'qtype_numerical' => 2024041600,
'qtype_calculated' => 2024041600,
'qtype_multichoice' => 2024041600,
]

◆ dependencies [3/4]

$plugin dependencies
Initial value:
= [
'qtype_numerical' => 2024041600,
'qtype_calculated' => 2024041600,
]

◆ dependencies [4/4]

$plugin dependencies
Initial value:
= [
'qtype_multichoice' => 2024041600,
'qtype_numerical' => 2024041600,
'qtype_shortanswer' => 2024041600,
]