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

Minor bug fixes and improvements.

parent e1453237
Branches
No related tags found
No related merge requests found
...@@ -171,9 +171,7 @@ Add the following to the question variables and feedback variables. ...@@ -171,9 +171,7 @@ Add the following to the question variables and feedback variables.
The symbol `diamonds` will then be treated as units in code such as `unitsp(ex)` and displayed with the TeX \(\diamond\) symbol. The symbol `diamonds` will then be treated as units in code such as `unitsp(ex)` and displayed with the TeX \(\diamond\) symbol.
You will need to put `diamonds` in the allow words of the input in the question. However, the input validation code is independent of the question variables, and hence the student's answer will not be displayed using the TeX \(\diamond\) symbol. If we add better support for custom units in the future, this may change. If your units are something like `lb` and you are happy with italic fonts, this might be fine for now. You will need to put `diamonds` in the allow words of the input in the question.
Note, the feedback created within potential response trees will not respect the above code.
## Tips for dealing with units in STACK ## ## Tips for dealing with units in STACK ##
......
...@@ -9,6 +9,7 @@ How to report bugs and make suggestions is described on the [community](../About ...@@ -9,6 +9,7 @@ How to report bugs and make suggestions is described on the [community](../About
Done: Done:
* Introduce "context variables" which propagate throughout a question, enabling `texput` to operate in inputs as well as general castext.
* Autoload `trigtools` to provide better simplification options for trig expressions and fix long-standing bug with `trigrat`. * Autoload `trigtools` to provide better simplification options for trig expressions and fix long-standing bug with `trigrat`.
* Make it much easier for colleagues to construct a test case using the "teacher's answer" input values as test case inputs. * Make it much easier for colleagues to construct a test case using the "teacher's answer" input values as test case inputs.
* Allow users to modify the `notanswered` message in dropdown and radio inputs. * Allow users to modify the `notanswered` message in dropdown and radio inputs.
......
...@@ -206,10 +206,16 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -206,10 +206,16 @@ class qtype_stack_edit_form extends question_edit_form {
$mform->addHelpButton('questionvariables', 'questionvariables', 'qtype_stack'); $mform->addHelpButton('questionvariables', 'questionvariables', 'qtype_stack');
if (isset($this->question->id)) { if (isset($this->question->id)) {
$out = stack_string('runquestiontests');
if (empty($this->question->deployedseeds) &&
qtype_stack_question::random_variants_check($this->question->options->questionvariables)) {
$out = stack_string('questionnotdeployedyet');
}
$qtestlink = html_writer::link($qtype->get_question_test_url($this->question), $qtestlink = html_writer::link($qtype->get_question_test_url($this->question),
stack_string('runquestiontests'), array('target' => '_blank')); $out, array('target' => '_blank'));
$qtlink = $mform->createElement('static', 'qtestlink', '', $qtestlink); $qtlink = $mform->createElement('static', 'runquestiontests', '', $qtestlink);
$mform->insertElementBefore($qtlink, 'questionvariables'); $mform->insertElementBefore($qtlink, 'questionvariables');
$mform->addHelpButton('runquestiontests', 'runquestiontests', 'qtype_stack');
} }
$seed = $mform->createElement('text', 'variantsselectionseed', $seed = $mform->createElement('text', 'variantsselectionseed',
...@@ -757,6 +763,7 @@ class qtype_stack_edit_form extends question_edit_form { ...@@ -757,6 +763,7 @@ class qtype_stack_edit_form extends question_edit_form {
$qtype = new qtype_stack(); $qtype = new qtype_stack();
list($errors, $warnings) = $qtype->validate_fromform($fromform, $errors); list($errors, $warnings) = $qtype->validate_fromform($fromform, $errors);
return $errors; return $errors;
} }
......
...@@ -516,6 +516,7 @@ $string['questiontestsfor'] = 'Question tests for seed {$a}'; ...@@ -516,6 +516,7 @@ $string['questiontestsfor'] = 'Question tests for seed {$a}';
$string['questiontestspass'] = 'All question tests passed.'; $string['questiontestspass'] = 'All question tests passed.';
$string['questiontestsdefault'] = '(Default)'; $string['questiontestsdefault'] = '(Default)';
$string['runquestiontests'] = 'Question tests & deployed variants'; $string['runquestiontests'] = 'Question tests & deployed variants';
$string['runquestiontests_help'] = 'The question tests unit-test the questions to ensure the behaviour matches expectations expressed by the teacher, and deployed variants ensure random versions seen by a student are pre-tested against the question tests. These are tools to help you create and test reliable questions and should be used in all cases a question will be used by students.';
$string['seethisquestioninthequestionbank'] = 'See this question in the question bank'; $string['seethisquestioninthequestionbank'] = 'See this question in the question bank';
$string['showingundeployedvariant'] = 'Showing undeployed variant: {$a}'; $string['showingundeployedvariant'] = 'Showing undeployed variant: {$a}';
$string['switchtovariant'] = 'Switch to arbitrary variant'; $string['switchtovariant'] = 'Switch to arbitrary variant';
......
...@@ -1009,7 +1009,14 @@ class qtype_stack_question extends question_graded_automatically_with_countback ...@@ -1009,7 +1009,14 @@ class qtype_stack_question extends question_graded_automatically_with_countback
* @return bool whether this question uses randomisation. * @return bool whether this question uses randomisation.
*/ */
public function has_random_variants() { public function has_random_variants() {
return preg_match('~\brand~', $this->questionvariables) || preg_match('~\bmultiselqn~', $this->questionvariables); return $this->random_variants_check($this->questionvariables);
}
/**
* @return bool Actual test of whether this question uses randomisation.
*/
public static function random_variants_check($text) {
return preg_match('~\brand~', $text) || preg_match('~\bmultiselqn~', $text);
} }
public function get_num_variants() { public function get_num_variants() {
......
...@@ -63,14 +63,9 @@ echo $OUTPUT->heading($question->name, 2); ...@@ -63,14 +63,9 @@ echo $OUTPUT->heading($question->name, 2);
$out = html_writer::link($testquestionlink, stack_string('runquestiontests'), array('target' => '_blank')); $out = html_writer::link($testquestionlink, stack_string('runquestiontests'), array('target' => '_blank'));
// If question has no random variants. // If question has no random variants.
if ($question->has_random_variants()) {
if (empty($question->deployedseeds)) {
$out .= stack_string('questionnotdeployedyet');
}
}
if (empty($question->deployedseeds)) { if (empty($question->deployedseeds)) {
if ($question->has_random_variants()) { if ($question->has_random_variants()) {
$out .= stack_string('questionnotdeployedyet'); $out .= ' ' . stack_string('questionnotdeployedyet');
} }
} }
......
...@@ -172,7 +172,11 @@ class stack_answertest_general_cas extends stack_anstest { ...@@ -172,7 +172,11 @@ class stack_answertest_general_cas extends stack_anstest {
} }
} }
// Guard clause to prevent an exception below and provide error messages to end user.
$unpacked = array('answernote' => '', 'feedback' => '');
if ($result->is_evaluated()) {
$unpacked = $this->unpack_result($result->get_evaluated()); $unpacked = $this->unpack_result($result->get_evaluated());
}
$this->atansnote = str_replace("\n", '', trim($unpacked['answernote'])); $this->atansnote = str_replace("\n", '', trim($unpacked['answernote']));
if ('' != $result->get_errors()) { if ('' != $result->get_errors()) {
......
...@@ -7104,6 +7104,10 @@ ...@@ -7104,6 +7104,10 @@
"stackunits_make": { "stackunits_make": {
"function": "s" "function": "s"
}, },
"stack_unit_si_declare": {
"function": "s",
"contextvariable": "true"
},
"stackvector": { "stackvector": {
"function": "s" "function": "s"
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment