1<?php declare(strict_types=1);
28include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
45 $rbacsystem =
$DIC[
'rbacsystem'];
47 $ilLog =
$DIC[
'ilLog'];
50 return $this->
raiseError(
'No valid target given.',
'Client');
54 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
57 $allowed_types = array(
'cat',
'grp',
'crs',
'fold',
'root');
58 if (!in_array($target_obj->getType(), $allowed_types)) {
60 'No valid target type. Target must be reference id of "course, group, category or folder"',
65 if (!$rbacsystem->checkAccess(
'create',
$target_id,
"exc")) {
66 return $this->
raiseError(
'No permission to create exercises in target ' . $target_id .
'!',
'Client');
70 include_once
'./Modules/Exercise/classes/class.ilObjExercise.php';
71 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLParser.php';
72 include_once
'./Modules/Exercise/exceptions/class.ilExerciseException.php';
86 if ($exerciseXMLParser->start()) {
87 $exerciseXMLParser->getAssignment()->update();
93 $exception->getMessage(),
102 public function updateExercise(
string $sid,
int $requested_ref_id,
string $exercise_xml)
112 $rbacsystem =
$DIC[
'rbacsystem'];
113 $tree =
$DIC[
'tree'];
114 $ilLog =
$DIC[
'ilLog'];
118 'Cannot perform update since exercise has been deleted.',
119 'CLIENT_OBJECT_DELETED'
125 'No exercise found for id: ' . $requested_ref_id,
126 'CLIENT_OBJECT_NOT_FOUND'
130 $permission_ok =
false;
132 if ($rbacsystem->checkAccess(
'edit',
$ref_id)) {
133 $permission_ok =
true;
138 if (!$permission_ok) {
140 'No permission to edit the exercise with id: ' . $requested_ref_id,
150 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
151 'CLIENT_OBJECT_NOI_FOUND'
155 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLParser.php';
156 include_once
'./Modules/Exercise/exceptions/class.ilExerciseException.php';
160 if ($exerciseXMLParser->start()) {
161 $exerciseXMLParser->getAssignment()->update();
167 $exception->getMessage(),
176 public function getExerciseXML(
string $sid,
int $requested_ref_id,
int $attachFileContentsMode)
184 if (!$requested_ref_id) {
186 'No ref id given. Aborting!',
192 $rbacsystem =
$DIC[
'rbacsystem'];
193 $tree =
$DIC[
'tree'];
194 $ilLog =
$DIC[
'ilLog'];
199 'No exercise found for id: ' . $requested_ref_id,
205 return $this->
raiseError(
"Parent with ID $requested_ref_id has been deleted.",
'Client');
208 $permission_ok =
false;
209 $write_permission_ok =
false;
211 if ($rbacsystem->checkAccess(
'write',
$ref_id)) {
212 $write_permission_ok =
true;
215 if ($rbacsystem->checkAccess(
'read',
$ref_id)) {
216 $permission_ok =
true;
221 if (!$permission_ok && !$write_permission_ok) {
223 'No permission to edit the object with id: ' . $requested_ref_id,
233 'Wrong obj id or type for exercise with id ' . $requested_ref_id,
238 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLWriter.php';
242 $xmlWriter->setAttachMembers($write_permission_ok);
243 $xmlWriter->setAttachFileContents($attachFileContentsMode);
246 return $xmlWriter->getXML();
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...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
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)
checkSession(string $sid)
Soap exercise administration methods.
addExercise(string $sid, int $target_id, string $exercise_xml)