ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilSoapExerciseAdministration Class Reference

Soap exercise administration methods. More...

+ Inheritance diagram for ilSoapExerciseAdministration:
+ Collaboration diagram for ilSoapExerciseAdministration:

Public Member Functions

 addExercise (string $sid, int $target_id, string $exercise_xml)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Additional Inherited Members

- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 
- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 checkObjectAccess (int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

Soap exercise administration methods.

Author
Roland Küstermann rolan.nosp@m.d@ku.nosp@m.ester.nosp@m.mann.nosp@m..com

Definition at line 31 of file class.ilSoapExerciseAdministration.php.

Member Function Documentation

◆ addExercise()

ilSoapExerciseAdministration::addExercise ( string  $sid,
int  $target_id,
string  $exercise_xml 
)
Returns
int|soap_fault|SoapFault|null

Definition at line 36 of file class.ilSoapExerciseAdministration.php.

References $DIC, $exercise, ilExerciseException\$ID_MISMATCH, $ref_id, $requested_ref_id, ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

37  {
38  $this->initAuth($sid);
39  $this->initIlias();
40 
41  if (!$this->checkSession($sid)) {
42  return $this->raiseError($this->getMessage(), $this->getMessageCode());
43  }
44  global $DIC;
45 
46  $rbacsystem = $DIC['rbacsystem'];
47  $tree = $DIC['tree'];
48  $ilLog = $DIC['ilLog'];
49 
50  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
51  return $this->raiseError('No valid target given.', 'Client');
52  }
53 
54  if (ilObject::_isInTrash($target_id)) {
55  return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
56  }
57 
58  $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
59  if (!in_array($target_obj->getType(), $allowed_types)) {
60  return $this->raiseError(
61  'No valid target type. Target must be reference id of "course, group, category or folder"',
62  'Client'
63  );
64  }
65 
66  if (!$rbacsystem->checkAccess('create', $target_id, "exc")) {
67  return $this->raiseError('No permission to create exercises in target ' . $target_id . '!', 'Client');
68  }
69 
70  // create object, put it into the tree and use the parser to update the settings
71 
72  $exercise = new ilObjExercise();
73  $exercise->create();
74  $exercise->createReference();
75  $exercise->putInTree($target_id);
76  $exercise->setPermissions($target_id);
77  $exercise->saveData();
78 
79  // we need this as workaround because file and member objects need to be initialised
80  $exercise->read();
81 
82  $exerciseXMLParser = new ilExerciseXMLParser($exercise, $exercise_xml);
83  try {
84  if ($exerciseXMLParser->start()) {
85  $exerciseXMLParser->getAssignment()->update();
86  return $exercise->update() ? $exercise->getRefId() : -1;
87  }
88  throw new ilExerciseException("Could not parse XML");
89  } catch (ilExerciseException $exception) {
90  return $this->raiseError(
91  $exception->getMessage(),
92  $exception->getCode() == ilExerciseException::$ID_MISMATCH ? "Client" : "Server"
93  );
94  }
95  }
raiseError(string $a_message, $a_code)
Class ilObjExercise.
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
global $DIC
Definition: shib_login.php:25
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...
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: