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..e335572 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; @@ -183,13 +183,8 @@ 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($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 +251,38 @@ 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); } diff --git a/version.php b/version.php index 09c624a..7ae1a1b 100644 --- a/version.php +++ b/version.php @@ -16,11 +16,11 @@ 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( - 'filter_wiris' => ANY_VERSION + 'filter_wiris' => 2024100700 );