-
Bug
-
Resolution: Fixed
-
Blocker
-
3.11.10, 4.0.4, 4.1
-
6
-
Team Hedgehog Sprint 1.3
Steps to reproduce:
- Create a quiz (default options)
- Create an essay question in that quiz:
- Set the "Allow attachments" option to 3
- Attempt the quiz as a student - save, but do not finish the attempt.
- Make a note of the attempt number in the URL
- Log in as admin
- Enable mobile web services from Site admin -> Advanced features
- Navigate to Site admin -> Server -> Web services -> Manage tokens
- Create a token for that user
- Tail your web server error log
- Curl the mod_quiz_get_attempt_data ws:
curl --location --request POST 'http://mandarin.local/sm/webservice/rest/server.php?moodlewsrestformat=json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'attemptid=4' \
--data-urlencode 'page=0' \
--data-urlencode 'wsfunction=mod_quiz_get_attempt_data' \
--data-urlencode 'wstoken=c2609ab77a4a51e01aeb129fb57a92da'
Note: You will need to replace the hostname, attemptid, and wstoken from the data you have collected
- Observe debugging notice
[Fri Oct 07 12:37:57.037742 2022] [php7:notice] [pid 14508] [client 127.0.0.1:58538] This page did not call $PAGE->set_url(...). Using http://mandarin.local/sm/webservice/rest/server.php?moodlewsrestformat=json
|
[Fri Oct 07 12:37:57.037811 2022] [php7:notice] [pid 14508] [client 127.0.0.1:58538] Debugging: This page did not call $PAGE->set_url(...). Using http://mandarin.local/sm/webservice/rest/server.php?moodlewsrestformat=json in \n* line 676 of /lib/pagelib.php: call to debugging()\n* line 964 of /lib/pagelib.php: call to moodle_page->magic_get_url()\n* line 189 of /lib/editor/atto/lib.php: call to moodle_page->__get()\n* line 159 of /lib/editor/atto/lib.php: call to atto_texteditor->get_init_params()\n* line 321 of /question/type/essay/renderer.php: call to atto_texteditor->use_editor()\n* line 53 of /question/type/essay/renderer.php: call to qtype_essay_format_editor_renderer->response_area_input()\n* line 378 of /question/engine/renderer.php: call to qtype_essay_renderer->formulation_and_controls()\n* line 102 of /question/engine/renderer.php: call to core_question_renderer->formulation()\n* line 113 of /question/behaviour/behaviourbase.php: call to core_question_renderer->question()\n* line 907 of /question/engine/questionattempt.php: call to question_behaviour->render()\n* line 461 of /question/engine/questionusage.php: call to question_attempt->render()\n* line 1779 of /mod/quiz/attemptlib.php: call to question_usage_by_activity->render_question()\n* line 1740 of /mod/quiz/attemptlib.php: call to quiz_attempt->render_question_helper()\n* line 989 of /mod/quiz/classes/external.php: call to quiz_attempt->render_question()\n* line 1076 of /mod/quiz/classes/external.php: call to mod_quiz_external::get_attempt_questions_data()\n* line 1516 of /webservice/lib.php: call to mod_quiz_external::get_attempt_data()\n* line 1362 of /webservice/lib.php: call to webservice_base_server->execute()\n* line 44 of /webservice/rest/server.php: call to webservice_base_server->run()\n
|
If the editor for a user is Atto, then the editor makes use of the Page URL, taken from $PAGE->url as part of the data to ensure that autosave works correctly.
When called from a web service, the PAGE->url is not set, hence the error.
This is currently eaten in its unit test (grr).
We need to fix this because if we change the default editor to not be Atto, then we no longer have debugging, and mod_quiz\external\external_test::test_process_attempt will fail because of the lack of debugging.
It is not clear whether we should:
- fix this just for this web service
- address this in the web service layer, by setting up a $PAGE object a bit more.