89 if ($this->availability == 0) {
111 $xml = simplexml_load_file(
'php://input');
112 $this->message_ref_id = (string)
$xml->imsx_POXHeader->imsx_POXRequestHeaderInfo->imsx_messageIdentifier;
113 $request = current(
$xml->imsx_POXBody->children());
114 $this->operation = str_replace(
'Request',
'', $request->getName());
119 if (empty($this->result)) {
136 if (
$result instanceof Exception) {
142 switch ($this->operation) {
147 case 'replaceResult':
161 }
catch (Exception $exception) {
178 header(
'Content-type: application/xml');
188 $result = (string) $request->resultRecord->result->resultScore->textString;
191 $severity =
"status";
192 $description =
"The result is not a number.";
193 } elseif ($result < 0 or $result > 1) {
195 $severity =
"status";
196 $description =
"The result is out of range from 0 to 1.";
198 $this->result->result = (float)
$result;
199 $this->result->save();
201 #if ($result >= $this->getMasteryScore())
203 # $lp_status = ilLTIConsumerLPStatus::LP_STATUS_COMPLETED_NUM;
207 # $lp_status = ilLTIConsumerLPStatus::LP_STATUS_FAILED_NUM;
209 #$lp_percentage = 100 * $result;
210 #ilLTIConsumerLPStatus::trackResult($this->result->usr_id, $this->result->obj_id, $lp_status, $lp_percentage);
213 $severity =
"status";
214 $description = sprintf(
"Score for %s is now %s", $this->result->id, $this->result->result);
225 header(
'Content-type: application/xml');
235 $this->result->result =
null;
236 $this->result->save();
238 #$lp_status = ilLTIConsumerLPStatus::LP_STATUS_IN_PROGRESS_NUM;
240 #ilLTIConsumerLPStatus::trackResult($this->result->usr_id, $this->result->obj_id, $lp_status, $lp_percentage);
243 $severity =
"status";
252 header(
'Content-type: application/xml');
264 return file_get_contents(
'./Modules/LTIConsumer/responses/' . $a_name);
279 header(
'Content-type: application/xml');
293 header(
'Content-type: application/xml');
304 header(
'HTTP/1.1 400 Bad Request');
305 header(
'Content-type: text/plain');
309 echo
'This is not a well-formed LTI Basic Outcomes Service request.';
321 header(
'HTTP/1.1 401 Unauthorized');
322 header(
'Content-type: text/plain');
326 echo
'This request could not be authorized.';
341 SELECT lti_ext_provider.availability, lti_consumer_settings.mastery_score
342 FROM lti_ext_provider, lti_consumer_settings
343 WHERE lti_ext_provider.id = lti_consumer_settings.provider_id
344 AND lti_consumer_settings.obj_id = %s
347 $res =
$DIC->database()->queryF(
$query, array(
'integer'), array($a_obj_id));
349 if ($row =
$DIC->database()->fetchAssoc(
$res)) {
366 SELECT lti_ext_provider.provider_key, lti_ext_provider.provider_secret, lti_consumer_settings.launch_key, lti_consumer_settings.launch_secret
367 FROM lti_ext_provider, lti_consumer_settings
368 WHERE lti_ext_provider.id = lti_consumer_settings.provider_id
369 AND lti_consumer_settings.obj_id = %s
372 $res =
$DIC->database()->queryF(
$query, array(
'integer'), array($a_obj_id));
374 while ($row =
$DIC->database()->fetchAssoc(
$res)) {
375 if (strlen($row[
"launch_key"] > 0)) {
376 $this->
fields[
"KEY"] = $row[
"launch_key"];
378 $this->
fields[
"KEY"] = $row[
"provider_key"];
380 if (strlen($row[
"launch_key"] > 0)) {
381 $this->
fields[
"SECRET"] = $row[
"launch_secret"];
383 $this->
fields[
"SECRET"] = $row[
"provider_secret"];
394 require_once(
'./Modules/LTIConsumer/lib/OAuth.php');
395 require_once(
'./Modules/LTIConsumer/lib/TrivialOAuthDataStore.php');
402 $server->add_signature_method($method);
406 $server->verify_request($request);
407 }
catch (Exception
$e) {
An exception for terminatinating execution or to throw for unit testing.
static from_request($http_method=null, $http_url=null, $parameters=null)
attempt to build up a request from what was passed to the server
A Trivial memory-based store - no support for tokens.
static getInstanceByToken($token)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
deleteResult($request)
Delete a stored result.
setMasteryScore(float $mastery_score)
readResult($request)
Read a stored result.
respondUnauthorized($message=null)
Send an "unauthorized" response.
handleRequest()
Handle an incoming request from the LTI tool provider.
respondBadRequest($message=null)
Send a "bad request" response.
__construct()
Constructor: general initialisations.
respondUnsupported()
Send a response that the operation is not supported This depends on the status of the object.
loadResponse($a_name)
Load the XML template for the response.
readFields($a_obj_id)
Read the LTI Consumer object fields.
readProperties($a_obj_id)
Read the LTI Consumer object properties.
replaceResult($request)
Replace a stored result.
setAvailability(int $availability)
checkSignature($a_key, $a_secret)
Check the reqest signature.
respondUnknown()
Send a "unknown operation" response.
static getByKeys($a_obj_id, $a_usr_id, $a_create=false)
Get a result by object and user key.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
foreach($_POST as $key=> $value) $res