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 | |
Definition at line 35 of file class.ilSoapExerciseAdministration.php.
| ilSoapExerciseAdministration::addExercise | ( | $ | sid, | |
| $ | target_id, | |||
| $ | exercise_xml | |||
| ) |
add an exercise with id.
| string | $session_id current session | |
| int | $target_id refid of parent in repository | |
| string | $exercise_xml qti xml description of test |
Definition at line 51 of file class.ilSoapExerciseAdministration.php.
References ilExerciseException::$ID_MISMATCH, $ilLog, $target_id, ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), ilObject::_isInTrash(), and ilObjectFactory::getInstanceByRefId().
{
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
}
include_once './include/inc.header.php';
global $rbacsystem, $tree, $ilLog;
if(!$target_obj =& ilObjectFactory::getInstanceByRefId($target_id,false))
{
return $this->__raiseError('No valid target given.', 'Client');
}
if(ilObject::_isInTrash($target_id))
{
return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
}
// Check access
$allowed_types = array('cat','grp','crs','fold');
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
{
return $exerciseXMLParser->start() && $exercise->update() ? $exercise->getRefId() : -1;
} 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
| string | $sid | |
| int | $ref_id | |
| int | $attachFileContentsMode see constants |
Definition at line 186 of file class.ilSoapExerciseAdministration.php.
References $ilLog, $ref_id, ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), ilObject::_getAllReferences(), ilObject::_isInTrash(), ilObject::_lookupObjectId(), and ilObjectFactory::getInstanceByObjId().
{
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
}
if(!strlen($ref_id))
{
return $this->__raiseError('No ref id given. Aborting!',
'Client');
}
include_once './include/inc.header.php';
global $rbacsystem, $tree, $ilLog;
// get obj_id
if(!$obj_id = ilObject::_lookupObjectId($ref_id))
{
return $this->__raiseError('No exercise found for id: '.$ref_id,
'Client');
}
if(ilObject::_isInTrash($ref_id))
{
return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'Client');
}
// Check access
$permission_ok = false;
foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
{
if($rbacsystem->checkAccess('read',$ref_id))
{
$permission_ok = true;
break;
}
}
if(!$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->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().
{
parent::ilSoapAdministration();
}
Here is the call graph for this function:| ilSoapExerciseAdministration::updateExercise | ( | $ | sid, | |
| $ | ref_id, | |||
| $ | exercise_xml | |||
| ) |
update a exercise with id.
| string | $session_id current session | |
| int | $ref_id refid id of exercise in repository | |
| string | $exercise_xml qti xml description of test |
Definition at line 117 of file class.ilSoapExerciseAdministration.php.
References ilExerciseException::$ID_MISMATCH, $ilLog, $ref_id, ilSoapAdministration::__checkSession(), ilSoapAdministration::__raiseError(), ilObject::_getAllReferences(), ilObject::_isInTrash(), ilObject::_lookupObjectId(), and ilObjectFactory::getInstanceByObjId().
{
if(!$this->__checkSession($sid))
{
return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
}
include_once './include/inc.header.php';
global $rbacsystem, $tree, $ilLog;
if(ilObject::_isInTrash($ref_id))
{
return $this->__raiseError('Cannot perform update since exercise has been deleted.', 'CLIENT_OBJECT_DELETED');
}
// get obj_id
if(!$obj_id = ilObject::_lookupObjectId($ref_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
{
return $exerciseXMLParser->start() && $exercise->update();
} 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:
1.7.1