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

Return contextid in core_course_get_contents

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.9
    • Fix Version/s: 3.10
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create or use an existing course with some activities
      3. Enrol one user from the site in that course
      4. Create a Token in the mobile app service for the user from the previous step
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Open the console an execute this new curl request, replacing wstoken with the token you just created, the course (step 2) id and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=YOUR_COURSE_ID&wsfunction=core_course_get_contents&wstoken=YOUR_WS_TOKEN' --compressed | python -m "json.tool"

      6. Confirm that:
        • In the curl request-response, you see listed all the sections and course modules within the sections that match the course structure that is displayed in the web browser
        • For each module, you see a contextid field which value matches the value for the context id of the module

      Note: An easy way to check the context id value via the Moodle interface is just opening the main page of the module as administrator, then clicking in the settings cog and placing the mouse over the "Permissions" link. You will see a parameter "contextid" in the link with the context id value.

      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create or use an existing course with some activities Enrol one user from the site in that course Create a Token in the mobile app service for the user from the previous step Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created, the course (step 2) id and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=YOUR_COURSE_ID&wsfunction=core_course_get_contents&wstoken=YOUR_WS_TOKEN' --compressed | python -m "json.tool" Confirm that: In the curl request-response, you see listed all the sections and course modules within the sections that match the course structure that is displayed in the web browser For each module, you see a contextid field which value matches the value for the context id of the module Note: An easy way to check the context id value via the Moodle interface is just opening the main page of the module as administrator, then clicking in the settings cog and placing the mouse over the "Permissions" link. You will see a parameter "contextid" in the link with the context id value.
    • Affected Branches:
      MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull from Repository:
    • Pull 3.10 Branch:
      MDL-68935-310
    • Pull Master Branch:
      MDL-68935-master

      Description

      Web Services are not supposed to use contextid as parameters never (instead we use context type and instance) but because since this rule was established several things happened, such as supporting AJAX via external functions, so sometimes it would solve problems to just have this information returned in the WS

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Pau Ferrer
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Anna Carissa Sadia
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 15 minutes
                  2h 15m