Skip to content

Commit

Permalink
feat: add option to log wiris quizzes server errors to php logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pol Torrent i Soler committed Sep 16, 2024
1 parent 544484d commit ee2cf5c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 55 deletions.
3 changes: 3 additions & 0 deletions lang/en/qtype_wq.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@
$string['privacy:metadata:qtype_wq:xml'] = 'Wiris Quizzes Question XML';

$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.';
5 changes: 5 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public function call_wiris_service($request) {
$service = $builder->getQuizzesService();

$isdebugmodeenabled = get_config('qtype_wq', 'debug_mode_enabled') == '1';
$islogmodeenabled = get_config('qtype_wq', 'log_server_errors') == '1';

if ($isdebugmodeenabled) {
// @codingStandardsIgnoreLine
Expand All @@ -382,6 +383,10 @@ public function call_wiris_service($request) {
print_object($e);
}

if ($islogmodeenabled) {
error_log('WirisQuizzes error ' . $e->__toString());
}

throw new moodle_exception('wirisquestionincorrect', 'qtype_wq', $link, $a, '');
}

Expand Down
139 changes: 84 additions & 55 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,92 @@
}
}

$settings->add(new admin_setting_heading('qtype_wq/connectionsettings',
get_string('connectionsettings', 'qtype_wq'),
get_string('connectionsettings_text', 'qtype_wq')));

$settings->add(new admin_setting_configtext('qtype_wq/quizzesserviceurl',
get_string('quizzesserviceurl', 'qtype_wq'),
get_string('quizzesserviceurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/quizzes',
PARAM_URL));

$settings->add(new admin_setting_configtext('qtype_wq/quizzeseditorurl',
get_string('quizzeseditorurl', 'qtype_wq'),
get_string('quizzeseditorurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/editor',
PARAM_URL));

$settings->add(new admin_setting_configtext('qtype_wq/quizzeshandurl',
get_string('quizzeshandurl', 'qtype_wq'),
get_string('quizzeshandurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/hand',
PARAM_URL));

$settings->add(new admin_setting_configtext('qtype_wq/quizzeswirislauncherurl',
get_string('quizzeswirislauncherurl', 'qtype_wq'),
get_string('quizzeswirislauncherurl_help', 'qtype_wq'),
'http://stateful.wiris.net/demo/wiris',
PARAM_URL));

$settings->add(new admin_setting_configtext('qtype_wq/quizzeswirisurl',
get_string('quizzeswirisurl', 'qtype_wq'),
get_string('quizzeswirisurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/wiris',
PARAM_URL));
$settings->add(new admin_setting_heading(
'qtype_wq/connectionsettings',
get_string('connectionsettings', 'qtype_wq'),
get_string('connectionsettings_text', 'qtype_wq')
));

$settings->add(new admin_setting_configtext(
'qtype_wq/quizzesserviceurl',
get_string('quizzesserviceurl', 'qtype_wq'),
get_string('quizzesserviceurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/quizzes',
PARAM_URL
));

$settings->add(new admin_setting_configtext(
'qtype_wq/quizzeseditorurl',
get_string('quizzeseditorurl', 'qtype_wq'),
get_string('quizzeseditorurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/editor',
PARAM_URL
));

$settings->add(new admin_setting_configtext(
'qtype_wq/quizzeshandurl',
get_string('quizzeshandurl', 'qtype_wq'),
get_string('quizzeshandurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/hand',
PARAM_URL
));

$settings->add(new admin_setting_configtext(
'qtype_wq/quizzeswirislauncherurl',
get_string('quizzeswirislauncherurl', 'qtype_wq'),
get_string('quizzeswirislauncherurl_help', 'qtype_wq'),
'http://stateful.wiris.net/demo/wiris',
PARAM_URL
));

$settings->add(new admin_setting_configtext(
'qtype_wq/quizzeswirisurl',
get_string('quizzeswirisurl', 'qtype_wq'),
get_string('quizzeswirisurl_help', 'qtype_wq'),
'http://www.wiris.net/demo/wiris',
PARAM_URL
));

// Access provider option. If enabled only loged users can access to Wiris Quizzes services.
$settings->add(new admin_setting_configcheckbox('qtype_wq/access_provider_enabled',
get_string('access_provider_enabled', 'qtype_wq'),
get_string('access_provider_enabled_help', 'qtype_wq'),
'0'));

$settings->add(new admin_setting_heading('qtype_wq/compatibility_settings',
get_string('compatibility_settings', 'qtype_wq'),
get_string('compatibility_settings_text', 'qtype_wq')));

$settings->add(new admin_setting_configcheckbox('qtype_wq/filtercodes_compatibility',
get_string('filtercodes_compatibility_enabled', 'qtype_wq'),
get_string('filtercodes_compatibility_enabled_help', 'qtype_wq'),
'0'));

$settings->add(new admin_setting_heading('qtype_wq/troubleshooting_settings',
get_string('troubleshooting_settings', 'qtype_wq'),
get_string('troubleshooting_settings_text', 'qtype_wq')));

$settings->add(new admin_setting_configcheckbox('qtype_wq/debug_mode_enabled',
get_string('debug_mode_enabled', 'qtype_wq'),
get_string('debug_mode_enabled_help', 'qtype_wq'),
'0'));
$settings->add(new admin_setting_configcheckbox(
'qtype_wq/access_provider_enabled',
get_string('access_provider_enabled', 'qtype_wq'),
get_string('access_provider_enabled_help', 'qtype_wq'),
'0'
));

$settings->add(new admin_setting_heading(
'qtype_wq/compatibility_settings',
get_string('compatibility_settings', 'qtype_wq'),
get_string('compatibility_settings_text', 'qtype_wq')
));

$settings->add(new admin_setting_configcheckbox(
'qtype_wq/filtercodes_compatibility',
get_string('filtercodes_compatibility_enabled', 'qtype_wq'),
get_string('filtercodes_compatibility_enabled_help', 'qtype_wq'),
'0'
));

$settings->add(new admin_setting_heading(
'qtype_wq/troubleshooting_settings',
get_string('troubleshooting_settings', 'qtype_wq'),
get_string('troubleshooting_settings_text', 'qtype_wq')
));

$settings->add(new admin_setting_configcheckbox(
'qtype_wq/debug_mode_enabled',
get_string('debug_mode_enabled', 'qtype_wq'),
get_string('debug_mode_enabled_help', 'qtype_wq'),
'0'
));

$settings->add(new admin_setting_configcheckbox(
'qtype_wq/log_server_errors',
get_string('log_server_errors', 'qtype_wq'),
get_string('log_server_errors_help', 'qtype_wq'),
'0'
));


if ($CFG->version >= 2012120300 && $CFG->version < 2013051400) {
Expand Down

0 comments on commit ee2cf5c

Please sign in to comment.