Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74193

Assign WebService: Activity instructions embedded file URLs are wrong

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • Hide
      1. Log in as admin
      2. Enable web services
      3. Create a test user
      4. Create a web service token for yourself
      5. Create a course
      6. Enrol yourself on course as a student
      7. Add a new Assignment activity:
        • Activity instructions: Enter some text and then add an image, via Insert or edit image, e.g.:
        • Allow submissions from: 1 March 2022
        • Save
      8. Navigate to assignment in course
      9. Add submission
      10. Log out
      11. Execute the following using your test user token:

        $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wsfunction=mod_assign_get_assignments&wstoken=<TOKEN>" | python -m json.tool
        

      12. Confirm the file URL in the "activity" property test is equal to the file URL in the "activityattachments" property (both should contain mod_assign/activityattachment/0/ for example)
      13. Note the "id" property of the assignment, it will be required on the next step
      14. Execute the following:

        $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wsfunction=mod_assign_get_submission_status&wstoken=<TOKEN>assignid=<ASSIGNID>" | python -m json.tool
        

      15. Confirm the file URL in the "activity" property test is equal to the file URL in the "attachments[activity]" property (both should contain mod_assign/activityattachment/0/ for example)
      Show
      Log in as admin Enable web services Create a test user Create a web service token for yourself Create a course Enrol yourself on course as a student Add a new Assignment activity: Activity instructions: Enter some text and then add an image, via Insert or edit image , e.g.: Allow submissions from: 1 March 2022 Save Navigate to assignment in course Add submission Log out Execute the following using your test user token: $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wsfunction=mod_assign_get_assignments&wstoken=<TOKEN>" | python -m json.tool Confirm the file URL in the "activity" property test is equal to the file URL in the "activityattachments" property (both should contain mod_assign/activityattachment/0/ for example) Note the "id" property of the assignment, it will be required on the next step Execute the following: $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wsfunction=mod_assign_get_submission_status&wstoken=<TOKEN>assignid=<ASSIGNID>" | python -m json.tool Confirm the file URL in the "activity" property test is equal to the file URL in the "attachments [activity] " property (both should contain mod_assign/activityattachment/0/ for example)

    Description

      It seems the external_format_text isn't applied as it should in the WebServices mod_assign_get_assignments and mod_assign_get_submission_status. The URL returned in the activity text is like:

      https://SITEURL/webservice/pluginfile.php/15318/mod_assign/activityattachment/image.jpeg

      And that URL doesn't work. In the activity attachments it's returned like this:

      https://SITEURL/webservice/pluginfile.php/15318/mod_assign/activityattachment/0/image.jpeg

      This last URL is the right one, the first one should also include the /0/.

      How to reproduce:

      1. As an admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a new course.
      3. Create a new assignment activity, setting the following:
        1. The assignment should be open (in the Availability section).
        2. In the Activity instructions field, add an image.
      4. Enrol one user as student in the course
      5. Create a Token in the mobile app service for the previous user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Open the console and execute this curl request, replacing wstoken with the token you created for the user, the SITE_URL with yours and COURSEID with the course id where the assignment is:
         

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids%5B0%5D=COURSEID&moodlewssettingfilter=true&moodlewssettingfileurl=true&moodlewssettinglang=en&wsfunction=mod_assign_get_assignments&wstoken=WSTOKEN' --compressed | python -m "json.tool"

      1. Check that the URL included in the activity field is different than the one returned in activityattachments.

      Attachments

        1. MDL-74193_1.png
          77 kB
          Angelia Dela Cruz
        2. MDL-74193_2.png
          87 kB
          Angelia Dela Cruz
        3. Screenshot_2022-03-14 Editing Assignment.png
          133 kB
          Paul Holden

        Issue Links

          Activity

            People

              pholden Paul Holden
              dpalou Dani Palou
              Dani Palou Dani Palou
              Ilya Tregubov Ilya Tregubov
              Angelia Dela Cruz Angelia Dela Cruz
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                19/Apr/22

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 30 minutes
                  30m