ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilExAssignment.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  const TYPE_UPLOAD = 1;
14  const TYPE_BLOG = 2;
15  const TYPE_PORTFOLIO = 3;
16  const TYPE_UPLOAD_TEAM = 4;
17  const TYPE_TEXT = 5;
18 
21 
25 
26  protected $id;
27  protected $exc_id;
28  protected $type;
29  protected $start_time;
30  protected $deadline;
31  protected $deadline2;
32  protected $instruction;
33  protected $title;
34  protected $mandatory;
35  protected $order_nr;
36  protected $peer;
37  protected $peer_min;
38  protected $peer_unlock;
39  protected $peer_dl;
40  protected $peer_valid;
41  protected $peer_file;
42  protected $peer_personal;
43  protected $peer_char;
44  protected $peer_text;
45  protected $peer_rating;
46  protected $peer_crit_cat;
47  protected $feedback_file;
48  protected $feedback_cron;
49  protected $feedback_date;
50  protected $team_tutor = false;
51  protected $max_file;
52 
53  protected $member_status = array(); // [array]
54 
58  function __construct($a_id = 0)
59  {
60  $this->setType(self::TYPE_UPLOAD);
61  $this->setFeedbackDate(self::FEEDBACK_DATE_DEADLINE);
62 
63  if ($a_id > 0)
64  {
65  $this->setId($a_id);
66  $this->read();
67  }
68  }
69 
70  public static function getInstancesByExercise($a_exc_id)
71  {
72  global $ilDB;
73 
74  $set = $ilDB->query("SELECT * FROM exc_assignment ".
75  " WHERE exc_id = ".$ilDB->quote($a_exc_id, "integer").
76  " ORDER BY order_nr ASC");
77  $data = array();
78 
79  $order_val = 10;
80  while ($rec = $ilDB->fetchAssoc($set))
81  {
82  // ???
83  $rec["order_val"] = $order_val;
84 
85  $ass = new self();
86  $ass->initFromDB($rec);
87  $data[] = $ass;
88 
89  $order_val += 10;
90  }
91 
92  return $data;
93  }
94 
95  public function hasTeam()
96  {
97  return $this->type == self::TYPE_UPLOAD_TEAM;
98  }
99 
105  function setId($a_val)
106  {
107  $this->id = $a_val;
108  }
109 
115  function getId()
116  {
117  return $this->id;
118  }
119 
125  function setExerciseId($a_val)
126  {
127  $this->exc_id = $a_val;
128  }
129 
135  function getExerciseId()
136  {
137  return $this->exc_id;
138  }
139 
145  function setStartTime($a_val)
146  {
147  $this->start_time = $a_val;
148  }
149 
155  function getStartTime()
156  {
157  return $this->start_time;
158  }
159 
165  function setDeadline($a_val)
166  {
167  $this->deadline = $a_val;
168  }
169 
175  function getDeadline()
176  {
177  return $this->deadline;
178  }
179 
185  function getPersonalDeadline($a_user_id)
186  {
187  global $ilDB;
188 
189  $is_team = false;
190  if($this->getType() == self::TYPE_UPLOAD_TEAM)
191  {
192  include_once("./Modules/Exercise/classes/class.ilExAssignmentTeam.php");
193  $team_id = ilExAssignmentTeam::getTeamId($this->getId(), $a_user_id);
194  if(!$team_id)
195  {
196  // #0021043
197  $this->getDeadline();
198  }
199  $a_user_id = $team_id;
200  $is_team = true;
201  }
202 
203  $set = $ilDB->query("SELECT tstamp FROM exc_idl".
204  " WHERE ass_id = ".$ilDB->quote($this->getId(), "integer").
205  " AND member_id = ".$ilDB->quote($a_user_id, "integer").
206  " AND is_team = ".$ilDB->quote($is_team, "integer"));
207  $row = $ilDB->fetchAssoc($set);
208 
209  // use assignment deadline if no direct personal
210  return max($row["tstamp"], $this->getDeadline());
211  }
212 
218  protected function getLastPersonalDeadline()
219  {
220  global $ilDB;
221 
222  $set = $ilDB->query("SELECT MAX(tstamp) FROM exc_idl".
223  " WHERE ass_id = ".$ilDB->quote($this->getId(), "integer"));
224  $row = $ilDB->fetchAssoc($set);
225  return $row["tstamp"];
226  }
227 
233  function setExtendedDeadline($a_val)
234  {
235  if($a_val !== null)
236  {
237  $a_val = (int)$a_val;
238  }
239  $this->deadline2 = $a_val;
240  }
241 
248  {
249  return $this->deadline2;
250  }
251 
257  function setInstruction($a_val)
258  {
259  $this->instruction = $a_val;
260  }
261 
267  function getInstruction()
268  {
269  return $this->instruction;
270  }
271 
277  function setTitle($a_val)
278  {
279  $this->title = $a_val;
280  }
281 
287  function getTitle()
288  {
289  return $this->title;
290  }
291 
297  function setMandatory($a_val)
298  {
299  $this->mandatory = $a_val;
300  }
301 
307  function getMandatory()
308  {
309  return $this->mandatory;
310  }
311 
317  function setOrderNr($a_val)
318  {
319  $this->order_nr = $a_val;
320  }
321 
327  function getOrderNr()
328  {
329  return $this->order_nr;
330  }
331 
337  function setType($a_value)
338  {
339  if($this->isValidType($a_value))
340  {
341  $this->type = (int)$a_value;
342 
343  if($this->type == self::TYPE_UPLOAD_TEAM)
344  {
345  $this->setPeerReview(false);
346  }
347  }
348  }
349 
355  function getType()
356  {
357  return $this->type;
358  }
359 
366  function isValidType($a_value)
367  {
368  if(in_array((int)$a_value, array(self::TYPE_UPLOAD, self::TYPE_BLOG,
369  self::TYPE_PORTFOLIO, self::TYPE_UPLOAD_TEAM, self::TYPE_TEXT)))
370  {
371  return true;
372  }
373  return false;
374  }
375 
381  function setPeerReview($a_value)
382  {
383  $this->peer = (bool)$a_value;
384  }
385 
391  function getPeerReview()
392  {
393  return (bool)$this->peer;
394  }
395 
401  function setPeerReviewMin($a_value)
402  {
403  $this->peer_min = (int)$a_value;
404  }
405 
411  function getPeerReviewMin()
412  {
413  return (int)$this->peer_min;
414  }
415 
421  function setPeerReviewSimpleUnlock($a_value)
422  {
423  $this->peer_unlock = (bool)$a_value;
424  }
425 
432  {
433  return (bool)$this->peer_unlock;
434  }
435 
441  function setPeerReviewDeadline($a_val)
442  {
443  $this->peer_dl = $a_val;
444  }
445 
452  {
453  return $this->peer_dl;
454  }
455 
461  function setPeerReviewValid($a_value)
462  {
463  $this->peer_valid = (int)$a_value;
464  }
465 
472  {
473  return (int)$this->peer_valid;
474  }
475 
481  function setPeerReviewRating($a_val)
482  {
483  $this->peer_rating = (bool)$a_val;
484  }
485 
492  {
493  return $this->peer_rating;
494  }
495 
501  function setPeerReviewText($a_val)
502  {
503  $this->peer_text = (bool)$a_val;
504  }
505 
511  function hasPeerReviewText()
512  {
513  return $this->peer_text;
514  }
515 
521  function setPeerReviewFileUpload($a_val)
522  {
523  $this->peer_file = (bool)$a_val;
524  }
525 
532  {
533  return $this->peer_file;
534  }
535 
541  function setPeerReviewPersonalized($a_val)
542  {
543  $this->peer_personal = (bool)$a_val;
544  }
545 
552  {
553  return $this->peer_personal;
554  }
555 
561  function setPeerReviewChars($a_value)
562  {
563  $a_value = (is_numeric($a_value) && (int)$a_value > 0)
564  ? (int)$a_value
565  : null;
566  $this->peer_char = $a_value;
567  }
568 
575  {
576  return $this->peer_char;
577  }
578 
585  {
586  $a_value = is_numeric($a_value)
587  ? (int)$a_value
588  : null;
589  $this->crit_cat = $a_value;
590  }
591 
598  {
599  return $this->crit_cat;
600  }
601 
603  {
604  include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
605 
606  if($this->crit_cat)
607  {
608  return ilExcCriteria::getInstancesByParentId($this->crit_cat);
609  }
610  else
611  {
612  $res = array();
613 
614  if($this->peer_rating)
615  {
617  }
618 
619  if($this->peer_text)
620  {
621  $crit = ilExcCriteria::getInstanceByType("text");
622  if($this->peer_char)
623  {
624  $crit->setMinChars($this->peer_char);
625  }
626  $res[] = $crit;
627  }
628 
629  if($this->peer_file)
630  {
632  }
633 
634  return $res;
635  }
636  }
637 
643  function setFeedbackFile($a_value)
644  {
645  $this->feedback_file = (string)$a_value;
646  }
647 
653  function getFeedbackFile()
654  {
655  return (string)$this->feedback_file;
656  }
657 
663  function setFeedbackCron($a_value)
664  {
665  $this->feedback_cron = (string)$a_value;
666  }
667 
673  function hasFeedbackCron()
674  {
675  return (bool)$this->feedback_cron;
676  }
677 
683  function setFeedbackDate($a_value)
684  {
685  $this->feedback_date = (int)$a_value;
686  }
687 
693  function getFeedbackDate()
694  {
695  return (int)$this->feedback_date;
696  }
697 
703  function setTeamTutor($a_value)
704  {
705  $this->team_tutor = (bool)$a_value;
706  }
707 
713  function getTeamTutor()
714  {
715  return $this->team_tutor;
716  }
717 
723  function setMaxFile($a_value)
724  {
725  if($a_value !== null)
726  {
727  $a_value = (int)$a_value;
728  }
729  $this->max_file = $a_value;
730  }
731 
737  function getMaxFile()
738  {
739  return $this->max_file;
740  }
741 
745  function read()
746  {
747  global $ilDB;
748 
749  $set = $ilDB->query("SELECT * FROM exc_assignment ".
750  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
751  );
752  $rec = $ilDB->fetchAssoc($set);
753 
754  // #16172 - might be deleted
755  if(is_array($rec))
756  {
757  $this->initFromDB($rec);
758  }
759  }
760 
767  protected function initFromDB(array $a_set)
768  {
769  $this->setId($a_set["id"]);
770  $this->setExerciseId($a_set["exc_id"]);
771  $this->setDeadline($a_set["time_stamp"]);
772  $this->setExtendedDeadline($a_set["deadline2"]);
773  $this->setInstruction($a_set["instruction"]);
774  $this->setTitle($a_set["title"]);
775  $this->setStartTime($a_set["start_time"]);
776  $this->setOrderNr($a_set["order_nr"]);
777  $this->setMandatory($a_set["mandatory"]);
778  $this->setType($a_set["type"]);
779  $this->setPeerReview($a_set["peer"]);
780  $this->setPeerReviewMin($a_set["peer_min"]);
781  $this->setPeerReviewSimpleUnlock($a_set["peer_unlock"]);
782  $this->setPeerReviewDeadline($a_set["peer_dl"]);
783  $this->setPeerReviewValid($a_set["peer_valid"]);
784  $this->setPeerReviewFileUpload($a_set["peer_file"]);
785  $this->setPeerReviewPersonalized($a_set["peer_prsl"]);
786  $this->setPeerReviewChars($a_set["peer_char"]);
787  $this->setPeerReviewText($a_set["peer_text"]);
788  $this->setPeerReviewRating($a_set["peer_rating"]);
789  $this->setPeerReviewCriteriaCatalogue($a_set["peer_crit_cat"]);
790  $this->setFeedbackFile($a_set["fb_file"]);
791  $this->setFeedbackDate($a_set["fb_date"]);
792  $this->setFeedbackCron($a_set["fb_cron"]);
793  $this->setTeamTutor($a_set["team_tutor"]);
794  $this->setMaxFile($a_set["max_file"]);
795  }
796 
800  function save()
801  {
802  global $ilDB;
803 
804  if ($this->getOrderNr() == 0)
805  {
806  $this->setOrderNr(
807  self::lookupMaxOrderNrForEx($this->getExerciseId())
808  + 10);
809  }
810 
811  $next_id = $ilDB->nextId("exc_assignment");
812  $ilDB->insert("exc_assignment", array(
813  "id" => array("integer", $next_id),
814  "exc_id" => array("integer", $this->getExerciseId()),
815  "time_stamp" => array("integer", $this->getDeadline()),
816  "deadline2" => array("integer", $this->getExtendedDeadline()),
817  "instruction" => array("clob", $this->getInstruction()),
818  "title" => array("text", $this->getTitle()),
819  "start_time" => array("integer", $this->getStartTime()),
820  "order_nr" => array("integer", $this->getOrderNr()),
821  "mandatory" => array("integer", $this->getMandatory()),
822  "type" => array("integer", $this->getType()),
823  "peer" => array("integer", $this->getPeerReview()),
824  "peer_min" => array("integer", $this->getPeerReviewMin()),
825  "peer_unlock" => array("integer", $this->getPeerReviewSimpleUnlock()),
826  "peer_dl" => array("integer", $this->getPeerReviewDeadline()),
827  "peer_valid" => array("integer", $this->getPeerReviewValid()),
828  "peer_file" => array("integer", $this->hasPeerReviewFileUpload()),
829  "peer_prsl" => array("integer", $this->hasPeerReviewPersonalized()),
830  "peer_char" => array("integer", $this->getPeerReviewChars()),
831  "peer_text" => array("integer", (int) $this->hasPeerReviewText()),
832  "peer_rating" => array("integer", (int) $this->hasPeerReviewRating()),
833  "peer_crit_cat" => array("integer", $this->getPeerReviewCriteriaCatalogue()),
834  "fb_file" => array("text", $this->getFeedbackFile()),
835  "fb_date" => array("integer", $this->getFeedbackDate()),
836  "fb_cron" => array("integer", $this->hasFeedbackCron()),
837  "team_tutor" => array("integer", $this->getTeamTutor()),
838  "max_file" => array("integer", $this->getMaxFile())
839  ));
840  $this->setId($next_id);
841  $exc = new ilObjExercise($this->getExerciseId(), false);
842  $exc->updateAllUsersStatus();
843  self::createNewAssignmentRecords($next_id, $exc);
844 
845  $this->handleCalendarEntries("create");
846  }
847 
851  function update()
852  {
853  global $ilDB;
854 
855  $ilDB->update("exc_assignment",
856  array(
857  "exc_id" => array("integer", $this->getExerciseId()),
858  "time_stamp" => array("integer", $this->getDeadline()),
859  "deadline2" => array("integer", $this->getExtendedDeadline()),
860  "instruction" => array("clob", $this->getInstruction()),
861  "title" => array("text", $this->getTitle()),
862  "start_time" => array("integer", $this->getStartTime()),
863  "order_nr" => array("integer", $this->getOrderNr()),
864  "mandatory" => array("integer", $this->getMandatory()),
865  "type" => array("integer", $this->getType()),
866  "peer" => array("integer", $this->getPeerReview()),
867  "peer_min" => array("integer", $this->getPeerReviewMin()),
868  "peer_unlock" => array("integer", $this->getPeerReviewSimpleUnlock()),
869  "peer_dl" => array("integer", $this->getPeerReviewDeadline()),
870  "peer_valid" => array("integer", $this->getPeerReviewValid()),
871  "peer_file" => array("integer", $this->hasPeerReviewFileUpload()),
872  "peer_prsl" => array("integer", $this->hasPeerReviewPersonalized()),
873  "peer_char" => array("integer", $this->getPeerReviewChars()),
874  "peer_text" => array("integer", (int) $this->hasPeerReviewText()),
875  "peer_rating" => array("integer", (int) $this->hasPeerReviewRating()),
876  "peer_crit_cat" => array("integer", $this->getPeerReviewCriteriaCatalogue()),
877  "fb_file" => array("text", $this->getFeedbackFile()),
878  "fb_date" => array("integer", $this->getFeedbackDate()),
879  "fb_cron" => array("integer", $this->hasFeedbackCron()),
880  "team_tutor" => array("integer", $this->getTeamTutor()),
881  "max_file" => array("integer", $this->getMaxFile())
882  ),
883  array(
884  "id" => array("integer", $this->getId()),
885  ));
886  $exc = new ilObjExercise($this->getExerciseId(), false);
887  $exc->updateAllUsersStatus();
888 
889  $this->handleCalendarEntries("update");
890  }
891 
895  function delete()
896  {
897  global $ilDB;
898 
899  $this->deleteGlobalFeedbackFile();
900 
901  $ilDB->manipulate("DELETE FROM exc_assignment WHERE ".
902  " id = ".$ilDB->quote($this->getId(), "integer")
903  );
904  $exc = new ilObjExercise($this->getExerciseId(), false);
905  $exc->updateAllUsersStatus();
906 
907  $this->handleCalendarEntries("delete");
908  }
909 
910 
914  static function getAssignmentDataOfExercise($a_exc_id)
915  {
916  global $ilDB;
917 
918  // should be changed to self::getInstancesByExerciseId()
919 
920  $set = $ilDB->query("SELECT * FROM exc_assignment ".
921  " WHERE exc_id = ".$ilDB->quote($a_exc_id, "integer").
922  " ORDER BY order_nr ASC");
923  $data = array();
924 
925  $order_val = 10;
926  while ($rec = $ilDB->fetchAssoc($set))
927  {
928 
929  $data[] = array(
930  "id" => $rec["id"],
931  "exc_id" => $rec["exc_id"],
932  "deadline" => $rec["time_stamp"],
933  "deadline2" => $rec["deadline2"],
934  "instruction" => $rec["instruction"],
935  "title" => $rec["title"],
936  "start_time" => $rec["start_time"],
937  "order_val" => $order_val,
938  "mandatory" => $rec["mandatory"],
939  "type" => $rec["type"],
940  "peer" => $rec["peer"],
941  "peer_min" => $rec["peer_min"],
942  "peer_dl" => $rec["peer_dl"],
943  "peer_file" => $rec["peer_file"],
944  "peer_prsl" => $rec["peer_prsl"],
945  "fb_file" => $rec["fb_file"],
946  "fb_date" => $rec["fb_date"],
947  "fb_cron" => $rec["fb_cron"],
948  );
949  $order_val += 10;
950  }
951  return $data;
952  }
953 
960  static function cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id, array $a_crit_cat_map)
961  {
962  $ass_data = self::getInstancesByExercise($a_old_exc_id);
963  foreach ($ass_data as $d)
964  {
965  // clone assignment
966  $new_ass = new ilExAssignment();
967  $new_ass->setExerciseId($a_new_exc_id);
968  $new_ass->setTitle($d->getTitle());
969  $new_ass->setDeadline($d->getDeadline());
970  $new_ass->setExtendedDeadline($d->getExtendedDeadline());
971  $new_ass->setInstruction($d->getInstruction());
972  $new_ass->setMandatory($d->getMandatory());
973  $new_ass->setOrderNr($d->getOrderNr());
974  $new_ass->setStartTime($d->getStartTime());
975  $new_ass->setType($d->getType());
976  $new_ass->setPeerReview($d->getPeerReview());
977  $new_ass->setPeerReviewMin($d->getPeerReviewMin());
978  $new_ass->setPeerReviewDeadline($d->getPeerReviewDeadline());
979  $new_ass->setPeerReviewFileUpload($d->hasPeerReviewFileUpload());
980  $new_ass->setPeerReviewPersonalized($d->hasPeerReviewPersonalized());
981  $new_ass->setPeerReviewValid($d->getPeerReviewValid());
982  $new_ass->setPeerReviewChars($d->getPeerReviewChars());
983  $new_ass->setPeerReviewText($d->hasPeerReviewText());
984  $new_ass->setPeerReviewRating($d->hasPeerReviewRating());
985  $new_ass->setPeerReviewCriteriaCatalogue($d->getPeerReviewCriteriaCatalogue());
986  $new_ass->setPeerReviewSimpleUnlock($d->getPeerReviewSimpleUnlock());
987  $new_ass->setPeerReviewText($d->hasPeerReviewText());
988  $new_ass->setPeerReviewRating($d->hasPeerReviewRating());
989  $new_ass->setFeedbackFile($d->getFeedbackFile());
990  $new_ass->setFeedbackDate($d->getFeedbackDate());
991  $new_ass->setFeedbackCron($d->hasFeedbackCron()); // #16295
992  $new_ass->setTeamTutor($d->getTeamTutor());
993  $new_ass->setMaxFile($d->getMaxFile());
994 
995  // criteria catalogue(s)
996  if($d->getPeerReviewCriteriaCatalogue() &&
997  array_key_exists($d->getPeerReviewCriteriaCatalogue(), $a_crit_cat_map))
998  {
999  $new_ass->setPeerReviewCriteriaCatalogue($a_crit_cat_map[$d->getPeerReviewCriteriaCatalogue()]);
1000  }
1001 
1002  $new_ass->save();
1003 
1004  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1005  $old_storage = new ilFSStorageExercise($a_old_exc_id, (int) $d->getId());
1006  $new_storage = new ilFSStorageExercise($a_new_exc_id, (int) $new_ass->getId());
1007  $new_storage->create();
1008 
1009  // clone assignment files
1010  if (is_dir($old_storage->getPath()))
1011  {
1012  ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath());
1013  }
1014 
1015  // clone global feedback file
1016  if (is_dir($old_storage->getGlobalFeedbackPath()))
1017  {
1018  ilUtil::rCopy($old_storage->getGlobalFeedbackPath(), $new_storage->getGlobalFeedbackPath());
1019  }
1020  }
1021  }
1022 
1026  public function getFiles()
1027  {
1028  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1029  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1030  return $storage->getFiles();
1031  }
1032 
1036  static function lookupMaxOrderNrForEx($a_exc_id)
1037  {
1038  global $ilDB;
1039 
1040  $set = $ilDB->query("SELECT MAX(order_nr) mnr FROM exc_assignment ".
1041  " WHERE exc_id = ".$ilDB->quote($a_exc_id, "integer")
1042  );
1043  while ($rec = $ilDB->fetchAssoc($set))
1044  {
1045  return (int) $rec["mnr"];
1046  }
1047  return 0;
1048  }
1049 
1055  public static function lookupAssignmentOnline($a_ass_id)
1056  {
1057  global $ilDB;
1058 
1059  $query = "SELECT id FROM exc_assignment ".
1060  "WHERE start_time <= ".$ilDB->quote(time(),'integer').' '.
1061  "AND time_stamp >= ".$ilDB->quote(time(),'integer').' '.
1062  "AND id = ".$ilDB->quote($a_ass_id,'integer');
1063  $res = $ilDB->query($query);
1064 
1065  return $res->numRows() ? true : false;
1066  }
1067 
1074  public static function lookupExerciseId($a_ass_id)
1075  {
1076  global $DIC;
1077 
1078  $ilDB = $DIC->database();
1079 
1080  $query = "SELECT exc_id FROM exc_assignment ".
1081  "WHERE id = ".$ilDB->quote($a_ass_id,'integer');
1082  $res = $ilDB->fetchAssoc($ilDB->query($query));
1083 
1084  return (int) $res["exc_id"];
1085  }
1086 
1090  private static function lookup($a_id, $a_field)
1091  {
1092  global $ilDB;
1093 
1094  $set = $ilDB->query("SELECT ".$a_field." FROM exc_assignment ".
1095  " WHERE id = ".$ilDB->quote($a_id, "integer")
1096  );
1097 
1098  $rec = $ilDB->fetchAssoc($set);
1099 
1100  return $rec[$a_field];
1101  }
1102 
1106  static function lookupTitle($a_id)
1107  {
1108  return self::lookup($a_id, "title");
1109  }
1110 
1114  static function lookupType($a_id)
1115  {
1116  return self::lookup($a_id, "type");
1117  }
1118 
1122  function saveAssOrderOfExercise($a_ex_id, $a_order)
1123  {
1124  global $ilDB;
1125 
1126  $result_order = array();
1127  asort($a_order);
1128  $nr = 10;
1129  foreach ($a_order as $k => $v)
1130  {
1131  // the check for exc_id is for security reasons. ass ids are unique.
1132  $ilDB->manipulate($t = "UPDATE exc_assignment SET ".
1133  " order_nr = ".$ilDB->quote($nr, "integer").
1134  " WHERE id = ".$ilDB->quote((int) $k, "integer").
1135  " AND exc_id = ".$ilDB->quote((int) $a_ex_id, "integer")
1136  );
1137  $nr+=10;
1138  }
1139  }
1140 
1144  static function orderAssByDeadline($a_ex_id)
1145  {
1146  global $ilDB;
1147 
1148  $set = $ilDB->query("SELECT id FROM exc_assignment ".
1149  " WHERE exc_id = ".$ilDB->quote($a_ex_id, "integer").
1150  " ORDER BY time_stamp ASC"
1151  );
1152  $nr = 10;
1153  while ($rec = $ilDB->fetchAssoc($set))
1154  {
1155  $ilDB->manipulate("UPDATE exc_assignment SET ".
1156  " order_nr = ".$ilDB->quote($nr, "integer").
1157  " WHERE id = ".$ilDB->quote($rec["id"], "integer")
1158  );
1159  $nr += 10;
1160  }
1161  }
1162 
1166  static function countMandatory($a_ex_id)
1167  {
1168  global $ilDB;
1169 
1170  $set = $ilDB->query("SELECT count(*) cntm FROM exc_assignment ".
1171  " WHERE exc_id = ".$ilDB->quote($a_ex_id, "integer").
1172  " AND mandatory = ".$ilDB->quote(1, "integer")
1173  );
1174  $rec = $ilDB->fetchAssoc($set);
1175  return $rec["cntm"];
1176  }
1177 
1179 
1183  static function lookupUpdatedSubmission($ass_id, $member_id)
1184  {
1185  global $ilDB, $lng;
1186 
1187  // team upload?
1188  $user_ids = self::getTeamMembersByAssignmentId($ass_id, $member_id);
1189  if(!$user_ids)
1190  {
1191  $user_ids = array($member_id);
1192  }
1193 
1194  $q="SELECT exc_mem_ass_status.status_time, exc_returned.ts ".
1195  "FROM exc_mem_ass_status, exc_returned ".
1196  "WHERE exc_mem_ass_status.status_time < exc_returned.ts ".
1197  "AND NOT exc_mem_ass_status.status_time IS NULL ".
1198  "AND exc_returned.ass_id = exc_mem_ass_status.ass_id ".
1199  "AND exc_returned.user_id = exc_mem_ass_status.usr_id ".
1200  "AND exc_returned.ass_id=".$ilDB->quote($ass_id, "integer").
1201  " AND ".$ilDB->in("exc_returned.user_id", $user_ids, "", "integer");
1202 
1203  $usr_set = $ilDB->query($q);
1204 
1205  $array = $ilDB->fetchAssoc($usr_set);
1206 
1207  if (count($array)==0)
1208  {
1209  return 0;
1210  }
1211  else
1212  {
1213  return 1;
1214  }
1215 
1216  }
1217 
1222  {
1223  global $ilDB;
1224 
1225  $mem = array();
1226 
1227  // first get list of members from member table
1228  $set = $ilDB->query("SELECT ud.usr_id, ud.lastname, ud.firstname, ud.login".
1229  " FROM exc_members excm".
1230  " JOIN usr_data ud ON (ud.usr_id = excm.usr_id)".
1231  " WHERE excm.obj_id = ".$ilDB->quote($this->getExerciseId(), "integer"));
1232  while($rec = $ilDB->fetchAssoc($set))
1233  {
1234  $mem[$rec["usr_id"]] =
1235  array(
1236  "name" => $rec["lastname"].", ".$rec["firstname"],
1237  "login" => $rec["login"],
1238  "usr_id" => $rec["usr_id"],
1239  "lastname" => $rec["lastname"],
1240  "firstname" => $rec["firstname"]
1241  );
1242  }
1243 
1244  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
1245 
1246  $q = "SELECT * FROM exc_mem_ass_status ".
1247  "WHERE ass_id = ".$ilDB->quote($this->getId(), "integer");
1248  $set = $ilDB->query($q);
1249  while($rec = $ilDB->fetchAssoc($set))
1250  {
1251  if (isset($mem[$rec["usr_id"]]))
1252  {
1253  $sub = new ilExSubmission($this, $rec["usr_id"]);
1254 
1255  $mem[$rec["usr_id"]]["sent_time"] = $rec["sent_time"];
1256  $mem[$rec["usr_id"]]["submission"] = $sub->getLastSubmission();
1257  $mem[$rec["usr_id"]]["status_time"] = $rec["status_time"];
1258  $mem[$rec["usr_id"]]["feedback_time"] = $rec["feedback_time"];
1259  $mem[$rec["usr_id"]]["notice"] = $rec["notice"];
1260  $mem[$rec["usr_id"]]["status"] = $rec["status"];
1261  $mem[$rec["usr_id"]]["mark"] = $rec["mark"];
1262  $mem[$rec["usr_id"]]["comment"] = $rec["u_comment"];
1263  }
1264  }
1265  return $mem;
1266  }
1267 
1271  static function createNewUserRecords($a_user_id, $a_exc_id)
1272  {
1273  global $ilDB;
1274 
1275  $ass_data = self::getAssignmentDataOfExercise($a_exc_id);
1276  foreach ($ass_data as $ass)
1277  {
1278 //echo "-".$ass["id"]."-".$a_user_id."-";
1279  $ilDB->replace("exc_mem_ass_status", array(
1280  "ass_id" => array("integer", $ass["id"]),
1281  "usr_id" => array("integer", $a_user_id)
1282  ), array(
1283  "status" => array("text", "notgraded")
1284  ));
1285  }
1286  }
1287 
1291  static function createNewAssignmentRecords($a_ass_id, $a_exc)
1292  {
1293  global $ilDB;
1294 
1295  include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
1296  $exmem = new ilExerciseMembers($a_exc);
1297  $mems = $exmem->getMembers();
1298 
1299  foreach ($mems as $mem)
1300  {
1301  $ilDB->replace("exc_mem_ass_status", array(
1302  "ass_id" => array("integer", $a_ass_id),
1303  "usr_id" => array("integer", $mem)
1304  ), array(
1305  "status" => array("text", "notgraded")
1306  ));
1307  }
1308  }
1309 
1314  function uploadAssignmentFiles($a_files)
1315  {
1316  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1317  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1318  $storage->create();
1319  $storage->uploadAssignmentFiles($a_files);
1320  }
1321 
1322 
1326 
1331  {
1332  global $ilDB;
1333 
1334 
1335  // send and delete the zip file
1336  $deliverFilename = trim(str_replace(" ", "_", $this->getTitle()."_".$this->getId()));
1337  $deliverFilename = ilUtil::getASCIIFilename($deliverFilename);
1338  $deliverFilename = "multi_feedback_".$deliverFilename;
1339 
1340  $exc = new ilObjExercise($this->getExerciseId(), false);
1341 
1342  $cdir = getcwd();
1343 
1344  // create temporary directoy
1345  $tmpdir = ilUtil::ilTempnam();
1346  ilUtil::makeDir($tmpdir);
1347  $mfdir = $tmpdir."/".$deliverFilename;
1348  ilUtil::makeDir($mfdir);
1349 
1350  // create subfolders <lastname>_<firstname>_<id> for each participant
1351  include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
1352  $exmem = new ilExerciseMembers($exc);
1353  $mems = $exmem->getMembers();
1354 
1355  foreach ($mems as $mem)
1356  {
1357  $name = ilObjUser::_lookupName($mem);
1358  $subdir = $name["lastname"]."_".$name["firstname"]."_".$name["login"]."_".$name["user_id"];
1359  $subdir = ilUtil::getASCIIFilename($subdir);
1360  ilUtil::makeDir($mfdir."/".$subdir);
1361  }
1362 
1363  // create the zip file
1364  chdir($tmpdir);
1365  $tmpzipfile = $tmpdir."/multi_feedback.zip";
1366  ilUtil::zip($tmpdir, $tmpzipfile, true);
1367  chdir($cdir);
1368 
1369 
1370  ilUtil::deliverFile($tmpzipfile, $deliverFilename.".zip", "", false, true);
1371  }
1372 
1379  function uploadMultiFeedbackFile($a_file)
1380  {
1381  global $lng, $ilUser;
1382 
1383  include_once("./Modules/Exercise/exceptions/class.ilExerciseException.php");
1384  if (!is_file($a_file["tmp_name"]))
1385  {
1386  throw new ilExerciseException($lng->txt("exc_feedback_file_could_not_be_uploaded"));
1387  }
1388 
1389  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1390  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1391  $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
1392  ilUtil::delDir($mfu, true);
1393  ilUtil::moveUploadedFile($a_file["tmp_name"], "multi_feedback.zip", $mfu."/"."multi_feedback.zip");
1394  ilUtil::unzip($mfu."/multi_feedback.zip", true);
1395  $subdirs = ilUtil::getDir($mfu);
1396  $subdir = "notfound";
1397  foreach ($subdirs as $s => $j)
1398  {
1399  if ($j["type"] == "dir" && substr($s, 0, 14) == "multi_feedback")
1400  {
1401  $subdir = $s;
1402  }
1403  }
1404 
1405  if (!is_dir($mfu."/".$subdir))
1406  {
1407  throw new ilExerciseException($lng->txt("exc_no_feedback_dir_found_in_zip"));
1408  }
1409 
1410  return true;
1411  }
1412 
1419  function getMultiFeedbackFiles($a_user_id = 0)
1420  {
1421  global $ilUser;
1422 
1423  if ($a_user_id == 0)
1424  {
1425  $a_user_id = $ilUser->getId();
1426  }
1427 
1428  $mf_files = array();
1429 
1430  // get members
1431  $exc = new ilObjExercise($this->getExerciseId(), false);
1432  include_once("./Modules/Exercise/classes/class.ilExerciseMembers.php");
1433  $exmem = new ilExerciseMembers($exc);
1434  $mems = $exmem->getMembers();
1435 
1436  // read mf directory
1437  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1438  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1439  $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
1440 
1441  // get subdir that starts with multi_feedback
1442  $subdirs = ilUtil::getDir($mfu);
1443  $subdir = "notfound";
1444  foreach ($subdirs as $s => $j)
1445  {
1446  if ($j["type"] == "dir" && substr($s, 0, 14) == "multi_feedback")
1447  {
1448  $subdir = $s;
1449  }
1450  }
1451 
1452  $items = ilUtil::getDir($mfu."/".$subdir);
1453  foreach ($items as $k => $i)
1454  {
1455  // check directory
1456  if ($i["type"] == "dir" && !in_array($k, array(".", "..")))
1457  {
1458  // check if valid member id is given
1459  $parts = explode("_", $i["entry"]);
1460  $user_id = (int) $parts[count($parts) - 1];
1461  if (in_array($user_id, $mems))
1462  {
1463  // read dir of user
1464  $name = ilObjUser::_lookupName($user_id);
1465  $files = ilUtil::getDir($mfu."/".$subdir."/".$k);
1466  foreach ($files as $k2 => $f)
1467  {
1468  // append files to array
1469  if ($f["type"] == "file" && substr($k2, 0, 1) != ".")
1470  {
1471  $mf_files[] = array(
1472  "lastname" => $name["lastname"],
1473  "firstname" => $name["firstname"],
1474  "login" => $name["login"],
1475  "user_id" => $name["user_id"],
1476  "full_path" => $mfu."/".$subdir."/".$k."/".$k2,
1477  "file" => $k2);
1478  }
1479  }
1480  }
1481  }
1482  }
1483  return $mf_files;
1484  }
1485 
1493  {
1494  global $lng, $ilUser;
1495 
1496  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1497  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1498  $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
1499  ilUtil::delDir($mfu);
1500  }
1501 
1508  function saveMultiFeedbackFiles($a_files, ilObjExercise $a_exc)
1509  {
1510  if($this->getExerciseId() != $a_exc->getId())
1511  {
1512  return;
1513  }
1514 
1515  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1516  $fstorage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1517  $fstorage->create();
1518 
1519  $team_map = array();
1520 
1521  $mf_files = $this->getMultiFeedbackFiles();
1522  foreach ($mf_files as $f)
1523  {
1524  $user_id = $f["user_id"];
1525  $file_path = $f["full_path"];
1526  $file_name = $f["file"];
1527 
1528  // if checked in confirmation gui
1529  if ($a_files[$user_id][md5($file_name)] != "")
1530  {
1531  $submission = new ilExSubmission($this, $user_id);
1532  $feedback_id = $submission->getFeedbackId();
1533  $noti_rec_ids = $submission->getUserIds();
1534 
1535  if ($feedback_id)
1536  {
1537  $fb_path = $fstorage->getFeedbackPath($feedback_id);
1538  $target = $fb_path."/".$file_name;
1539  if (is_file($target))
1540  {
1541  unlink($target);
1542  }
1543  // rename file
1544  rename($file_path, $target);
1545 
1546  if ($noti_rec_ids)
1547  {
1548  foreach($noti_rec_ids as $user_id)
1549  {
1550  $member_status = $this->getMemberStatus($user_id);
1551  $member_status->setFeedback(true);
1552  $member_status->update();
1553  }
1554 
1555  $a_exc->sendFeedbackFileNotification($file_name, $noti_rec_ids,
1556  (int) $this->getId());
1557  }
1558  }
1559  }
1560  }
1561 
1562  $this->clearMultiFeedbackDirectory();
1563  }
1564 
1565 
1566 
1567 
1573  protected function handleCalendarEntries($a_event)
1574  {
1575  global $ilAppEventHandler;
1576 
1577  $dl_id = $this->getId()."0";
1578  $fbdl_id = $this->getId()."1";
1579 
1580  $context_ids = array($dl_id, $fbdl_id);
1581  $apps = array();
1582 
1583  if($a_event != "delete")
1584  {
1585  include_once "Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php";
1586 
1587  if($this->getDeadline())
1588  {
1589  $app = new ilCalendarAppointmentTemplate($dl_id);
1590  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1591  $app->setSubtitle("cal_exc_deadline");
1592  $app->setTitle($this->getTitle());
1593  $app->setFullday(false);
1594  $app->setStart(new ilDateTime($this->getDeadline(), IL_CAL_UNIX));
1595 
1596  $apps[] = $app;
1597  }
1598 
1599  if($this->getPeerReview() &&
1600  $this->getPeerReviewDeadline())
1601  {
1602  $app = new ilCalendarAppointmentTemplate($fbdl_id);
1603  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1604  $app->setSubtitle("cal_exc_peer_review_deadline");
1605  $app->setTitle($this->getTitle());
1606  $app->setFullday(false);
1607  $app->setStart(new ilDateTime($this->getPeerReviewDeadline(), IL_CAL_UNIX));
1608 
1609  $apps[] = $app;
1610  }
1611 
1612  }
1613 
1614  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
1615  $exc = new ilObjExercise($this->getExerciseId(), false);
1616 
1617  $ilAppEventHandler->raise('Modules/Exercise',
1618  $a_event.'Assignment',
1619  array(
1620  'object' => $exc,
1621  'obj_id' => $exc->getId(),
1622  'context_ids' => $context_ids,
1623  'appointments' => $apps));
1624  }
1625 
1626 
1627  public static function getPendingFeedbackNotifications()
1628  {
1629  global $ilDB;
1630 
1631  $res = array();
1632 
1633  $set = $ilDB->query("SELECT id,fb_file FROM exc_assignment".
1634  " WHERE fb_cron = ".$ilDB->quote(1, "integer").
1635  " AND fb_date = ".$ilDB->quote(self::FEEDBACK_DATE_DEADLINE, "integer").
1636  " AND time_stamp IS NOT NULL".
1637  " AND time_stamp > ".$ilDB->quote(0, "integer").
1638  " AND time_stamp < ".$ilDB->quote(time(), "integer").
1639  " AND fb_cron_done = ".$ilDB->quote(0, "integer"));
1640  while($row = $ilDB->fetchAssoc($set))
1641  {
1642  if(trim($row["fb_file"]))
1643  {
1644  $res[] = $row["id"];
1645  }
1646  }
1647 
1648  return $res;
1649  }
1650 
1651  public static function sendFeedbackNotifications($a_ass_id, $a_user_id = null)
1652  {
1653  global $ilDB;
1654 
1655  $ass = new self($a_ass_id);
1656 
1657  // valid assignment?
1658  if(!$ass->hasFeedbackCron() || !$ass->getFeedbackFile())
1659  {
1660  return false;
1661  }
1662 
1663  if(!$a_user_id)
1664  {
1665  // already done?
1666  $set = $ilDB->query("SELECT fb_cron_done".
1667  " FROM exc_assignment".
1668  " WHERE id = ".$ilDB->quote($a_ass_id, "integer"));
1669  $row = $ilDB->fetchAssoc($set);
1670  if($row["fb_cron_done"])
1671  {
1672  return false;
1673  }
1674  }
1675 
1676  include_once "./Services/Notification/classes/class.ilSystemNotification.php";
1677  $ntf = new ilSystemNotification();
1678  $ntf->setLangModules(array("exc"));
1679  $ntf->setObjId($ass->getExerciseId());
1680  $ntf->setSubjectLangId("exc_feedback_notification_subject");
1681  $ntf->setIntroductionLangId("exc_feedback_notification_body");
1682  $ntf->addAdditionalInfo("exc_assignment", $ass->getTitle());
1683  $ntf->setGotoLangId("exc_feedback_notification_link");
1684  $ntf->setReasonLangId("exc_feedback_notification_reason");
1685 
1686  if(!$a_user_id)
1687  {
1688  include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php";
1689  $ntf->sendMail(ilExerciseMembers::_getMembers($ass->getExerciseId()));
1690 
1691  $ilDB->manipulate("UPDATE exc_assignment".
1692  " SET fb_cron_done = ".$ilDB->quote(1, "integer").
1693  " WHERE id = ".$ilDB->quote($a_ass_id, "integer"));
1694  }
1695  else
1696  {
1697  $ntf->sendMail(array($a_user_id));
1698  }
1699 
1700  return true;
1701  }
1702 
1703 
1704  // status
1705 
1706  public function afterDeadline()
1707  {
1708  global $ilUser;
1709 
1710  // :TODO: always current user?
1711  $idl = $this->getPersonalDeadline($ilUser->getId());
1712 
1713  // no deadline === true
1714  $deadline = max($this->deadline, $this->deadline2, $idl);
1715  return ($deadline - time() <= 0);
1716  }
1717 
1718  public function afterDeadlineStrict($a_include_personal = true)
1719  {
1720  // :TODO: this means that peer feedback, global feedback is available
1721  // after LAST personal deadline
1722  // team management is currently ignoring personal deadlines
1723  $idl = (bool)$a_include_personal
1724  ? $this->getLastPersonalDeadline()
1725  : null;
1726 
1727  // no deadline === false
1728  $deadline = max($this->deadline, $this->deadline2, $idl);
1729 
1730  // #18271 - afterDeadline() does not handle last personal deadline
1731  if($idl && $deadline == $idl)
1732  {
1733  return ($deadline - time() <= 0);
1734  }
1735 
1736  return ($deadline > 0 &&
1737  $this->afterDeadline());
1738  }
1739 
1740  public function beforeDeadline()
1741  {
1742  // no deadline === true
1743  return !$this->afterDeadlineStrict();
1744  }
1745 
1746  public function notStartedYet()
1747  {
1748  return (time() - $this->start_time <= 0);
1749  }
1750 
1751 
1752  //
1753  // FEEDBACK FILES
1754  //
1755 
1757  {
1758  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1759  $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
1760  return $storage->getGlobalFeedbackPath();
1761  }
1762 
1764  {
1766  }
1767 
1769  {
1771  ilUtil::delDir($path, true);
1772  if (ilUtil::moveUploadedFile($a_file["tmp_name"], $a_file["name"], $path."/".$a_file["name"]))
1773  {
1774  $this->setFeedbackFile($a_file["name"]);
1775  return true;
1776  }
1777  return false;
1778  }
1779 
1781  {
1782  $file = $this->getFeedbackFile();
1783  if($file)
1784  {
1786  return $path."/".$file;
1787  }
1788  }
1789 
1794  public function getMemberStatus($a_user_id = null)
1795  {
1796  global $ilUser;
1797 
1798  if(!$a_user_id)
1799  {
1800  $a_user_id = $ilUser->getId();
1801  }
1802  if(!array_key_exists($a_user_id, $this->member_status))
1803  {
1804  include_once "Modules/Exercise/classes/class.ilExAssignmentMemberStatus.php";
1805  $this->member_status[$a_user_id] = new ilExAssignmentMemberStatus($this->getId(), $a_user_id);
1806  }
1807  return $this->member_status[$a_user_id];
1808  }
1809 
1810  public function recalculateLateSubmissions()
1811  {
1812  global $ilDB;
1813 
1814  // see JF, 2015-05-11
1815 
1816  $ext_deadline = $this->getExtendedDeadline();
1817 
1818  include_once "Modules/Exercise/classes/class.ilExSubmission.php";
1819  foreach(ilExSubmission::getAllAssignmentFiles($this->exc_id, $this->getId()) as $file)
1820  {
1821  $id = $file["returned_id"];
1822  $uploaded = new ilDateTime($file["ts"], IL_CAL_DATETIME);
1823  $uploaded = $uploaded->get(IL_CAL_UNIX);
1824 
1825  $deadline = $this->getPersonalDeadline($file["user_id"]);
1826  $last_deadline = max($deadline, $this->getExtendedDeadline());
1827 
1828  $late = null;
1829 
1830  // upload is not late anymore
1831  if($file["late"] &&
1832  (!$last_deadline ||
1833  !$ext_deadline ||
1834  $uploaded < $deadline))
1835  {
1836  $late = false;
1837  }
1838  // upload is now late
1839  else if(!$file["late"] &&
1840  $ext_deadline &&
1841  $deadline &&
1842  $uploaded > $deadline)
1843  {
1844  $late = true;
1845  }
1846  else if($last_deadline && $uploaded > $last_deadline)
1847  {
1848  // do nothing, we do not remove submissions?
1849  }
1850 
1851  if($late !== null)
1852  {
1853  $ilDB->manipulate("UPDATE exc_returned".
1854  " SET late = ".$ilDB->quote($late, "integer").
1855  " WHERE returned_id = ".$ilDB->quote($id, "integer"));
1856  }
1857  }
1858  }
1859 
1860 
1861  //
1862  // individual deadlines
1863  //
1864 
1865  public function setIndividualDeadline($id, ilDateTime $date)
1866  {
1867  global $ilDB;
1868 
1869  $is_team = false;
1870  if(!is_numeric($id))
1871  {
1872  $id = substr($id, 1);
1873  $is_team = true;
1874  }
1875 
1876  $ilDB->replace("exc_idl",
1877  array(
1878  "ass_id" => array("integer", $this->getId()),
1879  "member_id" => array("integer", $id),
1880  "is_team" => array("integer", $is_team)
1881  ),
1882  array(
1883  "tstamp" => array("integer", $date->get(IL_CAL_UNIX))
1884  )
1885  );
1886  }
1887 
1888  public function getIndividualDeadlines()
1889  {
1890  global $ilDB;
1891 
1892  $res = array();
1893 
1894  $set = $ilDB->query("SELECT * FROM exc_idl".
1895  " WHERE ass_id = ".$ilDB->quote($this->getId(), "integer"));
1896  while($row = $ilDB->fetchAssoc($set))
1897  {
1898  if($row["is_team"])
1899  {
1900  $row["member_id"] = "t".$row["member_id"];
1901  }
1902 
1903  $res[$row["member_id"]] = $row["tstamp"];
1904  }
1905 
1906  return $res;
1907  }
1908 
1909  public function hasActiveIDl()
1910  {
1911  return (bool)$this->getDeadline();
1912  }
1913 
1914  public function hasReadOnlyIDl()
1915  {
1916  if($this->getType() != ilExAssignment::TYPE_UPLOAD_TEAM &&
1917  $this->getPeerReview())
1918  {
1919  // all deadlines are read-only if we have peer feedback
1920  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
1921  $peer_review = new ilExPeerReview($this);
1922  if($peer_review->hasPeerReviewGroups())
1923  {
1924  return true;
1925  }
1926  }
1927 
1928  return false;
1929  }
1930 }
1931 
1932 ?>
$files
Definition: add-vimline.php:18
getLastPersonalDeadline()
Get last/final personal deadline (of assignment)
getPeerReview()
Get peer review status.
static getInstanceByType($a_type)
static _lookupName($a_user_id)
lookup user name
Exercise assignment member status.
$path
Definition: aliased.php:25
getMemberStatus($a_user_id=null)
getPersonalDeadline($a_user_id)
Get individual deadline.
saveMultiFeedbackFiles($a_files, ilObjExercise $a_exc)
Save multi feedback files.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Exercise assignment.
static countMandatory($a_ex_id)
Order assignments by deadline date.
static sendFeedbackNotifications($a_ass_id, $a_user_id=null)
const IL_CAL_DATETIME
getMemberListData()
get member list data
Class ilExerciseMembers.
setMaxFile($a_value)
Set max number of uploads.
getFeedbackDate()
Get (global) feedback file availability date.
setFeedbackFile($a_value)
Set (global) feedback file.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
setPeerReviewMin($a_value)
Set peer review minimum.
const IL_CAL_TRANSLATION_SYSTEM
static getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
Get team id for member id.
static getPendingFeedbackNotifications()
setTeamTutor($a_value)
Set team management by tutor.
setPeerReviewFileUpload($a_val)
Set peer review file upload.
getStartTime()
Get start time (timestamp)
getId()
Get assignment id.
initFromDB(array $a_set)
Import DB record.
setPeerReview($a_value)
Toggle peer review.
setPeerReviewDeadline($a_val)
Set peer review deadline (timestamp)
getDeadline()
Get deadline (timestamp)
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
save()
Save assignment.
hasPeerReviewRating()
Get peer review rating status.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
hasFeedbackCron()
Get (global) feedback file cron status.
setPeerReviewValid($a_value)
Set peer review validation.
setType($a_value)
Set type.
Apointment templates are used for automatic generated apointments.
setTitle($a_val)
Set title.
Add rich text string
The name of the decorator.
saveAssOrderOfExercise($a_ex_id, $a_order)
Save ordering of all assignments of an exercise.
const IL_CAL_UNIX
setOrderNr($a_val)
Set order nr.
static lookup($a_id, $a_field)
Private lookup.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
setInstruction($a_val)
Set instruction.
for($col=0; $col< 50; $col++) $d
handleCalendarEntries($a_event)
Handle calendar entries for deadline(s)
getTeamTutor()
Get team management by tutor.
uploadMultiFeedbackFile($a_file)
Upload multi feedback file.
static lookupAssignmentOnline($a_ass_id)
Check if assignment is online.
setStartTime($a_val)
Set start time (timestamp)
Exercise peer review.
getExerciseId()
Get exercise id.
getPeerReviewValid()
Get peer review validatiob.
Class ilObjExercise.
setDeadline($a_val)
Set deadline (timestamp)
hasPeerReviewPersonalized()
Get peer review personalized status.
getId()
get object id public
static getInstancesByParentId($a_parent_id)
setPeerReviewCriteriaCatalogue($a_value)
Set peer review criteria catalogue id.
static lookupUpdatedSubmission($ass_id, $member_id)
Check whether student has upload new files after tutor has set the exercise to another than notgraded...
setPeerReviewPersonalized($a_val)
Set peer review personalized.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
setPeerReviewRating($a_val)
Set peer review rating.
static getInstancesByExercise($a_exc_id)
uploadAssignmentFiles($a_files)
Upload assignment files (from creation form)
setPeerReviewSimpleUnlock($a_value)
Set peer review simple unlock.
hasPeerReviewText()
Get peer review text status.
sendMultiFeedbackStructureFile()
Create member status record for a new assignment for all participants.
Date and time handling
setPeerReviewText($a_val)
Set peer review text.
$ilUser
Definition: imgupload.php:18
handleGlobalFeedbackFileUpload(array $a_file)
setExerciseId($a_val)
Set exercise id.
getFeedbackFile()
Get (global) feedback file.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
Create styles array
The data for the language used.
getMandatory()
Get mandatory.
getPeerReviewMin()
Get peer review minimum.
getExtendedDeadline()
Get extended deadline (timestamp)
sendFeedbackFileNotification($a_feedback_file, $a_user_id, $a_ass_id, $a_is_text_feedback=false)
Send feedback file notification to user.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id, array $a_crit_cat_map)
Clone assignments of exercise.
setFeedbackCron($a_value)
Toggle (global) feedback file cron.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
afterDeadlineStrict($a_include_personal=true)
static lookupType($a_id)
Lookup type.
clearMultiFeedbackDirectory()
Clear multi feedback directory.
setFeedbackDate($a_value)
Set (global) feedback file availability date.
static lookupMaxOrderNrForEx($a_exc_id)
Select the maximum order nr for an exercise.
getMultiFeedbackFiles($a_user_id=0)
Get multi feedback files (of uploader)
getInstruction()
Get instruction.
global $lng
Definition: privfeed.php:17
getPeerReviewSimpleUnlock()
Get peer review simple unlock.
global $ilDB
setPeerReviewChars($a_value)
Set peer review minimum characters.
setId($a_val)
Set assignment id.
getPeerReviewDeadline()
Get peer review deadline (timestamp)
Exercise submission.
hasPeerReviewFileUpload()
Get peer review file upload status.
static lookupExerciseId($a_ass_id)
Lookup excercise id for assignment id.
global $DIC
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
getPeerReviewChars()
Get peer review minimum characters.
static getAllAssignmentFiles($a_exc_id, $a_ass_id)
getMaxFile()
Get max number of uploads.
static createNewUserRecords($a_user_id, $a_exc_id)
Create member status record for a new participant for all assignments.
setMandatory($a_val)
Set mandatory.
static orderAssByDeadline($a_ex_id)
Order assignments by deadline date.
setIndividualDeadline($id, ilDateTime $date)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getPeerReviewCriteriaCatalogue()
Get peer review criteria catalogue id.
read()
Read from db.
Wrapper classes for system notifications.
setExtendedDeadline($a_val)
Set extended deadline (timestamp)
static _getMembers($a_obj_id)
isValidType($a_value)
Is given type valid?
static createNewAssignmentRecords($a_ass_id, $a_exc)
Create member status record for a new assignment for all participants.
__construct($a_id=0)
Constructor.
static lookupTitle($a_id)
Lookup title.
getOrderNr()
Get order nr.
Class to report exception.