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

New Web Service gradereport_overview_get_course_grades

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Find a student user account enrolled in at least a couple of courses where he has a final grade
      3. Create a Token for the student user mentioned in the previous step:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a CURL REST call simulating a WS client with the user.
        • 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=gradereport_overview_get_course_grades&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      5. Now, check that in the response you see the same courses and grades that in Moodle web when clicking in the "Grades" option in the user contextual menu (top right).
      6. In one of the courses where the user has a grade, enable the Show rank option via the Overview report settings (/grade/edit/settings/index.php?id=COURSE_ID)
      7. Execute the WS again and check that you now receive a new field with the rank position, the num of users will be always 0 for the system context so you won't receive that value in the WS response
      8. Now, create a token for the site admin, and execute the curl command appending: &userid=STUDENT_ID (the student account user id), as admin, you should be able to see the student grades
      9. If you execute the last curl command using another student token, you'll get an error (no permissions)
      10. Now, to test that the viewed events are triggered, execute the following curl command replacing the wstoken and url

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=1&userid=0&wsfunction=gradereport_overview_view_grade_report&wstoken=ffbe3a3002f235bf9d01fd9369e10b66'

      11. Then go to the system logs and check that you see a new entry: The user with id 'x' viewed the overview report in the gradebook. With origin: ws

      Now, we are going to check that there are not regressions in the report:

      1. Go to the Moodle site as student, in your profile (top right), display the menu and choose Grades
      2. Check that the final grades displayed there match with your single courses final grades (checking this in the gradebook for each course)
      3. Check that even in the courses where the Show rank option is set, you see always the number of users equal to 0 (this is because you are accessing the report via the system context)
      4. As a teacher, if you open the report from a course (via the Grades -> Overview report option), you should see correctly the user final grade and rank position
      5. You should also check that if you hide a course final grade as teacher or manager, the student shouldn't be able to see the grade in the report.
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Find a student user account enrolled in at least a couple of courses where he has a final grade Create a Token for the student user mentioned in the previous step: 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 and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=gradereport_overview_get_course_grades&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Now, check that in the response you see the same courses and grades that in Moodle web when clicking in the "Grades" option in the user contextual menu (top right). In one of the courses where the user has a grade, enable the Show rank option via the Overview report settings (/grade/edit/settings/index.php?id=COURSE_ID) Execute the WS again and check that you now receive a new field with the rank position, the num of users will be always 0 for the system context so you won't receive that value in the WS response Now, create a token for the site admin, and execute the curl command appending: &userid=STUDENT_ID (the student account user id), as admin, you should be able to see the student grades If you execute the last curl command using another student token, you'll get an error (no permissions) Now, to test that the viewed events are triggered, execute the following curl command replacing the wstoken and url curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=1&userid=0&wsfunction=gradereport_overview_view_grade_report&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' Then go to the system logs and check that you see a new entry: The user with id 'x' viewed the overview report in the gradebook. With origin: ws Now, we are going to check that there are not regressions in the report: Go to the Moodle site as student, in your profile (top right), display the menu and choose Grades Check that the final grades displayed there match with your single courses final grades (checking this in the gradebook for each course) Check that even in the courses where the Show rank option is set, you see always the number of users equal to 0 (this is because you are accessing the report via the system context) As a teacher, if you open the report from a course (via the Grades -> Overview report option), you should see correctly the user final grade and rank position You should also check that if you hide a course final grade as teacher or manager, the student shouldn't be able to see the grade in the report.
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-54854-master

      Description

      Retrieve the courses final grades for the given user.
      It will match the current "Grades" option in the user profile menu.

      Please, note that this WS does not cover all the functionalities from the user/overview/report, this WS is designed to return the course final grades in all the courses where he is enrolled, it can be used by admin/managers to retrieve other users final grades though.

      Information like numusers is not returned because is always 0 in the site context (this is not a bug, is how is designed the overview report)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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