Skip to content

Commit

Permalink
Merge pull request wiris#89 from wiris/v4.11.5
Browse files Browse the repository at this point in the history
V4.11.5
  • Loading branch information
ptorrent-at-wiris authored Nov 4, 2024
2 parents f5148c6 + 3b681d4 commit 87c0052
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lang/en/qtype_wq.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
2 changes: 2 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -384,6 +385,7 @@ public function call_wiris_service($request) {
}

if ($islogmodeenabled) {
// @codingStandardsIgnoreLine
error_log('WIRISQUIZZES SERVER ERROR --- REQUEST: --- ' . $request->serialize());
}

Expand Down
38 changes: 27 additions & 11 deletions step.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 87c0052

Please sign in to comment.