ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilExerciseDataSet Class Reference

Exercise data set class. More...

+ Inheritance diagram for ilExerciseDataSet:
+ Collaboration diagram for ilExerciseDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record (export) More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=NULL)
 Parse export id. More...
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 

Detailed Description

Exercise data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilExerciseDataSet.php.

Member Function Documentation

◆ getDependencies()

ilExerciseDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 230 of file class.ilExerciseDataSet.php.

231  {
232  switch ($a_entity)
233  {
234  case "exc":
235  return array (
236  "exc_assignment" => array("ids" => $a_rec["Id"])
237  );
238  }
239 
240  return false;
241  }

◆ getSupportedVersions()

ilExerciseDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

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

22  {
23  return array("4.1.0", "4.4.0", "5.0.0");
24  }

◆ getTypes()

ilExerciseDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters

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

44  {
45  if ($a_entity == "exc")
46  {
47  switch ($a_version)
48  {
49  case "4.1.0":
50  case "4.4.0":
51  case "5.0.0":
52  return array(
53  "Id" => "integer",
54  "Title" => "text",
55  "Description" => "text",
56  "PassMode" => "text",
57  "PassNr" => "integer",
58  "ShowSubmissions" => "integer");
59  }
60  }
61 
62  if ($a_entity == "exc_assignment")
63  {
64  switch ($a_version)
65  {
66  case "4.1.0":
67  return array(
68  "Id" => "integer",
69  "ExerciseId" => "integer",
70  "Deadline" => "text",
71  "Instruction" => "text",
72  "Title" => "text",
73  "Mandatory" => "integer",
74  "OrderNr" => "integer",
75  "Dir" => "directory");
76 
77  case "4.4.0":
78  return array(
79  "Id" => "integer",
80  "ExerciseId" => "integer",
81  "Type" => "integer",
82  "Deadline" => "integer",
83  "Instruction" => "text",
84  "Title" => "text",
85  "Mandatory" => "integer",
86  "OrderNr" => "integer",
87  "Dir" => "directory"
88  // peer
89  ,"Peer" => "integer"
90  ,"PeerMin" => "integer"
91  ,"PeerDeadline" => "integer"
92  // global feedback
93  ,"FeedbackFile" => "integer"
94  ,"FeedbackCron" => "integer"
95  ,"FeedbackDate" => "integer"
96  ,"FeedbackDir" => "directory"
97  );
98 
99  case "5.0.0":
100  return array(
101  "Id" => "integer",
102  "ExerciseId" => "integer",
103  "Type" => "integer",
104  "Deadline" => "integer",
105  "Instruction" => "text",
106  "Title" => "text",
107  "Mandatory" => "integer",
108  "OrderNr" => "integer",
109  "Dir" => "directory"
110  // peer
111  ,"Peer" => "integer"
112  ,"PeerMin" => "integer"
113  ,"PeerDeadline" => "integer"
114  ,"PeerFile" => "integer"
115  ,"PeerPersonal" => "integer"
116  // global feedback
117  ,"FeedbackFile" => "integer"
118  ,"FeedbackCron" => "integer"
119  ,"FeedbackDate" => "integer"
120  ,"FeedbackDir" => "directory"
121  );
122  }
123  }
124 
125  }

◆ getXmlNamespace()

ilExerciseDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

33  {
34  return "http://www.ilias.de/xml/Modules/Exercise/".$a_entity;
35  }

◆ getXmlRecord()

ilExerciseDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record (export)

Parameters
arrayabstract data record
Returns
array xml record

Definition at line 198 of file class.ilExerciseDataSet.php.

References IL_CAL_DATETIME, and IL_CAL_UNIX.

199  {
200  if ($a_entity == "exc_assignment")
201  {
202  // convert server dates to utc
203  if($a_set["StartTime"] != "")
204  {
205  $start = new ilDateTime($a_set["StartTime"], IL_CAL_UNIX);
206  $a_set["StartTime"] = $start->get(IL_CAL_DATETIME,'','UTC');
207  }
208  if($a_set["Deadline"] != "")
209  {
210  $deadline = new ilDateTime($a_set["Deadline"], IL_CAL_UNIX);
211  $a_set["Deadline"] = $deadline->get(IL_CAL_DATETIME,'','UTC');
212  }
213 
214  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
215  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
216  $a_set["Dir"] = $fstorage->getPath();
217 
218  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
219  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
220  $a_set["FeedbackDir"] = $fstorage->getGlobalFeedbackPath();
221  }
222 
223  return $a_set;
224  }
const IL_CAL_DATETIME
const IL_CAL_UNIX
Date and time handling

◆ importRecord()

ilExerciseDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 250 of file class.ilExerciseDataSet.php.

References ilFSStorageExercise\create(), ilDataSet\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), IL_CAL_DATETIME, IL_CAL_UNIX, and ilUtil\rCopy().

251  {
252 //echo $a_entity;
253 //var_dump($a_rec);
254 
255  switch ($a_entity)
256  {
257  case "exc":
258  include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
259 
260  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
261  {
262  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
263  }
264  else
265  {
266  $newObj = new ilObjExercise();
267  $newObj->setType("exc");
268  $newObj->create(true);
269  }
270 
271  $newObj->setTitle($a_rec["Title"]);
272  $newObj->setDescription($a_rec["Description"]);
273  $newObj->setPassMode($a_rec["PassMode"]);
274  $newObj->setPassNr($a_rec["PassNr"]);
275  $newObj->setShowSubmissions($a_rec["ShowSubmissions"]);
276  $newObj->update();
277  $newObj->saveData();
278 //var_dump($a_rec);
279  $this->current_exc = $newObj;
280 
281  $a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId());
282 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
283  break;
284 
285  case "exc_assignment":
286  $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]);
287  if ($exc_id > 0)
288  {
289  if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id)
290  {
291  $exc = $this->current_exc;
292  }
293  else
294  {
295  include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
296  $exc = new ilObjExercise($exc_id, false);
297  }
298 
299  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
300 
301  $ass = new ilExAssignment();
302  $ass->setExerciseId($exc_id);
303 
304  if ($a_rec["StartTime"] != "")
305  {
306  $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC");
307  $ass->setStartTime($start->get(IL_CAL_UNIX));
308  }
309 
310  if ($a_rec["Deadline"] != "")
311  {
312  $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC");
313  $ass->setDeadline($deadline->get(IL_CAL_UNIX));
314  }
315 //var_dump($a_rec);
316  $ass->setInstruction($a_rec["Instruction"]);
317  $ass->setTitle($a_rec["Title"]);
318  $ass->setMandatory($a_rec["Mandatory"]);
319  $ass->setOrderNr($a_rec["OrderNr"]);
320 
321  // 4.2
322  $ass->setType($a_rec["Type"]);
323 
324  // 4.4
325  $ass->setPeerReview($a_rec["Peer"]);
326  $ass->setPeerReviewMin($a_rec["PeerMin"]);
327  $ass->setPeerReviewDeadline($a_rec["PeerDeadline"]);
328  $ass->setFeedbackFile($a_rec["FeedbackFile"]);
329  $ass->setFeedbackCron($a_rec["FeedbackCron"]);
330  $ass->setFeedbackDate($a_rec["FeedbackDate"]);
331 
332  // 5.0
333  $ass->setPeerReviewFileUpload($a_rec["PeerFile"]);
334  $ass->setPeerReviewPersonalized($a_rec["PeerPersonal"]);
335 
336  $ass->save();
337 
338  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
339  $fstorage = new ilFSStorageExercise($exc_id, $ass->getId());
340  $fstorage->create();
341 
342  // assignment files
343  $dir = str_replace("..", "", $a_rec["Dir"]);
344  if ($dir != "" && $this->getImportDirectory() != "")
345  {
346  $source_dir = $this->getImportDirectory()."/".$dir;
347  $target_dir = $fstorage->getPath();
348  ilUtil::rCopy($source_dir, $target_dir);
349  }
350 
351  // (4.4) global feedback file
352  $dir = str_replace("..", "", $a_rec["FeedbackDir"]);
353  if ($dir != "" && $this->getImportDirectory() != "")
354  {
355  $source_dir = $this->getImportDirectory()."/".$dir;
356  $target_dir = $fstorage->getGlobalFeedbackPath();
357  ilUtil::rCopy($source_dir, $target_dir);
358  }
359 
360  $a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId());
361 
362  }
363 
364  break;
365  }
366  }
Exercise assignment.
const IL_CAL_DATETIME
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getImportDirectory()
Get import directory.
const IL_CAL_UNIX
Class ilObjExercise.
Date and time handling
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ readData()

ilExerciseDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 133 of file class.ilExerciseDataSet.php.

References $ilDB, and ilDataSet\getDirectDataFromQuery().

134  {
135  global $ilDB;
136 
137  if (!is_array($a_ids))
138  {
139  $a_ids = array($a_ids);
140  }
141 
142  if ($a_entity == "exc")
143  {
144  switch ($a_version)
145  {
146  case "4.1.0":
147  case "4.4.0":
148  case "5.0.0":
149  $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description, ".
150  " pass_mode, pass_nr, show_submissions".
151  " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id) ".
152  "WHERE ".
153  $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
154  break;
155  }
156  }
157 
158  if ($a_entity == "exc_assignment")
159  {
160  switch ($a_version)
161  {
162  case "4.1.0":
163  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline, ".
164  " instruction, title, start_time, mandatory, order_nr".
165  " FROM exc_assignment ".
166  "WHERE ".
167  $ilDB->in("exc_id", $a_ids, false, "integer"));
168  break;
169 
170  case "4.4.0":
171  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline,".
172  " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline,".
173  " fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date".
174  " FROM exc_assignment".
175  " WHERE ".
176  $ilDB->in("exc_id", $a_ids, false, "integer"));
177  break;
178 
179  case "5.0.0":
180  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline,".
181  " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline,".
182  " peer_file, peer_prsl peer_personal, fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date".
183  " FROM exc_assignment".
184  " WHERE ".
185  $ilDB->in("exc_id", $a_ids, false, "integer"));
186  break;
187  }
188  }
189 
190  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $ilDB
+ Here is the call graph for this function:

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