Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
qtype_calculatedsimple_qe2_attempt_updater Class Reference

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

Inheritance diagram for qtype_calculatedsimple_qe2_attempt_updater:
qtype_calculated_qe2_attempt_updater question_qtype_attempt_updater

Public Member Functions

 calculate ($expression)
 Evaluate an expression using the variable values.
 
 compare_answers ($answer1, $answer2)
 
 discard ()
 
 format_float ($x, $length=null, $format=null)
 This function should be identical to qtype_calculated_variable_substituter::format_float().
 
 is_blank_answer ($state)
 
 load_dataset ($selecteditem)
 
 question_summary ()
 
 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.
 
 response_summary ($state)
 
 right_answer ()
 
 set_data_elements_for_step ($state, &$data)
 
 set_first_step_data_elements ($state, &$data)
 
 supply_missing_first_step_data (&$data)
 
 was_answered ($state)
 

Protected Member Functions

 calculate_raw ($expression)
 Evaluate an expression after the variable values have been substituted.
 
 parse_response ($state)
 
 substitute_values_for_eval ($expression)
 Substitute variable placehodlers like {a} with their value wrapped in ().
 
 substitute_values_pretty ($text)
 Substitute variable placehodlers like {a} with their value without wrapping the value in anything.
 
 to_text ($html)
 

Protected Attributes

question_engine_assumption_logger $logger
 
array $prettyvalue = []
 variable values, with negative numbers wrapped in (...).
 
question_engine_attempt_upgrader $qeupdater
 
object $question
 the question definition data.
 
array $safevalue = []
 variable values, with negative numbers wrapped in (...).
 
array $search = []
 variable names wrapped in {...}.
 
 $selecteditem = null
 
question_behaviour_attempt_updater $updater
 
array $values = []
 variable name => value
 

Detailed Description

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

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

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ calculate()

qtype_calculated_qe2_attempt_updater::calculate ( $expression)
inherited

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.
Return values
floatthe computed result.

◆ calculate_raw()

qtype_calculated_qe2_attempt_updater::calculate_raw ( $expression)
protectedinherited

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.
Return values
floatthe computed result.

◆ format_float()

qtype_calculated_qe2_attempt_updater::format_float ( $x,
$length = null,
$format = null )
inherited

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.
Return values
stringformtted number.

◆ question_summary()

qtype_calculated_qe2_attempt_updater::question_summary ( )
inherited

Reimplemented from question_qtype_attempt_updater.

◆ replace_expressions_in_text()

qtype_calculated_qe2_attempt_updater::replace_expressions_in_text ( $text,
$length = null,
$format = null )
inherited

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

Parameters
string$textthe text to process.
Return values
stringthe text with values substituted.

◆ response_summary()

qtype_calculated_qe2_attempt_updater::response_summary ( $state)
inherited

Reimplemented from question_qtype_attempt_updater.

◆ right_answer()

qtype_calculated_qe2_attempt_updater::right_answer ( )
inherited

Reimplemented from question_qtype_attempt_updater.

◆ set_data_elements_for_step()

qtype_calculated_qe2_attempt_updater::set_data_elements_for_step ( $state,
& $data )
inherited

Reimplemented from question_qtype_attempt_updater.

◆ set_first_step_data_elements()

qtype_calculated_qe2_attempt_updater::set_first_step_data_elements ( $state,
& $data )
inherited

Reimplemented from question_qtype_attempt_updater.

◆ substitute_values_for_eval()

qtype_calculated_qe2_attempt_updater::substitute_values_for_eval ( $expression)
protectedinherited

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.
Return values
stringthe expression with each placeholder replaced by the corresponding value.

◆ substitute_values_pretty()

qtype_calculated_qe2_attempt_updater::substitute_values_pretty ( $text)
protectedinherited

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.
Return values
stringthe expression with each placeholder replaced by the corresponding value.

◆ supply_missing_first_step_data()

qtype_calculated_qe2_attempt_updater::supply_missing_first_step_data ( & $data)
inherited

Reimplemented from question_qtype_attempt_updater.

◆ was_answered()

qtype_calculated_qe2_attempt_updater::was_answered ( $state)
inherited

Reimplemented from question_qtype_attempt_updater.

Member Data Documentation

◆ $prettyvalue

array qtype_calculated_qe2_attempt_updater::$prettyvalue = []
protectedinherited

variable values, with negative numbers wrapped in (...).

Used by substitute_values().

◆ $safevalue

array qtype_calculated_qe2_attempt_updater::$safevalue = []
protectedinherited

variable values, with negative numbers wrapped in (...).

Used by substitute_values().

◆ $search

array qtype_calculated_qe2_attempt_updater::$search = []
protectedinherited

variable names wrapped in {...}.

Used by substitute_values().


The documentation for this class was generated from the following file: