From 6b40f7a80b6f942ec4e96d7fca6b46d92ab95a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20van=20Paassen?= Date: Sun, 24 May 2020 12:39:00 +0200 Subject: [PATCH] added attemptconfirmhtml option, displays in the next question presentation with the previous answer's feedback --- classes/combinator_grader_outcome.php | 7 ++++++- classes/testing_outcome.php | 4 ++++ renderer.php | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/classes/combinator_grader_outcome.php b/classes/combinator_grader_outcome.php index dfe19ffd1..cdb6ef3ce 100644 --- a/classes/combinator_grader_outcome.php +++ b/classes/combinator_grader_outcome.php @@ -32,7 +32,7 @@ class qtype_coderunner_combinator_grader_outcome extends qtype_coderunner_testin // A list of the allowed attributes in the combinator template grader return value. public $allowedfields = array('fraction', 'prologuehtml', 'testresults', 'epiloguehtml', 'feedbackhtml', 'columnformats', 'showdifferences', - 'showoutputonly' + 'showoutputonly', 'attemptconfirmhtml' ); public function __construct($isprecheck) { @@ -40,6 +40,7 @@ public function __construct($isprecheck) { $this->actualmark = 0; $this->epiloguehtml = null; $this->prologuehtml = null; + $this->attemptconfirmhtml = null; $this->testresults = null; $this->columnformats = null; $this->outputonly = false; @@ -200,6 +201,10 @@ public function show_differences() { $this->showdifferences && isset($this->testresults); } + public function get_attempt_confirm() { + return empty($this->attemptconfirmhtml) ? + '' : $this->attemptconfirmhtml; + } // Check that if a columnformats field is supplied // the number of entries is correct and that each entry is either '%s' diff --git a/classes/testing_outcome.php b/classes/testing_outcome.php index 95ffc91d9..9a80c4e85 100644 --- a/classes/testing_outcome.php +++ b/classes/testing_outcome.php @@ -416,6 +416,10 @@ public function get_epilogue() { return ''; } + public function get_attempt_confirm() { + return ''; + } + public function get_sourcecode_list() { return $this->sourcecodelist; } diff --git a/renderer.php b/renderer.php index 70c7c00b6..fb61ea128 100644 --- a/renderer.php +++ b/renderer.php @@ -209,6 +209,15 @@ public function formulation_and_controls(question_attempt $qa, question_display_ $PAGE->requires->js_call_amd('qtype_coderunner/textareas', 'initQuestionTA', array($responsefieldid)); } + // with the isoutputonly option, give feedback on the answer status here? + $toserialised = $qa->get_last_qt_var('_testoutcome'); + if ($toserialised) { + $outcome = unserialize($toserialised); + if ($outcome !== false) { + $qtext .= $outcome->get_attempt_confirm(); + } + } + return $qtext; }