Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
qtype_missingtype Class Reference

Missing question type class. More...

Inheritance diagram for qtype_missingtype:
question_type

Public Member Functions

 actual_number_of_questions ($question)
 Returns the number of question numbers which are used by the question.
 
 break_down_stats_and_response_analysis_by_variant ($questiondata)
 Whether or not to break down question stats and response analysis, for a question defined by $questiondata.
 
 can_analyse_responses ()
 Whether this question type can perform a frequency analysis of student responses.
 
 create_editing_form ($submiturl, $question, $category, $contexts, $formeditable)
 Return an instance of the question editing form definition.
 
 delete_question ($questionid, $contextid)
 Deletes the question-type specific data when a question is deleted.
 
 display_question_editing_page ($mform, $question, $wizardnow)
 This method should be overriden if you want to include a special heading or some other html on a question editing page besides the question editing form.
 
 export_to_xml ($question, qformat_xml $format, $extra=null)
 
 extra_answer_fields ()
 If your question type has a table that extends the question_answers table, make this method return an array wherer the first element is the table name, and the subsequent entries are the column names (apart from id and answerid).
 
 extra_question_fields ()
 If your question type has a table that extends the question table, and you want the base class to automatically save, backup and restore the extra fields, override this method to return an array wherer the first element is the table name, and the subsequent entries are the column names (apart from id and questionid).
 
 find_standard_scripts ()
 Utility method used by qtype_renderer::head_code().
 
 finished_edit_wizard ($form)
 Returns true if the editing wizard is finished, false otherwise.
 
 generate_test ($name, $courseid=null)
 Abstract function implemented by each question type.
 
 get_default_value (string $name, $default)
 Return default value for a given form element either from user_preferences table or $default.
 
 get_extra_question_bank_actions (stdClass $question)
 Get extra actions for a question of this type to add to the question bank edit menu.
 
 get_heading ($adding=false)
 Method called by display_question_editing_page and by question.php to get heading for breadcrumbs.
 
 get_possible_responses ($questiondata)
 This method should return all the possible types of response that are recognised for this question.
 
 get_question_options ($question)
 Loads the question type specific options for the question.
 
 get_random_guess_score ($questiondata)
 Calculate the score a monkey would get on a question by clicking randomly.
 
 has_html_answers ()
 
 import_file ($context, $component, $filearea, $itemid, $file)
 
 import_from_xml ($data, $question, qformat_xml $format, $extra=null)
 
 is_manual_graded ()
 
 is_question_manual_graded ($question, $otherquestionsinuse)
 
 is_real_question_type ()
 
 is_usable_by_random ()
 
 local_name ()
 
 make_deleted_instance ($questionid, $maxmark)
 
 make_question ($questiondata)
 Create an appropriate question_definition for the question of this type using data loaded from the database.
 
 menu_name ()
 The name this question should appear as in the create new question dropdown.
 
 move_files ($questionid, $oldcontextid, $newcontextid)
 Move all the files belonging to this question from one context to another.
 
 name ()
 
 plugin_baseurl ()
 
 plugin_dir ()
 
 plugin_name ()
 
 questionid_column_name ()
 If you use extra_question_fields, overload this function to return question id field name in case you table use another name for this column.
 
 response_file_areas ()
 If the quetsion type uses files in responses, then this method should return an array of all the response variables that might have corresponding files.
 
 save_defaults_for_new_questions (stdClass $fromform)
 Save question defaults when creating new questions.
 
 save_hints ($formdata, $withparts=false)
 
 save_question ($question, $form)
 Saves (creates or updates) a question.
 
 save_question_answers ($question)
 Save the answers, with any extra data.
 
 save_question_options ($question)
 Saves question-type specific options.
 
 set_default_options ($questiondata)
 Set any missing settings for this question to the default values.
 
 set_default_value (string $name, string $value)
 Save the default value for a given form element in user_preferences table.
 

