Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
Upgrade library code for the calculated question type.
Copyright: | 2011 The Open University |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 302 lines (11 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
qtype_calculated_qe2_attempt_updater:: (15 methods):
question_summary()
right_answer()
parse_response()
response_summary()
was_answered()
set_first_step_data_elements()
supply_missing_first_step_data()
set_data_elements_for_step()
load_dataset()
format_float()
calculate()
calculate_raw()
substitute_values_for_eval()
substitute_values_pretty()
replace_expressions_in_text()
Class: qtype_calculated_qe2_attempt_updater - X-Ref
Class for converting attempt data for calculated questions when upgradingquestion_summary() X-Ref |
right_answer() X-Ref |
No description |
parse_response($state) X-Ref |
No description |
response_summary($state) X-Ref |
No description |
was_answered($state) X-Ref |
No description |
set_first_step_data_elements($state, &$data) X-Ref |
No description |
supply_missing_first_step_data(&$data) X-Ref |
No description |
set_data_elements_for_step($state, &$data) X-Ref |
No description |
load_dataset($selecteditem) X-Ref |
No description |
format_float($x, $length = null, $format = null) X-Ref |
This function should be identical to {@link 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. param: number $x the number to format param: int $length restrict to this many decimal places or significant param: int format 1 => decimalformat, 2 => significantfigures. return: string formtted number. |
calculate($expression) X-Ref |
Evaluate an expression using the variable values. param: string $expression the expression. A PHP expression with placeholders return: float the computed result. |
calculate_raw($expression) X-Ref |
Evaluate an expression after the variable values have been substituted. param: string $expression the expression. A PHP expression with placeholders return: float the computed result. |
substitute_values_for_eval($expression) X-Ref |
Substitute variable placehodlers like {a} with their value wrapped in (). param: string $expression the expression. A PHP expression with placeholders return: string the expression with each placeholder replaced by the |
substitute_values_pretty($text) X-Ref |
Substitute variable placehodlers like {a} with their value without wrapping the value in anything. param: string $text some content with placeholders return: string the expression with each placeholder replaced by the |
replace_expressions_in_text($text, $length = null, $format = null) X-Ref |
Replace any embedded variables (like {a}) or formulae (like {={a} + {b}}) in some text with the corresponding values. param: string $text the text to process. return: string the text with values substituted. |