ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilExerciseXMLParser Class Reference

Exercise XML Parser which completes/updates a given exercise by an xml string. More...

+ Inheritance diagram for ilExerciseXMLParser:
+ Collaboration diagram for ilExerciseXMLParser:

Public Member Functions

 ilExerciseXMLParser (&$exercise, $a_xml_data, $obj_id=-1)
 Constructor.
 setHandlers ($a_xml_parser)
 set event handlers
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
 start ()
 starts parsing an changes object by side effect.
 getAssignment ()
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 startParsing ()
 stores xml data in array
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $exercise
 $obj_id
 $result
 $mode
 $assignment
 $storage
- Data Fields inherited from ilSaxParser
 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Static Public Attributes

static $CONTENT_NOT_COMPRESSED = 0
static $CONTENT_GZ_COMPRESSED = 1
static $CONTENT_ZLIB_COMPRESSED = 2

Private Member Functions

 updateMember ($user_id, $action)
 update member object according to given action
 updateFile ($filename, $b64encodedContent, $action)
 update file according to filename
 updateMarking ($usr_id)
 update marking of member

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Detailed Description

Exercise XML Parser which completes/updates a given exercise by an xml string.

Author
Roland Küstermann rolan.nosp@m.d@ku.nosp@m.ester.nosp@m.mann.nosp@m..com
Version
Id:
class.ilObjectXMLParser.php 12811 2006-12-08 18:37:44Z akill

Definition at line 19 of file class.ilExerciseXMLParser.php.

Member Function Documentation

ilExerciseXMLParser::getAssignment ( )

Definition at line 352 of file class.ilExerciseXMLParser.php.

References $assignment.

{
}
ilExerciseXMLParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array
Exceptions
ilExerciseExceptionwhen obj id != - 1 and if it it does not match the id in the xml

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

References $CONTENT_GZ_COMPRESSED, $CONTENT_NOT_COMPRESSED, $CONTENT_ZLIB_COMPRESSED, ilExerciseException\$ID_DEFLATE_METHOD_MISMATCH, ilExerciseException\$ID_MISMATCH, $ilErr, ilExerciseXMLWriter\$STATUS_NOT_GRADED, ilExerciseXMLWriter\$STATUS_PASSED, and ilUtil\__extractId().

{
global $ilErr;
switch($a_name)
{
case 'Exercise':
if (isset($a_attribs["obj_id"]))
{
$read_obj_id = ilUtil::__extractId($a_attribs["obj_id"], IL_INST_ID);
if ($this->obj_id != -1 && (int) $read_obj_id != -1 && (int) $this->obj_id != (int) $read_obj_id)
{
throw new ilExerciseException ("Object IDs (xml $read_obj_id and argument ".$this->obj_id.") do not match!", ilExerciseException::$ID_MISMATCH);
}
}
break;
case 'Member':
$this->usr_action = $a_attribs["action"];
$this->usr_id = ilUtil::__extractId($a_attribs["usr_id"], IL_INST_ID);
break;
case 'File':
$this->file_action = $a_attribs["action"];
break;
case 'Content':
if ($a_attribs["mode"] == "GZIP")
{
if (!function_exists("gzdecode"))
throw new ilExerciseException ("Deflating with gzip is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH);
} elseif ($a_attribs["mode"] == "ZLIB")
{
if (!function_exists("gzuncompress"))
throw new ilExerciseException ("Deflating with zlib (compress/uncompress) is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH);
}
break;
case 'Marking':
$this->status = $a_attribs["status"];
$this->status = "notgraded";
elseif ($this->status == ilExerciseXMLWriter::$STATUS_PASSED)
$this->status = "passed";
else
$this->status = "failed";
break;
}
}

+ Here is the call graph for this function:

ilExerciseXMLParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

Definition at line 244 of file class.ilExerciseXMLParser.php.

{
if($a_data != "\n")
{
$this->cdata .= $a_data;
}
}
ilExerciseXMLParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

Definition at line 185 of file class.ilExerciseXMLParser.php.

References updateFile(), updateMarking(), and updateMember().

{
switch($a_name)
{
case 'Exercise':
$this->result = true;
break;
case 'Title':
$this->exercise->setTitle(trim($this->cdata));
$this->assignment->setTitle(trim($this->cdata));
break;
case 'Description':
$this->exercise->setDescription(trim($this->cdata));
break;
case 'Instruction':
$this->assignment->setInstruction(trim($this->cdata));
break;
case 'DueDate':
$this->assignment->setDeadLine(trim($this->cdata));
break;
case 'Member':
$this->updateMember($this->usr_id, $this->usr_action);
// update marking after update member.
$this->updateMarking($this->usr_id);
break;
case 'Filename':
$this->file_name = trim($this->cdata);
break;
case 'Content':
$this->file_content = trim($this->cdata);
break;
case 'File':
$this->updateFile($this->file_name, $this->file_content, $this->file_action);
break;
case 'Comment':
$this->comment = trim($this->cdata);
break;
case 'Notice':
$this->notice = trim($this->cdata);
break;
case 'Mark':
$this->mark = trim($this->cdata);
break;
case 'Marking':
// see Member end tag
break;
}
$this->cdata = '';
return;
}

+ Here is the call graph for this function:

ilExerciseXMLParser::ilExerciseXMLParser ( $exercise,
  $a_xml_data,
  $obj_id = -1 
)

Constructor.

Parameters
ilExercise$exerciseexisting exercise object
string$a_xml_filexml data
int$obj_idobj id of exercise which is to be updated public

Definition at line 76 of file class.ilExerciseXMLParser.php.

References $exercise, $obj_id, ilFSStorageExercise\create(), ilExAssignment\getAssignmentDataOfExercise(), ilSaxParser\ilSaxParser(), and ilSaxParser\setXMLContent().

{
// @todo: needs to be revised for multiple assignments per exercise
$this->exercise = $exercise;
// get all assignments and choose first one if exists, otherwise create
if (count ($assignments) > 0) {
$this->assignment = new ilExAssignment($assignments [0]["id"]);
} else {
$this->assignment = new ilExAssignment();
$this->assignment->setExerciseId($exercise->getId());
$this->assignment->save();
}
include_once ("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
$this->storage = new ilFSStorageExercise ( $this->exercise->getId(), $this->assignment->getId());
$this->storage->create();
$this->storage->init();
$this->setXMLContent($a_xml_data);
$this->obj_id = $obj_id;
$this->result = false;
}

+ Here is the call graph for this function:

ilExerciseXMLParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser private

Reimplemented from ilSaxParser.

Definition at line 109 of file class.ilExerciseXMLParser.php.

{
xml_set_object($a_xml_parser,$this);
xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
}
ilExerciseXMLParser::start ( )

starts parsing an changes object by side effect.

Exceptions
ilExerciseExceptionwhen obj id != - 1 and if it it does not match the id in the xml
Returns
boolean true, if no errors happend.

Definition at line 316 of file class.ilExerciseXMLParser.php.

References ilSaxParser\startParsing().

{
$this->startParsing();
return $this->result > 0;
}

+ Here is the call graph for this function:

ilExerciseXMLParser::updateFile (   $filename,
  $b64encodedContent,
  $action 
)
private

update file according to filename

Parameters
string$filename
string$contentbase 64 encoded string
string$actioncan be Attach or Detach

Definition at line 283 of file class.ilExerciseXMLParser.php.

References $CONTENT_GZ_COMPRESSED, $CONTENT_ZLIB_COMPRESSED, and $filename.

Referenced by handlerEndTag().

{
if (strlen($filename) == 0) {
return;
}
$filename= $this->storage->getAbsolutePath()."/".$filename;
if ($action == "Attach")
{
$content = base64_decode((string) $b64encodedContent);
$content = gzdecode($content);
$content = gzuncompress($content);
}
//echo $filename;
$this->storage->writeToFile($content, $filename);
}
if ($action == "Detach")
{
$this->storage->deleteFile($filename);
}
}

+ Here is the caller graph for this function:

ilExerciseXMLParser::updateMarking (   $usr_id)
private

update marking of member

Parameters
int$usr_id

Definition at line 326 of file class.ilExerciseXMLParser.php.

References $usr_id, ilUtil\stripSlashes(), ilExAssignment\updateCommentForUser(), ilExAssignment\updateMarkOfUser(), ilExAssignment\updateNoticeForUser(), and ilExAssignment\updateStatusOfUser().

Referenced by handlerEndTag().

{
if (isset($this->mark))
{
ilExAssignment::updateMarkOfUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->mark));
}
if (isset($this->comment))
{
ilExAssignment::updateCommentForUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->comment));
}
//$memberObject = $this->exercise->members_obj;
if (isset ( $this->status )){
ilExAssignment::updateStatusOfUser ( $this->assignment->getId (), $usr_id, ilUtil::stripSlashes ( $this->status ) );
}
if (isset($this->notice)){
ilExAssignment::updateNoticeForUser($this->assignment->getId(), $usr_id, ilUtil::stripSlashes($this->notice));
}
// reset variables
$this->mark = null;
$this->status = null;
$this->notice = null;
$this->comment = null;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExerciseXMLParser::updateMember (   $user_id,
  $action 
)
private

update member object according to given action

Parameters
int$user_id
string$actioncan be Attach or Detach

Definition at line 259 of file class.ilExerciseXMLParser.php.

Referenced by handlerEndTag().

{
if (!is_int($user_id) || $user_id <= 0) {
return;
}
$memberObject = new ilExerciseMembers($this->exercise);
if ($action == "Attach" && !$memberObject->isAssigned($user_id))
{
$memberObject->assignMember ($user_id);
}
if ($action == "Detach" && $memberObject->isAssigned($user_id))
{
$memberObject->deassignMember ($user_id);
}
}

+ Here is the caller graph for this function:

Field Documentation

ilExerciseXMLParser::$assignment

Definition at line 60 of file class.ilExerciseXMLParser.php.

Referenced by getAssignment().

ilExerciseXMLParser::$CONTENT_GZ_COMPRESSED = 1
static

Definition at line 23 of file class.ilExerciseXMLParser.php.

Referenced by handlerBeginTag(), and updateFile().

ilExerciseXMLParser::$CONTENT_NOT_COMPRESSED = 0
static

Definition at line 22 of file class.ilExerciseXMLParser.php.

Referenced by handlerBeginTag().

ilExerciseXMLParser::$CONTENT_ZLIB_COMPRESSED = 2
static

Definition at line 24 of file class.ilExerciseXMLParser.php.

Referenced by handlerBeginTag(), and updateFile().

ilExerciseXMLParser::$exercise

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

Referenced by ilExerciseXMLParser().

ilExerciseXMLParser::$mode

Definition at line 54 of file class.ilExerciseXMLParser.php.

ilExerciseXMLParser::$obj_id

Definition at line 39 of file class.ilExerciseXMLParser.php.

Referenced by ilExerciseXMLParser().

ilExerciseXMLParser::$result

Definition at line 47 of file class.ilExerciseXMLParser.php.

ilExerciseXMLParser::$storage

Definition at line 66 of file class.ilExerciseXMLParser.php.


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