From 7706a7be28f399acf12c29ec9300a26260743f9e Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 4 Nov 2024 12:38:25 +0100 Subject: [PATCH 1/4] feat: raise tolerance to attempt evaluation failure and enable traces for log mode Kanbanize: #taskid 51138 --- lang/en/qtype_wq.php | 2 +- question.php | 2 ++ step.php | 34 +++++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lang/en/qtype_wq.php b/lang/en/qtype_wq.php index 7bc2de2..9498ddc 100644 --- a/lang/en/qtype_wq.php +++ b/lang/en/qtype_wq.php @@ -107,4 +107,4 @@ $string['auxiliar_text'] = 'Write an optional reasoning for your answer:'; $string['log_server_errors'] = 'Log server errors'; -$string['log_server_errors_help'] = 'Extensively log errors coming from the WirisQuizzes service to your server logs. This might cause an increase in the size of your log files but might help the Wiris team troubleshoot issues.'; +$string['log_server_errors_help'] = 'Extensively log errors coming from the WirisQuizzes service and other errors occurred when processing WirisQuizzes questions to your server logs. This might cause an increase in the size of your log files but might help the Wiris team troubleshoot issues.'; diff --git a/question.php b/question.php index 05ece33..0b02ac2 100644 --- a/question.php +++ b/question.php @@ -172,6 +172,7 @@ public function format_text($text, $format, $qa, $component, $filearea, $itemid, $format = FORMAT_HTML; } $text = $this->expand_variables($text); + return $this->base->format_text($text, $format, $qa, $component, $filearea, $itemid, $clean); } @@ -384,6 +385,7 @@ public function call_wiris_service($request) { } if ($islogmodeenabled) { + // @codingStandardsIgnoreLine error_log('WIRISQUIZZES SERVER ERROR --- REQUEST: --- ' . $request->serialize()); } diff --git a/step.php b/step.php index 3706746..408946e 100644 --- a/step.php +++ b/step.php @@ -36,9 +36,9 @@ defined('MOODLE_INTERNAL') || die(); class qtype_wirisstep { - const MAX_ATTEMPS_SHORTANSWER_WIRIS = 2; + const MAX_ATTEMPS_SHORTANSWER_WIRIS = 5; - private $step; + private ?question_attempt_step $step; private $stepid; private $extraprefix; @@ -189,7 +189,7 @@ public function get_qt_data() { * @param type $subquesbool whether the variable is from the subquestion or the parent (only cloze). * @return null */ - public function get_var($name, $subquesbool = true) { + public function get_var(string $name, bool $subquesbool = true) { $name = $this->trim_name($name, $subquesbool); if ($subquesbool && $this->step != null) { @@ -256,17 +256,41 @@ public function is_attempt_limit_reached() { if (is_null($c)) { return false; } - return $c >= self::MAX_ATTEMPS_SHORTANSWER_WIRIS; + + $isreached = $c >= self::MAX_ATTEMPS_SHORTANSWER_WIRIS; + + + $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; + + if ($islogmodeenabled) { + $errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' . + ($this->step != null ? $this->step->get_id() : $this->stepid); + // @codingStandardsIgnoreLine + error_log($errormessage); + } + + return $isreached; } /** * Increment number of failed attempts */ - public function inc_attempts() { + public function inc_attempts(moodle_exception $e) { $c = $this->get_var('_gc', false); if (is_null($c)) { $c = 0; } + + $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; + + if ($islogmodeenabled) { + $errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' . + ($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL . + 'EXCEPTION: ' . $e->getMessage(); + // @codingStandardsIgnoreLine + error_log($errormessage); + } + $this->set_var('_gc', $c + 1, false); } From cd277e6bc370f73f9950db97338f057da12b312c Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 4 Nov 2024 12:40:22 +0100 Subject: [PATCH 2/4] chore(deps): require filter_wiris v8.8.0 Kanbanize: #taskid 51652 --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 09c624a..fc3a858 100644 --- a/version.php +++ b/version.php @@ -22,5 +22,5 @@ $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_wq'; $plugin->dependencies = array( - 'filter_wiris' => ANY_VERSION + 'filter_wiris' => 2024100700 ); From 0cd3246a4fe101947af049f4695bd359bff3365c Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 4 Nov 2024 12:40:42 +0100 Subject: [PATCH 3/4] chore: bump version to v4.11.5 --- version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.php b/version.php index fc3a858..7ae1a1b 100644 --- a/version.php +++ b/version.php @@ -16,9 +16,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024032204; +$plugin->version = 2024032205; $plugin->requires = 2015111600; // Moodle 3.0. -$plugin->release = '4.11.4'; +$plugin->release = '4.11.5'; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'qtype_wq'; $plugin->dependencies = array( From 3b681d41113ed16b8675fc95067038e80552278a Mon Sep 17 00:00:00 2001 From: Pol Torrent i Soler Date: Mon, 4 Nov 2024 12:44:57 +0100 Subject: [PATCH 4/4] chore: cleanup --- step.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/step.php b/step.php index 408946e..e335572 100644 --- a/step.php +++ b/step.php @@ -183,12 +183,7 @@ public function get_qt_data() { $DB = $this->get_db(); } } - /** - * - * @param type $name - * @param type $subquesbool whether the variable is from the subquestion or the parent (only cloze). - * @return null - */ + public function get_var(string $name, bool $subquesbool = true) { $name = $this->trim_name($name, $subquesbool); @@ -259,9 +254,7 @@ public function is_attempt_limit_reached() { $isreached = $c >= self::MAX_ATTEMPS_SHORTANSWER_WIRIS; - $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; - if ($islogmodeenabled) { $errormessage = 'WIRISQUIZZES ATTEMPT LIMIT REACHED FOR STEP WITH ID ' . ($this->step != null ? $this->step->get_id() : $this->stepid); @@ -282,7 +275,6 @@ public function inc_attempts(moodle_exception $e) { } $islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1'; - if ($islogmodeenabled) { $errormessage = 'WIRISQUIZZES ATTEMPT ERROR --- INCREASING ATTEMPT COUNT TO ' . ($c + 1) . ' FOR STEP WITH ID ' . ($this->step != null ? $this->step->get_id() : $this->stepid) . PHP_EOL .