From 7d929b7dd87865602fe9ed4d4e01a7462d001cbe Mon Sep 17 00:00:00 2001 From: Marcus Green Date: Thu, 20 Jun 2024 20:29:52 +0100 Subject: [PATCH] Set the default response format via a new site wide setting --- edit_aitext_form.php | 2 +- lang/en/qtype_aitext.php | 1 + renderer.php | 3 +-- settings.php | 7 +++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/edit_aitext_form.php b/edit_aitext_form.php index 989776c..46a8345 100755 --- a/edit_aitext_form.php +++ b/edit_aitext_form.php @@ -87,7 +87,7 @@ protected function definition_inner($mform) { $mform->addElement('select', 'responseformat', get_string('responseformat', 'qtype_aitext'), $qtype->response_formats()); - $mform->setDefault('responseformat', $this->get_default_value('responseformat', 'editor')); + $mform->setDefault('responseformat', get_config('qtype_aitext', 'responseformat')); $mform->addElement('select', 'responsefieldlines', get_string('responsefieldlines', 'qtype_aitext'), $qtype->response_sizes()); diff --git a/lang/en/qtype_aitext.php b/lang/en/qtype_aitext.php index 377d96a..0259ff3 100755 --- a/lang/en/qtype_aitext.php +++ b/lang/en/qtype_aitext.php @@ -83,6 +83,7 @@ $string['prompttester'] = 'Prompt Tester'; $string['responsefieldlines'] = 'Input box size'; $string['responseformat'] = 'Response format'; +$string['responseformat_setting'] = 'The editor the student uses when responding'; $string['responseoptions'] = 'Response options'; $string['responsenotrequired'] = 'Text input is optional'; $string['responseisrequired'] = 'Require the student to enter text'; diff --git a/renderer.php b/renderer.php index a924d27..a6c7dfe 100755 --- a/renderer.php +++ b/renderer.php @@ -23,13 +23,12 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use Random\RandomException; defined('MOODLE_INTERNAL') || die(); /** * Generates the output for aitext questions. * - * @copyright 2023 Marcus Green + * @copyright 2024 Marcus Green * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_aitext_renderer extends qtype_renderer { diff --git a/settings.php b/settings.php index 8ab06cb..78a2da9 100644 --- a/settings.php +++ b/settings.php @@ -60,5 +60,12 @@ 20, 6 )); + $settings->add(new admin_setting_configselect( + 'qtype_aitext/responseformat', + new lang_string('responseformat', 'qtype_aitext'), + new lang_string('responseformat_setting', 'qtype_aitext'), + 0, ['plain' => 'plain', 'editor' => 'editor', 'monospaced' => 'monospaced'] + )); + }