ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
XapiProxy\XapiProxyPolyFill Class Reference
+ Inheritance diagram for XapiProxy\XapiProxyPolyFill:
+ Collaboration diagram for XapiProxy\XapiProxyPolyFill:

Public Member Functions

 __construct (string $client, string $token, ?bool $plugin=false)
 
 log ()
 
 msg (string $msg)
 
 initLrs ()
 

Data Fields

const PARTS_REG = '/^(.*?xapiproxy\.php)(\/([^?]+)?\??(.*))/'
 
const TERMINATED_VERB = "http://adlnet.gov/expapi/verbs/terminated"
 

Protected Attributes

string $client
 
string $token
 
bool $plugin = false
 
string $table_prefix
 
ilCmiXapiLrsType $lrsType = null
 
ilCmiXapiAuthToken $authToken = null
 
int $objId = null
 
array $specificAllowedStatements = null
 
array $replacedValues = null
 
bool $blockSubStatements = false
 
array $cmdParts = []
 
string $method
 
string $defaultLrsEndpoint = ''
 
string $defaultLrsKey = ''
 
string $defaultLrsSecret = ''
 
string $fallbackLrsEndpoint = ''
 
string $fallbackLrsKey = ''
 
string $fallbackLrsSecret = ''
 
array $sniffVerbs
 

Private Member Functions

 getLrsType ()
 
 getLrsTypeAndMoreByToken ()
 hybrid function, maybe two distinct functions would be better? More...
 

Detailed Description

Definition at line 23 of file XapiProxyPolyFill.php.

Constructor & Destructor Documentation

◆ __construct()

XapiProxy\XapiProxyPolyFill::__construct ( string  $client,
string  $token,
?bool  $plugin = false 
)

Reimplemented in XapiProxy\XapiProxy.

Definition at line 58 of file XapiProxyPolyFill.php.

59 {
60 $this->client = $client;
61 $this->token = $token;
62 $this->plugin = $plugin;
63 $this->table_prefix = $this->plugin ? "xxcf" : "cmix";
64 preg_match(self::PARTS_REG, (string) $GLOBALS['DIC']->http()->request()->getUri(), $this->cmdParts);
65 $this->method = strtolower($GLOBALS['DIC']->http()->request()->getMethod());
66 }
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:54

References $client, $GLOBALS, XapiProxy\$plugin, $token, ILIAS\UI\examples\Progress\Bar\client(), and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

Member Function Documentation

◆ getLrsType()

XapiProxy\XapiProxyPolyFill::getLrsType ( )
private
Returns
\ilCmiXapiLrsType|void|null

Definition at line 102 of file XapiProxyPolyFill.php.

103 { // Core new > 6
104 try {
106 $this->defaultLrsEndpoint = $lrsType->getLrsEndpoint();
107 $this->defaultLrsKey = $lrsType->getLrsKey();
108 $this->defaultLrsSecret = $lrsType->getLrsSecret();
109 $this->lrsType = $lrsType;
110 // one query IS better :-)
111 // $lrsType = new ilCmiXapiLrsType($authToken->getLrsTypeId());
112 $objId = $this->authToken->getObjId();
113 $this->objId = $objId;
114 if (!$lrsType->isAvailable()) {
115 throw new \ilCmiXapiException(
116 'lrs endpoint (id=' . $this->authToken->getLrsTypeId() . ') unavailable (responded 401-unauthorized)'
117 );
118 }
119 } catch (\ilCmiXapiException $e) {
120 $this->log()->error($this->msg($e->getMessage()));
121 header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
122 header('Access-Control-Allow-Credentials: true');
123 header('HTTP/1.1 401 Unauthorized');
124 exit;
125 }
126 \ilCmiXapiUser::saveProxySuccess($this->authToken->getObjId(), $this->authToken->getUsrId(), $this->lrsType->getPrivacyIdent());
127 return $lrsType;
128 }
getLrsTypeAndMoreByToken()
hybrid function, maybe two distinct functions would be better?
static saveProxySuccess(int $objId, int $usrId, int $privacyIdent)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER, Vendor\Package\$e, $objId, exit, ILIAS\UI\examples\Symbol\Glyph\Header\header(), and ilCmiXapiUser\saveProxySuccess().

+ Here is the call graph for this function:

◆ getLrsTypeAndMoreByToken()

XapiProxy\XapiProxyPolyFill::getLrsTypeAndMoreByToken ( )
private

hybrid function, maybe two distinct functions would be better?

Returns
\ilCmiXapiLrsType|null

Definition at line 134 of file XapiProxyPolyFill.php.

