Moodle  2.2.1
http://www.collinsharper.com
question_edit_form Class Reference
Inheritance diagram for question_edit_form:
Collaboration diagram for question_edit_form:

Public Member Functions

 __construct ($submiturl, $question, $category, $contexts, $formeditable=true)
 set_data ($question)
 validation ($fromform, $files)
 qtype ()

Data Fields

const DEFAULT_NUM_HINTS = 2
 $context
 $editoroptions
 $fileoptions
 $instance

Protected Member Functions

 definition ()
 definition_inner ($mform)
 get_per_answer_fields ($mform, $label, $gradeoptions, &$repeatedoptions, &$answersoption)
 add_per_answer_fields (&$mform, $label, $gradeoptions, $minoptions=QUESTION_NUMANS_START, $addoptions=QUESTION_NUMANS_ADD)
 add_combined_feedback_fields ($withshownumpartscorrect=false)
 get_hint_fields ($withclearwrong=false, $withshownumpartscorrect=false)
 add_interactive_settings ($withclearwrong=false, $withshownumpartscorrect=false)
 data_preprocessing ($question)
 data_preprocessing_answers ($question, $withanswerfiles=false)
 data_preprocessing_combined_feedback ($question, $withshownumcorrect=false)
 data_preprocessing_hints ($question, $withclearwrong=false, $withshownumpartscorrect=false)

Protected Attributes

 $question
 $contexts
 $category
 $categorycontext

Detailed Description

Form definition base class. This defines the common fields that all question types need. Question types should define their own class that inherits from this one, and implements the definition_inner() method.

Definition at line 69 of file edit_question_form.php.


Constructor & Destructor Documentation

__construct ( submiturl,
question,
category,
contexts,
formeditable = true 
)

Member Function Documentation

add_combined_feedback_fields ( withshownumpartscorrect = false) [protected]

Definition at line 336 of file edit_question_form.php.

Here is the caller graph for this function:

add_interactive_settings ( withclearwrong = false,
withshownumpartscorrect = false 
) [protected]

Definition at line 377 of file edit_question_form.php.

Here is the call graph for this function:

Here is the caller graph for this function:

add_per_answer_fields ( &$  mform,
label,
gradeoptions,
minoptions = QUESTION_NUMANS_START,
addoptions = QUESTION_NUMANS_ADD 
) [protected]

Add a set of form fields, obtained from get_per_answer_fields, to the form, one for each existing answer, with some blanks for some new ones.

Parameters:
object$mformthe form being built.
$labelthe label to use for each option.
$gradeoptionsthe possible grades for each answer.
$minoptionsthe minimum number of answer blanks to display. Default QUESTION_NUMANS_START.
$addoptionsthe number of answer blanks to add. Default QUESTION_NUMANS_ADD.

Definition at line 313 of file edit_question_form.php.

Here is the call graph for this function:

Here is the caller graph for this function:

data_preprocessing ( question) [protected]

Perform an preprocessing needed on the data passed to set_data() before it is used to initialise the form.

Parameters:
object$questionthe data being passed to the form.
Returns:
object $question the modified data.

Reimplemented in qtype_calculatedsimple_edit_form, qtype_calculatedmulti_edit_form, qtype_numerical_edit_form, qtype_calculated_edit_form, qtype_multichoice_edit_form, qtype_match_edit_form, qtype_truefalse_edit_form, qtype_essay_edit_form, qtype_shortanswer_edit_form, and qtype_randomsamatch_edit_form.

Definition at line 493 of file edit_question_form.php.

Here is the caller graph for this function:

data_preprocessing_answers ( question,
withanswerfiles = false 
) [protected]

Perform the necessary preprocessing for the fields added by add_per_answer_fields().

Parameters:
object$questionthe data being passed to the form.
Returns:
object $question the modified data.

Definition at line 503 of file edit_question_form.php.

Here is the call graph for this function:

Here is the caller graph for this function:

data_preprocessing_combined_feedback ( question,
withshownumcorrect = false 
) [protected]

Perform the necessary preprocessing for the fields added by add_combined_feedback_fields().

