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

Public Member Functions

 extra_question_fields ()
 questionid_column_name ()
 move_files ($questionid, $oldcontextid, $newcontextid)
 save_question_options ($question)
 get_random_guess_score ($questiondata)
 get_possible_responses ($questiondata)

Protected Member Functions

 delete_files ($questionid, $contextid)
 initialise_question_instance (question_definition $question, $questiondata)

Detailed Description

The short answer question type.

Definition at line 40 of file questiontype.php.


Member Function Documentation

delete_files ( questionid,
contextid 
) [protected]

Delete all the files belonging to this question.

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

Reimplemented from question_type.

Definition at line 54 of file questiontype.php.

Here is the call graph for this function:

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).

Returns:
mixed array as above, or null to tell the base class to do nothing.

Reimplemented from question_type.

Definition at line 41 of file questiontype.php.

get_possible_responses ( questiondata)

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.
Returns:
array keys are subquestionid, values are arrays of possible responses to that subquestion.

Reimplemented from question_type.

Definition at line 139 of file questiontype.php.

Here is the call graph for this function:

get_random_guess_score ( questiondata)
Parameters:
object$question
Returns:
number|null either a fraction estimating what the student would score by guessing, or null, if it is not possible to estimate.

Reimplemented from question_type.

Definition at line 130 of file questiontype.php.

initialise_question_instance ( question_definition question,
questiondata 
) [protected]

Initialise the common question_definition fields.

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

Reimplemented from question_type.

Definition at line 125 of file questiontype.php.

Here is the call graph for this function:

move_files ( questionid,
oldcontextid,
newcontextid 
)

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 from question_type.

Definition at line 49 of file questiontype.php.

Here is the call graph for this function:

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

Reimplemented from question_type.

Definition at line 45 of file questiontype.php.

save_question_options ( question)

Saves question-type specific options

This is called by save_question() to save the question-type specific data

Returns:
object $result->error or $result->noticeyesno or $result->notice
Parameters:
object$questionThis holds the information from the editing form, it is not a standard question object.

Reimplemented from question_type.

Definition at line 59 of file questiontype.php.

Here is the call graph for this function:


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