Moodle  2.2.1
http://www.collinsharper.com
test_question_maker Class Reference

Public Member Functions

 get_a_qa ($question, $maxmark=3)

Static Public Member Functions

static initialise_a_question ($q)
static initialise_question_data ($qdata)
static initialise_question_form_data ($qdata)
static get_test_helper ($qtype)
static make_question ($qtype, $which=null)
static get_question_data ($qtype, $which=null)
static get_question_form_data ($qtype, $which=null)
static make_a_multichoice_single_question ()
static make_a_multichoice_multi_question ()
static make_a_matching_question ()
static make_an_essay_question ()
static set_standard_combined_feedback_fields ($q)

Data Fields

const STANDARD_OVERALL_CORRECT_FEEDBACK = 'Well done!'
const STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK
const STANDARD_OVERALL_INCORRECT_FEEDBACK = 'That is not right at all.'

Static Protected Member Functions

static call_question_helper_method ($methodtemplate, $qtype, $which=null)

Static Protected Attributes

static $testhelpers = array()

Detailed Description

This class creates questions of various types, which can then be used when testing.

Definition at line 74 of file helpers.php.


Member Function Documentation

static call_question_helper_method ( methodtemplate,
qtype,
which = null 
) [static, protected]

Call a method on a qtype_{$qtype}_test_helper class and return the result.

Parameters:
string$methodtemplatee.g. 'make_{qtype}_question_{which}';
string$qtypethe question type to get a test question for.
string$whichone of the names returned by the get_test_questions method of the relevant qtype_{$qtype}_test_helper class.
unknown_type$which

Definition at line 189 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_a_qa ( question,
maxmark = 3 
)

Just make a question_attempt at a question. Useful for unit tests that need to pass a $qa to methods that call format_text. Probably not safe to use for anything beyond that.

Parameters:
question_definition$questiona question.
number$maxmarkthe max mark to set.
Returns:
question_attempt the question attempt.

Definition at line 91 of file helpers.php.

Here is the caller graph for this function:

static get_question_data ( qtype,
which = null 
) [static]

Like make_question() but returns the datastructure from get_question_options instead of the question_definition object.

Parameters:
string$qtypethe question type to get a test question for.
string$whichone of the names returned by the get_test_questions method of the relevant qtype_{$qtype}_test_helper class.
Returns:
stdClass the requested question object.

Definition at line 237 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static get_question_form_data ( qtype,
which = null 
) [static]

Like make_question() but returns the data what would be saved from the question editing form instead of the question_definition object.

Parameters:
string$qtypethe question type to get a test question for.
string$whichone of the names returned by the get_test_questions method of the relevant qtype_{$qtype}_test_helper class.
Returns:
stdClass the requested question object.

Definition at line 251 of file helpers.php.

Here is the call graph for this function:

static get_test_helper ( qtype) [static]

Get the test helper class for a particular question type.

Parameters:
$qtypethe question type name, e.g. 'multichoice'.
Returns:
question_test_helper the test helper class.

Definition at line 157 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static initialise_a_question ( q) [static]

Initialise the common fields of a question of any type.

Definition at line 98 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static initialise_question_data ( qdata) [static]

Definition at line 118 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static initialise_question_form_data ( qdata) [static]

Definition at line 140 of file helpers.php.

Here is the caller graph for this function:

static make_a_matching_question ( ) [static]

Makes a matching question to classify 'Dog', 'Frog', 'Toad' and 'Cat' as 'Mammal', 'Amphibian' or 'Insect'. defaultmark 1. Stems are shuffled by default.

Returns:
qtype_match_question

Definition at line 317 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static make_a_multichoice_multi_question ( ) [static]

Makes a multichoice question with choices 'A', 'B', 'C' and 'D' shuffled. 'A' and 'C' is correct, defaultmark 1.

Returns:
qtype_multichoice_multi_question

Definition at line 287 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Makes a multichoice question with choices 'A', 'B' and 'C' shuffled. 'A' is correct, defaultmark 1.

Returns:
qtype_multichoice_single_question

Definition at line 261 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static make_an_essay_question ( ) [static]

Makes a truefalse question with correct ansewer true, defaultmark 1.

Returns:
qtype_essay_question

Definition at line 347 of file helpers.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static make_question ( qtype,
which = null 
) [static]

Question types can provide a number of test question defintions. They do this by creating a qtype_{$qtype}_test_helper class that extends question_test_helper. The get_test_questions method returns the list of test questions available for this question type.

Parameters:
string$qtypethe question type to get a test question for.
string$whichone of the names returned by the get_test_questions method of the relevant qtype_{$qtype}_test_helper class.
Returns:
question_definition the requested question object.

Definition at line 223 of file helpers.php.

Here is the call graph for this function:

static set_standard_combined_feedback_fields ( q) [static]

Add some standard overall feedback to a question. You need to use these specific feedback strings for the corresponding contains_..._feedback methods in qbehaviour_walkthrough_test_base to works.

Parameters:
question_definition$qthe question to add the feedback to.

Definition at line 372 of file helpers.php.

Here is the caller graph for this function:


Field Documentation

$testhelpers = array() [static, protected]

Definition at line 81 of file helpers.php.

const STANDARD_OVERALL_CORRECT_FEEDBACK = 'Well done!'

Definition at line 75 of file helpers.php.

const STANDARD_OVERALL_INCORRECT_FEEDBACK = 'That is not right at all.'

Definition at line 78 of file helpers.php.

Initial value:
            'Parts, but only parts, of your response are correct.'

Definition at line 76 of file helpers.php.


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