Protected Member Functions

 count_hints_on_form ($formdata, $withparts)
 Count number of hints on the form.
 
 decode_file ($file)
 
 delete_files ($questionid, $contextid)
 Delete all the files belonging to this question.
 
 delete_files_in_answers ($questionid, $contextid, $answerstoo=false)
 Delete all the files belonging to this question's answers.
 
 delete_files_in_combined_feedback ($questionid, $contextid)
 Delete all the files belonging to this question's answers.
 
 delete_files_in_hints ($questionid, $contextid)
 Delete all the files belonging to this question's hints.
 
 fill_answer_fields ($answer, $questiondata, $key, $context)
 Return $answer, filling necessary fields for the question_answers table.
 
 fill_extra_answer_fields ($answerextra, $questiondata, $key, $context, $extraanswerfields)
 Return $answerextra, filling necessary fields for the extra answer fields table.
 
 get_context_by_category_id ($category)
 Get question context by category id.
 
 import_or_save_files ($field, $context, $component, $filearea, $itemid)
 Save the file belonging to one text field.
 
 initialise_combined_feedback (question_definition $question, $questiondata, $withparts=false)
 Initialise the combined feedback fields.
 
 initialise_core_question_metadata (question_definition $question, $questiondata)
 Initialise the question metadata.
 
 initialise_custom_fields (question_definition $question, $questiondata)
 Initialise question custom fields.
 
 initialise_question_answers (question_definition $question, $questiondata, $forceplaintextanswers=true)
 Initialise question_definition\answers field.
 
 initialise_question_hints (question_definition $question, $questiondata)
 Initialise question_definition\hints field.
 
 initialise_question_instance (question_definition $question, $questiondata)
 Initialise the common question_definition fields.
 
 is_answer_empty ($questiondata, $key)
 Returns true is answer with the $key is empty in the question data and should not be saved in DB.
 
 is_extra_answer_fields_empty ($questiondata, $key)
 Returns true if extra answer fields for answer with the $key is empty in the question data and should not be saved in DB.
 
 is_hint_empty_in_form_data ($formdata, $number, $withparts)
 Determine if the hint with specified number is not empty and should be saved.
 
 make_answer ($answer)
 Create a question_answer, or an appropriate subclass for this question, from a row loaded from the database.
 
 make_hint ($hint)
 Create a question_hint, or an appropriate subclass for this question, from a row loaded from the database.
 
 make_question_instance ($questiondata)
 Create an appropriate question_definition for the question of this type using data loaded from the database.
 
 move_files_in_answers ($questionid, $oldcontextid, $newcontextid, $answerstoo=false)
 Move all the files belonging to this question's answers when the question is moved from one context to another.
 
 move_files_in_combined_feedback ($questionid, $oldcontextid, $newcontextid)
 Move all the files belonging to this question's answers when the question is moved from one context to another.
 
 move_files_in_hints ($questionid, $oldcontextid, $newcontextid)
 Move all the files belonging to this question's hints when the question is moved from one context to another.
 
 save_combined_feedback_helper ($options, $formdata, $context, $withparts=false)
 Can be used to save_question_options() to transfer the combined feedback fields from $formdata to $options.
 
 save_hint_options ($formdata, $number, $withparts)
 Save additional question type data into the hint optional field.
 

Protected Attributes

 $fileoptions
 

Detailed Description

Missing question type class.

When we encounter a question of a type that is not currently installed, then we use this question type class instead so that some of the information about this question can be seen, and the rest of the system keeps working.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ actual_number_of_questions()

question_type::actual_number_of_questions ( $question)
inherited

Returns the number of question numbers which are used by the question.

This function returns the number of question numbers to be assigned to the question. Most question types will have length one; they will be assigned one number. The 'description' type, however does not use up a number and so has a length of zero. Other question types may wish to handle a bundle of questions and hence return a number greater than one.

Return values
intThe number of question numbers which should be assigned to the question.
Parameters
object$questionThe question whose length is to be determined. Question type specific information is included.

Reimplemented in qtype_description.

◆ break_down_stats_and_response_analysis_by_variant()

question_type::break_down_stats_and_response_analysis_by_variant ( $questiondata)
inherited

Whether or not to break down question stats and response analysis, for a question defined by $questiondata.

Parameters
object$questiondataThe full question definition data.
Return values
bool

◆ can_analyse_responses()

qtype_missingtype::can_analyse_responses ( )

Whether this question type can perform a frequency analysis of student responses.

If this method returns true, you must implement the get_possible_responses method, and the question_definition class must implement the classify_response method.

Return values
boolwhether this report can analyse all the student responses for things like the quiz statistics report.

Reimplemented from question_type.

◆ count_hints_on_form()

question_type::count_hints_on_form ( $formdata,
$withparts )
protectedinherited

Count number of hints on the form.

Overload if you use custom hint controls.

Parameters
object$formdatathe data from the form.
bool$withpartswhether to take into account clearwrong and shownumcorrect options.
Return values
intcount of hints on the form.

Reimplemented in qtype_ordering.

◆ create_editing_form()

question_type::create_editing_form ( $submiturl,
$question,
$category,
$contexts,
$formeditable )
inherited

Return an instance of the question editing form definition.

This looks for a class called edit_{$this->name()}_question_form in the file question/type/{$this->name()}/edit_{$this->name()}_question_form.php and if it exists returns an instance of it.

Parameters
string$submiturlpassed on to the constructor call.
Return values
objectan instance of the form definition, or null if one could not be found.

◆ delete_files()

question_type::delete_files ( $questionid,
$contextid )
protectedinherited

Delete all the files belonging to this question.

Parameters
int$questionidthe question being deleted.
int$contextidthe context the question is in.

Reimplemented in qtype_calculated, qtype_calculatedmulti, qtype_ddimageortext, qtype_ddmarker, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_randomsamatch, qtype_shortanswer, and qtype_truefalse.

◆ delete_files_in_answers()

question_type::delete_files_in_answers ( $questionid,
$contextid,
$answerstoo = false )
protectedinherited

Delete all the files belonging to this question's answers.

Parameters
int$questionidthe question being deleted.
int$contextidthe context the question is in.
bool$answerstoowhether there is an 'answer' question area, as well as an 'answerfeedback' one. Default false.

◆ delete_files_in_combined_feedback()

question_type::delete_files_in_combined_feedback ( $questionid,
$contextid )
protectedinherited

Delete all the files belonging to this question's answers.

Parameters
int$questionidthe question being deleted.
int$contextidthe context the question is in.
bool$answerstoowhether there is an 'answer' question area, as well as an 'answerfeedback' one. Default false.

◆ delete_files_in_hints()

question_type::delete_files_in_hints ( $questionid,
$contextid )
protectedinherited

Delete all the files belonging to this question's hints.

Parameters
int$questionidthe question being deleted.
int$contextidthe context the question is in.

◆ delete_question()

question_type::delete_question ( $questionid,
$contextid )
inherited

Deletes the question-type specific data when a question is deleted.

Parameters
int$questionthe question being deleted.
int$contextidthe context this quesiotn belongs to.

Reimplemented in qtype_calculated, qtype_ddtoimage_base, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_randomsamatch, and qtype_truefalse.

◆ display_question_editing_page()

qtype_missingtype::display_question_editing_page ( $mform,
$question,
$wizardnow )

This method should be overriden if you want to include a special heading or some other html on a question editing page besides the question editing form.

Parameters
question_edit_form$mforma child of question_edit_form
object$question
string$wizardnowis '' for first page.

Reimplemented from question_type.

◆ export_to_xml()

question_type::export_to_xml ( $question,
qformat_xml $format,
$extra = null )
inherited

Reimplemented in qtype_randomsamatch.

