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

Make it much easier for colleagues to construct a test case using the...

Make it much easier for colleagues to construct a test case using the "teacher's answer" input values as test case inputs.
parent f5bfb4f5
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,10 @@ How to report bugs and make suggestions is described on the [community](../About ...@@ -7,6 +7,10 @@ How to report bugs and make suggestions is described on the [community](../About
## Version 4.4 ## Version 4.4
Done:
* Make it much easier for colleagues to construct a test case using the "teacher's answer" input values as test case inputs.
## Maxima side PRTs. ## Maxima side PRTs.
* Move all functions to Maxima. * Move all functions to Maxima.
......
...@@ -465,6 +465,7 @@ $string['addatestcase'] = 'Add a test case...'; ...@@ -465,6 +465,7 @@ $string['addatestcase'] = 'Add a test case...';
$string['addingatestcase'] = 'Adding a test case to question {$a}'; $string['addingatestcase'] = 'Adding a test case to question {$a}';
$string['alreadydeployed'] = ' A variant matching this Question note is already deployed.'; $string['alreadydeployed'] = ' A variant matching this Question note is already deployed.';
$string['completetestcase'] = 'Fill in the rest of the form to make a passing test-case'; $string['completetestcase'] = 'Fill in the rest of the form to make a passing test-case';
$string['teacheranswercase'] = 'Use the teacher\'s answers as test-case';
$string['createtestcase'] = 'Create test case'; $string['createtestcase'] = 'Create test case';
$string['currentlyselectedvariant'] = 'This is the variant shown below'; $string['currentlyselectedvariant'] = 'This is the variant shown below';
$string['deletetestcase'] = 'Delete test case {$a->no} for question {$a->question}'; $string['deletetestcase'] = 'Delete test case {$a->no} for question {$a->question}';
......
...@@ -47,6 +47,8 @@ class qtype_stack_question_test_form extends moodleform { ...@@ -47,6 +47,8 @@ class qtype_stack_question_test_form extends moodleform {
$input->add_to_moodleform_testinput($mform); $input->add_to_moodleform_testinput($mform);
} }
$mform->addElement('submit', 'teacher', stack_string('teacheranswercase'));
$mform->registerNoSubmitButton('teacher');
$mform->addElement('submit', 'complete', stack_string('completetestcase')); $mform->addElement('submit', 'complete', stack_string('completetestcase'));
$mform->registerNoSubmitButton('complete'); $mform->registerNoSubmitButton('complete');
...@@ -80,6 +82,9 @@ class qtype_stack_question_test_form extends moodleform { ...@@ -80,6 +82,9 @@ class qtype_stack_question_test_form extends moodleform {
if ($this->_form->exportValue('complete')) { if ($this->_form->exportValue('complete')) {
$this->complete_passing_testcase(); $this->complete_passing_testcase();
} }
if ($this->_form->exportValue('teacher')) {
$this->complete_teacher_testcase();
}
} }
protected function complete_passing_testcase() { protected function complete_passing_testcase() {
...@@ -104,6 +109,18 @@ class qtype_stack_question_test_form extends moodleform { ...@@ -104,6 +109,18 @@ class qtype_stack_question_test_form extends moodleform {
} }
} }
protected function complete_teacher_testcase() {
$mform = $this->_form;
$question = $this->_customdata['question'];
$inputs = array();
foreach ($question->inputs as $inputname => $input) {
$ta = $input->get_teacher_answer_testcase();
$mform->getElement($inputname)->setValue($ta);
}
}
public function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
......
...@@ -173,6 +173,13 @@ class stack_checkbox_input extends stack_dropdown_input { ...@@ -173,6 +173,13 @@ class stack_checkbox_input extends stack_dropdown_input {
return $contents; return $contents;
} }
/**
* @return string the teacher's answer, suitable for testcase construction.
*/
public function get_teacher_answer_testcase() {
return 'mcq_correct(' . $this->teacheranswer . ')';
}
/** /**
* Decide if the contents of this attempt is blank. * Decide if the contents of this attempt is blank.
* *
......
...@@ -460,6 +460,13 @@ class stack_dropdown_input extends stack_input { ...@@ -460,6 +460,13 @@ class stack_dropdown_input extends stack_input {
return $this->maxima_to_response_array($this->teacheranswervalue); return $this->maxima_to_response_array($this->teacheranswervalue);
} }
/**
* @return string the teacher's answer, suitable for testcase construction.
*/
public function get_teacher_answer_testcase() {
return 'first(mcq_correct(' . $this->teacheranswer . '))';
}
/** /**
* Transforms a Maxima expression into an array of raw inputs which are part of a response. * Transforms a Maxima expression into an array of raw inputs which are part of a response.
* Most inputs are very simple, but textarea and matrix need more here. * Most inputs are very simple, but textarea and matrix need more here.
......
...@@ -541,6 +541,13 @@ abstract class stack_input { ...@@ -541,6 +541,13 @@ abstract class stack_input {
return $this->teacheranswer; return $this->teacheranswer;
} }
/**
* @return string the teacher's answer, suitable for testcase construction.
*/
public function get_teacher_answer_testcase() {
return $this->teacheranswer;
}
/** /**
* @return string the teacher's answer, displayed to the student in the general feedback. * @return string the teacher's answer, displayed to the student in the general feedback.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment