ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 196 of file class.ilExerciseDataSet.php.

197  {
198  switch ($a_entity)
199  {
200  case "exc":
201  return array (
202  "exc_assignment" => array("ids" => $a_rec["Id"])
203  );
204  }
205 
206  return false;
207  }

◆ 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");
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  return array(
52  "Id" => "integer",
53  "Title" => "text",
54  "Description" => "text",
55  "PassMode" => "text",
56  "PassNr" => "integer",
57  "ShowSubmissions" => "integer");
58  }
59  }
60 
61  if ($a_entity == "exc_assignment")
62  {
63  switch ($a_version)
64  {
65  case "4.1.0":
66  return array(
67  "Id" => "integer",
68  "ExerciseId" => "integer",
69  "Deadline" => "text",
70  "Instruction" => "text",
71  "Title" => "text",
72  "Mandatory" => "integer",
73  "OrderNr" => "integer",
74  "Dir" => "directory");
75 
76  case "4.4.0":
77  return array(
78  "Id" => "integer",
79  "ExerciseId" => "integer",
80  "Type" => "integer",
81  "Deadline" => "integer",
82  "Instruction" => "text",
83  "Title" => "text",
84  "Mandatory" => "integer",
85  "OrderNr" => "integer",
86  "Dir" => "directory"
87  // peer
88  ,"Peer" => "integer"
89  ,"PeerMin" => "integer"
90  ,"PeerDeadline" => "integer"
91  // global feedback
92  ,"FeedbackFile" => "integer"
93  ,"FeedbackCron" => "integer"
94  ,"FeedbackDate" => "integer"
95  ,"FeedbackDir" => "directory"
96  );
97  }
98  }
99 
100  }

◆ 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 163 of file class.ilExerciseDataSet.php.

References IL_CAL_DATETIME, and IL_CAL_UNIX.

164  {
165  if ($a_entity == "exc_assignment")
166  {
167  // convert server dates to utc
168  if($a_set["StartTime"] != "")
169  {
170  $start = new ilDateTime($a_set["StartTime"], IL_CAL_UNIX);
171  $a_set["StartTime"] = $start->get(IL_CAL_DATETIME,'','UTC');
172  }
173  if($a_set["Deadline"] != "")
174  {
175  $deadline = new ilDateTime($a_set["Deadline"], IL_CAL_UNIX);
176  $a_set["Deadline"] = $deadline->get(IL_CAL_DATETIME,'','UTC');
177  }
178 
179  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
180  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
181  $a_set["Dir"] = $fstorage->getPath();
182 
183  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
184  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
185  $a_set["FeedbackDir"] = $fstorage->getGlobalFeedbackPath();
186 
187  }
188 
189  return $a_set;
190  }
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 216 of file class.ilExerciseDataSet.php.

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

217  {
218 //echo $a_entity;
219 //var_dump($a_rec);
220 
221  switch ($a_entity)
222  {
223  case "exc":
224  include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
225 
226  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
227  {
228  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
229  }
230  else
231  {
232  $newObj = new ilObjExercise();
233  $newObj->setType("exc");
234  $newObj->create(true);
235  }
236 
237  $newObj->setTitle($a_rec["Title"]);
238  $newObj->setDescription($a_rec["Description"]);
239  $newObj->setPassMode($a_rec["PassMode"]);
240  $newObj->setPassNr($a_rec["PassNr"]);
241  $newObj->setShowSubmissions($a_rec["ShowSubmissions"]);
242  $newObj->update();
243  $newObj->saveData();
244 //var_dump($a_rec);
245  $this->current_exc = $newObj;
246 
247  $a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId());
248 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
249  break;
250 
251  case "exc_assignment":
252  $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]);
253  if ($exc_id > 0)
254  {
255  if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id)
256  {
257  $exc = $this->current_exc;
258  }
259  else
260  {
261  include_once("./Modules/Exercise/classes/class.ilObjExercise.php");
262  $exc = new ilObjExercise($exc_id, false);
263  }
264 
265  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
266 
267  $ass = new ilExAssignment();
268  $ass->setExerciseId($exc_id);
269 
270  if ($a_rec["StartTime"] != "")
271  {
272  $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC");
273  $ass->setStartTime($start->get(IL_CAL_UNIX));
274  }
275 
276  if ($a_rec["Deadline"] != "")
277  {
278  $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC");
279  $ass->setDeadline($deadline->get(IL_CAL_UNIX));
280  }
281 //var_dump($a_rec);
282  $ass->setInstruction($a_rec["Instruction"]);
283  $ass->setTitle($a_rec["Title"]);
284  $ass->setMandatory($a_rec["Mandatory"]);
285  $ass->setOrderNr($a_rec["OrderNr"]);
286 
287  // 4.2
288  $ass->setType($a_rec["Type"]);
289 
290  // 4.4
291  $ass->setPeerReview($a_rec["Peer"]);
292  $ass->setPeerReviewMin($a_rec["PeerMin"]);
293  $ass->setPeerReviewDeadline($a_rec["PeerDeadline"]);
294  $ass->setFeedbackFile($a_rec["FeedbackFile"]);
295  $ass->setFeedbackCron($a_rec["FeedbackCron"]);
296  $ass->setFeedbackDate($a_rec["FeedbackDate"]);
297 
298  $ass->save();
299 
300  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
301  $fstorage = new ilFSStorageExercise($exc_id, $ass->getId());
302  $fstorage->create();
303 
304  // assignment files
305  $dir = str_replace("..", "", $a_rec["Dir"]);
306  if ($dir != "" && $this->getImportDirectory() != "")
307  {
308  $source_dir = $this->getImportDirectory()."/".$dir;
309  $target_dir = $fstorage->getPath();
310  ilUtil::rCopy($source_dir, $target_dir);
311  }
312 
313  // (4.4) global feedback file
314  $dir = str_replace("..", "", $a_rec["FeedbackDir"]);
315  if ($dir != "" && $this->getImportDirectory() != "")
316  {
317  $source_dir = $this->getImportDirectory()."/".$dir;
318  $target_dir = $fstorage->getGlobalFeedbackPath();
319  ilUtil::rCopy($source_dir, $target_dir);
320  }
321 
322  $a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId());
323 
324  }
325 
326  break;
327  }
328  }
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 108 of file class.ilExerciseDataSet.php.

References ilDataSet\getDirectDataFromQuery().

109  {
110  global $ilDB;
111 
112  if (!is_array($a_ids))
113  {
114  $a_ids = array($a_ids);
115  }
116 
117  if ($a_entity == "exc")
118  {
119  switch ($a_version)
120  {
121  case "4.1.0":
122  case "4.4.0":
123  $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description, ".
124  " pass_mode, pass_nr, show_submissions".
125  " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id) ".
126  "WHERE ".
127  $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
128  break;
129  }
130  }
131 
132  if ($a_entity == "exc_assignment")
133  {
134  switch ($a_version)
135  {
136  case "4.1.0":
137  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline, ".
138  " instruction, title, start_time, mandatory, order_nr".
139  " FROM exc_assignment ".
140  "WHERE ".
141  $ilDB->in("exc_id", $a_ids, false, "integer"));
142  break;
143 
144  case "4.4.0":
145  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline,".
146  " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline,".
147  " fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date".
148  " FROM exc_assignment".
149  " WHERE ".
150  $ilDB->in("exc_id", $a_ids, false, "integer"));
151  break;
152  }
153  }
154 
155  }
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 ...
+ Here is the call graph for this function:

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