Parameters:
object$questionthe data being passed to the form.
Returns:
object $question the modified data.

Definition at line 566 of file edit_question_form.php.

Here is the call graph for this function:

Here is the caller graph for this function:

data_preprocessing_hints ( question,
withclearwrong = false,
withshownumpartscorrect = false 
) [protected]

Perform the necessary preprocessing for the hint fields.

Parameters:
object$questionthe data being passed to the form.
Returns:
object $question the modified data.

Definition at line 604 of file edit_question_form.php.

Here is the call graph for this function:

Here is the caller graph for this function:

definition ( ) [protected]

Build the form definition.

This adds all the form fields that the default question type supports. If your question type does not support all these fields, then you can override this method and remove the ones you don't want with $mform->removeElement().

Reimplemented from moodleform.

Reimplemented in qtype_random_edit_form.

Definition at line 120 of file edit_question_form.php.

Here is the call graph for this function:

get_hint_fields ( withclearwrong = false,
withshownumpartscorrect = false 
) [protected]

Definition at line 356 of file edit_question_form.php.

Here is the caller graph for this function:

get_per_answer_fields ( mform,
label,
gradeoptions,
&$  repeatedoptions,
&$  answersoption 
) [protected]

Get the list of form elements to repeat, one for each answer.

Parameters:
object$mformthe form being built.
$labelthe label to use for each option.
$gradeoptionsthe possible grades for each answer.
$repeatedoptionsreference to array of repeated options to fill
$answersoptionreference to return the name of $question->options field holding an array of answers
Returns:
array of form fields.

Reimplemented in qtype_calculated_edit_form, qtype_multichoice_edit_form, qtype_calculatedmulti_edit_form, qtype_numerical_edit_form, and qtype_match_edit_form.

Definition at line 287 of file edit_question_form.php.

Here is the caller graph for this function:

qtype ( ) [abstract]
set_data ( default_values)

Load in existing data as form defaults. Usually new entry defaults are stored directly in form definition (new entry form); this function is used to load in data where values already exist and data is being edited (edit entry form).

note: $slashed param removed

Parameters:
mixed$default_valuesobject or array of default values

Reimplemented from moodleform.

Reimplemented in qtype_multianswer_edit_form, qtype_random_edit_form, and qtype_missingtype_edit_form.

Definition at line 425 of file edit_question_form.php.

Here is the call graph for this function:

validation ( data,
files 
)

Dummy stub method - override if you needed to perform some extra validation. If there are errors return array of errors ("fieldname"=>"error message"), otherwise true if ok.

Server side rules do not work for uploaded files, implement serverside rules here if needed.

Parameters:
array$dataarray of ("fieldname"=>value) of submitted data
array$filesarray of uploaded files "element_name"=>tmp_file_path
Returns:
array of "element_name"=>"error_description" if there are errors, or an empty array if everything is OK (true allowed for backwards compatibility too).

Reimplemented from moodleform.

Reimplemented in qtype_calculatedsimple_edit_form, qtype_multianswer_edit_form, qtype_numerical_edit_form, qtype_calculatedmulti_edit_form, qtype_calculated_edit_form, qtype_match_edit_form, qtype_multichoice_edit_form, qtype_random_edit_form, qtype_missingtype_edit_form, qtype_randomsamatch_edit_form, and qtype_shortanswer_edit_form.

Definition at line 640 of file edit_question_form.php.


Field Documentation

$category [protected]

Definition at line 81 of file edit_question_form.php.

$categorycontext [protected]

Definition at line 82 of file edit_question_form.php.

Definition at line 85 of file edit_question_form.php.

$contexts [protected]

Definition at line 80 of file edit_question_form.php.

$editoroptions

Definition at line 87 of file edit_question_form.php.

$fileoptions

Definition at line 89 of file edit_question_form.php.

Definition at line 91 of file edit_question_form.php.

$question [protected]

Definition at line 78 of file edit_question_form.php.

const DEFAULT_NUM_HINTS = 2

Definition at line 70 of file edit_question_form.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations