33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
51 if (!$this->__checkSession($sid)) {
56 $rbacsystem = $DIC[
'rbacsystem'];
61 return $this->
__raiseError(
'No valid target given.',
'Client');
65 return $this->
__raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
69 $allowed_types = array(
'cat',
'grp',
'crs',
'fold',
'root');
70 if (!in_array($target_obj->getType(), $allowed_types)) {
71 return $this->
__raiseError(
'No valid target type. Target must be reference id of "course, group, category or folder"',
'Client');
74 if (!$rbacsystem->checkAccess(
'create',
$target_id,
"exc")) {
79 include_once
'./Modules/Exercise/classes/class.ilObjExercise.php';
80 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLParser.php';
81 include_once
'./Modules/Exercise/exceptions/class.ilExerciseException.php';
96 if ($exerciseXMLParser->start()) {
97 $exerciseXMLParser->getAssignment()->update();
103 $exception->getMessage(),
124 if (!$this->__checkSession($sid)) {
129 $rbacsystem = $DIC[
'rbacsystem'];
130 $tree = $DIC[
'tree'];
134 return $this->
__raiseError(
'Cannot perform update since exercise has been deleted.',
'CLIENT_OBJECT_DELETED');
139 'No exercise found for id: ' . $ref_id,
140 'CLIENT_OBJECT_NOT_FOUND' 145 $permission_ok =
false;
147 if ($rbacsystem->checkAccess(
'edit', $ref_id)) {
148 $permission_ok =
true;
153 if (!$permission_ok) {
155 'No permission to edit the exercise with id: ' . $ref_id,
165 'Wrong obj id or type for exercise with id ' . $ref_id,
166 'CLIENT_OBJECT_NOI_FOUND' 170 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLParser.php';
171 include_once
'./Modules/Exercise/exceptions/class.ilExerciseException.php';
175 if ($exerciseXMLParser->start()) {
176 $exerciseXMLParser->getAssignment()->update();
182 $exception->getMessage(),
204 if (!$this->__checkSession($sid)) {
207 if (!strlen($ref_id)) {
209 'No ref id given. Aborting!',
215 $rbacsystem = $DIC[
'rbacsystem'];
216 $tree = $DIC[
'tree'];
222 'No exercise found for id: ' . $ref_id,
228 return $this->
__raiseError(
"Parent with ID $ref_id has been deleted.",
'Client');
234 $permission_ok =
false;
235 $write_permission_ok =
false;
237 if ($rbacsystem->checkAccess(
'write', $ref_id)) {
238 $write_permission_ok =
true;
241 if ($rbacsystem->checkAccess(
'read', $ref_id)) {
242 $permission_ok =
true;
247 if (!$permission_ok && !$write_permission_ok) {
249 'No permission to edit the object with id: ' . $ref_id,
258 'Wrong obj id or type for exercise with id ' . $ref_id,
263 include_once
'./Modules/Exercise/classes/class.ilExerciseXMLWriter.php';
268 $xmlWriter->setAttachMembers($write_permission_ok);
269 $xmlWriter->setAttachFileContents($attachFileContentsMode);
272 return $xmlWriter->getXML();
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
updateExercise($sid, $ref_id, $exercise_xml)
update a exercise with id.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
addExercise($sid, $target_id, $exercise_xml)
add an exercise with id.
initAuth($sid)
Init authentication.
Exercise XML Parser which completes/updates a given exercise by an xml string.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
getExerciseXML($sid, $ref_id, $attachFileContentsMode)
get exercise xml
Exercise exceptions class.