ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSoapExerciseAdministration Class Reference
+ Inheritance diagram for ilSoapExerciseAdministration:
+ Collaboration diagram for ilSoapExerciseAdministration:

Public Member Functions

 ilSoapExerciseAdministration ()
 addExercise ($sid, $target_id, $exercise_xml)
 add an exercise with id.
 updateExercise ($sid, $ref_id, $exercise_xml)
 update a exercise with id.
 getExerciseXML ($sid, $ref_id, $attachFileContentsMode)
 get exercise xml
- Public Member Functions inherited from ilSoapAdministration
 ilSoapAdministration ($use_nusoap=true)
 initErrorWriter ()
 Overwrite error handler.
 __explodeSid ($sid)
 __setMessage ($a_str)
 __getMessage ()
 __appendMessage ($a_str)
 __setMessageCode ($a_code)
 __getMessageCode ()
 initAuth ($sid)
 initIlias ()
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 __raiseError ($a_message, $a_code)
 getNIC ($sid)
 get client information from current as xml result set
 isFault ($object)
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true
 getInstallationInfoXML ()
 getClientInfoXML ($clientid)

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 $error_method = null
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true

Detailed Description

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

Member Function Documentation

ilSoapExerciseAdministration::addExercise (   $sid,
  $target_id,
  $exercise_xml 
)

add an exercise with id.

Parameters
string$session_idcurrent session
int$target_idrefid of parent in repository
string$exercise_xmlqti xml description of test
Returns
int reference id in the tree, 0 if not successful

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

References ilExerciseException\$ID_MISMATCH, $ilLog, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
global $rbacsystem, $tree, $ilLog;
{
return $this->__raiseError('No valid target given.', 'Client');
}
{
return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
}
// Check access
$allowed_types = array('cat','grp','crs','fold','root');
if(!in_array($target_obj->getType(), $allowed_types))
{
return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
}
if(!$rbacsystem->checkAccess('create',$target_id,"exc"))
{
return $this->__raiseError('No permission to create exercises in target '.$target_id.'!', 'Client');
}
// create object, put it into the tree and use the parser to update the settings
include_once './Modules/Exercise/classes/class.ilObjExercise.php';
include_once './Modules/Exercise/classes/class.ilExerciseXMLParser.php';
include_once './Modules/Exercise/classes/class.ilExerciseException.php';
$exercise = new ilObjExercise();
$exercise->create();
$exercise->createReference();
$exercise->putInTree($target_id);
$exercise->setPermissions($target_id);
$exercise->saveData();
// we need this as workaround because file and member objects need to be initialised
$exercise->read();
$exerciseXMLParser = new ilExerciseXMLParser($exercise, $exercise_xml);
try
{
if ($exerciseXMLParser->start()) {
$exerciseXMLParser->getAssignment()->update();
return $exercise->update() ? $exercise->getRefId() : -1;
}
throw new ilExerciseException ("Could not parse XML");
} catch(ilExerciseException $exception) {
return $this->__raiseError($exception->getMessage(),
$exception->getCode() == ilExerciseException::$ID_MISMATCH ? "Client" : "Server");
}
}

+ Here is the call graph for this function:

ilSoapExerciseAdministration::getExerciseXML (   $sid,
  $ref_id,
  $attachFileContentsMode 
)

get exercise xml

Parameters
string$sid
int$ref_id
int$attachFileContentsModesee constants
Returns
xml following ilias_exercise_x.dtd

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

References $ilLog, $ref_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
if(!strlen($ref_id))
{
return $this->__raiseError('No ref id given. Aborting!',
'Client');
}
global $rbacsystem, $tree, $ilLog;
// get obj_id
{
return $this->__raiseError('No exercise found for id: '.$ref_id,
'Client');
}
{
return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'Client');
}
// Check access
$permission_ok = false;
$write_permission_ok = false;
foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
{
if($rbacsystem->checkAccess('write',$ref_id)) // #14299
{
$write_permission_ok = true;
break;
}
if($rbacsystem->checkAccess('read',$ref_id))
{
$permission_ok = true;
break;
}
}
if(!$permission_ok && !$write_permission_ok)
{
return $this->__raiseError('No permission to edit the object with id: '.$ref_id,
'Server');
}
$exercise = ilObjectFactory::getInstanceByObjId($obj_id, false);
if (!is_object($exercise) || $exercise->getType()!= "exc")
{
return $this->__raiseError('Wrong obj id or type for exercise with id '.$ref_id,
'Server');
}
// store into xml result set
include_once './Modules/Exercise/classes/class.ilExerciseXMLWriter.php';
// create writer
$xmlWriter = new ilExerciseXMLWriter();
$xmlWriter->setExercise($exercise);
$xmlWriter->setAttachMembers($write_permission_ok);
$xmlWriter->setAttachFileContents($attachFileContentsMode);
$xmlWriter->start();
return $xmlWriter->getXML();
}

+ Here is the call graph for this function:

ilSoapExerciseAdministration::ilSoapExerciseAdministration ( )

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

References ilSoapAdministration\ilSoapAdministration().

+ Here is the call graph for this function:

ilSoapExerciseAdministration::updateExercise (   $sid,
  $ref_id,
  $exercise_xml 
)

update a exercise with id.

Parameters
string$session_idcurrent session
int$ref_idrefid id of exercise in repository
string$exercise_xmlqti xml description of test
Returns
boolean true, if update successful, false otherwise

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

References ilExerciseException\$ID_MISMATCH, $ilLog, $ref_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

{
$this->initAuth($sid);
$this->initIlias();
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
}
global $rbacsystem, $tree, $ilLog;
{
return $this->__raiseError('Cannot perform update since exercise has been deleted.', 'CLIENT_OBJECT_DELETED');
}
// get obj_id
{
return $this->__raiseError('No exercise found for id: '.$ref_id,
'CLIENT_OBJECT_NOT_FOUND');
}
// Check access
$permission_ok = false;
foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
{
if($rbacsystem->checkAccess('edit',$ref_id))
{
$permission_ok = true;
break;
}
}
if(!$permission_ok)
{
return $this->__raiseError('No permission to edit the exercise with id: '.$ref_id,
'Server');
}
$exercise = ilObjectFactory::getInstanceByObjId($obj_id, false);
if (!is_object($exercise) || $exercise->getType()!= "exc")
{
return $this->__raiseError('Wrong obj id or type for exercise with id '.$ref_id,
'CLIENT_OBJECT_NOI_FOUND');
}
include_once './Modules/Exercise/classes/class.ilExerciseXMLParser.php';
include_once './Modules/Exercise/classes/class.ilExerciseException.php';
$exerciseXMLParser = new ilExerciseXMLParser($exercise, $exercise_xml, $obj_id);
try
{
if ($exerciseXMLParser->start()) {
$exerciseXMLParser->getAssignment()->update();
return $exercise->update();
}
throw new ilExerciseException ("Could not parse XML");
} catch(ilExerciseException $exception) {
return $this->__raiseError($exception->getMessage(),
$exception->getCode() == ilExerciseException::$ID_MISMATCH ? "Client" : "Server");
}
return false;
}

+ Here is the call graph for this function:


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