ILIAS  release_8 Revision v8.24
class.ilSoapSCORMAdministration.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
30include_once './webservice/soap/classes/class.ilSoapAdministration.php';
31
33{
37 public function getIMSManifestXML(string $sid, int $requested_ref_id)
38 {
39 $this->initAuth($sid);
40 $this->initIlias();
41
42 if (!$this->checkSession($sid)) {
43 return $this->raiseError($this->getMessage(), $this->getMessageCode());
44 }
45 if (!($requested_ref_id > 0)) {
46 return $this->raiseError(
47 'No ref id given. Aborting!',
48 'Client'
49 );
50 }
51 global $DIC;
52
53 $rbacsystem = $DIC['rbacsystem'];
54 $tree = $DIC['tree'];
55 $ilLog = $DIC['ilLog'];
56
58 return $this->raiseError(
59 'No exercise found for id: ' . $requested_ref_id,
60 'Client'
61 );
62 }
63
65 return $this->raiseError("Parent with ID $requested_ref_id has been deleted.", 'Client');
66 }
67
68 $permission_ok = false;
69 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
70 if ($rbacsystem->checkAccess('read', $ref_id)) {
71 $permission_ok = true;
72 break;
73 }
74 }
75
76 if (!$permission_ok) {
77 return $this->raiseError(
78 'No permission to read the object with id: ' . $requested_ref_id,
79 'Server'
80 );
81 }
82
83 $lm_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
84 if (!is_object($lm_obj) || $lm_obj->getType() !== "sahs") {
85 return $this->raiseError(
86 'Wrong obj id or type for scorm object with id ' . $requested_ref_id,
87 'Server'
88 );
89 }
90
91 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
92 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
93
94 $imsFilename = $lm_obj->getDataDirectory() . DIRECTORY_SEPARATOR . "imsmanifest.xml";
95
96 if (!file_exists($imsFilename)) {
97 return $this->raiseError(
98 'Could not find manifest file for object with ref id ' . $requested_ref_id,
99 'Server'
100 );
101 }
102 return file_get_contents($imsFilename);
103 }
104
108 public function hasSCORMCertificate(string $sid, int $ref_id, int $usr_id)
109 {
110 $this->initAuth($sid);
111 $this->initIlias();
112
113 if (!$this->checkSession($sid)) {
114 return $this->raiseError($this->getMessage(), $this->getMessageCode());
115 }
116 if (!($ref_id > 0)) {
117 return $this->raiseError(
118 'No ref id given. Aborting!',
119 'Client'
120 );
121 }
122 global $DIC;
123
124 $rbacsystem = $DIC['rbacsystem'];
125 $tree = $DIC['tree'];
126 $ilLog = $DIC['ilLog'];
127
128 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
129 return $this->raiseError(
130 'No exercise found for id: ' . $ref_id,
131 'Client'
132 );
133 }
134
136 return $this->raiseError("Parent with ID $ref_id has been deleted.", 'Client');
137 }
138
139 $certValidator = new ilCertificateUserCertificateAccessValidator();
140
141 return $certValidator->validate($usr_id, $obj_id);
142 }
143
147 public function getSCORMCompletionStatus(string $sid, int $a_usr_id, int $a_ref_id)
148 {
149 $this->initAuth($sid);
150 $this->initIlias();
151
152 if (!$this->checkSession($sid)) {
153 return $this->raiseError($this->getMessage(), $this->getMessageCode());
154 }
155
156 if (!($a_ref_id > 0)) {
157 return $this->raiseError('No ref_id given. Aborting!', 'Client');
158 }
159
160 include_once 'include/inc.header.php';
161
162 if (!$obj_id = ilObject::_lookupObjectId($a_ref_id)) {
163 return $this->raiseError(
164 'No scorm module found for id: ' . $a_ref_id,
165 'Client'
166 );
167 }
168
169 include_once 'Services/Tracking/classes/class.ilLPStatus.php';
170 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
171
173 return $this->raiseError('Learning progress not enabled in this installation. Aborting!', 'Server');
174 }
175
176 $status = ilLPStatus::_lookupStatus($obj_id, $a_usr_id);
177 if ($status === ilLPStatus::LP_STATUS_COMPLETED_NUM) {
178 return 'completed';
179 } elseif ($status === ilLPStatus::LP_STATUS_FAILED_NUM) {
180 return 'failed';
181 } elseif ($status === ilLPStatus::LP_STATUS_IN_PROGRESS_NUM) {
182 return 'in_progress';
183 } else {
184 return 'not_attempted';
185 }
186 }
187}
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)
soap server Base class for all SOAP registered methods.
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
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67