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

Web Service core_course_get_course_contents is not returning stealth activities

XMLWordPrintable

    • MOODLE_35_STABLE
    • MOODLE_34_STABLE, MOODLE_35_STABLE
    • MDL-63542-master
    • Hide
      1. As admin, create a new empty course with 3 sections (using topic format)
      2. In the first section create a resource, type page, with any content
      3. In the first section, create another page resource, this time in the activity settings Common module settings -> Availability select "Make available but not shown on course page"
      4. Hide the second section, using the "Hide topic"
      5. Create a new page resource in the second section, setting Common module settings -> Availability to "Make available but not shown on course page"
      6. Enrol a user as student in the course
      7. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      8. Create a Token in the mobile app service for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      9. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. Remember to replace the COURSE_ID as well with the course created in the first step

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=excludemodules&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=includestealthmodules&options%5B1%5D%5Bvalue%5D=0&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool"

      10. Confirm that:
        • You receive a JSON structure listing all the sections BUT not the hidden one
        • In the first section you see the two page resources you created, the last one has the visibleoncoursepage field set to 0
      11. Now, execute this CURL request

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=excludemodules&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=includestealthmodules&options%5B1%5D%5Bvalue%5D=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool"

      12. Confirm that:
        • You receive a JSON structure listing all the sections BUT not the hidden one
        • There is a section with id -1 and with empty name and description that includes the stealh activity you created in the hidden section
      13. Enrol a new user in the course as teacher
      14. Create a WS token for this user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      15. Now, execute the first CURL request and confirm that:
        • You receive a JSON listing all the sections (including the hidden one) and all the activities
      Show
      As admin, create a new empty course with 3 sections (using topic format) In the first section create a resource, type page, with any content In the first section, create another page resource, this time in the activity settings Common module settings -> Availability select "Make available but not shown on course page" Hide the second section, using the "Hide topic" Create a new page resource in the second section, setting Common module settings -> Availability to "Make available but not shown on course page" Enrol a user as student in the course As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the student user 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 and the site url with yours. Remember to replace the COURSE_ID as well with the course created in the first step curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=excludemodules&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=includestealthmodules&options%5B1%5D%5Bvalue%5D=0&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool" Confirm that: You receive a JSON structure listing all the sections BUT not the hidden one In the first section you see the two page resources you created, the last one has the visibleoncoursepage field set to 0 Now, execute this CURL request curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=excludemodules&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=includestealthmodules&options%5B1%5D%5Bvalue%5D=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool" Confirm that: You receive a JSON structure listing all the sections BUT not the hidden one There is a section with id -1 and with empty name and description that includes the stealh activity you created in the hidden section Enrol a new user in the course as teacher Create a WS token for this user: Click on Site administration ► Plugins ► Web services ► Manage tokens Now, execute the first CURL request and confirm that: You receive a JSON listing all the sections (including the hidden one) and all the activities

      Steps to replicate this issue:

      1) create an activity or resource in a section/topic
      2) hide the section/topic
      3) make the activity or resource created in 1) available to students
      4) call the core_course_get_course_contents WS, the stealth activity is not returned

        1. 1.PNG
          179 kB
          Janelle Barcega
        2. 2.PNG
          274 kB
          Janelle Barcega
        3. 3.PNG
          270 kB
          Janelle Barcega

            jleyva Juan Leyva
            jleyva Juan Leyva
            Dani Palou Dani Palou
            Andrew Lyons Andrew Lyons
            Janelle Barcega Janelle Barcega
            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 - 1 hour
                1h

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