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

Some gradebook external services have uncallable execute methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.1.5, 4.2.2
    • 4.1.4, 4.2
    • Gradebook
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78872-401
    • Hide

      Setup

      1. Log in as admin
      2. Enable and configure webservices
      3. Create a token for the admin user
      4. Create a course
        • Note it's ID (course/view.php?id=<COURSEID>)

      Master/402

      1. Execute the following:

        $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=gradereport_grader_get_users_in_report&courseid=<COURSEID>" | python -m "json.tool"
        

      2. Confirm it doesn't return an exception
      3. Execute the following:

        $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=core_grades_get_groups_for_selector&courseid=<COURSEID>" | python -m "json.tool"
        

      4. Confirm it doesn't return an exception

      401

      1. Execute the following:

        $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=core_grades_get_groups_for_search_widget&actionbaseurl=http://example.com&courseid=<COURSEID>" | python -m "json.tool"
        

      2. Confirm it doesn't return an exception
      Show
      Setup Log in as admin Enable and configure webservices Create a token for the admin user Create a course Note it's ID ( course/view.php?id=<COURSEID> ) Master/402 Execute the following: $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=gradereport_grader_get_users_in_report&courseid=<COURSEID>" | python -m "json.tool" Confirm it doesn't return an exception Execute the following: $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=core_grades_get_groups_for_selector&courseid=<COURSEID>" | python -m "json.tool" Confirm it doesn't return an exception 401 Execute the following: $ curl --silent "<WWWROOT>/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=<TOKEN>&wsfunction=core_grades_get_groups_for_search_widget&actionbaseurl=http://example.com&courseid=<COURSEID>" | python -m "json.tool" Confirm it doesn't return an exception

      Found on another issue:

      $ git grep "protected static function execute"
      grade/classes/external/get_groups_for_search_widget.php:    protected static function execute(int $courseid, string $actionbaseurl): array {
      grade/classes/external/get_groups_for_selector.php:    protected static function execute(int $courseid): array {
      grade/report/grader/classes/external/get_users_in_report.php:    protected static function execute(int $courseid): array {
      

      The problem is that each method adds itself to the Moodle mobile service, but is impossible to actually call due to the method visibility:

      $ curl --silent "http://localhost:8000/webservice/rest/server.php?moodlewsrestformat=json" --data "wstoken=7e5286681acdad9312994c188ec92766&wsfunction=gradereport_grader_get_users_in_report&courseid=2" | python -m "json.tool"
      {
          "exception": "TypeError",
          "message": "call_user_func_array(): Argument #1 ($callback) must be a valid callback, cannot access protected method gradereport_grader\\external\\get_users_in_report::execute()"
      }
      

      We should fix that

      https://github.com/moodle/moodle/blob/a1d5d1b2f758a3178bff4c42883a477f4b1ea50c/lib/db/services.php#L980-L995
      https://github.com/moodle/moodle/blob/a1d5d1b2f758a3178bff4c42883a477f4b1ea50c/grade/report/grader/db/services.php#L35

            pholden Paul Holden
            pholden Paul Holden
            Glyn (Mathew) May Glyn (Mathew) May
            Jun Pataleta Jun Pataleta
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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