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

Course modules with access restrictions are not being returned by core_course_get_contents

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. In a course create:
      2. One URL resource with one access restriction (date for example), using a future date so the activity is not available yet.
      3. One URL resource with one access restriction (date for example), using an old date so the activity is available.
      4. A section containing at least one visible activity. The section should have an access restriction not met yet (like a future date)
      5. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      6. Create a Token in the mobile app service for one student user in the course:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, courseid (with the id of the course where the activities are) and the URL of your moodle instance

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

      8. Now check that you can see in the response all the activities and the section with the access restriction.
      9. You don't see any module inside the section with the access restriction and you see a field called availabilityinfo describing why the section is not enabled yet.
      10. You see a field called "contents" in the module that has the access restriction met and you don't see a field called availabilityinfo
      11. You don't see a field called "contents" in the module that has the access restriction not yet met and you see a field called availabilityinfo describing why the module is not enabled yet.
      12. Now, if you edit the section access restriction to a old date (like a week ago) and execute the curl request again you should see the module inside the section.
      Show
      In a course create: One URL resource with one access restriction (date for example), using a future date so the activity is not available yet. One URL resource with one access restriction (date for example), using an old date so the activity is available. A section containing at least one visible activity. The section should have an access restriction not met yet (like a future date) As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for one student user in the course: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken, courseid (with the id of the course where the activities are) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=16&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool" Now check that you can see in the response all the activities and the section with the access restriction. You don't see any module inside the section with the access restriction and you see a field called availabilityinfo describing why the section is not enabled yet. You see a field called "contents" in the module that has the access restriction met and you don't see a field called availabilityinfo You don't see a field called "contents" in the module that has the access restriction not yet met and you see a field called availabilityinfo describing why the module is not enabled yet. Now, if you edit the section access restriction to a old date (like a week ago) and execute the curl request again you should see the module inside the section.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-58720-master

      Description

      This WS is only checking for modules visible by the user (via uservisible) is not checking for modules that are not visible for the user but should be displayed in the course because they have access restrictions configured.

      Unfortunately, for solving this we'll need to return additional field sin the WS so this seems to not be backportable.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  15/May/17