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

New Web Service core_course_get_courses_by_field

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a few categories and courses, make some courses not visible, and make at least one category with one course not visible
      2. The courses should have a description and attached files in the description summary fields file manager, they should have different enrolment methods enabled and there should be at least one teacher in one course enrolled.
      3. Create a couple of user accounts in the site, one of the users must be enrolled in a couple of courses (including one of the not visible)
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token for the two users and the site admin:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with all the users.
        • You need to replace the wstoken, and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_get_courses_by_field&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      7. Now check that:
        • The admin can see all the courses, even the not visible ones, including all the course fields (28 fields)
        • The student can see all the courses that are visible, but in the courses where is not enrolled he will see only 12 public fields, in the courses where he is enrolled he will see 28 fields
        • The authenticated user (not enrolled) can see all the visible courses, but it see only the 12 public fields
        • In all the cases check that the courses fields matches the Moodle ones, and that the course description files are returned
      8. Now, execute the curl command for all the users but filtering by field (append to the command): &field=x&value=y, possible fields are: id, idnumber, shortname and cateogyr, also ids (the value will be comma separated ids)
      9. In all the cases check that you can retrieve courses by these fields and that the admin can see all the courses, the authenticated user only the visible ones (and only the public fields) and the student the visible ones and in the courses where he is enrolled all the 28 fields
      Show
      Create a few categories and courses, make some courses not visible, and make at least one category with one course not visible The courses should have a description and attached files in the description summary fields file manager, they should have different enrolment methods enabled and there should be at least one teacher in one course enrolled. Create a couple of user accounts in the site, one of the users must be enrolled in a couple of courses (including one of the not visible) As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the two users and the site admin: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with all the users. You need to replace the wstoken, and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_course_get_courses_by_field&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Now check that: The admin can see all the courses, even the not visible ones, including all the course fields (28 fields) The student can see all the courses that are visible, but in the courses where is not enrolled he will see only 12 public fields, in the courses where he is enrolled he will see 28 fields The authenticated user (not enrolled) can see all the visible courses, but it see only the 12 public fields In all the cases check that the courses fields matches the Moodle ones, and that the course description files are returned Now, execute the curl command for all the users but filtering by field (append to the command): &field=x&value=y, possible fields are: id, idnumber, shortname and cateogyr, also ids (the value will be comma separated ids) In all the cases check that you can retrieve courses by these fields and that the admin can see all the courses, the authenticated user only the visible ones (and only the public fields) and the student the visible ones and in the courses where he is enrolled all the 28 fields
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55100-master

      Description

      This new WS is intended to be a replacement of the current core_course_get_courses, reasons are:

      • core_course_get_courses only works for courses where the user have the course:view capability on
      • Users should be able to view the basic course information (id, fullname,...) even if they are not enrolled in a course (but only if the course is visible).
      • Returned data is missing some key information, like the enrolment methods enabled in the course, the "public visible teachers", filters enabled, etc..
      • It doesn't handle nicely exception/warnings (the whole WS fails if you requested a course where you don't have permissions)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jleyva Juan Leyva
                Reporter:
                jleyva Juan Leyva
                Peer reviewer:
                Dani Palou
                Integrator:
                Dan Poltawski
                Tester:
                John Okely
                Participants:
                Component watchers:
                Amaia Anabitarte, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Juan Leyva, Jake Dallimore, Jun Pataleta, Ryan Wyllie
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16