LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
AssessmentControl.php
1<?php
2
3namespace ceLTIc\LTI\Service;
4
8
17{
18
24 public static $SCOPE = 'https://purl.imsglobal.org/spec/lti-ap/scope/control.all';
25
31 private $resourceLink = null;
32
39 public function __construct($resourceLink, $endpoint)
40 {
41 parent::__construct($resourceLink->getPlatform(), $endpoint);
42 $this->resourceLink = $resourceLink;
43 $this->scope = self::$SCOPE;
44 $this->mediaType = 'application/vnd.ims.lti-ap.v1.control+json';
45 }
46
56 public function submitAction($assessmentControlAction, $user, $attemptNumber)
57 {
58 $status = false;
59 $json = array(
60 'user' => array('iss' => $this->resourceLink->getPlatform()->platformId, 'sub' => $user->ltiUserId),
61 'resource_link' => array('id' => $this->resourceLink->ltiResourceLinkId),
62 'attempt_number' => $attemptNumber,
63 'action' => $assessmentControlAction->getAction(),
64 'incident_time' => $assessmentControlAction->getDate()->format('Y-m-d\TH:i:s\Z'),
65 'incident_severity' => $assessmentControlAction->getSeverity()
66 );
67 if (!empty($assessmentControlAction->extraTime)) {
68 $json['extra_time'] = $assessmentControlAction->extraTime;
69 }
70 if (!empty($assessmentControlAction->code)) {
71 $json['reason_code'] = $assessmentControlAction->code;
72 }
73 if (!empty($assessmentControlAction->message)) {
74 $json['reason_msg'] = $assessmentControlAction->message;
75 }
76 $data = json_encode($json);
77 $http = $this->send('POST', null, $data);
78 if ($http->ok) {
79 $http->ok = !empty($http->responseJson->status);
80 if ($http->ok) {
81 $status = $http->responseJson->status;
82 }
83 }
84
85 return $status;
86 }
87
88}
Class to represent an assessment control action.
Class to implement the Assessment Control service.
__construct($resourceLink, $endpoint)
Class constructor.
submitAction($assessmentControlAction, $user, $attemptNumber)
Submit an assessment control action.
Class to implement a service.
Definition Service.php:19
send($method, $parameters=array(), $body=null)
Send a service request.
Definition Service.php:119
$endpoint
Service endpoint.
Definition Service.php:33
Class to represent a platform user.
Definition User.php:13