ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilExerciseDataSet Class Reference

Exercise data set class. More...

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

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 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 fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $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 ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

DomainService $ass_domain
 
ilObjExercise $current_exc
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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
 
int $dircnt = 0
 

Detailed Description

Exercise data set class.

Entities:

  • exc: Exercise data
  • exc_assignment: Assignment data
  • exc_crit_cat: criteria category
  • exc_crit: criteria
  • exc_ass_file_order: Order of instruction files
  • exc_ass_reminders: Assingment reminder data
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseDataSet::__construct ( )

Reimplemented from ilDataSet.

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

45 {
46 global $DIC;
47
49 $this->ass_domain = $DIC->exercise()->internal()->domain()->assignment();
50 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getCollection()

ilExerciseDataSet::getCollection ( array  $record,
string  $entity,
string  $schema_version,
string  $field,
string  $value 
)

Reimplemented from ilDataSet.

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

783 if ($entity === "exc_assignment" && $field === "InstructionCollection") {
784 return $this->ass_domain->instructionFiles((int) $record["Id"])->getCollection();
785 }
786 return null;
787 }
string $entity

◆ getDependencies()

ilExerciseDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Reimplemented from ilDataSet.

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

524 : array {
525 switch ($a_entity) {
526 case "exc":
527 switch ($a_version) {
528 case "4.1.0":
529 case "4.4.0":
530 case "5.0.0":
531 return array(
532 "exc_assignment" => array("ids" => $a_rec["Id"] ?? null)
533 );
534
535 case "5.1.0":
536 case "5.2.0":
537 case "5.3.0":
538 case "9.0":
539 return array(
540 "exc_crit_cat" => array("ids" => $a_rec["Id"] ?? null),
541 "exc_assignment" => array("ids" => $a_rec["Id"] ?? null)
542 );
543 }
544 break;
545
546 case "exc_crit_cat":
547 return array(
548 "exc_crit" => array("ids" => $a_rec["Id"] ?? null)
549 );
550
551 case "exc_assignment":
552 switch ($a_version) {
553 case "5.3.0":
554 case "9.0":
555 return array(
556 "exc_ass_file_order" => array("ids" => $a_rec["Id"] ?? null),
557 "exc_ass_reminders" => array("ids" => $a_rec["Id"] ?? null)
558 );
559 }
560 break;
561 }
562 return [];
563 }

◆ getSupportedVersions()

ilExerciseDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

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

53 : array
54 {
55 return array("4.1.0", "4.4.0", "5.0.0", "5.1.0", "5.2.0", "5.3.0", "9.0");
56 }

◆ getTypes()

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

Get (abstract) types for (abstract) field names.

Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Reimplemented from ilDataSet.

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

