3 declare(strict_types=1);
36 public function addExercise(
string $sid,
int $target_id,
string $exercise_xml)
46 $rbacsystem = $DIC[
'rbacsystem'];
48 $ilLog = $DIC[
'ilLog'];
51 return $this->
raiseError(
'No valid target given.',
'Client');
55 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
58 $allowed_types = array(
'cat',
'grp',
'crs',
'fold',
'root');
59 if (!in_array($target_obj->getType(), $allowed_types)) {
61 'No valid target type. Target must be reference id of "course, group, category or folder"',
66 if (!$rbacsystem->checkAccess(
'create', $target_id,
"exc")) {
67 return $this->
raiseError(
'No permission to create exercises in target ' . $target_id .
'!',
'Client');
84 if ($exerciseXMLParser->start()) {
85 $exerciseXMLParser->getAssignment()->update();
91 $exception->getMessage(),
100 public function updateExercise(
string $sid,
int $requested_ref_id,
string $exercise_xml)
110 $rbacsystem = $DIC[
'rbacsystem'];
111 $tree = $DIC[
'tree'];
112 $ilLog = $DIC[
'ilLog'];
116 'Cannot perform update since exercise has been deleted.',
117 'CLIENT_OBJECT_DELETED' 123 'No exercise found for id: ' . $requested_ref_id,
124 'CLIENT_OBJECT_NOT_FOUND' 128 $permission_ok =
false;
130 if ($rbacsystem->checkAccess(
'edit', $ref_id)) {
131 $permission_ok =
true;
136 if (!$permission_ok) {
138 'No permission to edit the exercise with id: ' . $requested_ref_id,
148 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
149 'CLIENT_OBJECT_NOI_FOUND' 156 if ($exerciseXMLParser->start()) {
157 $exerciseXMLParser->getAssignment()->update();
163 $exception->getMessage(),
172 public function getExerciseXML(
string $sid,
int $requested_ref_id,
int $attachFileContentsMode)
180 if (!$requested_ref_id) {
182 'No ref id given. Aborting!',
188 $rbacsystem = $DIC[
'rbacsystem'];
189 $tree = $DIC[
'tree'];
190 $ilLog = $DIC[
'ilLog'];
195 'No exercise found for id: ' . $requested_ref_id,
201 return $this->
raiseError(
"Parent with ID $requested_ref_id has been deleted.",
'Client');
204 $permission_ok =
false;
205 $write_permission_ok =
false;
207 if ($rbacsystem->checkAccess(
'write', $ref_id)) {
208 $write_permission_ok =
true;
211 if ($rbacsystem->checkAccess(
'read', $ref_id)) {
212 $permission_ok =
true;
217 if (!$permission_ok && !$write_permission_ok) {
219 'No permission to edit the object with id: ' . $requested_ref_id,
229 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
236 $xmlWriter->setAttachMembers($write_permission_ok);
237 $xmlWriter->setAttachFileContents($attachFileContentsMode);
240 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...