From e252818139b034ff44a7c43260aefcec1dd06426 Mon Sep 17 00:00:00 2001 From: David Szkiba Date: Fri, 20 Dec 2024 13:21:20 +0100 Subject: [PATCH] GH-779 Get main scale from selected template --- classes/catquiz_handler.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/classes/catquiz_handler.php b/classes/catquiz_handler.php index fe2a1d774..113d0cd46 100644 --- a/classes/catquiz_handler.php +++ b/classes/catquiz_handler.php @@ -153,7 +153,19 @@ public static function instance_form_definition(MoodleQuickForm &$mform) { // ... after this function has finished execution. submitted form. // But the submitted via post, so we can access the variable via the superglobal $POST. - $selectedparentscale = optional_param('catquiz_catscales', 0, PARAM_INT); + if ($chosentemplate = optional_param('choosetemplate', 0, PARAM_INT)) { + // Get parent scale ID from template. + $cattest = (object)[ + 'id' => $chosentemplate, + 'component' => 'mod_adaptivequiz', + ]; + + // Pass on the values as stdClass. + $test = new testenvironment($cattest); + $selectedparentscale = $test->return_as_array()['catscaleid']; + } else { + $selectedparentscale = optional_param('catquiz_catscales', 0, PARAM_INT); + } if (!empty($selectedparentscale)) { $element = $mform->getElement('catquiz_catscales');