◆ extra_answer_fields()

question_type::extra_answer_fields ( )
inherited

If your question type has a table that extends the question_answers table, make this method return an array wherer the first element is the table name, and the subsequent entries are the column names (apart from id and answerid).

Return values
mixedarray as above, or null to tell the base class to do nothing.

◆ extra_question_fields()

question_type::extra_question_fields ( )
inherited

If your question type has a table that extends the question table, and you want the base class to automatically save, backup and restore the extra fields, override this method to return an array wherer the first element is the table name, and the subsequent entries are the column names (apart from id and questionid).

Return values
mixedarray as above, or null to tell the base class to do nothing.

Reimplemented in qtype_ordering, qtype_randomsamatch, and qtype_shortanswer.

◆ fill_answer_fields()

question_type::fill_answer_fields ( $answer,
$questiondata,
$key,
$context )
protectedinherited

Return $answer, filling necessary fields for the question_answers table.

The questions using question_answers table may want to overload this. Default code will work for shortanswer and similar question types.

Parameters
stdClass$answerObject to save data.
object$questiondataThis holds the information from the question editing form or import.
int$keyA key of the answer in question.
object$contextneeded for working with files.
Return values
$answeranswer with filled data.

Reimplemented in qtype_shortanswer.

◆ fill_extra_answer_fields()

question_type::fill_extra_answer_fields ( $answerextra,
$questiondata,
$key,
$context,
$extraanswerfields )
protectedinherited

Return $answerextra, filling necessary fields for the extra answer fields table.

The questions may want to overload it to save files or do other data processing.

Parameters
stdClass$answerextraObject to save data.
object$questiondataThis holds the information from the question editing form or import.
int$keyA key of the answer in question.
object$contextneeded for working with files.
array$extraanswerfieldsextra answer fields (without table name).
Return values
$answeranswerextra with filled data.

◆ find_standard_scripts()

question_type::find_standard_scripts ( )
inherited

Utility method used by qtype_renderer::head_code().

It looks for any of the files script.js or script.php that exist in the plugin folder and ensures they get included.

◆ finished_edit_wizard()

question_type::finished_edit_wizard ( $form)
inherited

Returns true if the editing wizard is finished, false otherwise.

The default implementation returns true, which is suitable for all question- types that only use one editing form. This function is used in question.php to decide whether we can regrade any states of the edited question and redirect to edit.php.

The dataset dependent question-type, which is extended by the calculated question-type, overwrites this method because it uses multiple pages (i.e. a wizard) to set up the question and associated datasets.

Parameters
object$formThe data submitted by the previous page.
Return values
boolWhether the wizard's last page was submitted or not.

Reimplemented in qtype_calculated, and qtype_calculatedsimple.

◆ generate_test()

question_type::generate_test ( $name,
$courseid = null )
inherited

Abstract function implemented by each question type.

It runs all the code required to set up and save a question of any type for testing purposes. Alternate DB table prefix may be used to facilitate data deletion.

◆ get_context_by_category_id()

question_type::get_context_by_category_id ( $category)
protectedinherited

Get question context by category id.

Parameters
int$category
Return values
object\$context

◆ get_default_value()

question_type::get_default_value ( string $name,
$default )
inherited

Return default value for a given form element either from user_preferences table or $default.

Parameters
string$namethe name of the form element.
mixed$defaultdefault value.
Return values
string|nulldefault value for a given form element.

◆ get_extra_question_bank_actions()

◆ get_heading()

question_type::get_heading ( $adding = false)
inherited

Method called by display_question_editing_page and by question.php to get heading for breadcrumbs.

Return values
stringthe heading

◆ get_possible_responses()

question_type::get_possible_responses ( $questiondata)
inherited

This method should return all the possible types of response that are recognised for this question.

The question is modelled as comprising one or more subparts. For each subpart, there are one or more classes that that students response might fall into, each of those classes earning a certain score.

