3declare(strict_types=1);
79 if ($this->availability == 0) {
92 $xml = simplexml_load_file(
'php://input');
93 $this->message_ref_id = (string)
$xml->imsx_POXHeader->imsx_POXRequestHeaderInfo->imsx_messageIdentifier;
94 $request = current(
$xml->imsx_POXBody->children());
95 $this->operation = str_replace(
'Request',
'', $request->getName());
100 if (empty($this->result)) {
117 if ($result instanceof Exception) {
123 switch ($this->operation) {
128 case 'replaceResult':
142 }
catch (Exception $exception) {
150 protected function readResult(\SimpleXMLElement $request): void
153 $response = str_replace(
'{message_id}', md5((
string) rand(0, 999_999_999)),
$response);
158 header(
'Content-type: application/xml');
167 $result = (string) $request->resultRecord->result->resultScore->textString;
170 $severity =
"status";
171 $description =
"The result is not a number.";
172 } elseif ($result < 0 or $result > 1) {
174 $severity =
"status";
175 $description =
"The result is out of range from 0 to 1.";
177 $this->result->result = (float)
$result;
178 $this->result->
save();
191 $severity =
"status";
192 $description = sprintf(
"Score for %s is now %s", $this->result->id, $this->result->result);
196 $response = str_replace(
'{message_id}', md5((
string) rand(0, 999_999_999)),
$response);
203 header(
'Content-type: application/xml');
212 $this->result->result =
null;
213 $this->result->save();
220 $severity =
"status";
223 $response = str_replace(
'{message_id}', md5((
string) rand(0, 999_999_999)),
$response);
229 header(
'Content-type: application/xml');
241 return file_get_contents(
'./Modules/LTIConsumer/responses/' . $a_name);
252 $response = str_replace(
'{message_id}', md5((
string) rand(0, 999_999_999)),
$response);
256 header(
'Content-type: application/xml');
266 $response = str_replace(
'{message_id}', md5((
string) rand(0, 999_999_999)),
$response);
270 header(
'Content-type: application/xml');
279 header(
'HTTP/1.1 400 Bad Request');
280 header(
'Content-type: text/plain');
284 echo
'This is not a well-formed LTI Basic Outcomes Service request.';
294 header(
'HTTP/1.1 401 Unauthorized');
295 header(
'Content-type: text/plain');
299 echo
'This request could not be authorized.';
311 SELECT lti_ext_provider.availability, lti_consumer_settings.mastery_score
312 FROM lti_ext_provider, lti_consumer_settings
313 WHERE lti_ext_provider.id = lti_consumer_settings.provider_id
314 AND lti_consumer_settings.obj_id = %s
317 $res =
$DIC->database()->queryF(
$query, array(
'integer'), array($a_obj_id));
319 if ($row =
$DIC->database()->fetchAssoc(
$res)) {
334 SELECT lti_ext_provider.provider_key, lti_ext_provider.provider_secret, lti_consumer_settings.launch_key, lti_consumer_settings.launch_secret
335 FROM lti_ext_provider, lti_consumer_settings
336 WHERE lti_ext_provider.id = lti_consumer_settings.provider_id
337 AND lti_consumer_settings.obj_id = %s
340 $res =
$DIC->database()->queryF(
$query, array(
'integer'), array($a_obj_id));
342 while ($row =
$DIC->database()->fetchAssoc(
$res)) {
343 if (strlen($row[
"launch_key"]) > 0) {
344 $this->
fields[
"KEY"] = $row[
"launch_key"];
346 $this->
fields[
"KEY"] = $row[
"provider_key"];
348 if (strlen($row[
"launch_key"]) > 0) {
349 $this->
fields[
"SECRET"] = $row[
"launch_secret"];
351 $this->
fields[
"SECRET"] = $row[
"provider_secret"];
363 $store->add_consumer($a_key, $a_secret);
366 $method = new \ILIAS\LTIOAuth\OAuthSignatureMethod_HMAC_SHA1();
367 $server->add_signature_method($method);
369 $request = \ILIAS\LTIOAuth\OAuthRequest::from_request();
371 $server->verify_request($request);
372 }
catch (Exception
$e) {
A Trivial memory-based store - no support for tokens.
static getInstanceByToken(string $token)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static writeStatus(int $a_obj_id, int $a_user_id, int $a_status, int $a_percentage=0, bool $a_force_per=false, ?int &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
Write status for user and object.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
readFields(int $a_obj_id)
Read the LTI Consumer object fields.
setMasteryScore(float $mastery_score)
checkSignature(string $a_key, string $a_secret)
Check the reqest signature.
readProperties(int $a_obj_id)
Read the LTI Consumer object properties.
handleRequest()
Handle an incoming request from the LTI tool provider.
respondBadRequest(?string $message=null)
Send a "bad request" response.
respondUnsupported()
Send a response that the operation is not supported This depends on the status of the object.
respondUnauthorized(?string $message=null)
Send an "unauthorized" response.
loadResponse($a_name)
Load the XML template for the response.
replaceResult(\SimpleXMLElement $request)
Replace a stored result.
ilLTIConsumerResult $result
setAvailability(int $availability)
readResult(\SimpleXMLElement $request)
Read a stored result.
respondUnknown()
Send a "unknown operation" response.
deleteResult(\SimpleXMLElement $request)
Delete a stored result.
static getByKeys(int $a_obj_id, int $a_usr_id, ?bool $a_create=false)
Get a result by object and user key.
save()
Save a result object.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...