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

Public Member Functions

 question_summary ()
 right_answer ()
 response_summary ($state)
 was_answered ($state)
 set_first_step_data_elements ($state, &$data)
 supply_missing_first_step_data (&$data)
 set_data_elements_for_step ($state, &$data)
 load_dataset ($selecteditem)
 format_float ($x, $length=null, $format=null)
 calculate ($expression)
 replace_expressions_in_text ($text, $length=null, $format=null)

Protected Member Functions

 parse_response ($state)
 calculate_raw ($expression)
 substitute_values_for_eval ($expression)
 substitute_values_pretty ($text)

Protected Attributes

 $selecteditem = null
 $values
 $search
 $safevalue
 $prettyvalue

Detailed Description

Class for converting attempt data for calculated questions when upgrading attempts to the new question engine.

This class is used by the code in question/engine/upgrade/upgradelib.php.

Definition at line 39 of file upgradelib.php.


Member Function Documentation

calculate ( expression)

Evaluate an expression using the variable values.

Parameters:
string$expressionthe expression. A PHP expression with placeholders like {a} for where the variables need to go.
Returns:
float the computed result.

Definition at line 240 of file upgradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

calculate_raw ( expression) [protected]

Evaluate an expression after the variable values have been substituted.

Parameters:
string$expressionthe expression. A PHP expression with placeholders like {a} for where the variables need to go.
Returns:
float the computed result.

Definition at line 250 of file upgradelib.php.

Here is the caller graph for this function:

format_float ( x,
length = null,
format = null 
)

This function should be identical to qtype_calculated_variable_substituter::format_float(). Except that we do not try to do locale-aware replacement of the decimal point.

Having to copy it here is a pain, but it is the standard rule about not using library code (which may change in future) in upgrade code, which exists at a point in time.

Display a float properly formatted with a certain number of decimal places.

Parameters:
number$xthe number to format
int$lengthrestrict to this many decimal places or significant figures. If null, the number is not rounded.
intformat 1 => decimalformat, 2 => significantfigures.
Returns:
string formtted number.

Definition at line 221 of file upgradelib.php.

Here is the caller graph for this function:

load_dataset ( selecteditem)

Definition at line 181 of file upgradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

parse_response ( state) [protected]

Definition at line 83 of file upgradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from question_qtype_attempt_updater.

Definition at line 59 of file upgradelib.php.

replace_expressions_in_text ( text,
length = null,
format = null 
)

Replace any embedded variables (like {a}) or formulae (like {={a} + {b}}) in some text with the corresponding values.

Parameters:
string$textthe text to process.
Returns:
string the text with values substituted.

Definition at line 287 of file upgradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

response_summary ( state)

Reimplemented from question_qtype_attempt_updater.

Definition at line 114 of file upgradelib.php.

Here is the call graph for this function:

Reimplemented from question_qtype_attempt_updater.

Definition at line 63 of file upgradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_data_elements_for_step ( state,
&$  data 
)

Reimplemented from question_qtype_attempt_updater.

Definition at line 155 of file upgradelib.php.

Here is the call graph for this function:

set_first_step_data_elements ( state,
&$  data 
)

Reimplemented from question_qtype_attempt_updater.

Definition at line 138 of file upgradelib.php.

Here is the call graph for this function:

substitute_values_for_eval ( expression) [protected]

Substitute variable placehodlers like {a} with their value wrapped in ().

Parameters:
string$expressionthe expression. A PHP expression with placeholders like {a} for where the variables need to go.
Returns:
string the expression with each placeholder replaced by the corresponding value.

Definition at line 265 of file upgradelib.php.

Here is the caller graph for this function:

substitute_values_pretty ( text) [protected]

Substitute variable placehodlers like {a} with their value without wrapping the value in anything.

Parameters:
string$textsome content with placeholders like {a} for where the variables need to go.
Returns:
string the expression with each placeholder replaced by the corresponding value.

Definition at line 277 of file upgradelib.php.

Here is the caller graph for this function:

Reimplemented from question_qtype_attempt_updater.

Definition at line 151 of file upgradelib.php.

was_answered ( state)

Reimplemented from question_qtype_attempt_updater.

Definition at line 134 of file upgradelib.php.


Field Documentation

$prettyvalue [protected]

Definition at line 57 of file upgradelib.php.

$safevalue [protected]

Definition at line 51 of file upgradelib.php.

$search [protected]

Definition at line 45 of file upgradelib.php.

$selecteditem = null [protected]

Definition at line 40 of file upgradelib.php.

$values [protected]

Definition at line 42 of file upgradelib.php.


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