For example, in a shortanswer question, there is only one subpart, the text entry field. The response the student gave will be classified according to which of the possible $question->options->answers it matches.

For the matching question type, there will be one subpart for each question stem, and for each stem, each of the possible choices is a class of student's response.

A response is an object with two fields, ->responseclass is a string presentation of that response, and ->fraction, the credit for a response in that class.

Array keys have no specific meaning, but must be unique, and must be the same if this function is called repeatedly.

Parameters
object$questionthe question definition data.
Return values
arraykeys are subquestionid, values are arrays of possible responses to that subquestion.

Reimplemented in qtype_calculated, qtype_calculatedmulti, qtype_ddtoimage_base, qtype_gapselect_base, qtype_match, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_shortanswer, and qtype_truefalse.

◆ get_question_options()

question_type::get_question_options ( $question)
inherited

Loads the question type specific options for the question.

This function loads any question type specific options for the question from the database into the question object. This information is placed in the $question->options field. A question type is free, however, to decide on a internal structure of the options field.

Return values
boolIndicates success or failure.
Parameters
object$questionThe question object for the question. This object should be updated to include the question type specific information (it is passed by reference).

Reimplemented in qtype_calculated, qtype_ddtoimage_base, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_random, qtype_randomsamatch, and qtype_truefalse.

◆ get_random_guess_score()

qtype_missingtype::get_random_guess_score ( $questiondata)

Calculate the score a monkey would get on a question by clicking randomly.

Some question types have significant non-zero average expected score of the response is just selected randomly. For example 50% for a true-false question. It is useful to know what this is. For example it gets shown in the quiz statistics report.

For almost any open-ended question type (E.g. shortanswer or numerical) this should be 0.

For selective response question types (e.g. multiple choice), you can probably compute this.

For particularly complicated question types the may be impossible or very difficult to compute. In this case return null. (Or, if the expected score is very tiny even though the exact value is unknown, it may appropriate to return 0.)

Parameters
stdClass$questiondatadata defining a question, as returned by question_bank\load_question_data().
Return values
number|nulleither a fraction estimating what the student would score by guessing, or null, if it is not possible to estimate.

Reimplemented from question_type.

◆ has_html_answers()

question_type::has_html_answers ( )
inherited
Return values
whetherthe question_answers.answer field needs to have restore_decode_content_links_worker called on it.

Reimplemented in qtype_ordering.

◆ import_from_xml()

question_type::import_from_xml ( $data,
$question,
qformat_xml $format,
$extra = null )
inherited

Reimplemented in qtype_randomsamatch.

◆ import_or_save_files()

question_type::import_or_save_files ( $field,
$context,
$component,
$filearea,
$itemid )
protectedinherited

Save the file belonging to one text field.

Parameters
array$fieldthe data from the form (or from import). This will normally have come from the formslib editor element, so it will be an array with keys 'text', 'format' and 'itemid'. However, when we are importing, it will be an array with keys 'text', 'format' and 'files'
object$contextthe context the question is in.
string$componentindentifies the file area question.
string$fileareaindentifies the file area questiontext, generalfeedback, answerfeedback, etc.
int$itemididentifies the file area.
Return values
stringthe text for this field, after files have been processed.

◆ initialise_combined_feedback()

question_type::initialise_combined_feedback ( question_definition $question,
$questiondata,
$withparts = false )
protectedinherited

Initialise the combined feedback fields.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.
bool$withpartswhether to set the shownumcorrect field.

Reimplemented in qtype_ddmarker.

◆ initialise_core_question_metadata()

question_type::initialise_core_question_metadata ( question_definition $question,
$questiondata )
protectedinherited

Initialise the question metadata.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.

◆ initialise_custom_fields()

question_type::initialise_custom_fields ( question_definition $question,
$questiondata )
protectedinherited

Initialise question custom fields.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.

◆ initialise_question_answers()