135 {
136 $type_id = null;
137 $lrs = null;
138 $db = $GLOBALS['DIC']->database();
139 $query = "SELECT {$this->table_prefix}_settings.lrs_type_id,
140 {$this->table_prefix}_settings.only_moveon,
141 {$this->table_prefix}_settings.achieved,
142 {$this->table_prefix}_settings.answered,
143 {$this->table_prefix}_settings.completed,
144 {$this->table_prefix}_settings.failed,
145 {$this->table_prefix}_settings.initialized,
146 {$this->table_prefix}_settings.passed,
147 {$this->table_prefix}_settings.progressed,
148 {$this->table_prefix}_settings.satisfied,
149 {$this->table_prefix}_settings.c_terminated,
150 {$this->table_prefix}_settings.hide_data,
151 {$this->table_prefix}_settings.c_timestamp,
152 {$this->table_prefix}_settings.duration,
153 {$this->table_prefix}_settings.no_substatements,
154 {$this->table_prefix}_settings.privacy_ident
155 FROM {$this->table_prefix}_settings, {$this->table_prefix}_token
156 WHERE {$this->table_prefix}_settings.obj_id = {$this->table_prefix}_token.obj_id AND {$this->table_prefix}_token.token = " . $db->quote($this->token, 'text');
157
158 $res = $db->query($query);
159 while ($row = $db->fetchObject($res)) {
160 $type_id = (int) $row->lrs_type_id;
161 if ($type_id) {
162 // $lrs = ($this->plugin) ? new \ilXapiCmi5LrsType($type_id) : new \ilCmiXapiLrsType($type_id);
163 $lrs = new \ilCmiXapiLrsType($type_id);
164 }
165
166 $sarr = [];
167 if ((bool) $row->only_moveon) {
168 if ((bool) $row->achieved) {
169 $sarr[] = "https://w3id.org/xapi/dod-isd/verbs/achieved";
170 }
171 if ((bool) $row->answered) {
172 $sarr[] = "http://adlnet.gov/expapi/verbs/answered";
173 $sarr[] = "https://w3id.org/xapi/dod-isd/verbs/answered";
174 }
175 if ((bool) $row->completed) {
176 $sarr[] = "http://adlnet.gov/expapi/verbs/completed";
177 $sarr[] = "https://w3id.org/xapi/dod-isd/verbs/completed";
178 }
179 if ((bool) $row->failed) {
180 $sarr[] = "http://adlnet.gov/expapi/verbs/failed";
181 }
182 if ((bool) $row->initialized) {
183 $sarr[] = "http://adlnet.gov/expapi/verbs/initialized";
184 $sarr[] = "https://w3id.org/xapi/dod-isd/verbs/initialized";
185 }
186 if ((bool) $row->passed) {
187 $sarr[] = "http://adlnet.gov/expapi/verbs/passed";
188 }
189 if ((bool) $row->progressed) {
190 $sarr[] = "http://adlnet.gov/expapi/verbs/progressed";
191 }
192 if ((bool) $row->satisfied) {
193 $sarr[] = "https://w3id.org/xapi/adl/verbs/satisfied";
194 }
195 if ((bool) $row->c_terminated) {
196 $sarr[] = "http://adlnet.gov/expapi/verbs/terminated";
197 }
198 if (count($sarr) > 0) {
199 $this->specificAllowedStatements = $sarr;
200 $this->log()->debug($this->msg('getSpecificAllowedStatements: ' . var_export($this->specificAllowedStatements, true)));
201 }
202 }
203 if ((bool) $row->hide_data) {
204 $rarr = array();
205 if ((bool) $row->c_timestamp) {
206 $rarr['timestamp'] = '1970-01-01T00:00:00.000Z';
207 }
208 if ((bool) $row->duration) {
209 $rarr['result.duration'] = 'PT00.000S';
210 }
211 if (count($rarr) > 0) {
212 $this->replacedValues = $rarr;
213 $this->log()->debug($this->msg('getReplacedValues: ' . var_export($this->replacedValues, true)));
214 }
215 }
216 if ((bool) $row->no_substatements) {
217 $this->blockSubStatements = true;
218 $this->log()->debug($this->msg('getBlockSubStatements: ' . $this->blockSubStatements));
219 }
220 $lrs->setPrivacyIdent((int) $row->privacy_ident);
221 }
222 return $lrs;
223 }
$res
Definition: ltiservices.php:69
if(!file_exists('../ilias.ini.php'))

References $GLOBALS, $res, if, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ initLrs()

XapiProxy\XapiProxyPolyFill::initLrs ( )

Definition at line 82 of file XapiProxyPolyFill.php.

82 : void
83 {
84 $this->log()->debug($this->msg('initLrs'));
85 try {
87 } catch (\ilCmiXapiException $e) {
88 $this->log()->error($this->msg($e->getMessage()));
89 header('HTTP/1.1 401 Unauthorized');
90 header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
91 header('Access-Control-Allow-Credentials: true');
92 exit;
93 }
94
95 $this->authToken = $authToken;
96 $this->getLrsType();
97 }
static getInstanceByToken(string $token)

References $_SERVER, Vendor\Package\$e, exit, ilCmiXapiAuthToken\getInstanceByToken(), and ILIAS\UI\examples\Symbol\Glyph\Header\header().

