MDL-75914 webservice: Added fake URL to avoid debugging output.

Webservice doesn't need to set the page URL. Hence,
any function that requires a page URL will raise debugging output.
The patch fixes it by adding a fake URL for the webservice.
The patch also removed assertDebuggingCalled because it is no longer needed.
This commit is contained in:
Meirza 2022-12-15 12:13:24 +07:00
parent 5019abfdd6
commit e33194755f
2 changed files with 5 additions and 1 deletions

View File

@ -1050,6 +1050,7 @@ class mod_quiz_external extends external_api {
* @throws moodle_quiz_exceptions
*/
public static function get_attempt_data($attemptid, $page, $preflightdata = array()) {
global $PAGE;
$warnings = array();
@ -1068,6 +1069,10 @@ class mod_quiz_external extends external_api {
$nextpage = $params['page'] + 1;
}
// TODO: Remove the code once the long-term solution (MDL-76728) has been applied.
// Set a default URL to stop the debugging output.
$PAGE->set_url('/fake/url');
$result = array();
$result['attempt'] = $attemptobj->get_attempt();
$result['messages'] = $messages;

View File

@ -1321,7 +1321,6 @@ class external_test extends externallib_advanced_testcase {
// Now, get the summary.
$result = mod_quiz_external::get_attempt_summary($attempt->id);
$result = \external_api::clean_returnvalue(mod_quiz_external::get_attempt_summary_returns(), $result);
$this->assertDebuggingCalled(); // Expect $PAGE->set_url debugging.
// Check it's marked as completed only the first one.
$this->assertEquals('complete', $result['questions'][0]['state']);