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

Web Service core_enrol_get_users_courses is missing hidden, starred and course completion courses information

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.2
    • Fix Version/s: 3.6
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin set the global enablecompletion setting to enabled (in Site administration > Advanced features)
      2. Create two new courses, C1 and C2
      3. * C1 with enablecompletion set to 1
      4. Go to the C1 main page, and via the "Cog" open the "Course completion" option and Enable the "Condition: Course grade" using a required course grade of 50
      5. Create two users U1 and U2
      6. Enrol U1 as students in C1 and C2
      7. Enrol U2 as teacher in C1 and C2
      8. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      9. Create a Token in the mobile app service for all the users
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      10. As U1 access the Moodle web interface, in the dashboard using the three dots menu at each course, "Hide from view" course C1 and "Star course C2"
      11. Open the console an execute this new curl request, replacing wstoken with the token for U1 and the site url with yours. Replace also the userid to mach U1 one

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=3af67232a7596ceb658df4db329e5ad6&userid=19' --compressed | python -m "json.tool"

      12. After executing the WS check that:
        • You receive all the courses you are enrolled, C1 and C2
        • C1 field isfavourite is set to false
        • C1 field hidden is set to true
        • C1 field completionhascriteria is set to true
        • C2 field isfavourite is set to true
        • C2 field hidden is set to false
        • C2 field completionhascriteria is set to false
      13. Now, execute the same CURL request but using the U2 token (keeping the original userid) and check that
        • C1 field isfavourite is set to false
        • C1 field hidden is set to false
        • C1 field completionhascriteria is set to true
        • C2 field isfavourite is set to false
        • C2 field hidden is set to false
        • C2 field completionhascriteria is set to false
      Show
      As admin set the global enablecompletion setting to enabled (in Site administration > Advanced features) Create two new courses, C1 and C2 * C1 with enablecompletion set to 1 Go to the C1 main page, and via the "Cog" open the "Course completion" option and Enable the "Condition: Course grade" using a required course grade of 50 Create two users U1 and U2 Enrol U1 as students in C1 and C2 Enrol U2 as teacher in C1 and C2 Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for all the users Click on Site administration ► Plugins ► Web services ► Manage tokens As U1 access the Moodle web interface, in the dashboard using the three dots menu at each course, "Hide from view" course C1 and "Star course C2" Open the console an execute this new curl request, replacing wstoken with the token for U1 and the site url with yours. Replace also the userid to mach U1 one curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=3af67232a7596ceb658df4db329e5ad6&userid=19' --compressed | python -m "json.tool" After executing the WS check that: You receive all the courses you are enrolled, C1 and C2 C1 field isfavourite is set to false C1 field hidden is set to true C1 field completionhascriteria is set to true C2 field isfavourite is set to true C2 field hidden is set to false C2 field completionhascriteria is set to false Now, execute the same CURL request but using the U2 token (keeping the original userid) and check that C1 field isfavourite is set to false C1 field hidden is set to false C1 field completionhascriteria is set to true C2 field isfavourite is set to false C2 field hidden is set to false C2 field completionhascriteria is set to false
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-63739-master

      Description

      MDL-63522 was created to support all the new fields for building the users dashboard but is missing the hidden and starred courses information (probably because it was developed before hidden courses were supported).

      Also, even returning enablecompletion and progress and completed field we are not able to know if course completion is set, we need to return if the course has completions set. (via $info->get_completions($USER->id);
      )

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/18

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h