ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSoapSCORMAdministration.php
Go to the documentation of this file.
1<?php
25{
29 public function getIMSManifestXML(string $sid, int $requested_ref_id)
30 {
31 $this->initAuth($sid);
32 $this->initIlias();
33
34 if (!$this->checkSession($sid)) {
35 return $this->raiseError($this->getMessage(), $this->getMessageCode());
36 }
37 if (!($requested_ref_id > 0)) {
38 return $this->raiseError(
39 'No ref id given. Aborting!',
40 'Client'
41 );
42 }
43 global $DIC;
44
45 $rbacsystem = $DIC['rbacsystem'];
46 $tree = $DIC['tree'];
47 $ilLog = $DIC['ilLog'];
48
50 return $this->raiseError(
51 'No exercise found for id: ' . $requested_ref_id,
52 'Client'
53 );
54 }
55
57 return $this->raiseError("Parent with ID $requested_ref_id has been deleted.", 'Client');
58 }
59
60 $permission_ok = false;
61 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
62 if ($rbacsystem->checkAccess('read', $ref_id)) {
63 $permission_ok = true;
64 break;
65 }
66 }
67
68 if (!$permission_ok) {
69 return $this->raiseError(
70 'No permission to read the object with id: ' . $requested_ref_id,
71 'Server'
72 );
73 }
74
75 $lm_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
76 if (!is_object($lm_obj) || $lm_obj->getType() !== "sahs") {
77 return $this->raiseError(
78 'Wrong obj id or type for scorm object with id ' . $requested_ref_id,
79 'Server'
80 );
81 }
82
83 $imsFilename = $lm_obj->getDataDirectory() . DIRECTORY_SEPARATOR . "imsmanifest.xml";
84
85 if (!file_exists($imsFilename)) {
86 return $this->raiseError(
87 'Could not find manifest file for object with ref id ' . $requested_ref_id,
88 'Server'
89 );
90 }
91 return file_get_contents($imsFilename);
92 }
93
97 public function hasSCORMCertificate(string $sid, int $ref_id, int $usr_id)
98 {
99 $this->initAuth($sid);
100 $this->initIlias();
101
102 if (!$this->checkSession($sid)) {
103 return $this->raiseError($this->getMessage(), $this->getMessageCode());
104 }
105 if (!($ref_id > 0)) {
106 return $this->raiseError(
107 'No ref id given. Aborting!',
108 'Client'
109 );
110 }
111 global $DIC;
112
113 $rbacsystem = $DIC['rbacsystem'];
114 $tree = $DIC['tree'];
115 $ilLog = $DIC['ilLog'];
116
117 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
118 return $this->raiseError(
119 'No exercise found for id: ' . $ref_id,
120 'Client'
121 );
122 }
123
125 return $this->raiseError("Parent with ID $ref_id has been deleted.", 'Client');
126 }
127
128 $certValidator = new ilCertificateUserCertificateAccessValidator();
129
130 return $certValidator->validate($usr_id, $obj_id);
131 }
132
136 public function getSCORMCompletionStatus(string $sid, int $a_usr_id, int $a_ref_id)
137 {
138 $this->initAuth($sid);
139 $this->initIlias();
140
141 if (!$this->checkSession($sid)) {
142 return $this->raiseError($this->getMessage(), $this->getMessageCode());
143 }
144
145 if (!($a_ref_id > 0)) {
146 return $this->raiseError('No ref_id given. Aborting!', 'Client');
147 }
148
150
151 if (!$obj_id = ilObject::_lookupObjectId($a_ref_id)) {
152 return $this->raiseError(
153 'No scorm module found for id: ' . $a_ref_id,
154 'Client'
155 );
156 }
157
159 return $this->raiseError('Learning progress not enabled in this installation. Aborting!', 'Server');
160 }
161
162 $status = ilLPStatus::_lookupStatus($obj_id, $a_usr_id);
163 if ($status === ilLPStatus::LP_STATUS_COMPLETED_NUM) {
164 return 'completed';
165 } elseif ($status === ilLPStatus::LP_STATUS_FAILED_NUM) {
166 return 'failed';
167 } elseif ($status === ilLPStatus::LP_STATUS_IN_PROGRESS_NUM) {
168 return 'in_progress';
169 } else {
170 return 'not_attempted';
171 }
172 }
173}
static initILIAS()
ilias initialisation
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
const LP_STATUS_FAILED_NUM
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjectId(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _isInTrash(int $ref_id)
raiseError(string $a_message, $a_code)
hasSCORMCertificate(string $sid, int $ref_id, int $usr_id)
getIMSManifestXML(string $sid, int $requested_ref_id)
getSCORMCompletionStatus(string $sid, int $a_usr_id, int $a_ref_id)
$requested_ref_id
Definition: feed.php:40
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26