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

Incorrect return parameters definition in core_grades_get_grades function

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Testing:

      Enable Web Services in Advanced features
      Enable Web services for mobile devices in Plugins / WebServices / Services

      Use this client: https://gist.github.com/jleyva/3ccf5a8540b0e2609d29
      The curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php

      You need a token related to a service, for get a token you need to create a new service, add a shortname to that service, and add the core_grade_get_grades function to that service

      Create Token:

      1. Click on Site administration ► Plugins ► Web services ► Manage tokens
      2. Click add, select user and service (You should get two tokens, one for student and one for teacher account)

      1 Create a new course, enrol the student and user used before
      2 As teacher, create a new assign (require a only text submission) as a the same student you used for getting the token, submit a text.
      3 Grade the submission as the teacher, now open the course gradebook -> Grader report. Turn editing on and edit the grade (click in the settings icon just above the grade value for the student/activity) Add some feedback there with some HTML formatting
      4 Edit the client.php for adding your custom tokens and Moodle URL, also the parameters required (courseid, userids with the student user id, and cmid for the assign module)
      5 Open the script in a browser
      6 The script returns a JSON object displaying the grade and feedback information correctly
      7 You can change the userid to a different id that the current user to test if you got permission errors, you should change alto the activityid to an existing activity, you should get errors also

      Show
      Testing: Enable Web Services in Advanced features Enable Web services for mobile devices in Plugins / WebServices / Services Use this client: https://gist.github.com/jleyva/3ccf5a8540b0e2609d29 The curl.php file is here: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/curl.php You need a token related to a service, for get a token you need to create a new service, add a shortname to that service, and add the core_grade_get_grades function to that service Create Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service (You should get two tokens, one for student and one for teacher account) 1 Create a new course, enrol the student and user used before 2 As teacher, create a new assign (require a only text submission) as a the same student you used for getting the token, submit a text. 3 Grade the submission as the teacher, now open the course gradebook -> Grader report. Turn editing on and edit the grade (click in the settings icon just above the grade value for the student/activity) Add some feedback there with some HTML formatting 4 Edit the client.php for adding your custom tokens and Moodle URL, also the parameters required (courseid, userids with the student user id, and cmid for the assign module) 5 Open the script in a browser 6 The script returns a JSON object displaying the grade and feedback information correctly 7 You can change the userid to a different id that the current user to test if you got permission errors, you should change alto the activityid to an existing activity, you should get errors also
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      If we use the core_grades_get_grades function for retrieving grade information with feedback formatted we get this error:

      {"exception":"invalid_response_exception","errorcode":"invalidresponse","message":"Invalid response value detected","debuginfo":"items => Invalid response value detected: grades => Invalid response value detected: str_feedback => Invalid response value detected: Invalid external api response: the value is \"<p><b>Feedback<\/b> information<\/p>\", the server was expecting \"text\" type"}
      

      This is because the return parameter in the WS definition is incorrect

      'str_feedback' => new external_value(
       311                                              PARAM_TEXT, 'A string representation of the feedback from the grader'),
      

      It should be PARAM_RAW instead PARAM_TEXT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Ankit Agarwal
              Integrator:
              Dan Poltawski
              Tester:
              John Okely
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Sep/14