ILIAS  release_8 Revision v8.24
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 30 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 35 of file class.ilSoapExerciseAdministration.php.

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

References $DIC, $exercise, ilExerciseException\$ID_MISMATCH, $target_id, ilObject\_isInTrash(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

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