+ Here is the call graph for this function:

◆ log()

XapiProxy\XapiProxyPolyFill::log ( )

Definition at line 68 of file XapiProxyPolyFill.php.

68 : \ilLogger
69 {
70 return \ilLoggerFactory::getLogger('cmix');
71 }
Component logger with individual log levels by component id.

◆ msg()

XapiProxy\XapiProxyPolyFill::msg ( string  $msg)

Definition at line 73 of file XapiProxyPolyFill.php.

73 : string
74 {
75 if ($this->plugin) {
76 return "XapiCmi5Plugin: " . $msg;
77 } else {
78 return $msg;
79 }
80 }

Field Documentation

◆ $authToken

ilCmiXapiAuthToken XapiProxy\XapiProxyPolyFill::$authToken = null
protected

Definition at line 31 of file XapiProxyPolyFill.php.

◆ $blockSubStatements

bool XapiProxy\XapiProxyPolyFill::$blockSubStatements = false
protected

Definition at line 35 of file XapiProxyPolyFill.php.

◆ $client

string XapiProxy\XapiProxyPolyFill::$client
protected

Definition at line 25 of file XapiProxyPolyFill.php.

◆ $cmdParts

array XapiProxy\XapiProxyPolyFill::$cmdParts = []
protected

Definition at line 36 of file XapiProxyPolyFill.php.

◆ $defaultLrsEndpoint

string XapiProxy\XapiProxyPolyFill::$defaultLrsEndpoint = ''
protected

Definition at line 39 of file XapiProxyPolyFill.php.

◆ $defaultLrsKey

string XapiProxy\XapiProxyPolyFill::$defaultLrsKey = ''
protected

Definition at line 40 of file XapiProxyPolyFill.php.

◆ $defaultLrsSecret

string XapiProxy\XapiProxyPolyFill::$defaultLrsSecret = ''
protected

Definition at line 41 of file XapiProxyPolyFill.php.

◆ $fallbackLrsEndpoint

string XapiProxy\XapiProxyPolyFill::$fallbackLrsEndpoint = ''
protected

Definition at line 43 of file XapiProxyPolyFill.php.

◆ $fallbackLrsKey

string XapiProxy\XapiProxyPolyFill::$fallbackLrsKey = ''
protected

Definition at line 44 of file XapiProxyPolyFill.php.

◆ $fallbackLrsSecret

string XapiProxy\XapiProxyPolyFill::$fallbackLrsSecret = ''
protected

Definition at line 45 of file XapiProxyPolyFill.php.

◆ $lrsType

ilCmiXapiLrsType XapiProxy\XapiProxyPolyFill::$lrsType = null
protected

Definition at line 30 of file XapiProxyPolyFill.php.

◆ $method

string XapiProxy\XapiProxyPolyFill::$method
protected

Definition at line 37 of file XapiProxyPolyFill.php.

◆ $objId

int XapiProxy\XapiProxyPolyFill::$objId = null
protected

Definition at line 32 of file XapiProxyPolyFill.php.

◆ $plugin

bool XapiProxy\XapiProxyPolyFill::$plugin = false
protected

Definition at line 28 of file XapiProxyPolyFill.php.

◆ $replacedValues

array XapiProxy\XapiProxyPolyFill::$replacedValues = null
protected

Definition at line 34 of file XapiProxyPolyFill.php.

◆ $sniffVerbs

array XapiProxy\XapiProxyPolyFill::$sniffVerbs
protected
Initial value:
= array(
"http://adlnet.gov/expapi/verbs/completed" => "completed",
"http://adlnet.gov/expapi/verbs/passed" => "passed",
"http://adlnet.gov/expapi/verbs/failed" => "failed",
"http://adlnet.gov/expapi/verbs/satisfied" => "passed"
)

Definition at line 49 of file XapiProxyPolyFill.php.

◆ $specificAllowedStatements

array XapiProxy\XapiProxyPolyFill::$specificAllowedStatements = null
protected

Definition at line 33 of file XapiProxyPolyFill.php.

◆ $table_prefix

string XapiProxy\XapiProxyPolyFill::$table_prefix
protected

Definition at line 29 of file XapiProxyPolyFill.php.

◆ $token

string XapiProxy\XapiProxyPolyFill::$token
protected

Definition at line 26 of file XapiProxyPolyFill.php.

◆ PARTS_REG

const XapiProxy\XapiProxyPolyFill::PARTS_REG = '/^(.*?xapiproxy\.php)(\/([^?]+)?\??(.*))/'

Definition at line 47 of file XapiProxyPolyFill.php.

◆ TERMINATED_VERB

const XapiProxy\XapiProxyPolyFill::TERMINATED_VERB = "http://adlnet.gov/expapi/verbs/terminated"

Definition at line 56 of file XapiProxyPolyFill.php.


The documentation for this class was generated from the following file: