ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilExerciseXMLWriter Class Reference

XML writer class. More...

+ Inheritance diagram for ilExerciseXMLWriter:
+ Collaboration diagram for ilExerciseXMLWriter:

Public Member Functions

 ilExerciseXMLWriter ()
 constructor More...
 
 setExercise (& $exercise)
 set exercise object More...
 
 setAttachFileContents ($attachFileContents)
 set attachment content mode More...
 
 start ()
 
 getXML ()
 
 __buildHeader ()
 
 __buildFooter ()
 
 setAttachMembers ($value)
 write access to property attchMarkings More...
 
- Public Member Functions inherited from ilXmlWriter
 ilXmlWriter ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header @access public. More...
 
 xmlStartTag ($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=TRUE, $escape=TRUE)
 Writes data. More...
 
 xmlElement ($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=TRUE)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=TRUE)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr @access public More...
 

Data Fields

 $attachFileContents
 
 $attachMembers
 
 $exercise
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Static Public Attributes

static $CONTENT_ATTACH_NO = 0
 
static $CONTENT_ATTACH_ENCODED = 1
 
static $CONTENT_ATTACH_ZLIB_ENCODED = 2
 
static $CONTENT_ATTACH_GZIP_ENCODED = 3
 
static $STATUS_NOT_GRADED = "NOT_GRADED"
 
static $STATUS_PASSED = "PASSED"
 
static $STATUS_FAILED = "FAILED"
 

Private Member Functions

 attachMarking ($user_id, $assignment_id)
 attach marking tag to member for given assignment More...
 
 handleAssignmentFiles ($ex_id, $as_id)
 
 handleAssignmentMembers ($ex_id, $assignment_id)
 create xml for files per assignment More...
 

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author
Roland Küstermann Rolan.nosp@m.d@ku.nosp@m.ester.nosp@m.mann.nosp@m..com
Version
Id
class.ilExerciseXMLWriter.php,v 1.3 2005/11/04 12:50:24 smeyer Exp

Definition at line 21 of file class.ilExerciseXMLWriter.php.

Member Function Documentation

◆ __buildFooter()

ilExerciseXMLWriter::__buildFooter ( )

Definition at line 147 of file class.ilExerciseXMLWriter.php.

147 {
148
149 }

Referenced by start().

+ Here is the caller graph for this function:

◆ __buildHeader()

ilExerciseXMLWriter::__buildHeader ( )

Definition at line 139 of file class.ilExerciseXMLWriter.php.

139 {
140 $this->xmlSetDtdDef ( "<!DOCTYPE Exercise PUBLIC \"-//ILIAS//DTD ExerciseAdministration//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_exercise_4_4.dtd\">" );
141 $this->xmlSetGenCmt ( "Exercise Object" );
142 $this->xmlHeader ();
143
144 return true;
145 }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), and ilXmlWriter\xmlSetGenCmt().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attachMarking()

ilExerciseXMLWriter::attachMarking (   $user_id,
  $assignment_id 
)
private

attach marking tag to member for given assignment

Parameters
int$user_id
int$assignment_id

Definition at line 166 of file class.ilExerciseXMLWriter.php.

166 {
167
168 $ass = new ilExAssignment($assignment_id);
169
170 $amark = $ass->getMemberStatus($user_id)->getMark();
171 $astatus = $ass->getMemberStatus($user_id)->getStatus();
172 $acomment = $ass->getMemberStatus($user_id)->getComment();
173 $anotice = $ass->getMemberStatus($user_id)->getNotice();
174
175
176 if ($astatus == "notgraded") {
178 } elseif ($astatus == "failed") {
180 } else {
182 }
183
184 $this->xmlStartTag ( "Marking", array ("status" => $status ) );
185 $this->xmlElement ( "Mark", null, $amark);
186 $this->xmlElement ( "Notice", null, $anotice );
187 $this->xmlElement ( "Comment", null, $acomment );
188 $this->xmlEndTag ( "Marking" );
189 }
Exercise assignment.
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)

References $STATUS_FAILED, $STATUS_NOT_GRADED, $STATUS_PASSED, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by handleAssignmentMembers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilExerciseXMLWriter::getXML ( )

Definition at line 135 of file class.ilExerciseXMLWriter.php.

135 {
136 return $this->xmlDumpMem ( FALSE );
137 }
xmlDumpMem($format=TRUE)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ handleAssignmentFiles()

ilExerciseXMLWriter::handleAssignmentFiles (   $ex_id,
  $as_id 
)
private

Definition at line 191 of file class.ilExerciseXMLWriter.php.

191 {
192 $this->xmlStartTag ( "Files" );
193 include_once ("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
194 $storage = new ilFSStorageExercise ( $ex_id, $as_id );
195 $files = $storage->getFiles ();
196
197 if (count ( $files )) {
198 foreach ( $files as $file ) {
199 $this->xmlStartTag ( "File", array ("size" => $file ["size"] ) );
200 $this->xmlElement ( "Filename", null, $file ["name"] );
201 if ($this->attachFileContents) {
202 $filename = $file ["fullpath"];
203 if (@is_file ( $filename )) {
204 $content = @file_get_contents ( $filename );
205 $attribs = array ("mode" => "PLAIN" );
206 if ($this->attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED) {
207 $attribs = array ("mode" => "ZLIB" );
208 $content = gzcompress ( $content, 9 );
209 } elseif ($this->attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED) {
210 $attribs = array ("mode" => "GZIP" );
211 $content = gzencode ( $content, 9 );
212 }
213 $content = base64_encode ( $content );
214 $this->xmlElement ( "Content", $attribs, $content );
215 }
216 }
217 $this->xmlEndTag ( "File" );
218 }
219 }
220 $this->xmlEndTag ( "Files" );
221 }
print $file
$filename
Definition: buildRTE.php:89

References $CONTENT_ATTACH_GZIP_ENCODED, $CONTENT_ATTACH_ZLIB_ENCODED, $file, $filename, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleAssignmentMembers()

ilExerciseXMLWriter::handleAssignmentMembers (   $ex_id,
  $assignment_id 
)
private

create xml for files per assignment

Parameters
integer$ex_idexercise id
array$assignmentsassignment id

Definition at line 229 of file class.ilExerciseXMLWriter.php.

229 {
230 $this->xmlStartTag ( "Members" );
231 include_once ("./Modules/Exercise/classes/class.ilExerciseMembers.php");
232 $members = ilExerciseMembers::_getMembers($ex_id);
233 if (count ( $members )) {
234 foreach ( $members as $member_id ) {
235 $this->xmlStartTag ( "Member", array ("usr_id" => "il_" . IL_INST_ID . "_usr_" . $member_id ) );
236 $this->attachMarking ( $member_id, $assignment_id);
237 $this->xmlEndTag ( "Member" );
238 }
239 }
240 $this->xmlEndTag ( "Members" );
241 }
attachMarking($user_id, $assignment_id)
attach marking tag to member for given assignment

References ilExerciseMembers\_getMembers(), attachMarking(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilExerciseXMLWriter()

ilExerciseXMLWriter::ilExerciseXMLWriter ( )

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding @access public

Definition at line 59 of file class.ilExerciseXMLWriter.php.

59 {
60 // @todo: needs to be revised for multiple assignments per exercise
61 //die ("Needs revision for ILIAS 4.1");
62 parent::ilXmlWriter ();
63 $this->attachFileContents = ilExerciseXMLWriter::$CONTENT_ATTACH_NO;
64 }

References $CONTENT_ATTACH_NO.

◆ setAttachFileContents()

ilExerciseXMLWriter::setAttachFileContents (   $attachFileContents)

set attachment content mode

Parameters
int$attachFileContents
Exceptions
ilExerciseExceptionif mode is not supported

Definition at line 82 of file class.ilExerciseXMLWriter.php.

82 {
83 if ($attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED && ! function_exists ( "gzencode" )) {
84 throw new ilExerciseException ( "Inflating with gzip is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH );
85 }
86 if ($attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED && ! function_exists ( "gzcompress" )) {
87 throw new ilExerciseException ( "Inflating with zlib (compress/uncompress) is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH );
88 }
89
90 $this->attachFileContents = $attachFileContents;
91 }
Class to report exception.

References $attachFileContents, $CONTENT_ATTACH_GZIP_ENCODED, $CONTENT_ATTACH_ZLIB_ENCODED, and ilExerciseException\$ID_DEFLATE_METHOD_MISMATCH.

◆ setAttachMembers()

ilExerciseXMLWriter::setAttachMembers (   $value)

write access to property attchMarkings

Parameters
boolean$value

Definition at line 156 of file class.ilExerciseXMLWriter.php.

156 {
157 $this->attachMembers = $value ? true : false;
158 }

◆ setExercise()

ilExerciseXMLWriter::setExercise ( $exercise)

set exercise object

Parameters
ilObjExercise$exercise

Definition at line 72 of file class.ilExerciseXMLWriter.php.

72 {
73 $this->exercise = & $exercise;
74 }

References $exercise.

◆ start()

ilExerciseXMLWriter::start ( )

Definition at line 93 of file class.ilExerciseXMLWriter.php.

93 {
94 $this->__buildHeader ();
95
96 $attribs = array ("obj_id" => "il_" . IL_INST_ID . "_exc_" . $this->exercise->getId () );
97
98 if ($this->exercise->getOwner ())
99 $attribs ["owner"] = "il_" . IL_INST_ID . "_usr_" . $this->exercise->getOwner ();
100
101 $this->xmlStartTag ( "Exercise", $attribs );
102
103 //todo: create new dtd for new assignment structure
104 $this->xmlElement("Title", null,$this->exercise->getTitle());
105 $this->xmlElement("Description", null,$this->exercise->getDescription());
106 //$this->xmlElement("Instruction", null,$this->exercise->getInstruction());
107 //$this->xmlElement("DueDate", null,$this->exercise->getTimestamp());
108
109
110 //todo: as a workaround use first assignment for compatibility with old exercise dtd
111 $assignments = ilExAssignment::getAssignmentDataOfExercise ( $this->exercise->getId () );
112
113 if (count ( $assignments ) > 0) {
114 foreach ( $assignments as $assignment ) {
115 $this->xmlStartTag ("Assignment");
116 $this->xmlElement ( "Instruction", null, $assignment ["instruction"] );
117 $this->xmlElement ( "DueDate", null, $assignment ["deadline"] );
118
119 $this->handleAssignmentFiles ( $this->exercise->getId (), $assignment ["id"] );
120 if ($this->attachMembers)
121 {
122 $this->handleAssignmentMembers ($this->exercise->getId (), $assignment ["id"]);
123 }
124 $this->xmlEndTag ( "Assignment" );
125 }
126 }
127
128
129 $this->xmlEndTag ( "Exercise" );
130 $this->__buildFooter ();
131
132 return true;
133 }
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
handleAssignmentMembers($ex_id, $assignment_id)
create xml for files per assignment

References __buildFooter(), __buildHeader(), ilExAssignment\getAssignmentDataOfExercise(), handleAssignmentFiles(), handleAssignmentMembers(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

Field Documentation

◆ $attachFileContents

ilExerciseXMLWriter::$attachFileContents

Definition at line 36 of file class.ilExerciseXMLWriter.php.

Referenced by setAttachFileContents().

◆ $attachMembers

ilExerciseXMLWriter::$attachMembers

Definition at line 43 of file class.ilExerciseXMLWriter.php.

◆ $CONTENT_ATTACH_ENCODED

ilExerciseXMLWriter::$CONTENT_ATTACH_ENCODED = 1
static

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

◆ $CONTENT_ATTACH_GZIP_ENCODED

ilExerciseXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED = 3
static

Definition at line 26 of file class.ilExerciseXMLWriter.php.

Referenced by handleAssignmentFiles(), and setAttachFileContents().

◆ $CONTENT_ATTACH_NO

ilExerciseXMLWriter::$CONTENT_ATTACH_NO = 0
static

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

Referenced by ilExerciseXMLWriter().

◆ $CONTENT_ATTACH_ZLIB_ENCODED

ilExerciseXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED = 2
static

Definition at line 25 of file class.ilExerciseXMLWriter.php.

Referenced by handleAssignmentFiles(), and setAttachFileContents().

◆ $exercise

ilExerciseXMLWriter::$exercise

Definition at line 50 of file class.ilExerciseXMLWriter.php.

Referenced by setExercise().

◆ $STATUS_FAILED

ilExerciseXMLWriter::$STATUS_FAILED = "FAILED"
static

Definition at line 30 of file class.ilExerciseXMLWriter.php.

Referenced by attachMarking().

◆ $STATUS_NOT_GRADED

ilExerciseXMLWriter::$STATUS_NOT_GRADED = "NOT_GRADED"
static

◆ $STATUS_PASSED

ilExerciseXMLWriter::$STATUS_PASSED = "PASSED"
static

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