<unitgradingtype>1</unitgradingtype>
is the parameter for unit handling.
the meaning is defined in question/type/numerical/questiontype.php
class qtype_numerical extends question_type {
const UNITINPUT = 0;
const UNITRADIO = 1;
const UNITSELECT = 2;
const UNITNONE = 3;
const UNITGRADED = 1;
const UNITOPTIONAL = 0;
const UNITGRADEDOUTOFMARK = 1;
const UNITGRADEDOUTOFMAX = 2;
and the handling in edit_numerical_form.php
/**
* Add the unit handling options to the form.
* @param object $mform the form being built.
*/
protected function add_unit_options($mform) {
$mform->addElement('header', 'unithandling',
get_string('unithandling', 'qtype_numerical'));
$unitoptions = array(
qtype_numerical::UNITNONE => get_string('onlynumerical', 'qtype_numerical'),
qtype_numerical::UNITOPTIONAL => get_string('manynumerical', 'qtype_numerical'),
qtype_numerical::UNITGRADED => get_string('unitgraded', 'qtype_numerical'),
);
$mform->addElement('select', 'unitrole',
get_string('unithandling', 'qtype_numerical'), $unitoptions);
to ilustrate how this is used look in numerical/question.php:
/**
* Adjust the fraction based on whether the unit was correct.
* @param number $fraction
* @param bool $unitisright
* @return number
*/
public function apply_unit_penalty($fraction, $unitisright) {
if ($unitisright) {
return $fraction;
}
if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMARK) {
$fraction -= $this->unitpenalty * $fraction;
} else if ($this->unitgradingtype == qtype_numerical::UNITGRADEDOUTOFMAX) {
$fraction -= $this->unitpenalty;
}
return max($fraction, 0);
}
Not easy to follow !!
Pierre