question_type::initialise_question_answers ( question_definition $question,
$questiondata,
$forceplaintextanswers = true )
protectedinherited

Initialise question_definition\answers field.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.
bool$forceplaintextanswersmost qtypes assume that answers are FORMAT_PLAIN, and dont use the answerformat DB column (it contains the default 0 = FORMAT_MOODLE). Therefore, by default this method ingores answerformat. Pass false here to use answerformat. For example multichoice does this.

◆ initialise_question_hints()

question_type::initialise_question_hints ( question_definition $question,
$questiondata )
protectedinherited

Initialise question_definition\hints field.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.

◆ initialise_question_instance()

question_type::initialise_question_instance ( question_definition $question,
$questiondata )
protectedinherited

Initialise the common question_definition fields.

Parameters
question_definition$questionthe question_definition we are creating.
object$questiondatathe question data loaded from the database.

Reimplemented in qtype_calculated, qtype_calculatedmulti, qtype_ddtoimage_base, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_randomsamatch, qtype_shortanswer, and qtype_truefalse.

◆ is_answer_empty()

question_type::is_answer_empty ( $questiondata,
$key )
protectedinherited

Returns true is answer with the $key is empty in the question data and should not be saved in DB.

The questions using question_answers table may want to overload this. Default code will work for shortanswer and similar question types.

Parameters
object$questiondataThis holds the information from the question editing form or import.
int$keyA key of the answer in question.
Return values
boolTrue if answer shouldn't be saved in DB.

◆ is_extra_answer_fields_empty()

question_type::is_extra_answer_fields_empty ( $questiondata,
$key )
protectedinherited

Returns true if extra answer fields for answer with the $key is empty in the question data and should not be saved in DB.

Questions where extra answer fields are optional will want to overload this.

Parameters
object$questiondataThis holds the information from the question editing form or import.
int$keyA key of the answer in question.
Return values
boolTrue if extra answer data shouldn't be saved in DB.

◆ is_hint_empty_in_form_data()

question_type::is_hint_empty_in_form_data ( $formdata,
$number,
$withparts )
protectedinherited

Determine if the hint with specified number is not empty and should be saved.

Overload if you use custom hint controls.

Parameters
object$formdatathe data from the form.
int$numbernumber of hint under question.
bool$withpartswhether to take into account clearwrong and shownumcorrect options.
Return values
boolis this particular hint data empty.

Reimplemented in qtype_ordering.

◆ is_manual_graded()

question_type::is_manual_graded ( )
inherited
Return values
booltrue if this question type sometimes requires manual grading.

Reimplemented in qtype_essay, and qtype_random.

◆ is_question_manual_graded()

question_type::is_question_manual_graded ( $question,
$otherquestionsinuse )
inherited
Parameters
object$questiona question of this type.
string$otherquestionsinusecomma-separate list of other question ids in this attempt.
Return values
booltrue if a particular instance of this question requires manual grading.

Reimplemented in qtype_random.

◆ is_real_question_type()

question_type::is_real_question_type ( )
inherited
Return values
booloverride this to return false if this is not really a question type, for example the description question type is not really a question type.

Reimplemented in qtype_description.

◆ is_usable_by_random()

qtype_missingtype::is_usable_by_random ( )
Return values
booltrue if this question type can be used by the random question type.

Reimplemented from question_type.

◆ local_name()

question_type::local_name ( )
inherited
Return values
stringthe name of this question type in the user's language. You should not need to override this method, the default behaviour should be fine.

◆ make_answer()

question_type::make_answer ( $answer)
protectedinherited

Create a question_answer, or an appropriate subclass for this question, from a row loaded from the database.

Parameters
object$answerthe DB row from the question_answers table plus extra answer fields.
Return values
question_answer

Reimplemented in qtype_calculatedmulti, and qtype_multichoice.

◆ make_hint()

question_type::make_hint ( $hint)
protectedinherited

Create a question_hint, or an appropriate subclass for this question, from a row loaded from the database.

Parameters
object$hintthe DB row from the question hints table.
Return values
question_hint

Reimplemented in qtype_calculatedmulti, qtype_ddimageortext, qtype_ddmarker, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_ordering, and qtype_randomsamatch.

◆ make_question()

qtype_missingtype::make_question ( $questiondata)

Create an appropriate question_definition for the question of this type using data loaded from the database.

Parameters
object$questiondatathe question data loaded from the database.
Return values
question_definitionthe corresponding question_definition.

Reimplemented from question_type.

◆ make_question_instance()

question_type::make_question_instance ( $questiondata)
protectedinherited

Create an appropriate question_definition for the question of this type using data loaded from the database.

Parameters
object$questiondatathe question data loaded from the database.
Return values
question_definitionan instance of the appropriate question_definition subclass. Still needs to be initialised.

Reimplemented in qtype_calculatedmulti, and qtype_multichoice.

◆ menu_name()

qtype_missingtype::menu_name ( )

The name this question should appear as in the create new question dropdown.

Override this method to return false if you don't want your question type to be createable, for example if it is an abstract base type, otherwise, you should not need to override this method.

Return values
mixedthe desired string, or false to hide this question type in the menu.

Reimplemented from question_type.

◆ move_files()

question_type::move_files ( $questionid,
$oldcontextid,
$newcontextid )
inherited

Move all the files belonging to this question from one context to another.

Parameters
int$questionidthe question being moved.
int$oldcontextidthe context it is moving from.
int$newcontextidthe context it is moving to.

Reimplemented in qtype_calculated, qtype_calculatedmulti, qtype_ddimageortext, qtype_ddmarker, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_randomsamatch, qtype_shortanswer, and qtype_truefalse.

◆ move_files_in_answers()

question_type::move_files_in_answers ( $questionid,
$oldcontextid,
$newcontextid,
$answerstoo = false )
protectedinherited

Move all the files belonging to this question's answers when the question is moved from one context to another.

Parameters
int$questionidthe question being moved.
int$oldcontextidthe context it is moving from.
int$newcontextidthe context it is moving to.
bool$answerstoowhether there is an 'answer' question area, as well as an 'answerfeedback' one. Default false.

◆ move_files_in_combined_feedback()

question_type::move_files_in_combined_feedback ( $questionid,
$oldcontextid,
$newcontextid )
protectedinherited

Move all the files belonging to this question's answers when the question is moved from one context to another.

Parameters
int$questionidthe question being moved.
int$oldcontextidthe context it is moving from.
int$newcontextidthe context it is moving to.
bool$answerstoowhether there is an 'answer' question area, as well as an 'answerfeedback' one. Default false.

◆ move_files_in_hints()

question_type::move_files_in_hints ( $questionid,
$oldcontextid,
$newcontextid )
protectedinherited

Move all the files belonging to this question's hints when the question is moved from one context to another.

Parameters
int$questionidthe question being moved.
int$oldcontextidthe context it is moving from.
int$newcontextidthe context it is moving to.
bool$answerstoowhether there is an 'answer' question area, as well as an 'answerfeedback' one. Default false.

◆ name()

question_type::name ( )
inherited
Return values
stringthe name of this question type.

◆ plugin_baseurl()

question_type::plugin_baseurl ( )
inherited
Return values
stringthe URL of the folder this plugin's files live in.

◆ plugin_dir()

question_type::plugin_dir ( )
inherited
Return values
stringthe full path of the folder this plugin's files live in.

◆ plugin_name()

question_type::plugin_name ( )
inherited
Return values
stringthe full frankenstyle name for this plugin.

◆ response_file_areas()

question_type::response_file_areas ( )
inherited

If the quetsion type uses files in responses, then this method should return an array of all the response variables that might have corresponding files.

For example, the essay qtype returns array('attachments', 'answers').

Return values
arrayresponse variable names that may have associated files.

