19 declare(strict_types=1);
29 public function addExercise(
string $sid,
int $target_id,
string $exercise_xml)
39 $rbacsystem = $DIC[
'rbacsystem'];
41 $ilLog = $DIC[
'ilLog'];
44 return $this->
raiseError(
'No valid target given.',
'Client');
48 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
51 $allowed_types = array(
'cat',
'grp',
'crs',
'fold',
'root');
52 if (!in_array($target_obj->getType(), $allowed_types)) {
54 'No valid target type. Target must be reference id of "course, group, category or folder"',
59 if (!$rbacsystem->checkAccess(
'create', $target_id,
"exc")) {
60 return $this->
raiseError(
'No permission to create exercises in target ' . $target_id .
'!',
'Client');
77 if ($exerciseXMLParser->start()) {
78 $exerciseXMLParser->getAssignment()->update();
84 $exception->getMessage(),
93 public function updateExercise(
string $sid,
int $requested_ref_id,
string $exercise_xml)
103 $rbacsystem = $DIC[
'rbacsystem'];
104 $tree = $DIC[
'tree'];
105 $ilLog = $DIC[
'ilLog'];
109 'Cannot perform update since exercise has been deleted.',
110 'CLIENT_OBJECT_DELETED' 116 'No exercise found for id: ' . $requested_ref_id,
117 'CLIENT_OBJECT_NOT_FOUND' 121 $permission_ok =
false;
123 if ($rbacsystem->checkAccess(
'edit', $ref_id)) {
124 $permission_ok =
true;
129 if (!$permission_ok) {
131 'No permission to edit the exercise with id: ' . $requested_ref_id,
141 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
142 'CLIENT_OBJECT_NOI_FOUND' 149 if ($exerciseXMLParser->start()) {
150 $exerciseXMLParser->getAssignment()->update();
156 $exception->getMessage(),
165 public function getExerciseXML(
string $sid,
int $requested_ref_id,
int $attachFileContentsMode)
173 if (!$requested_ref_id) {
175 'No ref id given. Aborting!',
181 $rbacsystem = $DIC[
'rbacsystem'];
182 $tree = $DIC[
'tree'];
183 $ilLog = $DIC[
'ilLog'];
188 'No exercise found for id: ' . $requested_ref_id,
194 return $this->
raiseError(
"Parent with ID $requested_ref_id has been deleted.",
'Client');
197 $permission_ok =
false;
198 $write_permission_ok =
false;
200 if ($rbacsystem->checkAccess(
'write', $ref_id)) {
201 $write_permission_ok =
true;
204 if ($rbacsystem->checkAccess(
'read', $ref_id)) {
205 $permission_ok =
true;
210 if (!$permission_ok && !$write_permission_ok) {
212 'No permission to edit the object with id: ' . $requested_ref_id,
222 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
229 $xmlWriter->setAttachMembers($write_permission_ok);
230 $xmlWriter->setAttachFileContents($attachFileContentsMode);
233 return $xmlWriter->getXML();
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
Soap exercise administration methods.
checkSession(string $sid)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjectId(int $ref_id)
addExercise(string $sid, int $target_id, string $exercise_xml)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...