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