// This will allow others to extend the LTI services, which I expect to be a common // use case, at least until the spec matures. $data = new stdClass(); $data->body = $rawbody; $data->xml = $xml; $data->messageid = lti_parse_message_id($xml); $data->messagetype = $messagetype; $data->consumerkey = $consumerkey; $data->sharedsecret = $sharedsecret; $eventdata = array(); $eventdata['other'] = array(); $eventdata['other']['messageid'] = $data->messageid; $eventdata['other']['messagetype'] = $messagetype; $eventdata['other']['consumerkey'] = $consumerkey; // Before firing the event, allow subplugins a chance to handle. if (lti_extend_lti_services($data)) { break; } // If an event handler handles the web service, it should set this global to true // So this code knows whether to send an "operation not supported" or not. global $ltiwebservicehandled; $ltiwebservicehandled = false; try { $event = \mod_lti\event\unknown_service_api_called::create($eventdata); $event->set_message_data($data); $event->trigger(); } catch (Exception $e) { $ltiwebservicehandled = false; } if (!$ltiwebservicehandled) { $responsexml = lti_get_response_xml('unsupported', 'unsupported', lti_parse_message_id($xml), $messagetype);
$responsexml = lti_get_response_xml($gradestatus ? 'success' : 'failure', 'Grade delete request', $parsed->messageid, 'deleteResultResponse'); echo $responsexml->asXML(); break; default: //Fire an event if we get a web service request which we don't support directly. //This will allow others to extend the LTI services, which I expect to be a common //use case, at least until the spec matures. $eventdata = array(); $eventdata['other'] = array(); $eventdata['other']['body'] = $rawbody; $eventdata['other']['messageid'] = lti_parse_message_id($xml); $eventdata['other']['messagetype'] = $messagetype; $eventdata['other']['consumerkey'] = $consumerkey; $eventdata['other']['sharedsecret'] = $sharedsecret; // Before firing the event, allow subplugins a chance to handle. if (lti_extend_lti_services((object) $eventdata['other'])) { break; } //If an event handler handles the web service, it should set this global to true //So this code knows whether to send an "operation not supported" or not. global $lti_web_service_handled; $lti_web_service_handled = false; try { $event = \mod_lti\event\unknown_service_api_called::create($eventdata); $event->trigger(); } catch (Exception $e) { $lti_web_service_handled = false; } if (!$lti_web_service_handled) { $responsexml = lti_get_response_xml('unsupported', 'unsupported', lti_parse_message_id($xml), $messagetype); echo $responsexml->asXML();