ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExerciseDataSet.php
Go to the documentation of this file.
1 <?php
2 
22 
38 {
40 
41  public function getSupportedVersions(): array
42  {
43  return array("4.1.0", "4.4.0", "5.0.0", "5.1.0", "5.2.0", "5.3.0");
44  }
45 
46  protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
47  {
48  return "https://www.ilias.de/xml/Modules/Exercise/" . $a_entity;
49  }
50 
51  protected function getTypes(string $a_entity, string $a_version): array
52  {
53  if ($a_entity == "exc") {
54  switch ($a_version) {
55  case "4.1.0":
56  return array(
57  "Id" => "integer",
58  "Title" => "text",
59  "Description" => "text",
60  "PassMode" => "text",
61  "PassNr" => "integer",
62  "ShowSubmissions" => "integer"
63  );
64 
65  case "4.4.0":
66  case "5.0.0":
67  case "5.1.0":
68  return array(
69  "Id" => "integer",
70  "Title" => "text",
71  "Description" => "text",
72  "PassMode" => "text",
73  "PassNr" => "integer",
74  "ShowSubmissions" => "integer",
75  "ComplBySubmission" => "integer"
76  );
77 
78  case "5.2.0":
79  case "5.3.0":
80  return array(
81  "Id" => "integer",
82  "Title" => "text",
83  "Description" => "text",
84  "PassMode" => "text",
85  "PassNr" => "integer",
86  "NrMandatoryRandom" => "integer",
87  "ShowSubmissions" => "integer",
88  "ComplBySubmission" => "integer",
89  "Tfeedback" => "integer"
90  );
91  }
92  }
93 
94  if ($a_entity == "exc_assignment") {
95  switch ($a_version) {
96  case "4.1.0":
97  return array(
98  "Id" => "integer",
99  "ExerciseId" => "integer",
100  "Deadline" => "text",
101  "Instruction" => "text",
102  "Title" => "text",
103  "Mandatory" => "integer",
104  "OrderNr" => "integer",
105  "Dir" => "directory");
106 
107  case "4.4.0":
108  return array(
109  "Id" => "integer",
110  "ExerciseId" => "integer",
111  "Type" => "integer",
112  "Deadline" => "integer",
113  "Instruction" => "text",
114  "Title" => "text",
115  "Mandatory" => "integer",
116  "OrderNr" => "integer",
117  "Dir" => "directory"
118  // peer
119  ,"Peer" => "integer"
120  ,"PeerMin" => "integer"
121  ,"PeerDeadline" => "integer"
122  // global feedback
123  ,"FeedbackFile" => "integer"
124  ,"FeedbackCron" => "integer"
125  ,"FeedbackDate" => "integer"
126  ,"FeedbackDir" => "directory"
127  );
128 
129  case "5.0.0":
130  return array(
131  "Id" => "integer",
132  "ExerciseId" => "integer",
133  "Type" => "integer",
134  "Deadline" => "integer",
135  "Instruction" => "text",
136  "Title" => "text",
137  "Mandatory" => "integer",
138  "OrderNr" => "integer",
139  "Dir" => "directory"
140  // peer
141  ,"Peer" => "integer"
142  ,"PeerMin" => "integer"
143  ,"PeerDeadline" => "integer"
144  ,"PeerFile" => "integer"
145  ,"PeerPersonal" => "integer"
146  // global feedback
147  ,"FeedbackFile" => "integer"
148  ,"FeedbackCron" => "integer"
149  ,"FeedbackDate" => "integer"
150  ,"FeedbackDir" => "directory"
151  );
152 
153  case "5.1.0":
154  case "5.2.0":
155  return array(
156  "Id" => "integer",
157  "ExerciseId" => "integer",
158  "Type" => "integer",
159  "Deadline" => "integer",
160  "Deadline2" => "integer",
161  "Instruction" => "text",
162  "Title" => "text",
163  "Mandatory" => "integer",
164  "OrderNr" => "integer",
165  "TeamTutor" => "integer",
166  "MaxFile" => "integer",
167  "Dir" => "directory"
168  // peer
169  ,"Peer" => "integer"
170  ,"PeerMin" => "integer"
171  ,"PeerDeadline" => "integer"
172  ,"PeerFile" => "integer"
173  ,"PeerPersonal" => "integer"
174  ,"PeerChar" => "integer"
175  ,"PeerUnlock" => "integer"
176  ,"PeerValid" => "integer"
177  ,"PeerText" => "integer"
178  ,"PeerRating" => "integer"
179  ,"PeerCritCat" => "integer"
180  // global feedback
181  ,"FeedbackFile" => "integer"
182  ,"FeedbackCron" => "integer"
183  ,"FeedbackDate" => "integer"
184  ,"FeedbackDir" => "directory"
185  );
186  case "5.3.0":
187  return array(
188  "Id" => "integer",
189  "ExerciseId" => "integer",
190  "Type" => "integer",
191  "Deadline" => "integer",
192  "Deadline2" => "integer",
193  "Instruction" => "text",
194  "Title" => "text",
195  "Mandatory" => "integer",
196  "OrderNr" => "integer",
197  "TeamTutor" => "integer",
198  "MaxFile" => "integer",
199  "Dir" => "directory",
200  //web data directory
201  "WebDataDir" => "directory"
202  // peer
203  ,"Peer" => "integer"
204  ,"PeerMin" => "integer"
205  ,"PeerDeadline" => "integer"
206  ,"PeerFile" => "integer"
207  ,"PeerPersonal" => "integer"
208  ,"PeerChar" => "integer"
209  ,"PeerUnlock" => "integer"
210  ,"PeerValid" => "integer"
211  ,"PeerText" => "integer"
212  ,"PeerRating" => "integer"
213  ,"PeerCritCat" => "integer"
214  // global feedback
215  ,"FeedbackFile" => "integer"
216  ,"FeedbackCron" => "integer"
217  ,"FeedbackDate" => "integer"
218  ,"FeedbackDir" => "directory"
219  ,"FbDateCustom" => "integer"
220  ,"DeadlineMode" => "integer"
221  ,"RelativeDeadline" => "integer"
222  ,"RelDeadlineLastSubm" => "integer"
223  );
224  }
225  }
226 
227  if ($a_entity == "exc_cit_cat") {
228  switch ($a_version) {
229  case "5.1.0":
230  case "5.2.0":
231  case "5.3.0":
232  return array(
233  "Id" => "integer"
234  ,"Parent" => "integer"
235  ,"Title" => "text"
236  ,"Pos" => "integer"
237  );
238  }
239  }
240 
241  if ($a_entity == "exc_cit") {
242  switch ($a_version) {
243  case "5.1.0":
244  case "5.2.0":
245  case "5.3.0":
246  return array(
247  "Id" => "integer"
248  ,"Parent" => "integer"
249  ,"Type" => "text"
250  ,"Title" => "text"
251  ,"Descr" => "text"
252  ,"Pos" => "integer"
253  ,"Required" => "integer"
254  ,"Def" => "text"
255  ,"DefJson" => "text"
256  );
257  }
258  }
259 
260  if ($a_entity == "exc_ass_file_order") {
261  switch ($a_version) {
262  case "5.3.0":
263  return array(
264  "Id" => "integer"
265  , "AssignmentId" => "integer"
266  , "Filename" => "text"
267  , "OrderNr" => "integer"
268  );
269  }
270  }
271 
272  if ($a_entity == "exc_ass_reminders") {
273  switch ($a_version) {
274  case "5.3.0":
275  return array(
276  "Type" => "text",
277  "AssignmentId" => "integer",
278  "ExerciseId" => "integer",
279  "Status" => "integer",
280  "Start" => "integer",
281  "End" => "integer",
282  "Frequency" => "integer",
283  "LastSend" => "integer",
284  "TemplateId" => "integer"
285  );
286  }
287  }
288  return [];
289  }
290 
291  public function readData(string $a_entity, string $a_version, array $a_ids): void
292  {
293  $ilDB = $this->db;
294 
295  if (!is_array($a_ids)) {
296  $a_ids = array($a_ids);
297  }
298 
299  if ($a_entity == "exc") {
300  switch ($a_version) {
301  case "4.1.0":
302  $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
303  " pass_mode, pass_nr, show_submissions" .
304  " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
305  " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
306  break;
307 
308  case "4.4.0":
309  case "5.0.0":
310  case "5.1.0":
311  $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
312  " pass_mode, pass_nr, show_submissions, compl_by_submission" .
313  " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
314  " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
315  break;
316 
317  case "5.2.0":
318  case "5.3.0":
319  $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
320  " pass_mode, pass_nr, show_submissions, compl_by_submission, tfeedback,nr_mandatory_random" .
321  " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
322  " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
323  break;
324  }
325  }
326 
327  if ($a_entity == "exc_assignment") {
328  switch ($a_version) {
329  case "4.1.0":
330  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline, " .
331  " instruction, title, start_time, mandatory, order_nr" .
332  " FROM exc_assignment" .
333  " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
334  break;
335 
336  case "4.4.0":
337  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline," .
338  " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline," .
339  " fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date" .
340  " FROM exc_assignment" .
341  " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
342  break;
343 
344  case "5.0.0":
345  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline," .
346  " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline," .
347  " peer_file, peer_prsl peer_personal, fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date" .
348  " FROM exc_assignment" .
349  " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
350  break;
351 
352  case "5.1.0":
353  case "5.2.0":
354  case "5.3.0":
355  $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline, deadline2," .
356  " instruction, title, start_time, mandatory, order_nr, team_tutor, max_file, peer, peer_min," .
357  " peer_dl peer_deadline, peer_file, peer_prsl peer_personal, peer_char, peer_unlock, peer_valid," .
358  " peer_text, peer_rating, peer_crit_cat, fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date," .
359  " fb_date_custom, rel_deadline_last_subm, deadline_mode, relative_deadline" .
360  " FROM exc_assignment" .
361  " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
362  break;
363  }
364  }
365 
366  if ($a_entity == "exc_crit_cat") {
367  switch ($a_version) {
368  case "5.1.0":
369  case "5.2.0":
370  case "5.3.0":
371  $this->getDirectDataFromQuery("SELECT id, parent, title, pos" .
372  " FROM exc_crit_cat" .
373  " WHERE " . $ilDB->in("parent", $a_ids, false, "integer"));
374  break;
375  }
376  }
377 
378  if ($a_entity == "exc_crit") {
379  switch ($a_version) {
380  case "5.1.0":
381  case "5.2.0":
382  case "5.3.0":
383  $this->getDirectDataFromQuery("SELECT id, parent, type, title" .
384  ", descr, pos, required, def" .
385  " FROM exc_crit" .
386  " WHERE " . $ilDB->in("parent", $a_ids, false, "integer"));
387  foreach ($this->data as $k => $v) {
388  $this->data[$k]["DefJson"] = "";
389  if ($v["Def"] != "") {
390  $this->data[$k]["DefJson"] = json_encode(unserialize($v["Def"], ['allowed_classes' => false]));
391  }
392  }
393  break;
394  }
395  }
396 
397  if ($a_entity == "exc_ass_file_order") {
398  switch ($a_version) {
399  case "5.3.0":
400  $this->getDirectDataFromQuery("SELECT id, assignment_id, filename, order_nr" .
401  " FROM exc_ass_file_order" .
402  " WHERE " . $ilDB->in("assignment_id", $a_ids, false, "integer"));
403  break;
404  }
405  }
406 
407  if ($a_entity == "exc_ass_reminders") {
408  switch ($a_version) {
409  case "5.3.0":
410  $this->getDirectDataFromQuery("SELECT type, ass_id, exc_id, status, start, end, freq, last_send, template_id" .
411  " FROM exc_ass_reminders" .
412  " WHERE " . $ilDB->in("ass_id", $a_ids, false, "integer"));
413  break;
414  }
415  }
416  }
417 
421  public function getXmlRecord(string $a_entity, string $a_version, array $a_set): array
422  {
423  if ($a_entity == "exc_assignment") {
424  // convert server dates to utc
425  if ($a_set["StartTime"] != "") {
426  $start = new ilDateTime($a_set["StartTime"], IL_CAL_UNIX);
427  $a_set["StartTime"] = $start->get(IL_CAL_DATETIME, '', 'UTC');
428  }
429  if ($a_set["Deadline"] != "") {
430  $deadline = new ilDateTime($a_set["Deadline"], IL_CAL_UNIX);
431  $a_set["Deadline"] = $deadline->get(IL_CAL_DATETIME, '', 'UTC');
432  }
433  if ($a_set["Deadline2"] != "") {
434  $deadline = new ilDateTime($a_set["Deadline2"], IL_CAL_UNIX);
435  $a_set["Deadline2"] = $deadline->get(IL_CAL_DATETIME, '', 'UTC');
436  }
437 
438  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
439  $a_set["Dir"] = $fstorage->getAbsolutePath();
440 
441  $fstorage = new ilFSStorageExercise($a_set["ExerciseId"], $a_set["Id"]);
442  $a_set["FeedbackDir"] = $fstorage->getGlobalFeedbackPath();
443 
444  //now the instruction files inside the root directory
445  $fswebstorage = new ilFSWebStorageExercise($a_set['ExerciseId'], $a_set['Id']);
446  $a_set['WebDataDir'] = $fswebstorage->getAbsolutePath();
447  }
448 
449  //Discuss if necessary when working with timestamps.
450  if ($a_entity == "exc_ass_reminders") {
451  if ($a_set["End"] != "") {
452  $end = new ilDateTime($a_set["End"], IL_CAL_UNIX);
453  $a_set["End"] = $end->get(IL_CAL_DATETIME, '', 'UTC');
454  }
455  if ($a_set["LastSend"] != "") {
456  $last = new ilDateTime($a_set["LastSend"], IL_CAL_UNIX);
457  $a_set["LastSend"] = $last->get(IL_CAL_DATETIME, '', 'UTC');
458  }
459  }
460 
461  return $a_set;
462  }
463 
464  protected function getDependencies(
465  string $a_entity,
466  string $a_version,
467  ?array $a_rec = null,
468  ?array $a_ids = null
469  ): array {
470  switch ($a_entity) {
471  case "exc":
472  switch ($a_version) {
473  case "4.1.0":
474  case "4.4.0":
475  case "5.0.0":
476  return array(
477  "exc_assignment" => array("ids" => $a_rec["Id"] ?? null)
478  );
479 
480  case "5.1.0":
481  case "5.2.0":
482  case "5.3.0":
483  return array(
484  "exc_crit_cat" => array("ids" => $a_rec["Id"] ?? null),
485  "exc_assignment" => array("ids" => $a_rec["Id"] ?? null)
486  );
487  }
488  break;
489 
490  case "exc_crit_cat":
491  return array(
492  "exc_crit" => array("ids" => $a_rec["Id"] ?? null)
493  );
494 
495  case "exc_assignment":
496  switch ($a_version) {
497  case "5.3.0":
498  return array(
499  "exc_ass_file_order" => array("ids" => $a_rec["Id"] ?? null),
500  "exc_ass_reminders" => array("ids" => $a_rec["Id"] ?? null)
501  );
502 
503  }
504  break;
505  }
506  return [];
507  }
508 
518  public function importRecord(
519  string $a_entity,
520  array $a_types,
521  array $a_rec,
522  ilImportMapping $a_mapping,
523  string $a_schema_version
524  ): void {
525  $a_rec = $this->stripTags($a_rec, ["Instruction"]);
526  $purifier = new ilExcInstructionPurifier();
527  $a_rec["Instruction"] = $purifier->purify((string) ($a_rec["Instruction"] ?? ""));
528 
529  switch ($a_entity) {
530  case "exc":
531  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
532  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
533  } else {
534  $newObj = new ilObjExercise();
535  $newObj->setType("exc");
536  $newObj->create();
537  }
538 
539  $newObj->setTitle($a_rec["Title"]);
540  $newObj->setDescription($a_rec["Description"]);
541  $newObj->setPassMode($a_rec["PassMode"]);
542  $newObj->setPassNr((int) $a_rec["PassNr"]);
543  $newObj->setNrMandatoryRandom((int) $a_rec["NrMandatoryRandom"]);
544  $newObj->setShowSubmissions((bool) (int) $a_rec["ShowSubmissions"]);
545  $newObj->setCompletionBySubmission((bool) (int) $a_rec["ComplBySubmission"]);
546  $newObj->setTutorFeedback((int) $a_rec["Tfeedback"]);
547  $newObj->update();
548  $newObj->saveData();
549  $this->current_exc = $newObj;
550 
551  $a_mapping->addMapping("Modules/Exercise", "exc", $a_rec["Id"], $newObj->getId());
552  $a_mapping->addMapping('Services/Object', 'objs', $a_rec['Id'], $newObj->getId());
553  $a_mapping->addMapping('Services/AdvancedMetaData', 'parent', $a_rec['Id'], $newObj->getId());
554  $a_mapping->addMapping(
555  "Services/MetaData",
556  "md",
557  $a_rec["Id"] . ":0:exc",
558  $newObj->getId() . ":0:exc"
559  );
560  break;
561 
562  case "exc_assignment":
563  $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["ExerciseId"]);
564  if ($exc_id > 0) {
565  if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id) {
566  $exc = $this->current_exc;
567  } else {
568  $exc = new ilObjExercise($exc_id, false);
569  }
570 
571  $ass = new ilExAssignment();
572  $ass->setExerciseId($exc_id);
573 
574  if ($a_rec["StartTime"] != "") {
575  $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC");
576  $ass->setStartTime($start->get(IL_CAL_UNIX));
577  }
578 
579  if ($a_rec["Deadline"] != "") {
580  $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC");
581  $ass->setDeadline($deadline->get(IL_CAL_UNIX));
582  }
583 
584  $ass->setInstruction($a_rec["Instruction"] ?? "");
585  $ass->setTitle($a_rec["Title"] ?? "");
586  $ass->setMandatory((bool) ($a_rec["Mandatory"] ?? false));
587  $ass->setOrderNr((int) ($a_rec["OrderNr"] ?? 0));
588 
589  // 4.2
590  $ass->setType((int) ($a_rec["Type"] ?? 0));
591 
592  // 4.4
593  $ass->setPeerReview((bool) ($a_rec["Peer"] ?? false));
594  $ass->setPeerReviewMin((int) ($a_rec["PeerMin"] ?? 0));
595  $ass->setPeerReviewDeadline((int) $a_rec["PeerDeadline"]);
596  $ass->setFeedbackFile($a_rec["FeedbackFile"] ?? "");
597  $ass->setFeedbackCron((bool) ($a_rec["FeedbackCron"] ?? false));
598  $ass->setFeedbackDate((int) ($a_rec["FeedbackDate"] ?? 0));
599 
600  // 5.0
601  $ass->setPeerReviewFileUpload((bool) ($a_rec["PeerFile"] ?? false));
602  $ass->setPeerReviewPersonalized((bool) ($a_rec["PeerPersonal"] ?? false));
603 
604  // 5.1
605  if (($a_rec["Deadline2"] ?? "") !== "") {
606  $deadline = new ilDateTime($a_rec["Deadline2"], IL_CAL_DATETIME, "UTC");
607  $ass->setExtendedDeadline($deadline->get(IL_CAL_UNIX));
608  }
609  $ass->setMaxFile((int) ($a_rec["MaxFile"] ?? 0));
610  $ass->setTeamTutor((bool) ($a_rec["TeamTutor"] ?? false));
611  $ass->setPeerReviewChars((int) ($a_rec["PeerChar"] ?? null));
612  $ass->setPeerReviewSimpleUnlock((bool) ($a_rec["PeerUnlock"] ?? false));
613  $ass->setPeerReviewValid((int) ($a_rec["PeerValid"] ?? 0));
614  $ass->setPeerReviewText((bool) ($a_rec["PeerText"] ?? false));
615  $ass->setPeerReviewRating((bool) ($a_rec["PeerRating"] ?? false));
616 
617  // 5.3
618  $ass->setFeedbackDateCustom((int) ($a_rec["FbDateCustom"] ?? 0));
619  $ass->setRelDeadlineLastSubmission((int) ($a_rec["RelDeadlineLastSubm"] ?? 0));
620  $ass->setDeadlineMode((int) ($a_rec["DeadlineMode"] ?? 0));
621  $ass->setRelativeDeadline((int) ($a_rec["RelativeDeadline"] ?? 0));
622 
623  // criteria catalogue
624  if ($a_rec["PeerCritCat"]) {
625  $ass->setPeerReviewCriteriaCatalogue((int) $a_mapping->getMapping("Modules/Exercise", "exc_crit_cat", $a_rec["PeerCritCat"]));
626  }
627 
628  $ass->save();
629 
630  $fstorage = new ilFSStorageExercise($exc_id, $ass->getId());
631  $fstorage->create();
632 
633  // assignment files
634  $dir = str_replace("..", "", $a_rec["Dir"]);
635  if ($dir != "" && $this->getImportDirectory() != "") {
636  $source_dir = $this->getImportDirectory() . "/" . $dir;
637  $target_dir = $fstorage->getAbsolutePath();
638  ilFileUtils::rCopy($source_dir, $target_dir);
639  }
640 
641  // (4.4) global feedback file
642  $dir = str_replace("..", "", $a_rec["FeedbackDir"]);
643  if ($dir != "" && $this->getImportDirectory() != "") {
644  $source_dir = $this->getImportDirectory() . "/" . $dir;
645  $target_dir = $fstorage->getGlobalFeedbackPath();
646  ilFileUtils::rCopy($source_dir, $target_dir);
647  }
648 
649  // (5.3) assignment files inside ILIAS
650  $fwebstorage = new ilFSWebStorageExercise($exc_id, $ass->getId());
651  $fwebstorage->create();
652  $dir = str_replace("..", "", $a_rec["WebDataDir"]);
653  if ($dir != "" && $this->getImportDirectory() != "") {
654  $source_dir = $this->getImportDirectory() . "/" . $dir;
655  $target_dir = $fwebstorage->getAbsolutePath();
656  ilFileUtils::rCopy($source_dir, $target_dir);
657  }
658 
659  // 5.4 Team wiki assignment AR
660  if ($a_rec["Type"] == ilExAssignment::TYPE_WIKI_TEAM) {
661  $ar = new ilExAssWikiTeamAR();
662  $ar->setId($ass->getId());
663  $ar->setTemplateRefId(0);
664  $ar->setContainerRefId(0);
665  $ar->save();
666  }
667 
668  $a_mapping->addMapping("Modules/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId());
669  }
670 
671  break;
672 
673  case "exc_crit_cat":
674  $exc_id = $a_mapping->getMapping("Modules/Exercise", "exc", $a_rec["Parent"]);
675  if ($exc_id > 0) {
676  $crit_cat = new ilExcCriteriaCatalogue();
677  $crit_cat->setParent($exc_id);
678  $crit_cat->setTitle($a_rec["Title"]);
679  $crit_cat->setPosition($a_rec["Pos"]);
680  $crit_cat->save();
681 
682  $a_mapping->addMapping("Modules/Exercise", "exc_crit_cat", $a_rec["Id"], $crit_cat->getId());
683  }
684  break;
685 
686  case "exc_crit":
687  $crit_cat_id = $a_mapping->getMapping("Modules/Exercise", "exc_crit_cat", $a_rec["Parent"]);
688  if ($crit_cat_id > 0) {
689  $crit = ilExcCriteria::getInstanceByType($a_rec["Type"]);
690  $crit->setParent($crit_cat_id);
691  $crit->setTitle($a_rec["Title"]);
692  $crit->setDescription($a_rec["Descr"]);
693  $crit->setPosition($a_rec["Pos"]);
694  $crit->setRequired($a_rec["Required"]);
695  $crit->importDefinition($a_rec["Def"], $a_rec["DefJson"]);
696  $crit->save();
697  }
698  break;
699 
700  case "exc_ass_file_order":
701 
702  $ass_id = $a_mapping->getMapping("Modules/Exercise", "exc_assignment", $a_rec["AssignmentId"]);
703  if ($ass_id > 0) {
704  ilExAssignment::instructionFileInsertOrder($a_rec["Filename"], $ass_id, $a_rec["OrderNr"]);
705  }
706  break;
707 
708  case "exc_ass_reminders":
709  // (5.3) reminders
710  $new_ass_id = $a_mapping->getMapping("Modules/Exercise", "exc_assignment", $a_rec["AssId"]);
711  $new_exc_id = $a_mapping->getMapping('Modules/Exercise', 'exc', $a_rec['ExcId']);
712  //always UTC timestamp in db.
713  $end = new ilDateTime($a_rec["End"], IL_CAL_DATETIME, "UTC");
714  $rmd = new ilExAssignmentReminder($new_exc_id, $new_ass_id, $a_rec["Type"]);
715  $rmd->setReminderStatus($a_rec["Status"]);
716  $rmd->setReminderStart((int) ($a_rec["Start"] ?? 0));
717  $rmd->setReminderEnd((int) $end->get(IL_CAL_UNIX));
718  $rmd->setReminderFrequency((int) ($a_rec["Freq"] ?? 0));
719  $rmd->setReminderLastSend((int) ($a_rec["LastSend"] ?? 0));
720  $rmd->setReminderMailTemplate((int) ($a_rec["TemplateId"] ?? 0));
721  $rmd->save();
722  }
723  }
724 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Exercise assignment.
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlRecord(string $a_entity, string $a_version, array $a_set)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static getInstanceByType(string $a_type)
const IL_CAL_UNIX
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjExercise.
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
ilDBInterface $db
Exercise data set class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTypes(string $a_entity, string $a_version)
getXmlNamespace(string $a_entity, string $a_schema_version)
static instructionFileInsertOrder(string $a_filename, int $a_ass_id, int $a_order_nr=0)
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readData(string $a_entity, string $a_version, array $a_ids)
stripTags(array $rec, array $omit_keys=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)