Skip to content
Snippets Groups Projects
Commit 799363d8 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Penalty field added to the question editing form + import & export.

parent 7ebb741b
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
<FIELD NAME="multiplicationsign" TYPE="char" LENGTH="8" NOTNULL="true" DEFAULT="dot" SEQUENCE="false" COMMENT="The symbol to use for multiplication." PREVIOUS="prtincorrectformat" NEXT="sqrtsign"/> <FIELD NAME="multiplicationsign" TYPE="char" LENGTH="8" NOTNULL="true" DEFAULT="dot" SEQUENCE="false" COMMENT="The symbol to use for multiplication." PREVIOUS="prtincorrectformat" NEXT="sqrtsign"/>
<FIELD NAME="sqrtsign" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether to display square roots as surds." PREVIOUS="multiplicationsign" NEXT="complexno"/> <FIELD NAME="sqrtsign" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether to display square roots as surds." PREVIOUS="multiplicationsign" NEXT="complexno"/>
<FIELD NAME="complexno" TYPE="char" LENGTH="8" NOTNULL="true" DEFAULT="i" SEQUENCE="false" COMMENT="How complex numbers should be displayed and represented." PREVIOUS="sqrtsign" NEXT="variantsselectionseed"/> <FIELD NAME="complexno" TYPE="char" LENGTH="8" NOTNULL="true" DEFAULT="i" SEQUENCE="false" COMMENT="How complex numbers should be displayed and represented." PREVIOUS="sqrtsign" NEXT="variantsselectionseed"/>
<FIELD NAME="variantsselectionseed" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="If set, used to control the random seed in a deterministic way, so different questions in the quiz can use the same random variable values." PREVIOUS="complexno"/> <FIELD NAME="variantsselectionseed" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="If set, used to control the random seed in a deterministic way, so different questions in the quiz can use the same random variable values." PREVIOUS="complexno" NEXT="penalty"/>
<FIELD NAME="penalty" TYPE="number" LENGTH="5" NOTNULL="false" SEQUENCE="false" DECIMALS="0" PREVIOUS="variantsselectionseed"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/>
......
...@@ -36,7 +36,9 @@ Please note the following. ...@@ -36,7 +36,9 @@ Please note the following.
* Worked Solution on Demand (Reason: the quiz behaviours are the right place to deal with this. Providing this option was always a hack in the first place...). * Worked Solution on Demand (Reason: the quiz behaviours are the right place to deal with this. Providing this option was always a hack in the first place...).
* Feedback shown (Reason: again, the quiz behaviours are the right place to deal with this.) * Feedback shown (Reason: again, the quiz behaviours are the right place to deal with this.)
* From the old MetaData only the `name` is preserved. All other MetaData is lost on import. * From the old MetaData only the `name` is preserved. All other MetaData is lost on import.
* STACK 2 exporter does not seem to export some of the interaction element options correctly, in particular the options which ask the student to verify and to show validation feedback. * STACK 2 exporter does not seem to export some of the interaction element options correctly, in particular
* the options which ask the student to verify and to show validation feedback.
* question level penalty option.
* Questions with a single potential response tree import with the PRT feedback in the specific feedback slot, not in the question text. We envisage this will enable single part questions to respect a wider variety of Moodle question behaviours. * Questions with a single potential response tree import with the PRT feedback in the specific feedback slot, not in the question text. We envisage this will enable single part questions to respect a wider variety of Moodle question behaviours.
* When importing question tests, the new testing mechanism in STACK 3 enables the teacher to specifiy a score and penalty, not just an answernote. Since we have to set defaults on import, most question tests now fail and this information will need to be added by hand. A good opportunity to confirm questions have imported correctly..... * When importing question tests, the new testing mechanism in STACK 3 enables the teacher to specifiy a score and penalty, not just an answernote. Since we have to set defaults on import, most question tests now fail and this information will need to be added by hand. A good opportunity to confirm questions have imported correctly.....
...@@ -215,6 +215,10 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -215,6 +215,10 @@ class qtype_stack_edit_form extends question_edit_form {
$mform->insertElementBefore($seed, 'questiontext'); $mform->insertElementBefore($seed, 'questiontext');
$mform->addHelpButton('variantsselectionseed', 'variantsselectionseed', 'qtype_stack'); $mform->addHelpButton('variantsselectionseed', 'variantsselectionseed', 'qtype_stack');
$pen = $mform->createElement('text', 'penalty', get_string('penalty', 'qtype_stack'), array('size' => 5));
$mform->insertElementBefore($pen, 'generalfeedback');
$mform->addHelpButton('penalty', 'penalty', 'qtype_stack');
$sf = $mform->createElement('editor', 'specificfeedback', $sf = $mform->createElement('editor', 'specificfeedback',
get_string('specificfeedback', 'question'), array('rows' => 10), $this->editoroptions); get_string('specificfeedback', 'question'), array('rows' => 10), $this->editoroptions);
$mform->insertElementBefore($sf, 'generalfeedback'); $mform->insertElementBefore($sf, 'generalfeedback');
...@@ -287,11 +291,6 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -287,11 +291,6 @@ class qtype_stack_edit_form extends question_edit_form {
get_string('complexno', 'qtype_stack'), array( get_string('complexno', 'qtype_stack'), array(
'i' => 'i', 'j' => 'j', 'symi' => 'symi', 'symj' => 'symj')); 'i' => 'i', 'j' => 'j', 'symi' => 'symi', 'symj' => 'symj'));
$mform->addHelpButton('complexno', 'complexno', 'qtype_stack'); $mform->addHelpButton('complexno', 'complexno', 'qtype_stack');
// Question tests.
// To stop Moodle compaining.
$mform->addElement('hidden', 'penalty', 0);
} }
protected function definition_input($inputname, MoodleQuickForm $mform) { protected function definition_input($inputname, MoodleQuickForm $mform) {
...@@ -621,7 +620,7 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -621,7 +620,7 @@ class qtype_stack_edit_form extends question_edit_form {
public function validation($fromform, $files) { public function validation($fromform, $files) {
$errors = parent::validation($fromform, $files); $errors = parent::validation($fromform, $files);
// 1) Validate all the fixes question fields. // 1) Validate all the fixed question fields.
$questionvars = new stack_cas_keyval($fromform['questionvariables'], null, null, 't'); $questionvars = new stack_cas_keyval($fromform['questionvariables'], null, null, 't');
if (!$questionvars->get_valid()) { if (!$questionvars->get_valid()) {
$errors['questionvariables'] = $questionvars->get_errors(); $errors['questionvariables'] = $questionvars->get_errors();
...@@ -646,6 +645,11 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -646,6 +645,11 @@ class qtype_stack_edit_form extends question_edit_form {
$inputs = array_keys($this->get_input_names_from_question_text()); $inputs = array_keys($this->get_input_names_from_question_text());
$potentialresponsetrees = $this->get_prt_names_from_question(); $potentialresponsetrees = $this->get_prt_names_from_question();
$penalty = $fromform['penalty'];
if (!is_numeric($penalty) || $penalty<0 || $penalty>1) {
$errors['penalty'] = get_string('penaltyerror', 'qtype_stack');
}
// 2) Validate all inputs. // 2) Validate all inputs.
foreach ($inputs as $inputname) { foreach ($inputs as $inputname) {
$teacheranswer = new stack_cas_casstring($fromform[$inputname . 'tans']); $teacheranswer = new stack_cas_casstring($fromform[$inputname . 'tans']);
......
...@@ -105,6 +105,9 @@ $string['nodexwhentrue'] = 'Node {no} when true'; ...@@ -105,6 +105,9 @@ $string['nodexwhentrue'] = 'Node {no} when true';
$string['nodex'] = 'Node {$a}'; $string['nodex'] = 'Node {$a}';
$string['nonempty'] = 'This must not be empty.'; $string['nonempty'] = 'This must not be empty.';
$string['penalty'] = 'Penalty'; $string['penalty'] = 'Penalty';
$string['penalty_help'] = 'The penalty scheme deducts this value from the result of each PRT for each different and valid attempt which is not completely correct.';
$string['penalty_link'] = 'question/type/stack/doc/doc.php/Authoring/Feedback.md';
$string['penaltyerror'] = 'The penalty must be a numeric value between 0 and 1.';
$string['prtcorrectfeedback'] = 'Standard feedback for correct'; $string['prtcorrectfeedback'] = 'Standard feedback for correct';
$string['prtheading'] = 'Potential response tree: {$a}'; $string['prtheading'] = 'Potential response tree: {$a}';
$string['prtincorrectfeedback'] = 'Standard feedback for incorrect'; $string['prtincorrectfeedback'] = 'Standard feedback for incorrect';
......
...@@ -736,7 +736,6 @@ class qtype_stack extends question_type { ...@@ -736,7 +736,6 @@ class qtype_stack extends question_type {
$fromform = $format->import_headers($xml); $fromform = $format->import_headers($xml);
$fromform->qtype = $this->name(); $fromform->qtype = $this->name();
$fromform->penalty = 0;
$fromform->questionvariables = $format->getpath($xml, array('#', 'questionvariables', $fromform->questionvariables = $format->getpath($xml, array('#', 'questionvariables',
0, '#', 'text', 0, '#'), '', true); 0, '#', 'text', 0, '#'), '', true);
...@@ -748,6 +747,7 @@ class qtype_stack extends question_type { ...@@ -748,6 +747,7 @@ class qtype_stack extends question_type {
$fromform->prtpartiallycorrect = $this->import_xml_text($xml, 'prtpartiallycorrect', $fromform->prtpartiallycorrect = $this->import_xml_text($xml, 'prtpartiallycorrect',
$format, $fromform->questiontextformat); $format, $fromform->questiontextformat);
$fromform->prtincorrect = $this->import_xml_text($xml, 'prtincorrect', $format, $fromform->questiontextformat); $fromform->prtincorrect = $this->import_xml_text($xml, 'prtincorrect', $format, $fromform->questiontextformat);
$fromform->penalty = $format->getpath($xml, array('#', 'penalty', 0, '#'), 0.1);
$fromform->multiplicationsign = $format->getpath($xml, array('#', 'multiplicationsign', 0, '#'), 'dot'); $fromform->multiplicationsign = $format->getpath($xml, array('#', 'multiplicationsign', 0, '#'), 'dot');
$fromform->sqrtsign = $format->getpath($xml, array('#', 'sqrtsign', 0, '#'), 1); $fromform->sqrtsign = $format->getpath($xml, array('#', 'sqrtsign', 0, '#'), 1);
$fromform->complexno = $format->getpath($xml, array('#', 'complexno', 0, '#'), 'i'); $fromform->complexno = $format->getpath($xml, array('#', 'complexno', 0, '#'), 'i');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment