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

WebService core_enrol_get_users_courses should return extra information for the app

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.6
    • 3.5.2
    • Web Services
    • MOODLE_35_STABLE
    • MOODLE_36_STABLE
    • MDL-63523-master
    • Hide
      1. As admin set the global enablecompletion setting to enabled (in Site administration > Advanced features)
      2. Create two new courses:
        • C1 with enablecompletion set to 1 and an overview file added (an image)
        • C2 with enablecompletion disabled
      3. 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
      4. Create three users U1, U2 and U3
      5. Enrol U1 and U2 as students in C1
      6. Enrol U3 as teacher in C1 and C2
      7. Enrol U1 as student in C2
      8. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      9. Create a Token in the mobile app service for all the users (U1, U2 and U3)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      10. 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"

      11. After executing the WS check that:
        • You receive all the courses you are enrolled, C1 and C2
        • The displayname match the course fullname
        • Completed field is set to false/0 for C1 but NULL for C2
        • Progress field is set to false/0 for C1 but NULL for C2
        • Lastaccess is set to 0 for both courses
        • Marker is set to 0 for both courses
        • Overviewfiles lists the file you added to C1 and is empty for C2
      12. Now, as admin, make the first section of C1 active (using the Edit option located at the right of the section name in the course, select "Highlight this section")
      13. Now, log-in into the Moodle site as U1 and access C1
      14. Execute again the last CURL request, copy the output in a text file and check that
        • Lastaccess is now filled with a number > 0 for C1
        • Marker is set to 1
      15. Now, execute again the same CURL request but this time using the teacher token and check that
        • You see the same information than in the previous CURL request
      16. Now, execute the same CURL request but using the U2 token and check that
        • You only see C1
        • The Completed and Progress fields are set to NULL
        • You see the lastaccessed time with a value bigger than 0
      Show
      As admin set the global enablecompletion setting to enabled (in Site administration > Advanced features) Create two new courses: C1 with enablecompletion set to 1 and an overview file added (an image) C2 with enablecompletion disabled 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 three users U1, U2 and U3 Enrol U1 and U2 as students in C1 Enrol U3 as teacher in C1 and C2 Enrol U1 as student in C2 Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for all the users (U1, U2 and U3) Click on Site administration ► Plugins ► Web services ► Manage tokens 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 The displayname match the course fullname Completed field is set to false/0 for C1 but NULL for C2 Progress field is set to false/0 for C1 but NULL for C2 Lastaccess is set to 0 for both courses Marker is set to 0 for both courses Overviewfiles lists the file you added to C1 and is empty for C2 Now, as admin, make the first section of C1 active (using the Edit option located at the right of the section name in the course, select "Highlight this section") Now, log-in into the Moodle site as U1 and access C1 Execute again the last CURL request, copy the output in a text file and check that Lastaccess is now filled with a number > 0 for C1 Marker is set to 1 Now, execute again the same CURL request but this time using the teacher token and check that You see the same information than in the previous CURL request Now, execute the same CURL request but using the U2 token and check that You only see C1 The Completed and Progress fields are set to NULL You see the lastaccessed time with a value bigger than 0

      This WS is currently returning some useful information but still missing some pieces to be able to print in the dashboard all the courses relevant information like:

      • Course completion information (completed or not)
      • Course image (if any)
      • Marker (for the active section)
      • Starred / favourited
      • Hidden (not related to visible, if it is hidden for the user because he selected to not display it anymore in the list of courses), see MDL-63457
      • Last accessed
      • Display name (that calculates if the shortname should be displayed)

      Right now, we require extra WS calls to be able to retrieve the missing information and with the new dashboard we should be able to avoid multiple WS calls.

            jleyva Juan Leyva
            jleyva Juan Leyva
            Albert Gasset Albert Gasset
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m

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