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

Improve the error handling of the LTI service handler

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Pre-conditions:

      1. Go to Home / Site administration / Plugins / Activity modules / LTI / Manage external tool types
      2. Add an external tool:
        • Ensure that the tool URL is set to: http://ltiapps.net/test/tp.php
        • Ensure the Consumer key is set to: consumerkey
        • Ensure the Shared secret is set to: secret
      3. Click Save changes.

      Use Case:

      Must test on a publicly available site. (e.g. through ngrok) The following only tests that the error handling works properly. It doesn't test every single change made.

      1. Go to a course and add an External tool. Ensure the following are set for the tool:
      2. Click Save and display. This will launch to the tool in a new window. Keep this window open
      3. Go back to your External tool, edit the settings, and uncheck Accept grades from the tool under the Privacy section. Click Save and return to course
      4. Go back to the window where we launched to the tool.
      5. Click on the Outcomes button.
      6. Click on the Update button. Enter 1 in the modal that appears. Then press OK.
      7. Wait for a couple of seconds for the response modal to show. The contents of the response modal should look something like:

        HTTP/1.1 200
        Content-Type: text/html; charset=utf-8
        Date: Fri, 25 Sep 2015 20:43:34 GMT
        Server: Apache/2.4.7 (Ubuntu)
        X-Powered-By: PHP/5.5.9-1ubuntu4
        Content-Length: 769
        Connection: keep-alive
         
        <?xml version="1.0" encoding="UTF-8"?>
        <imsx_POXEnvelopeResponse xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0"><imsx_POXHeader><imsx_POXResponseHeaderInfo><imsx_version>V1.0</imsx_version><imsx_messageIdentifier>696871276</imsx_messageIdentifier><imsx_statusInfo><imsx_codeMajor>failure</imsx_codeMajor><imsx_severity>status</imsx_severity><imsx_description>Tool does not accept grades
        * line 94 of /mod/lti/service.php: Exception thrown
        </imsx_description><imsx_messageRefIdentifier>5605b1f78d122</imsx_messageRefIdentifier><imsx_operationRefIdentifier>replaceResultRequest</imsx_operationRefIdentifier></imsx_statusInfo></imsx_POXResponseHeaderInfo></imsx_POXHeader><imsx_POXBody><replaceResultResponse/></imsx_POXBody></imsx_POXEnvelopeResponse>
        

      Before this fix, the response modal would show a HTML document instead of a XML document.

      In addition, run the unit tests.

      Show
      Pre-conditions: Go to Home / Site administration / Plugins / Activity modules / LTI / Manage external tool types Add an external tool: Ensure that the tool URL is set to: http://ltiapps.net/test/tp.php Ensure the Consumer key is set to: consumerkey Ensure the Shared secret is set to: secret Click Save changes. Use Case: Must test on a publicly available site. (e.g. through ngrok) The following only tests that the error handling works properly. It doesn't test every single change made. Go to a course and add an External tool. Ensure the following are set for the tool: Launch url: http://ltiapps.net/test/tp.php Launch container: New window Under Privacy, Accept grades from the tool should be checked . Click Save and display . This will launch to the tool in a new window. Keep this window open Go back to your External tool, edit the settings, and uncheck Accept grades from the tool under the Privacy section. Click Save and return to course Go back to the window where we launched to the tool. Click on the Outcomes button. Click on the Update button. Enter 1 in the modal that appears. Then press OK. Wait for a couple of seconds for the response modal to show. The contents of the response modal should look something like: HTTP/1.1 200 Content-Type: text/html; charset=utf-8 Date: Fri, 25 Sep 2015 20:43:34 GMT Server: Apache/2.4.7 (Ubuntu) X-Powered-By: PHP/5.5.9-1ubuntu4 Content-Length: 769 Connection: keep-alive   <?xml version="1.0" encoding="UTF-8"?> <imsx_POXEnvelopeResponse xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0"><imsx_POXHeader><imsx_POXResponseHeaderInfo><imsx_version>V1.0</imsx_version><imsx_messageIdentifier>696871276</imsx_messageIdentifier><imsx_statusInfo><imsx_codeMajor>failure</imsx_codeMajor><imsx_severity>status</imsx_severity><imsx_description>Tool does not accept grades * line 94 of /mod/lti/service.php: Exception thrown </imsx_description><imsx_messageRefIdentifier>5605b1f78d122</imsx_messageRefIdentifier><imsx_operationRefIdentifier>replaceResultRequest</imsx_operationRefIdentifier></imsx_statusInfo></imsx_POXResponseHeaderInfo></imsx_POXHeader><imsx_POXBody><replaceResultResponse/></imsx_POXBody></imsx_POXEnvelopeResponse> Before this fix, the response modal would show a HTML document instead of a XML document. In addition, run the unit tests.
    • Affected Branches:
      MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull Master Branch:
      MDL-51571_ltiErrorHandler

      Description

      The mod/lti/service.php should be returning errors as XML so that the tool provider can handle them appropriately and display the error to the end user, log the error, or whatever.

      Currently though, there are several areas where exceptions are throw which are handled by Moodle's default exception handler which then produces a HTML document.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16