63 : array
64 {
65 if ($a_entity == "exc") {
66 switch ($a_version) {
67 case "4.1.0":
68 return array(
69 "Id" => "integer",
70 "Title" => "text",
71 "Description" => "text",
72 "PassMode" => "text",
73 "PassNr" => "integer",
74 "ShowSubmissions" => "integer"
75 );
76
77 case "4.4.0":
78 case "5.0.0":
79 case "5.1.0":
80 return array(
81 "Id" => "integer",
82 "Title" => "text",
83 "Description" => "text",
84 "PassMode" => "text",
85 "PassNr" => "integer",
86 "ShowSubmissions" => "integer",
87 "ComplBySubmission" => "integer"
88 );
89
90 case "5.2.0":
91 case "5.3.0":
92 case "9.0":
93 return array(
94 "Id" => "integer",
95 "Title" => "text",
96 "Description" => "text",
97 "PassMode" => "text",
98 "PassNr" => "integer",
99 "NrMandatoryRandom" => "integer",
100 "ShowSubmissions" => "integer",
101 "ComplBySubmission" => "integer",
102 "Tfeedback" => "integer"
103 );
104 }
105 }
106
107 if ($a_entity == "exc_assignment") {
108 switch ($a_version) {
109 case "4.1.0":
110 return array(
111 "Id" => "integer",
112 "ExerciseId" => "integer",
113 "Deadline" => "text",
114 "Instruction" => "text",
115 "Title" => "text",
116 "Mandatory" => "integer",
117 "OrderNr" => "integer",
118 "Dir" => "directory");
119
120 case "4.4.0":
121 return array(
122 "Id" => "integer",
123 "ExerciseId" => "integer",
124 "Type" => "integer",
125 "Deadline" => "integer",
126 "Instruction" => "text",
127 "Title" => "text",
128 "Mandatory" => "integer",
129 "OrderNr" => "integer",
130 "Dir" => "directory"
131 // peer
132 ,"Peer" => "integer"
133 ,"PeerMin" => "integer"
134 ,"PeerDeadline" => "integer"
135 // global feedback
136 ,"FeedbackFile" => "integer"
137 ,"FeedbackCron" => "integer"
138 ,"FeedbackDate" => "integer"
139 ,"FeedbackDir" => "directory"
140 );
141
142 case "5.0.0":
143 return array(
144 "Id" => "integer",
145 "ExerciseId" => "integer",
146 "Type" => "integer",
147 "Deadline" => "integer",
148 "Instruction" => "text",
149 "Title" => "text",
150 "Mandatory" => "integer",
151 "OrderNr" => "integer",
152 "Dir" => "directory"
153 // peer
154 ,"Peer" => "integer"
155 ,"PeerMin" => "integer"
156 ,"PeerDeadline" => "integer"
157 ,"PeerFile" => "integer"
158 ,"PeerPersonal" => "integer"
159 // global feedback
160 ,"FeedbackFile" => "integer"
161 ,"FeedbackCron" => "integer"
162 ,"FeedbackDate" => "integer"
163 ,"FeedbackDir" => "directory"
164 );
165
166 case "5.1.0":
167 case "5.2.0":
168 return array(
169 "Id" => "integer",
170 "ExerciseId" => "integer",
171 "Type" => "integer",
172 "Deadline" => "integer",
173 "Deadline2" => "integer",
174 "Instruction" => "text",
175 "Title" => "text",
176 "Mandatory" => "integer",
177 "OrderNr" => "integer",
178 "TeamTutor" => "integer",
179 "MaxFile" => "integer",
180 "Dir" => "directory"
181 // peer
182 ,"Peer" => "integer"
183 ,"PeerMin" => "integer"
184 ,"PeerDeadline" => "integer"
185 ,"PeerFile" => "integer"
186 ,"PeerPersonal" => "integer"
187 ,"PeerChar" => "integer"
188 ,"PeerUnlock" => "integer"
189 ,"PeerValid" => "integer"
190 ,"PeerText" => "integer"
191 ,"PeerRating" => "integer"
192 ,"PeerCritCat" => "integer"
193 // global feedback
194 ,"FeedbackFile" => "integer"
195 ,"FeedbackCron" => "integer"
196 ,"FeedbackDate" => "integer"
197 ,"FeedbackDir" => "directory"
198 );
199 case "5.3.0":
200 return array(
201 "Id" => "integer",
202 "ExerciseId" => "integer",
203 "Type" => "integer",
204 "Deadline" => "integer",
205 "Deadline2" => "integer",
206 "Instruction" => "text",
207 "Title" => "text",
208 "Mandatory" => "integer",
209 "OrderNr" => "integer",
210 "TeamTutor" => "integer",
211 "MaxFile" => "integer",
212 "Dir" => "directory",
213 //web data directory
214 "WebDataDir" => "directory"
215 // peer
216 ,"Peer" => "integer"
217 ,"PeerMin" => "integer"
218 ,"PeerDeadline" => "integer"
219 ,"PeerFile" => "integer"
220 ,"PeerPersonal" => "integer"
221 ,"PeerChar" => "integer"
222 ,"PeerUnlock" => "integer"
223 ,"PeerValid" => "integer"
224 ,"PeerText" => "integer"
225 ,"PeerRating" => "integer"
226 ,"PeerCritCat" => "integer"
227 // global feedback
228 ,"FeedbackFile" => "integer"
229 ,"FeedbackCron" => "integer"
230 ,"FeedbackDate" => "integer"
231 ,"FeedbackDir" => "directory"
232 ,"FbDateCustom" => "integer"
233 ,"DeadlineMode" => "integer"
234 ,"RelativeDeadline" => "integer"
235 ,"RelDeadlineLastSubm" => "integer"
236 );
237 case "9.0":
238 return array(
239 "Id" => "integer",
240 "ExerciseId" => "integer",
241 "Type" => "integer",
242 "Deadline" => "integer",
243 "Deadline2" => "integer",
244 "Instruction" => "text",
245 "Title" => "text",
246 "Mandatory" => "integer",
247 "OrderNr" => "integer",
248 "TeamTutor" => "integer",
249 "MaxFile" => "integer",
250 "InstructionCollection" => "rscollection",
251 //web data directory
252 "WebDataDir" => "directory"
253 // peer
254 ,"Peer" => "integer"
255 ,"PeerMin" => "integer"
256 ,"PeerDeadline" => "integer"
257 ,"PeerFile" => "integer"
258 ,"PeerPersonal" => "integer"
259 ,"PeerChar" => "integer"
260 ,"PeerUnlock" => "integer"
261 ,"PeerValid" => "integer"
262 ,"PeerText" => "integer"
263 ,"PeerRating" => "integer"
264 ,"PeerCritCat" => "integer"
265 // global feedback
266 ,"FeedbackFile" => "integer"
267 ,"FeedbackCron" => "integer"
268 ,"FeedbackDate" => "integer"
269 ,"FeedbackDir" => "directory"
270 ,"FbDateCustom" => "integer"
271 ,"DeadlineMode" => "integer"
272 ,"RelativeDeadline" => "integer"
273 ,"RelDeadlineLastSubm" => "integer"
274 );
275 }
276 }
277
278 if ($a_entity == "exc_cit_cat") {
279 switch ($a_version) {
280 case "5.1.0":
281 case "5.2.0":
282 case "5.3.0":
283 case "9.0":
284 return array(
285 "Id" => "integer"
286 ,"Parent" => "integer"
287 ,"Title" => "text"
288 ,"Pos" => "integer"
289 );
290 }
291 }
292
293 if ($a_entity == "exc_cit") {
294 switch ($a_version) {
295 case "5.1.0":
296 case "5.2.0":
297 case "5.3.0":
298 case "9.0":
299 return array(
300 "Id" => "integer"
301 ,"Parent" => "integer"
302 ,"Type" => "text"
303 ,"Title" => "text"
304 ,"Descr" => "text"
305 ,"Pos" => "integer"
306 ,"Required" => "integer"
307 ,"Def" => "text"
308 ,"DefJson" => "text"
309 );
310 }
311 }
312
313 if ($a_entity == "exc_ass_file_order") {
314 switch ($a_version) {
315 case "5.3.0":
316 case "9.0":
317 return array(
318 "Id" => "integer"
319 , "AssignmentId" => "integer"
320 , "Filename" => "text"
321 , "OrderNr" => "integer"
322 );
323 }
324 }
325
326 if ($a_entity == "exc_ass_reminders") {
327 switch ($a_version) {
328 case "5.3.0":
329 case "9.0":
330 return array(
331 "Type" => "text",
332 "AssignmentId" => "integer",
333 "ExerciseId" => "integer",
334 "Status" => "integer",
335 "Start" => "integer",
336 "End" => "integer",
337 "Frequency" => "integer",
338 "LastSend" => "integer",
339 "TemplateId" => "integer"
340 );
341 }
342 }
343 return [];
344 }