Reimplemented in qtype_essay.

◆ save_combined_feedback_helper()

question_type::save_combined_feedback_helper ( $options,
$formdata,
$context,
$withparts = false )
protectedinherited

Can be used to save_question_options() to transfer the combined feedback fields from $formdata to $options.

Parameters
object$optionsthe $question->options object being built.
object$formdatathe data from the form.
object$contextthe context the quetsion is being saved into.
bool$withpartswhether $options->shownumcorrect should be set.

◆ save_defaults_for_new_questions()

question_type::save_defaults_for_new_questions ( stdClass $fromform)
inherited

Save question defaults when creating new questions.

Parameters
stdClass$fromformdata from the form.

Reimplemented in qtype_ddimageortext, qtype_ddmarker, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_shortanswer, and qtype_truefalse.

◆ save_hint_options()

question_type::save_hint_options ( $formdata,
$number,
$withparts )
protectedinherited

Save additional question type data into the hint optional field.

Overload if you use custom hint information.

Parameters
object$formdatathe data from the form.
int$numbernumber of hint to get options from.
bool$withpartswhether question have parts.
Return values
stringvalue to save into the options field of question_hints table.

Reimplemented in qtype_ordering.

◆ save_question()

question_type::save_question ( $question,
$form )
inherited

Saves (creates or updates) a question.

Given some question info and some data about the answers this function parses, organises and saves the question It is used by question.php when saving new data from a form, and also by import.php when importing questions This function in turn calls save_question_options to save question-type specific data.

Whether we are saving a new question or updating an existing one can be determined by testing !empty($question->id). If it is not empty, we are updating.

The question will be saved in category $form->category.

Parameters
object$questionthe question object which should be updated. For a new question will be mostly empty.
object$formthe object containing the information to save, as if from the question editing form.
object$coursenot really used any more.
Return values
objectOn success, return the new question object. On failure, return an object as follows. If the error object has an errors field, display that as an error message. Otherwise, the editing form will be redisplayed with validation errors, from validation_errors field, which is itself an object, shown next to the form fields. (I don't think this is accurate any more.)

Reimplemented in qtype_calculated, qtype_description, qtype_multianswer, and qtype_random.

◆ save_question_answers()

question_type::save_question_answers ( $question)
inherited

Save the answers, with any extra data.

Questions that use answers will call it from save_question_options().

Parameters
object$questionThis holds the information from the editing form, it is not a standard question object.
Return values
object\$result-,>erroror $result->notice

◆ save_question_options()

question_type::save_question_options ( $question)
inherited

Saves question-type specific options.

This is called by {

See also
save_question()} to save the question-type specific data
Parameters
object$questionThis holds the information from the editing form, it is not a standard question object.
Return values
bool|stdClass\$result-,>erroror $result->notice

Reimplemented in qtype_calculated, qtype_calculatedmulti, qtype_calculatedsimple, qtype_ddimageortext, qtype_ddmarker, qtype_essay, qtype_gapselect_base, qtype_match, qtype_multianswer, qtype_multichoice, qtype_numerical, qtype_ordering, qtype_random, qtype_randomsamatch, qtype_shortanswer, and qtype_truefalse.

◆ set_default_options()

question_type::set_default_options ( $questiondata)
inherited

Set any missing settings for this question to the default values.

This is called before displaying the question editing form.

Parameters
object$questiondatathe question data, loaded from the databsae, or more likely a newly created question object that is only partially initialised.

◆ set_default_value()

question_type::set_default_value ( string $name,
string $value )
inherited

Save the default value for a given form element in user_preferences table.

Parameters
string$namethe name of the value to set.
string$valuethe setting value.

Member Data Documentation

◆ $fileoptions

question_type::$fileoptions
protectedinherited
Initial value:
= array(
'subdirs' => true,
'maxfiles' => -1,
'maxbytes' => 0,
)

The documentation for this class was generated from the following file: