ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExerciseXMLWriter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ()
 
 setExercise (ilObjExercise $exercise)
 
 setAttachFileContents (int $attachFileContents)
 set attachment content mode More...
 
 start ()
 
 getXML ()
 
 __buildHeader ()
 
 __buildFooter ()
 
 setAttachMembers (bool $value)
 write access to property attchMarkings More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Data Fields

bool $attachFileContents
 
bool $attachMembers
 
ilObjExercise $exercise
 

Static Public Attributes

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

Private Member Functions

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseXMLWriter::__construct ( )

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

References $CONTENT_ATTACH_NO, and ILIAS\GlobalScreen\Provider\__construct().

43  {
44  // @todo: needs to be revised for multiple assignments per exercise
45  //die ("Needs revision for ILIAS 4.1");
47  $this->attachFileContents = ilExerciseXMLWriter::$CONTENT_ATTACH_NO;
48  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ __buildFooter()

ilExerciseXMLWriter::__buildFooter ( )

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

Referenced by start().

127  : void
128  {
129  }
+ Here is the caller graph for this function:

◆ __buildHeader()

ilExerciseXMLWriter::__buildHeader ( )

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

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

Referenced by start().

119  : bool
120  {
121  $this->xmlSetGenCmt("Exercise Object");
122  $this->xmlHeader();
123 
124  return true;
125  }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlHeader()
Writes xml header.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attachMarking()

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

attach marking tag to member for given assignment

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

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

Referenced by handleAssignmentMembers().

145  : void {
146  $ass = new ilExAssignment($assignment_id);
147 
148  $amark = $ass->getMemberStatus($user_id)->getMark();
149  $astatus = $ass->getMemberStatus($user_id)->getStatus();
150  $acomment = $ass->getMemberStatus($user_id)->getComment();
151  $anotice = $ass->getMemberStatus($user_id)->getNotice();
152 
153 
154  if ($astatus == "notgraded") {
156  } elseif ($astatus == "failed") {
158  } else {
160  }
161 
162  $this->xmlStartTag("Marking", array("status" => $status ));
163  $this->xmlElement("Mark", null, $amark);
164  $this->xmlElement("Notice", null, $anotice);
165  $this->xmlElement("Comment", null, $acomment);
166  $this->xmlEndTag("Marking");
167  }
Exercise assignment.
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getXML()

ilExerciseXMLWriter::getXML ( )

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

References ilXmlWriter\xmlDumpMem().

114  : string
115  {
116  return $this->xmlDumpMem(false);
117  }
xmlDumpMem(bool $format=true)
Returns xml document from memory.
+ Here is the call graph for this function:

◆ handleAssignmentFiles()

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

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

Referenced by start().

172  : void {
173  }
+ Here is the caller graph for this function:

◆ handleAssignmentMembers()

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

create xml for files per assignment

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

References ilExerciseMembers\_getMembers(), ilObjUser\_lookupName(), attachMarking(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

181  : void {
182  $this->xmlStartTag("Members");
183  $members = ilExerciseMembers::_getMembers($ex_id);
184  if (count($members)) {
185  foreach ($members as $member_id) {
186  $this->xmlStartTag("Member", array("usr_id" => "il_" . IL_INST_ID . "_usr_" . $member_id ));
187 
188  $name = ilObjUser::_lookupName($member_id);
189 
190  $this->xmlElement("Firstname", array(), $name['firstname']);
191  $this->xmlElement("Lastname", array(), $name['lastname']);
192  $this->xmlElement("Login", array(), $name['login']);
193  $this->attachMarking($member_id, $assignment_id);
194  $this->xmlEndTag("Member");
195  }
196  }
197  $this->xmlEndTag("Members");
198  }
const IL_INST_ID
Definition: constants.php:40
attachMarking(int $user_id, int $assignment_id)
attach marking tag to member for given assignment
static _lookupName(int $a_user_id)
lookup user name
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
static _getMembers(int $a_obj_id)
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttachFileContents()

ilExerciseXMLWriter::setAttachFileContents ( int  $attachFileContents)

set attachment content mode

Exceptions
ilExerciseExceptionif mode is not supported

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

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

59  : void
60  {
61  if ($attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED && !function_exists("gzencode")) {
62  throw new ilExerciseException("Inflating with gzip is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH);
63  }
64  if ($attachFileContents == ilExerciseXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED && !function_exists("gzcompress")) {
65  throw new ilExerciseException("Inflating with zlib (compress/uncompress) is not supported", ilExerciseException::$ID_DEFLATE_METHOD_MISMATCH);
66  }
67 
68  $this->attachFileContents = $attachFileContents;
69  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setAttachMembers()

ilExerciseXMLWriter::setAttachMembers ( bool  $value)

write access to property attchMarkings

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

134  : void
135  {
136  $this->attachMembers = $value;
137  }

◆ setExercise()

ilExerciseXMLWriter::setExercise ( ilObjExercise  $exercise)

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

References $exercise.

50  : void
51  {
52  $this->exercise = $exercise;
53  }

◆ start()

ilExerciseXMLWriter::start ( )

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

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

71  : bool
72  {
73  $this->__buildHeader();
74 
75  $attribs = array("obj_id" => "il_" . IL_INST_ID . "_exc_" . $this->exercise->getId() );
76 
77  if ($this->exercise->getOwner() !== 0) {
78  $attribs ["owner"] = "il_" . IL_INST_ID . "_usr_" . $this->exercise->getOwner();
79  }
80 
81  $this->xmlStartTag("Exercise", $attribs);
82 
83  //todo: create new dtd for new assignment structure
84  $this->xmlElement("Title", null, $this->exercise->getTitle());
85  $this->xmlElement("Description", null, $this->exercise->getDescription());
86  //$this->xmlElement("Instruction", null,$this->exercise->getInstruction());
87  //$this->xmlElement("DueDate", null,$this->exercise->getTimestamp());
88 
89 
90  //todo: as a workaround use first assignment for compatibility with old exercise dtd
91  $assignments = ilExAssignment::getAssignmentDataOfExercise($this->exercise->getId());
92 
93  if (count($assignments) > 0) {
94  foreach ($assignments as $assignment) {
95  $this->xmlStartTag("Assignment");
96  $this->xmlElement("Instruction", null, $assignment ["instruction"]);
97  $this->xmlElement("DueDate", null, $assignment ["deadline"]);
98 
99  $this->handleAssignmentFiles($this->exercise->getId(), $assignment ["id"]);
100  if ($this->attachMembers) {
101  $this->handleAssignmentMembers($this->exercise->getId(), $assignment ["id"]);
102  }
103  $this->xmlEndTag("Assignment");
104  }
105  }
106 
107 
108  $this->xmlEndTag("Exercise");
109  $this->__buildFooter();
110 
111  return true;
112  }
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
handleAssignmentMembers(int $ex_id, int $assignment_id)
create xml for files per assignment
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getAssignmentDataOfExercise(int $a_exc_id)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
handleAssignmentFiles(int $ex_id, int $as_id)
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

Field Documentation

◆ $attachFileContents

bool ilExerciseXMLWriter::$attachFileContents

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

Referenced by setAttachFileContents().

◆ $attachMembers

bool ilExerciseXMLWriter::$attachMembers

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

◆ $CONTENT_ATTACH_ENCODED

int ilExerciseXMLWriter::$CONTENT_ATTACH_ENCODED = 1
static

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

◆ $CONTENT_ATTACH_GZIP_ENCODED

int ilExerciseXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED = 3
static

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

Referenced by setAttachFileContents().

◆ $CONTENT_ATTACH_NO

int ilExerciseXMLWriter::$CONTENT_ATTACH_NO = 0
static

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

Referenced by __construct().

◆ $CONTENT_ATTACH_ZLIB_ENCODED

int ilExerciseXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED = 2
static

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

Referenced by setAttachFileContents().

◆ $exercise

ilObjExercise ilExerciseXMLWriter::$exercise

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

Referenced by setExercise().

◆ $STATUS_FAILED

string ilExerciseXMLWriter::$STATUS_FAILED = "FAILED"
static

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

Referenced by attachMarking().

◆ $STATUS_NOT_GRADED

string ilExerciseXMLWriter::$STATUS_NOT_GRADED = "NOT_GRADED"
static

◆ $STATUS_PASSED

string ilExerciseXMLWriter::$STATUS_PASSED = "PASSED"
static

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