◆ getXmlNamespace()

ilExerciseDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Reimplemented from ilDataSet.

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

58 : string
59 {
60 return "https://www.ilias.de/xml/Modules/Exercise/" . $a_entity;
61 }

◆ getXmlRecord()

ilExerciseDataSet::getXmlRecord ( string  $a_entity,
string  $a_version,
array  $a_set 
)
Exceptions
ilDateTimeException

Reimplemented from ilDataSet.

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

482 : array
483 {
484 if ($a_entity == "exc_assignment") {
485 // convert server dates to utc
486 if ($a_set["StartTime"] != "") {
487 $start = new ilDateTime($a_set["StartTime"], IL_CAL_UNIX);
488 $a_set["StartTime"] = $start->get(IL_CAL_DATETIME, '', 'UTC');
489 }
490 if ($a_set["Deadline"] != "") {
491 $deadline = new ilDateTime($a_set["Deadline"], IL_CAL_UNIX);
492 $a_set["Deadline"] = $deadline->get(IL_CAL_DATETIME, '', 'UTC');
493 }
494 if ($a_set["Deadline2"] != "") {
495 $deadline = new ilDateTime($a_set["Deadline2"], IL_CAL_UNIX);
496 $a_set["Deadline2"] = $deadline->get(IL_CAL_DATETIME, '', 'UTC');
497 }
498
499 $if = $this->ass_domain->instructionFiles((int) $a_set["Id"]);
500 $a_set["InstructionCollection"] = $if->getCollectionIdString();
501
502 }
503
504 //Discuss if necessary when working with timestamps.
505 if ($a_entity == "exc_ass_reminders") {
506 if ($a_set["End"] != "") {
507 $end = new ilDateTime($a_set["End"], IL_CAL_UNIX);
508 $a_set["End"] = $end->get(IL_CAL_DATETIME, '', 'UTC');
509 }
510 if ($a_set["LastSend"] != "") {
511 $last = new ilDateTime($a_set["LastSend"], IL_CAL_UNIX);
512 $a_set["LastSend"] = $last->get(IL_CAL_DATETIME, '', 'UTC');
513 }
514 }
515
516 return $a_set;
517 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling

References IL_CAL_DATETIME, and IL_CAL_UNIX.

◆ importRecord()

ilExerciseDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)
Exceptions
FileNotFoundException
DirectoryNotFoundException
ilDatabaseException
ilExcUnknownAssignmentTypeException
ilDateTimeException
ilObjectNotFoundException
IOException

Reimplemented from ilDataSet.

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

580 : void {
581 $a_rec = $this->stripTags($a_rec, ["Instruction"]);
582 $purifier = new ilExcInstructionPurifier();
583 $a_rec["Instruction"] = $purifier->purify((string) ($a_rec["Instruction"] ?? ""));
584
585 switch ($a_entity) {
586 case "exc":
587 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
588 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
589 } else {
590 $newObj = new ilObjExercise();
591 $newObj->setType("exc");
592 $newObj->create();
593 }
594
595 $newObj->setTitle($a_rec["Title"]);
596 $newObj->setDescription($a_rec["Description"]);
597 $newObj->setPassMode($a_rec["PassMode"]);
598 $newObj->setPassNr((int) $a_rec["PassNr"]);
599 $newObj->setNrMandatoryRandom((int) $a_rec["NrMandatoryRandom"]);
600 $newObj->setShowSubmissions((bool) (int) $a_rec["ShowSubmissions"]);
601 $newObj->setCompletionBySubmission((bool) (int) $a_rec["ComplBySubmission"]);
602 $newObj->setTutorFeedback((int) $a_rec["Tfeedback"]);
603 $newObj->update();
604 $newObj->saveData();
605 $this->current_exc = $newObj;
606
607 $a_mapping->addMapping("components/ILIAS/Exercise", "exc", $a_rec["Id"], $newObj->getId());
608 $a_mapping->addMapping('components/ILIAS/ILIASObject', 'objs', $a_rec['Id'], $newObj->getId());
609 $a_mapping->addMapping('components/ILIAS/AdvancedMetaData', 'parent', $a_rec['Id'], $newObj->getId());
610 $a_mapping->addMapping(
611 "components/ILIAS/MetaData",
612 "md",
613 $a_rec["Id"] . ":0:exc",
614 $newObj->getId() . ":0:exc"
615 );
616 $a_mapping->addMapping(
617 "components/ILIAS/Tracking",
618 "obj",
619 (string) $a_rec["Id"],
620 (string) $newObj->getId()
621 );
622 break;
623
624 case "exc_assignment":
625 $exc_id = $a_mapping->getMapping("components/ILIAS/Exercise", "exc", $a_rec["ExerciseId"]);
626 if ($exc_id > 0) {
627 if (is_object($this->current_exc) && $this->current_exc->getId() == $exc_id) {
628 $exc = $this->current_exc;
629 } else {
630 $exc = new ilObjExercise($exc_id, false);
631 }
632
633 $ass = new ilExAssignment();
634 $ass->setExerciseId($exc_id);
635
636 if ($a_rec["StartTime"] != "") {
637 $start = new ilDateTime($a_rec["StartTime"], IL_CAL_DATETIME, "UTC");
638 $ass->setStartTime($start->get(IL_CAL_UNIX));
639 }
640
641 if ($a_rec["Deadline"] != "") {
642 $deadline = new ilDateTime($a_rec["Deadline"], IL_CAL_DATETIME, "UTC");
643 $ass->setDeadline($deadline->get(IL_CAL_UNIX));
644 }
645
646 $ass->setInstruction($a_rec["Instruction"] ?? "");
647 $ass->setTitle($a_rec["Title"] ?? "");
648 $ass->setMandatory((bool) ($a_rec["Mandatory"] ?? false));
649 $ass->setOrderNr((int) ($a_rec["OrderNr"] ?? 0));
650
651 // 4.2
652 $ass->setType((int) ($a_rec["Type"] ?? 0));
653
654 // 4.4
655 $ass->setPeerReview((bool) ($a_rec["Peer"] ?? false));
656 $ass->setPeerReviewMin((int) ($a_rec["PeerMin"] ?? 0));
657 $ass->setPeerReviewDeadline((int) $a_rec["PeerDeadline"]);
658 $ass->setFeedbackFile($a_rec["FeedbackFile"] ?? "");
659 $ass->setFeedbackCron((bool) ($a_rec["FeedbackCron"] ?? false));
660 $ass->setFeedbackDate((int) ($a_rec["FeedbackDate"] ?? 0));
661
662 // 5.0
663 $ass->setPeerReviewFileUpload((bool) ($a_rec["PeerFile"] ?? false));
664 $ass->setPeerReviewPersonalized((bool) ($a_rec["PeerPersonal"] ?? false));
665
666 // 5.1
667 if (($a_rec["Deadline2"] ?? "") !== "") {
668 $deadline = new ilDateTime($a_rec["Deadline2"], IL_CAL_DATETIME, "UTC");
669 $ass->setExtendedDeadline($deadline->get(IL_CAL_UNIX));
670 }
671 $ass->setMaxFile((int) ($a_rec["MaxFile"] ?? 0));
672 $ass->setTeamTutor((bool) ($a_rec["TeamTutor"] ?? false));
673 $ass->setPeerReviewChars((int) ($a_rec["PeerChar"] ?? null));
674 $ass->setPeerReviewSimpleUnlock((int) ($a_rec["PeerUnlock"] ?? 0));
675 $ass->setPeerReviewValid((int) ($a_rec["PeerValid"] ?? 0));
676 $ass->setPeerReviewText((bool) ($a_rec["PeerText"] ?? false));
677 $ass->setPeerReviewRating((bool) ($a_rec["PeerRating"] ?? false));
678
679 // 5.3
680 $ass->setFeedbackDateCustom((int) ($a_rec["FbDateCustom"] ?? 0));
681 $ass->setRelDeadlineLastSubmission((int) ($a_rec["RelDeadlineLastSubm"] ?? 0));
682 $ass->setDeadlineMode((int) ($a_rec["DeadlineMode"] ?? 0));
683 $ass->setRelativeDeadline((int) ($a_rec["RelativeDeadline"] ?? 0));
684
685 // criteria catalogue
686 if ($a_rec["PeerCritCat"]) {
687 $ass->setPeerReviewCriteriaCatalogue((int) $a_mapping->getMapping("components/ILIAS/Exercise", "exc_crit_cat", $a_rec["PeerCritCat"]));
688 }
689
690 $ass->save();
691
692 // instruction files
693 $dir = str_replace("..", "", ($a_rec["InstructionCollection"] ?? ""));
694 if ($dir != "" && $this->getImportDirectory() != "") {
695 $if = $this->ass_domain->instructionFiles($ass->getId());
696 $if->importFromDirectory($this->getImportDirectory() . "/" . $dir);
697 } else {
698 $dir = str_replace("..", "", ($a_rec["Dir"] ?? "")); // legacy Dir
699 if ($dir != "" && $this->getImportDirectory() != "") {
700 $if = $this->ass_domain->instructionFiles($ass->getId());
701 $if->importFromDirectory($this->getImportDirectory() . "/" . $dir);
702 }
703 $dir = str_replace("..", "", ($a_rec["WebDataDir"] ?? "")); // legacy WebDataDir
704 if ($dir != "" && $this->getImportDirectory() != "") {
705 $if = $this->ass_domain->instructionFiles($ass->getId());
706 $if->importFromDirectory($this->getImportDirectory() . "/" . $dir);
707 }
708 }
709
710 // 5.4 Team wiki assignment AR
711 if ($a_rec["Type"] == ilExAssignment::TYPE_WIKI_TEAM) {
712 $ar = new ilExAssWikiTeamAR();
713 $ar->setId($ass->getId());
714 $ar->setTemplateRefId(0);
715 $ar->setContainerRefId(0);
716 $ar->save();
717 }
718
719 $a_mapping->addMapping("components/ILIAS/Exercise", "exc_assignment", $a_rec["Id"], $ass->getId());
720 }
721
722 break;
723
724 case "exc_crit_cat":
725 $exc_id = $a_mapping->getMapping("components/ILIAS/Exercise", "exc", $a_rec["Parent"]);
726 if ($exc_id > 0) {
727 $crit_cat = new ilExcCriteriaCatalogue();
728 $crit_cat->setParent($exc_id);
729 $crit_cat->setTitle($a_rec["Title"]);
730 $crit_cat->setPosition($a_rec["Pos"]);
731 $crit_cat->save();
732
733 $a_mapping->addMapping("components/ILIAS/Exercise", "exc_crit_cat", $a_rec["Id"], $crit_cat->getId());
734 }
735 break;
736
737 case "exc_crit":
738 $crit_cat_id = $a_mapping->getMapping("components/ILIAS/Exercise", "exc_crit_cat", $a_rec["Parent"]);
739 if ($crit_cat_id > 0) {
740 $crit = ilExcCriteria::getInstanceByType($a_rec["Type"]);
741 $crit->setParent($crit_cat_id);
742 $crit->setTitle($a_rec["Title"]);
743 $crit->setDescription($a_rec["Descr"]);
744 $crit->setPosition($a_rec["Pos"]);
745 $crit->setRequired($a_rec["Required"]);
746 $crit->importDefinition($a_rec["Def"], $a_rec["DefJson"]);
747 $crit->save();
748 }
749 break;
750
751 case "exc_ass_file_order":
752
753 $ass_id = $a_mapping->getMapping("components/ILIAS/Exercise", "exc_assignment", $a_rec["AssignmentId"]);
754 if ($ass_id > 0) {
755 ilExAssignment::instructionFileInsertOrder($a_rec["Filename"], $ass_id, $a_rec["OrderNr"]);
756 }
757 break;
758
759 case "exc_ass_reminders":
760 // (5.3) reminders
761 $new_ass_id = $a_mapping->getMapping("components/ILIAS/Exercise", "exc_assignment", $a_rec["AssId"]);
762 $new_exc_id = $a_mapping->getMapping('components/ILIAS/Exercise', 'exc', $a_rec['ExcId']);
763 //always UTC timestamp in db.
764 $end = new ilDateTime($a_rec["End"], IL_CAL_DATETIME, "UTC");
765 $rmd = new ilExAssignmentReminder($new_exc_id, $new_ass_id, $a_rec["Type"]);
766 $rmd->setReminderStatus($a_rec["Status"]);
767 $rmd->setReminderStart((int) ($a_rec["Start"] ?? 0));
768 $rmd->setReminderEnd((int) $end->get(IL_CAL_UNIX));
769 $rmd->setReminderFrequency((int) ($a_rec["Freq"] ?? 0));
770 $rmd->setReminderLastSend((int) ($a_rec["LastSend"] ?? 0));
771 $rmd->setReminderMailTemplate((int) ($a_rec["TemplateId"] ?? 0));
772 $rmd->save();
773 }
774 }
stripTags(array $rec, array $omit_keys=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TODO: import/export reminder data with the exercise/assignment.
Exercise assignment.
static instructionFileInsertOrder(string $a_filename, int $a_ass_id, int $a_order_nr=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByType(string $a_type)
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
Class ilObjExercise.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id

◆ readData()

ilExerciseDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Reimplemented from ilDataSet.

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

346 : void
347 {
349
350 if (!is_array($a_ids)) {
351 $a_ids = array($a_ids);
352 }
353
354 if ($a_entity == "exc") {
355 switch ($a_version) {
356 case "4.1.0":
357 $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
358 " pass_mode, pass_nr, show_submissions" .
359 " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
360 " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
361 break;
362
363 case "4.4.0":
364 case "5.0.0":
365 case "5.1.0":
366 $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
367 " pass_mode, pass_nr, show_submissions, compl_by_submission" .
368 " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
369 " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
370 break;
371
372 case "5.2.0":
373 case "5.3.0":
374 case "9.0":
375 $this->getDirectDataFromQuery("SELECT exc_data.obj_id id, title, description," .
376 " pass_mode, pass_nr, show_submissions, compl_by_submission, tfeedback,nr_mandatory_random" .
377 " FROM exc_data JOIN object_data ON (exc_data.obj_id = object_data.obj_id)" .
378 " WHERE " . $ilDB->in("exc_data.obj_id", $a_ids, false, "integer"));
379 break;
380 }
381 }
382
383 if ($a_entity == "exc_assignment") {
384 switch ($a_version) {
385 case "4.1.0":
386 $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, time_stamp deadline, " .
387 " instruction, title, start_time, mandatory, order_nr" .
388 " FROM exc_assignment" .
389 " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
390 break;
391
392 case "4.4.0":
393 $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline," .
394 " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline," .
395 " fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date" .
396 " FROM exc_assignment" .
397 " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
398 break;
399
400 case "5.0.0":
401 $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline," .
402 " instruction, title, start_time, mandatory, order_nr, peer, peer_min, peer_dl peer_deadline," .
403 " peer_file, peer_prsl peer_personal, fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date" .
404 " FROM exc_assignment" .
405 " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
406 break;
407
408 case "5.1.0":
409 case "5.2.0":
410 case "5.3.0":
411 case "9.0":
412 $this->getDirectDataFromQuery("SELECT id, exc_id exercise_id, type, time_stamp deadline, deadline2," .
413 " instruction, title, start_time, mandatory, order_nr, team_tutor, max_file, peer, peer_min," .
414 " peer_dl peer_deadline, peer_file, peer_prsl peer_personal, peer_char, peer_unlock, peer_valid," .
415 " peer_text, peer_rating, peer_crit_cat, fb_file feedback_file, fb_cron feedback_cron, fb_date feedback_date," .
416 " fb_date_custom, rel_deadline_last_subm, deadline_mode, relative_deadline" .
417 " FROM exc_assignment" .
418 " WHERE " . $ilDB->in("exc_id", $a_ids, false, "integer"));
419 break;
420 }
421 }
422
423 if ($a_entity == "exc_crit_cat") {
424 switch ($a_version) {
425 case "5.1.0":
426 case "5.2.0":
427 case "5.3.0":
428 case "9.0":
429 $this->getDirectDataFromQuery("SELECT id, parent, title, pos" .
430 " FROM exc_crit_cat" .
431 " WHERE " . $ilDB->in("parent", $a_ids, false, "integer"));
432 break;
433 }
434 }
435
436 if ($a_entity == "exc_crit") {
437 switch ($a_version) {
438 case "5.1.0":
439 case "5.2.0":
440 case "5.3.0":
441 case "9.0":
442 $this->getDirectDataFromQuery("SELECT id, parent, type, title" .
443 ", descr, pos, required, def" .
444 " FROM exc_crit" .
445 " WHERE " . $ilDB->in("parent", $a_ids, false, "integer"));
446 foreach ($this->data as $k => $v) {
447 $this->data[$k]["DefJson"] = "";
448 if ($v["Def"] != "") {
449 $this->data[$k]["DefJson"] = json_encode(unserialize($v["Def"], ['allowed_classes' => false]));
450 }
451 }
452 break;
453 }
454 }
455
456 if ($a_entity == "exc_ass_file_order") {
457 switch ($a_version) {
458 case "5.3.0":
459 case "9.0":
460 $this->getDirectDataFromQuery("SELECT id, assignment_id, filename, order_nr" .
461 " FROM exc_ass_file_order" .
462 " WHERE " . $ilDB->in("assignment_id", $a_ids, false, "integer"));
463 break;
464 }
465 }
466
467 if ($a_entity == "exc_ass_reminders") {
468 switch ($a_version) {
469 case "5.3.0":
470 case "9.0":
471 $this->getDirectDataFromQuery("SELECT type, ass_id, exc_id, status, start, end, freq, last_send, template_id" .
472 " FROM exc_ass_reminders" .
473 " WHERE " . $ilDB->in("ass_id", $a_ids, false, "integer"));
474 break;
475 }
476 }
477 }
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 ...
ilDBInterface $db

References ilDataSet\$db, $ilDB, and ilDataSet\getDirectDataFromQuery().

+ Here is the call graph for this function:

Field Documentation

◆ $ass_domain

DomainService ilExerciseDataSet::$ass_domain
protected

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

◆ $current_exc

ilObjExercise ilExerciseDataSet::$current_exc
protected

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


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