ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 24 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 29 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().

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