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

Return contextid in core_course_get_contents

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.10
    • 3.9
    • Web Services
    • MOODLE_39_STABLE
    • MOODLE_310_STABLE
    • MDL-68935-master
    • 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.

      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

        1. MDL-68935.jpg
          64 kB
          Anna Carissa Sadia

            jleyva Juan Leyva
            jleyva Juan Leyva
            Pau Ferrer Pau Ferrer
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.