Skip to content

Commit 9a91870

Browse files
authored
Merge pull request #1438 from maths/iss1436
iss1436 - Question library fixes
2 parents 4a5000a + d225753 commit 9a91870

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

stack/cas/castext2/blocks/textdownload.block.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public function postprocess(array $params, castext2_processor $processor,
9595
castext2_placeholder_holder $holder): string {
9696
if (get_config('qtype_stack', 'stackapi')) {
9797
return "javascript:download('{$params[1]}', {$params[2]});";
98+
} else if (!isset($processor->qa) || !function_exists($processor->qa->get_database_id)) {
99+
// ISS1436 - Basic fix for STACK library where there is no question attempt.
100+
return "#";
98101
} else {
99102
// Note different systems serve out through different logic.
100103
if (count($params) > 3 && $params[3] === 'stateful') {

stack/input/inputbase.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,9 @@ public function requires_validation() {
14221422
* @param string student's current answer to insert into the xhtml.
14231423
* @param string $fieldname the field name to use in the HTML for this input.
14241424
* @param bool $readonly whether the control should be displayed read-only.
1425-
* @param array $tavalue the value of the teacher's answer for this input.
1425+
* ISS1436 - As far as I can tell, only equiv input is using $tavalue
1426+
* and that's expecting a string not an array.
1427+
* @param string $tavalue the value of the teacher's answer for this input.
14261428
* @return string HTML for this input.
14271429
*/
14281430
abstract public function render(stack_input_state $state, $fieldname, $readonly, $tavalue);

stack/questionlibrary.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public static function render_question(object $question): string {
9090
$tavalue = $question->get_ta_for_input($name);
9191
$fieldname = 'stack_temp_' . $name;
9292
$state = $question->get_input_state($name, []);
93-
$render = $input->render($state, $fieldname, false, [$tavalue]);
93+
// ISS1436 - As far as I can tell, only equiv input is using $tavalue
94+
// and that's expecting a string not an array.
95+
$render = $input->render($state, $fieldname, false, $tavalue);
9496
StackPlotReplacer::replace_plots($plots, $render, "answer-".$name, $storeprefix);
9597
$questiontext = str_replace("[[input:{$name}]]",
9698
$render,

0 commit comments

Comments
 (0)