51 $this->
setType(self::TYPE_UPLOAD);
88 $this->exc_id = $a_val;
108 $this->start_time = $a_val;
128 $this->deadline = $a_val;
148 $this->instruction = $a_val;
168 $this->title = $a_val;
188 $this->mandatory = $a_val;
208 $this->order_nr = $a_val;
230 $this->type = (int)$a_value;
232 if($this->type == self::TYPE_UPLOAD_TEAM)
257 if(in_array((
int)$a_value, array(self::TYPE_UPLOAD, self::TYPE_BLOG,
258 self::TYPE_PORTFOLIO, self::TYPE_UPLOAD_TEAM, self::TYPE_TEXT)))
272 $this->peer = (bool)$a_value;
292 $this->peer_min = (int)$a_value;
312 $this->peer_dl = $a_val;
332 $this->peer_file = (bool)$a_val;
352 $this->peer_personal = (bool)$a_val;
372 $this->feedback_file = (string)$a_value;
392 $this->feedback_cron = (string)$a_value;
412 $this->feedback_date = (int)$a_value;
432 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
433 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
435 while ($rec = $ilDB->fetchAssoc($set))
470 $next_id = $ilDB->nextId(
"exc_assignment");
471 $ilDB->insert(
"exc_assignment", array(
472 "id" => array(
"integer", $next_id),
474 "time_stamp" => array(
"integer", $this->
getDeadline()),
476 "title" => array(
"text", $this->
getTitle()),
477 "start_time" => array(
"integer", $this->
getStartTime()),
478 "order_nr" => array(
"integer", $this->
getOrderNr()),
480 "type" => array(
"integer", $this->
getType()),
490 $this->
setId($next_id);
492 $exc->updateAllUsersStatus();
505 $ilDB->update(
"exc_assignment",
508 "time_stamp" => array(
"integer", $this->
getDeadline()),
510 "title" => array(
"text", $this->
getTitle()),
511 "start_time" => array(
"integer", $this->
getStartTime()),
512 "order_nr" => array(
"integer", $this->
getOrderNr()),
514 "type" => array(
"integer", $this->
getType()),
525 "id" => array(
"integer", $this->
getId()),
528 $exc->updateAllUsersStatus();
542 $ilDB->manipulate(
"DELETE FROM exc_assignment WHERE ".
543 " id = ".$ilDB->quote($this->getId(),
"integer")
546 $exc->updateAllUsersStatus();
553 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
555 $path = $storage->getGlobalFeedbackPath();
561 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
563 $path = $storage->getGlobalFeedbackPath();
565 if(@move_uploaded_file($a_file[
"tmp_name"],
$path.
"/".$a_file[
"name"]))
578 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
580 $path = $storage->getGlobalFeedbackPath();
592 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
593 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer").
594 " ORDER BY order_nr ASC");
598 while ($rec = $ilDB->fetchAssoc($set))
603 "exc_id" => $rec[
"exc_id"],
604 "deadline" => $rec[
"time_stamp"],
605 "instruction" => $rec[
"instruction"],
606 "title" => $rec[
"title"],
607 "start_time" => $rec[
"start_time"],
608 "order_val" => $order_val,
609 "mandatory" => $rec[
"mandatory"],
610 "type" => $rec[
"type"],
611 "peer" => $rec[
"peer"],
612 "peer_min" => $rec[
"peer_min"],
613 "peer_dl" => $rec[
"peer_dl"],
614 "peer_file" => $rec[
"peer_file"],
615 "peer_prsl" => $rec[
"peer_prsl"],
616 "fb_file" => $rec[
"fb_file"],
617 "fb_date" => $rec[
"fb_date"],
618 "fb_cron" => $rec[
"fb_cron"],
634 foreach ($ass_data as
$d)
638 $new_ass->setExerciseId($a_new_exc_id);
639 $new_ass->setTitle($d[
"title"]);
640 $new_ass->setDeadline($d[
"deadline"]);
641 $new_ass->setInstruction($d[
"instruction"]);
642 $new_ass->setMandatory($d[
"mandatory"]);
643 $new_ass->setOrderNr($d[
"order_val"]);
644 $new_ass->setStartTime($d[
"start_time"]);
645 $new_ass->setType($d[
"type"]);
646 $new_ass->setPeerReview($d[
"peer"]);
647 $new_ass->setPeerReviewMin($d[
"peer_min"]);
648 $new_ass->setPeerReviewDeadline($d[
"peer_dl"]);
649 $new_ass->setPeerReviewFileUpload($d[
"peer_file"]);
650 $new_ass->setPeerReviewPersonalized($d[
"peer_prsl"]);
651 $new_ass->setFeedbackFile($d[
"fb_file"]);
652 $new_ass->setFeedbackDate($d[
"fb_date"]);
653 $new_ass->setFeedbackCron($d[
"fb_cron"]);
657 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
662 if (is_dir($old_storage->getPath()))
664 ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath());
674 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
676 return $storage->getFiles();
686 $set = $ilDB->query(
"SELECT MAX(order_nr) mnr FROM exc_assignment ".
687 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer")
689 while ($rec = $ilDB->fetchAssoc($set))
691 return (
int) $rec[
"mnr"];
705 $query =
"SELECT id FROM exc_assignment ".
706 "WHERE start_time <= ".$ilDB->quote(time(),
'integer').
' '.
707 "AND time_stamp >= ".$ilDB->quote(time(),
'integer').
' '.
708 "AND id = ".$ilDB->quote($a_ass_id,
'integer');
711 return $res->numRows() ?
true :
false;
718 private static function lookup($a_id, $a_field)
722 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_assignment ".
723 " WHERE id = ".$ilDB->quote($a_id,
"integer")
726 $rec = $ilDB->fetchAssoc($set);
728 return $rec[$a_field];
754 $result_order = array();
757 foreach ($a_order as $k => $v)
760 $ilDB->manipulate(
$t =
"UPDATE exc_assignment SET ".
761 " order_nr = ".$ilDB->quote($nr,
"integer").
762 " WHERE id = ".$ilDB->quote((
int) $k,
"integer").
763 " AND exc_id = ".$ilDB->quote((
int) $a_ex_id,
"integer")
776 $set = $ilDB->query(
"SELECT id FROM exc_assignment ".
777 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
778 " ORDER BY time_stamp ASC"
781 while ($rec = $ilDB->fetchAssoc($set))
783 $ilDB->manipulate(
"UPDATE exc_assignment SET ".
784 " order_nr = ".$ilDB->quote($nr,
"integer").
785 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
798 $set = $ilDB->query(
"SELECT count(*) cntm FROM exc_assignment ".
799 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
800 " AND mandatory = ".$ilDB->quote(1,
"integer")
802 $rec = $ilDB->fetchAssoc($set);
817 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_mem_ass_status ".
818 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
819 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
821 $rec = $ilDB->fetchAssoc($set);
823 return $rec[$a_field];
833 $ilDB->manipulate(
"UPDATE exc_mem_ass_status SET ".
834 " ".$a_field.
" = ".$ilDB->quote($a_value, $a_type).
835 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
836 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
868 "u_comment", $a_value,
"text");
885 "mark", $a_value,
"text");
908 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
909 "SET status = %s, status_time= %s ".
910 " WHERE ass_id = %s AND usr_id = %s AND status <> %s ",
911 array(
"text",
"timestamp",
"integer",
"integer",
"text"),
912 array($a_status,
ilUtil::now(), $a_ass_id, $a_user_id, $a_status));
959 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
960 "SET sent = %s, sent_time = %s ".
961 " WHERE ass_id = %s AND usr_id = %s ",
962 array(
"integer",
"timestamp",
"integer",
"integer"),
963 array((
int) $a_status, ($a_status ?
ilUtil::now() : null),
964 $a_ass_id, $a_user_id));
998 !self::lookupStatusReturnedOfUser($a_ass_id, $a_user_id))
1000 $set = $ilDB->query(
"SELECT fb_cron, fb_date, fb_file".
1001 " FROM exc_assignment".
1002 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
1003 $row = $ilDB->fetchAssoc($set);
1004 if(
$row[
"fb_cron"] &&
1006 $row[
"fb_date"] == self::FEEDBACK_DATE_SUBMISSION)
1013 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status".
1014 " SET returned = %s".
1015 " WHERE ass_id = %s AND usr_id = %s",
1016 array(
"integer",
"integer",
"integer"),
1017 array((
int) $a_status, $a_ass_id, $a_user_id));
1050 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
1051 "SET feedback = %s, feedback_time = %s ".
1052 " WHERE ass_id = %s AND usr_id = %s",
1053 array(
"integer",
"timestamp",
"integer",
"integer"),
1054 array((
int) $a_status, ($a_status ?
ilUtil::now() : null),
1055 $a_ass_id, $a_user_id));
1118 $user_ids = array($a_user_id);
1121 $result = $ilDB->query(
"SELECT returned_id FROM exc_returned".
1122 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1123 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1124 return $ilDB->numRows(
$result);
1134 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1137 $query =
"SELECT * FROM exc_returned WHERE ass_id = ".
1138 $ilDB->quote($a_ass_id,
"integer");
1141 while(
$row = $ilDB->fetchAssoc(
$res))
1144 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
1145 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
1146 $delivered[] =
$row;
1151 return $delivered ? $delivered : array();
1164 $user_ids = array($a_user_id);
1167 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1170 $result = $ilDB->query(
"SELECT * FROM exc_returned".
1171 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1172 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1174 $delivered_files = array();
1179 if($a_filter_empty_filename && !
$row[
"filename"])
1183 $row[
"owner_id"] =
$row[
"user_id"];
1185 $row[
"timestamp14"] = substr(
$row[
"ts"], 0, 4).
1186 substr(
$row[
"ts"], 5, 2).substr(
$row[
"ts"], 8, 2).
1187 substr(
$row[
"ts"], 11, 2).substr(
$row[
"ts"], 14, 2).
1188 substr(
$row[
"ts"], 17, 2);
1189 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
1190 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
1191 array_push($delivered_files,
$row);
1196 return $delivered_files;
1206 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1209 if (count($file_id_array))
1223 $user_ids = array($a_user_id);
1226 $result = $ilDB->query(
"SELECT * FROM exc_returned".
1227 " WHERE ".$ilDB->in(
"returned_id", $file_id_array,
false,
"integer").
1228 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1232 $result_array = array();
1236 array_push($result_array,
$row);
1240 $ilDB->manipulate(
"DELETE FROM exc_returned".
1241 " WHERE ".$ilDB->in(
"returned_id", $file_id_array,
false,
"integer").
1242 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1245 foreach ($result_array as $key => $value)
1247 if($value[
"filename"])
1255 $filename = $fs->getAbsoluteSubmissionPath().
1256 "/".$value[
"user_id"].
"/".basename($value[
"filename"]);
1274 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1276 $delete_ids = array();
1279 $set = $ilDB->query(
"SELECT * FROM exc_returned ".
1280 " WHERE obj_id = ".$ilDB->quote($a_exc_id,
"integer").
1281 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
1283 while ($rec = $ilDB->fetchAssoc($set))
1285 $ass =
new self($rec[
"ass_id"]);
1290 if(
sizeof($team) > 1)
1292 $new_owner = array_pop($team);
1293 while($new_owner == $a_user_id &&
sizeof($team))
1295 $new_owner = array_pop($team);
1298 $ilDB->manipulate(
"UPDATE exc_returned".
1299 " SET user_id = ".$ilDB->quote($new_owner,
"integer").
1300 " WHERE returned_id = ".$ilDB->quote($rec[
"returned_id"],
"integer")
1308 $delete_ids[] = $rec[
"returned_id"];
1313 $filename = $fs->getAbsoluteSubmissionPath().
1314 "/".$a_user_id.
"/".basename($rec[
"filename"]);
1324 $ilDB->manipulate(
"DELETE FROM exc_returned".
1325 " WHERE ".$ilDB->in(
"returned_id", $delete_ids,
"",
"integer"));
1330 foreach(self::getAssignmentDataOfExercise($a_exc_id) as $item)
1334 $ass_ids[] = $item[
"id"];
1338 $ilDB->manipulate(
$d =
"DELETE FROM il_exc_team WHERE ".
1339 "user_id = ".$ilDB->quote($a_user_id,
"integer").
1340 " AND ".$ilDB->in(
"ass_id", $ass_ids,
"",
"integer")
1349 function deliverReturnedFiles($a_exc_id, $a_ass_id, $a_user_id, $a_only_new =
false, $a_peer_review_mask_filename =
false)
1359 $user_ids = array($a_user_id);
1366 $q =
"SELECT download_time FROM exc_usr_tutor WHERE ".
1367 " ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND ".
1368 $ilDB->in(
"usr_id", $user_ids,
"",
"integer").
" AND ".
1369 " tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer");
1370 $lu_set = $ilDB->query($q);
1371 if ($lu_rec = $ilDB->fetchAssoc($lu_set))
1373 if ($lu_rec[
"download_time"] > 0)
1375 $and_str =
" AND ts > ".$ilDB->quote($lu_rec[
"download_time"],
"timestamp");
1380 foreach($user_ids as $user_id)
1385 if($a_peer_review_mask_filename)
1389 foreach($this->ass->getPeerReviewsByGiver($ilUser->getId()) as $idx => $item)
1391 if($item[
"peer_id"] == $a_user_id)
1399 $query =
"SELECT * FROM exc_returned".
1400 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1401 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer").
1405 $count = $ilDB->numRows(
$result);
1410 switch(self::lookupType($a_ass_id))
1412 case self::TYPE_BLOG:
1413 case self::TYPE_PORTFOLIO:
1417 $row[
"filetitle"][
"firstname"].
" ".
1418 $row[
"filetitle"][
"lastname"].
" (".
1419 $row[
"filetitle"][
"login"].
").zip";
1426 if($a_peer_review_mask_filename)
1428 $suffix = array_pop(explode(
".",
$row[
"filetitle"]));
1433 $row[
"filename"],
$row[
"filetitle"]);
1435 else if ($count > 0)
1437 $array_files = array();
1441 $src = basename(
$row[
"filename"]);
1442 if($a_peer_review_mask_filename)
1444 $suffix = array_pop(explode(
".", $src));
1446 "_".(++$seq).
".".$suffix;
1448 $array_files[
$row[
"user_id"]][] = array($src, $tgt);
1452 $array_files[
$row[
"user_id"]][] = $src;
1456 ($is_team ? null : $a_user_id), $is_team);
1474 $ilDB->manipulateF(
"DELETE FROM exc_usr_tutor ".
1475 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
1476 array(
"integer",
"integer",
"integer"),
1477 array($a_ass_id, $a_user_id, $ilUser->getId()));
1479 $ilDB->manipulateF(
"INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES ".
1480 "(%s, %s, %s, %s, %s)",
1481 array(
"integer",
"integer",
"integer",
"integer",
"timestamp"),
1482 array($a_ass_id, $a_exc_id, $a_user_id, $ilUser->getId(),
ilUtil::now()));
1492 if (count($array_file_id))
1500 $user_ids = array($a_user_id);
1503 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE ".
1504 $ilDB->in(
"returned_id", $array_file_id,
false,
"integer").
1505 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1508 $array_found = array();
1512 array_push($array_found,
$row);
1514 if (count($array_found) == 1)
1517 if(is_numeric($array_found[0][
"filetitle"]))
1525 $ass->getTitle().
" - ".
1526 $user_data[
"firstname"].
" ".
1527 $user_data[
"lastname"].
" (".
1528 $user_data[
"login"].
").zip";
1533 $array_found[0][
"filename"], $array_found[0][
"filetitle"]);
1537 $filenames = array();
1538 foreach ($array_found as $value)
1540 $filenames[$value[
"user_id"]][] = basename($value[
"filename"]);
1543 $filenames, ($is_team ? null : $a_user_id), $is_team);
1554 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1557 $filename = $fs->getAbsoluteSubmissionPath().
1560 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1569 $a_user_id, $a_multi_user =
false)
1571 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1574 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1580 $tmpzipfile = $tmpfile .
".zip";
1586 $deliverFilename = str_replace(
" ",
"_", $assTitle);
1587 if ($a_user_id > 0 && !$a_multi_user)
1590 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
1594 $deliverFilename .=
"_files";
1596 $orgDeliverFilename = trim($deliverFilename);
1599 chdir($tmpdir.
"/".$deliverFilename);
1602 $parsed_files = $duplicates = array();
1603 foreach ($array_filenames as $user_id => $files)
1605 $pathname = $fs->getAbsoluteSubmissionPath().
"/".$user_id;
1610 if(is_array($filename))
1612 $newFilename = $filename[1];
1613 $filename = $filename[0];
1618 $newFilename = trim($filename);
1619 $pos = strpos($newFilename ,
"_");
1622 $newFilename = substr($newFilename, $pos + 1);
1625 $chkName = strtolower($newFilename);
1626 if(array_key_exists($chkName, $duplicates))
1628 $suffix = strrpos($newFilename,
".");
1629 $newFilename = substr($newFilename, 0, $suffix).
1630 " (".(++$duplicates[$chkName]).
")".
1631 substr($newFilename, $suffix);
1635 $duplicates[$chkName] = 1;
1638 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename.DIRECTORY_SEPARATOR.$newFilename;
1640 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$filename;
1641 if (!copy ($oldFilename, $newFilename))
1643 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
1645 touch($newFilename, filectime($oldFilename));
1668 global
$lng, $ilObjDataCache, $ilias;
1670 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1671 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1678 $savepath = $storage->getAbsoluteSubmissionPath();
1686 if (!is_dir($savepath))
1692 chdir($storage->getTempPath());
1702 foreach ($members as
$id => $object) {
1703 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
1706 if ($dirsize > disk_free_space($tmpdir)) {
1717 foreach ($members as
$id => $user)
1719 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
1720 if (!is_dir($sourcedir))
1725 trim($userName[
"firstname"]).
"_".trim($userName[
"login"]).
"_".$userName[
"user_id"]);
1736 $cache[$directory] = $directory;
1738 $sourcefiles = scandir($sourcedir);
1739 $duplicates = array();
1740 foreach ($sourcefiles as $sourcefile) {
1741 if ($sourcefile ==
"." || $sourcefile ==
"..")
1746 $targetfile = trim(basename($sourcefile));
1747 $pos = strpos($targetfile,
"_");
1750 $targetfile= substr($targetfile, $pos + 1);
1754 if(array_key_exists($targetfile, $duplicates))
1756 $suffix = strrpos($targetfile,
".");
1757 $targetfile = substr($targetfile, 0, $suffix).
1758 " (".(++$duplicates[$targetfile]).
")".
1759 substr($targetfile, $suffix);
1763 $duplicates[$targetfile] = 1;
1766 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
1767 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
1769 if (!copy ($sourcefile, $targetfile))
1772 $ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
1773 $ilias->error_obj->MESSAGE);
1778 touch($targetfile, filectime($sourcefile));
1785 unlink($targetfile);
1793 $tmpzipfile = $tmpfile .
".zip";
1802 ? strtolower($lng->txt(
"exc_assignment"))
1803 : $assTitle).
".zip",
"",
false,
true);
1814 $ilDB->manipulate(
"UPDATE exc_mem_ass_status".
1815 " SET notice = ".$ilDB->quote($a_notice,
"text").
1816 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1817 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
1818 " AND ".$ilDB->equalsNot(
"notice", $a_notice,
"text",
true));
1828 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_mem_ass_status ".
1829 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1833 while(
$row = $ilDB->fetchObject(
$res))
1835 $usr_ids[] =
$row->ud;
1838 return $usr_ids ? $usr_ids : array();
1856 $user_ids = array($a_user_id);
1861 $q =
"SELECT obj_id,user_id,ts FROM exc_returned".
1862 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1863 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer").
1864 " ORDER BY ts DESC";
1866 $usr_set = $ilDB->query($q);
1868 $array = $ilDB->fetchAssoc($usr_set);
1869 if ($array[
"ts"]==NULL)
1886 $q =
"SELECT count(*) AS cnt FROM exc_mem_ass_status".
1887 " WHERE NOT sent_time IS NULL".
1888 " AND ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1890 $set = $ilDB->query($q);
1891 $rec = $ilDB->fetchAssoc($set);
1893 if ($rec[
"cnt"] > 0)
1915 $user_ids = array($member_id);
1918 $q=
"SELECT exc_mem_ass_status.status_time, exc_returned.ts ".
1919 "FROM exc_mem_ass_status, exc_returned ".
1920 "WHERE exc_mem_ass_status.status_time < exc_returned.ts ".
1921 "AND NOT exc_mem_ass_status.status_time IS NULL ".
1922 "AND exc_returned.ass_id = exc_mem_ass_status.ass_id ".
1923 "AND exc_returned.user_id = exc_mem_ass_status.usr_id ".
1924 "AND exc_returned.ass_id=".$ilDB->quote($ass_id,
"integer").
1925 " AND ".$ilDB->in(
"exc_returned.user_id", $user_ids,
"",
"integer");
1927 $usr_set = $ilDB->query($q);
1929 $array = $ilDB->fetchAssoc($usr_set);
1931 if (count($array)==0)
1954 $user_ids = array($member_id);
1957 $q =
"SELECT exc_returned.returned_id AS id ".
1958 "FROM exc_usr_tutor, exc_returned ".
1959 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id ".
1960 " AND exc_returned.user_id = exc_usr_tutor.usr_id ".
1961 " AND exc_returned.ass_id = ".$ilDB->quote($ass_id,
"integer").
1962 " AND ".$ilDB->in(
"exc_returned.user_id", $user_ids,
"",
"integer").
1963 " AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer").
1964 " AND exc_usr_tutor.download_time < exc_returned.ts ";
1966 $new_up_set = $ilDB->query($q);
1969 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set))
1971 $new_up[] = $new_up_rec[
"id"];
1987 $set = $ilDB->query(
"SELECT ud.usr_id, ud.lastname, ud.firstname, ud.login".
1988 " FROM exc_members excm".
1989 " JOIN usr_data ud ON (ud.usr_id = excm.usr_id)".
1990 " WHERE excm.obj_id = ".$ilDB->quote($a_exc_id,
"integer"));
1991 while($rec = $ilDB->fetchAssoc($set))
1993 $mem[$rec[
"usr_id"]] =
1995 "name" => $rec[
"lastname"].
", ".$rec[
"firstname"],
1996 "login" => $rec[
"login"],
1997 "usr_id" => $rec[
"usr_id"],
1998 "lastname" => $rec[
"lastname"],
1999 "firstname" => $rec[
"firstname"]
2003 $q =
"SELECT * FROM exc_mem_ass_status ".
2004 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
2005 $set = $ilDB->query($q);
2006 while($rec = $ilDB->fetchAssoc($set))
2008 if (isset($mem[$rec[
"usr_id"]]))
2010 $mem[$rec[
"usr_id"]][
"sent_time"] = $rec[
"sent_time"];
2012 $mem[$rec[
"usr_id"]][
"status_time"] = $rec[
"status_time"];
2013 $mem[$rec[
"usr_id"]][
"feedback_time"] = $rec[
"feedback_time"];
2014 $mem[$rec[
"usr_id"]][
"notice"] = $rec[
"notice"];
2015 $mem[$rec[
"usr_id"]][
"status"] = $rec[
"status"];
2029 foreach ($ass_data as $ass)
2032 $ilDB->replace(
"exc_mem_ass_status", array(
2033 "ass_id" => array(
"integer", $ass[
"id"]),
2034 "usr_id" => array(
"integer", $a_user_id)
2036 "status" => array(
"text",
"notgraded")
2048 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
2050 $mems = $exmem->getMembers();
2052 foreach ($mems as $mem)
2054 $ilDB->replace(
"exc_mem_ass_status", array(
2055 "ass_id" => array(
"integer", $a_ass_id),
2056 "usr_id" => array(
"integer", $mem)
2058 "status" => array(
"text",
"notgraded")
2069 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2072 $storage->uploadAssignmentFiles($a_files);
2092 $sql =
"SELECT id FROM il_exc_team".
2093 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2094 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
2095 $set = $ilDB->query($sql);
2096 $row = $ilDB->fetchAssoc($set);
2099 if(!
$id && $a_create_on_demand)
2101 $id = $ilDB->nextId(
"il_exc_team");
2103 $fields = array(
"id" => array(
"integer",
$id),
2104 "ass_id" => array(
"integer", $this->
getId()),
2105 "user_id" => array(
"integer", $a_user_id));
2106 $ilDB->insert(
"il_exc_team", $fields);
2128 $sql =
"SELECT user_id".
2129 " FROM il_exc_team".
2130 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2131 " AND id = ".$ilDB->quote($a_team_id,
"integer");
2132 $set = $ilDB->query($sql);
2133 while(
$row = $ilDB->fetchAssoc($set))
2135 $ids[] =
$row[
"user_id"];
2152 $sql =
"SELECT user_id".
2153 " FROM il_exc_team".
2154 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer");
2155 $set = $ilDB->query($sql);
2156 while(
$row = $ilDB->fetchAssoc($set))
2158 $ids[] =
$row[
"user_id"];
2176 if(!in_array($a_user_id, $members))
2178 $fields = array(
"id" => array(
"integer", $a_team_id),
2179 "ass_id" => array(
"integer", $this->
getId()),
2180 "user_id" => array(
"integer", $a_user_id));
2181 $ilDB->insert(
"il_exc_team", $fields);
2204 $sql =
"DELETE FROM il_exc_team".
2205 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2206 " AND id = ".$ilDB->quote($a_team_id,
"integer").
2207 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
2208 $ilDB->manipulate($sql);
2232 $set = $ilDB->query(
"SELECT user_id".
2233 " FROM il_exc_team".
2234 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2235 " AND id = ". $ilDB->quote($team_id,
"integer"));
2236 while(
$row = $ilDB->fetchAssoc($set))
2238 $ids[] =
$row[
"user_id"];
2256 $result = $ilDB->query(
"SELECT type".
2257 " FROM exc_assignment".
2258 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
2261 if(
$type[
"type"] == self::TYPE_UPLOAD_TEAM)
2263 $set = $ilDB->query(
"SELECT id".
2264 " FROM il_exc_team".
2265 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2266 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
2267 $team_id = $ilDB->fetchAssoc($set);
2268 return $team_id[
"id"];
2284 $sql =
"SELECT * FROM il_exc_team".
2285 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
2286 $set = $ilDB->query($sql);
2287 while(
$row = $ilDB->fetchAssoc($set))
2289 $map[
$row[
"user_id"]] = $row[
"id"];
2302 public static function writeTeamLog($a_team_id, $a_action, $a_details = null)
2307 "team_id" => array(
"integer", $a_team_id),
2308 "user_id" => array(
"integer", $ilUser->getId()),
2309 "action" => array(
"integer", $a_action),
2310 "details" => array(
"text", $a_details),
2311 "tstamp" => array(
"integer", time())
2314 $ilDB->insert(
"il_exc_team_log", $fields);
2329 $sql =
"SELECT * FROM il_exc_team_log".
2330 " WHERE team_id = ".$ilDB->quote($a_team_id,
"integer").
2331 " ORDER BY tstamp DESC";
2332 $set = $ilDB->query($sql);
2333 while(
$row = $ilDB->fetchAssoc($set))
2352 if($ilUser->getId() == $a_user_id)
2357 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
2359 $ntf->setLangModules(array(
"exc"));
2360 $ntf->setRefId($a_exc_ref_id);
2361 $ntf->setChangedByUserId($ilUser->getId());
2362 $ntf->setSubjectLangId(
'exc_team_notification_subject_'.$a_action);
2363 $ntf->setIntroductionLangId(
'exc_team_notification_body_'.$a_action);
2364 $ntf->addAdditionalInfo(
"exc_assignment", $this->
getTitle());
2365 $ntf->setGotoLangId(
'exc_team_notification_link');
2366 $ntf->setReasonLangId(
'exc_team_notification_reason');
2367 $ntf->sendMail(array($a_user_id));
2375 $result[
"files"][
"count"] =
"---";
2377 $ilCtrl->setParameter($a_parent_obj,
"ass_id", $a_ass_id);
2396 $result[
"last_submission"][
"txt"] = $lng->txt(
"exc_last_submission");
2397 $result[
"last_submission"][
"value"] = $last_sub;
2408 $result[
"files"][
"txt"] = $lng->txt(
"exc_files_returned");
2411 if (count($new) > 0)
2413 $sub_cnt.=
" ".sprintf($lng->txt(
"cnt_new"),count($new));
2415 $result[
"files"][
"count"] = $sub_cnt;
2418 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2422 $result[
"files"][
"download_url"] =
2423 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2425 if (count($new) <= 0)
2427 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2431 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_all");
2435 if (count($new) > 0)
2437 $result[
"files"][
"download_new_url"] =
2438 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadNewReturned");
2440 $result[
"files"][
"download_new_txt"] = $lng->txt(
"exc_download_new");
2446 $result[
"files"][
"txt"] =$lng->txt(
"exc_blog_returned");
2450 $blogs = array_pop($blogs);
2451 if($blogs && substr($blogs[
"filename"], -1) !=
"/")
2453 $result[
"files"][
"count"] = 1;
2455 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2456 $result[
"files"][
"download_url"] =
2457 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2458 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2460 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2466 $result[
"files"][
"txt"] = $lng->txt(
"exc_portfolio_returned");
2470 $portfolios = array_pop($portfolios);
2471 if($portfolios && substr($portfolios[
"filename"], -1) !=
"/")
2473 $result[
"files"][
"count"] = 1;
2475 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2476 $result[
"files"][
"download_url"] =
2477 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2478 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2480 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2486 $result[
"files"][
"txt"] = $lng->txt(
"exc_files_returned_text");
2490 $result[
"files"][
"count"] = 1;
2492 $files = array_shift($files);
2493 if(trim($files[
"atext"]))
2498 $ilCtrl->setParameter($a_parent_obj,
"grd", (($a_parent_cmd ==
"members") ? 1 : 2));
2500 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2501 $result[
"files"][
"download_url"] =
2502 $ilCtrl->getLinkTarget($a_parent_obj,
"showAssignmentText");
2503 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2504 $ilCtrl->setParameter($a_parent_obj,
"grd",
"");
2506 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_text_assignment_show");
2519 $set = $ilDB->query(
"SELECT count(*) cnt".
2520 " FROM exc_assignment_peer".
2521 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer"));
2522 $cnt = $ilDB->fetchAssoc($set);
2523 return (
bool)$cnt[
"cnt"];
2530 $user_ids = array();
2533 $set = $ilDB->query(
"SELECT DISTINCT(user_id)".
2534 " FROM exc_returned".
2535 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer"));
2536 while(
$row = $ilDB->fetchAssoc($set))
2538 $user_ids[] =
$row[
"user_id"];
2559 if(
sizeof($user_ids) < 2)
2564 $rater_ids = $user_ids;
2568 for($loop = 0; $loop < $max; $loop++)
2570 $run_ids = array_combine($user_ids, $user_ids);
2572 foreach($rater_ids as $rater_id)
2574 $possible_peer_ids = $run_ids;
2577 unset($possible_peer_ids[$rater_id]);
2580 if(array_key_exists($rater_id, $matrix))
2582 $possible_peer_ids = array_diff($possible_peer_ids, $matrix[$rater_id]);
2586 if(!
sizeof($possible_peer_ids))
2589 $run_ids = array_combine($user_ids, $user_ids);
2592 $possible_peer_ids = $run_ids;
2595 unset($possible_peer_ids[$rater_id]);
2598 if(array_key_exists($rater_id, $matrix))
2600 $possible_peer_ids = array_diff($possible_peer_ids, $matrix[$rater_id]);
2605 if(
sizeof($possible_peer_ids))
2607 $peer_id = array_rand($possible_peer_ids);
2608 if(!array_key_exists($rater_id, $matrix))
2610 $matrix[$rater_id] = array();
2612 $matrix[$rater_id][] = $peer_id;
2616 unset($run_ids[$peer_id]);
2620 foreach($matrix as $rater_id => $peer_ids)
2622 foreach($peer_ids as $peer_id)
2624 $ilDB->manipulate(
"INSERT INTO exc_assignment_peer".
2625 " (ass_id, giver_id, peer_id)".
2626 " VALUES (".$ilDB->quote($this->getId(),
"integer").
2627 ", ".$ilDB->quote($rater_id,
"integer").
2628 ", ".$ilDB->quote($peer_id,
"integer").
")");
2640 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2642 $storage->deletePeerReviewUploads();
2655 foreach($reviews as $giver_id => $review)
2658 $peer_id,
"peer", $giver_id);
2666 $ilDB->manipulate(
"DELETE FROM exc_assignment_peer".
2667 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer"));
2675 include_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
2679 $peer_ids = $invalid_peer_ids = $invalid_giver_ids = $all_reviews = array();
2682 $peer_ids[] = $peer_id;
2684 if(!in_array($peer_id, $all_valid) ||
2685 !in_array($peer_id, $all_exc))
2687 $invalid_peer_ids[] = $peer_id;
2689 foreach($reviews as $giver_id => $review)
2691 if(!in_array($giver_id, $all_valid) ||
2692 !in_array($giver_id, $all_exc))
2694 $invalid_giver_ids[] = $giver_id;
2698 $valid = (trim($review[0]) || $review[1]);
2699 $all_reviews[$peer_id][$giver_id] =
$valid;
2703 $invalid_giver_ids = array_unique($invalid_giver_ids);
2705 $missing_user_ids = array();
2706 foreach($all_valid as $user_id)
2709 if(!in_array($user_id, $peer_ids))
2711 $missing_user_ids[] = $user_id;
2715 $not_returned_ids = array();
2716 foreach($all_exc as $user_id)
2718 if(!in_array($user_id, $all_valid))
2720 $not_returned_ids[] = $user_id;
2725 "invalid" => (
sizeof($missing_user_ids) ||
2726 sizeof($invalid_peer_ids) ||
2727 sizeof($invalid_giver_ids)),
2728 "missing_user_ids" => $missing_user_ids,
2729 "not_returned_ids" => $not_returned_ids,
2730 "invalid_peer_ids" => $invalid_peer_ids,
2731 "invalid_giver_ids" => $invalid_giver_ids,
2732 "reviews" => $all_reviews);
2744 $set = $ilDB->query(
"SELECT *".
2745 " FROM exc_assignment_peer".
2746 " WHERE giver_id = ".$ilDB->quote($a_user_id,
"integer").
2747 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2748 " ORDER BY peer_id");
2749 while(
$row = $ilDB->fetchAssoc($set))
2763 if(trim($a_data[
"pcomment"]))
2771 if($a_rating === null)
2773 include_once
'./Services/Rating/classes/class.ilRating.php';
2775 "ass", $a_data[
"peer_id"],
"peer", $a_data[
"giver_id"]));
2786 $ass =
new self($a_data[
"ass_id"]);
2787 $valid = (bool)
sizeof($ass->getPeerUploadFiles($a_data[
"peer_id"], $a_data[
"giver_id"]));
2799 $set = $ilDB->query(
"SELECT *".
2800 " FROM exc_assignment_peer".
2801 " WHERE peer_id = ".$ilDB->quote($a_user_id,
"integer").
2802 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2803 " ORDER BY peer_id");
2804 while(
$row = $ilDB->fetchAssoc($set))
2806 if(!$a_only_valid ||
2807 self::validatePeerReview(
$row))
2822 include_once
'./Services/Rating/classes/class.ilRating.php';
2824 $set = $ilDB->query(
"SELECT *".
2825 " FROM exc_assignment_peer".
2826 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer").
2827 " ORDER BY peer_id");
2828 while(
$row = $ilDB->fetchAssoc($set))
2831 "ass",
$row[
"peer_id"],
"peer",
$row[
"giver_id"]));
2834 self::validatePeerReview(
$row, $rating))
2836 $res[
$row[
"peer_id"]][
$row[
"giver_id"]] = array($row[
"pcomment"], $rating);
2847 $set = $ilDB->query(
"SELECT ass_id".
2848 " FROM exc_assignment_peer".
2849 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2850 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2851 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer"));
2852 $row = $ilDB->fetchAssoc($set);
2853 return (
bool)
$row[
"ass_id"];
2860 $ilDB->manipulate(
"UPDATE exc_assignment_peer".
2861 " SET tstamp = ".$ilDB->quote(
ilUtil::now(),
"timestamp").
2862 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2863 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2864 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer"));
2873 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2875 $path = $storage->getPeerReviewUploadPath($a_peer_id, $a_giver_id);
2876 return glob(
$path.
"/*.*");
2883 $sql =
"UPDATE exc_assignment_peer".
2884 " SET tstamp = ".$ilDB->quote(
ilUtil::now(),
"timestamp").
2885 ",pcomment = ".$ilDB->quote(trim($a_comment),
"text").
2886 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2887 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2888 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer");
2890 $ilDB->manipulate($sql);
2899 include_once
'./Services/Rating/classes/class.ilRating.php';
2901 $set = $ilDB->query(
"SELECT *".
2902 " FROM exc_assignment_peer".
2903 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2904 " AND giver_id = ".$ilDB->quote($ilUser->getId(),
"integer"));
2905 while(
$row = $ilDB->fetchAssoc($set))
2907 if(self::validatePeerReview(
$row))
2921 $set = $ilDB->query(
"SELECT COUNT(DISTINCT(user_id)) cnt".
2922 " FROM exc_returned".
2923 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer"));
2924 $cnt = $ilDB->fetchAssoc($set);
2925 $cnt = (int)$cnt[
"cnt"];
2933 $a_min = min($cnt-1, $a_min);
2935 return max(0, $a_min-self::countGivenFeedback($a_ass_id));
2944 $set = $ilDB->query(
"SELECT id,fb_file FROM exc_assignment".
2945 " WHERE fb_cron = ".$ilDB->quote(1,
"integer").
2946 " AND fb_date = ".$ilDB->quote(self::FEEDBACK_DATE_DEADLINE,
"integer").
2947 " AND time_stamp IS NOT NULL".
2948 " AND time_stamp > ".$ilDB->quote(0,
"integer").
2949 " AND time_stamp < ".$ilDB->quote(time(),
"integer").
2950 " AND fb_cron_done = ".$ilDB->quote(0,
"integer"));
2951 while(
$row = $ilDB->fetchAssoc($set))
2953 if(trim(
$row[
"fb_file"]))
2966 $ass =
new self($a_ass_id);
2969 if(!$ass->hasFeedbackCron() || !$ass->getFeedbackFile())
2977 $set = $ilDB->query(
"SELECT fb_cron_done".
2978 " FROM exc_assignment".
2979 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
2980 $row = $ilDB->fetchAssoc($set);
2981 if(
$row[
"fb_cron_done"])
2987 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
2989 $ntf->setLangModules(array(
"exc"));
2990 $ntf->setObjId($ass->getExerciseId());
2991 $ntf->setSubjectLangId(
"exc_feedback_notification_subject");
2992 $ntf->setIntroductionLangId(
"exc_feedback_notification_body");
2993 $ntf->addAdditionalInfo(
"exc_assignment", $ass->getTitle());
2994 $ntf->setGotoLangId(
"exc_feedback_notification_link");
2995 $ntf->setReasonLangId(
"exc_feedback_notification_reason");
2999 include_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
3002 $ilDB->manipulate(
"UPDATE exc_assignment".
3003 " SET fb_cron_done = ".$ilDB->quote(1,
"integer").
3004 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
3008 $ntf->sendMail(array($a_user_id));
3027 $deliverFilename = trim(str_replace(
" ",
"_", $this->
getTitle().
"_".$this->
getId()));
3029 $deliverFilename =
"multi_feedback_".$deliverFilename;
3038 $mfdir = $tmpdir.
"/".$deliverFilename;
3042 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
3044 $mems = $exmem->getMembers();
3046 foreach ($mems as $mem)
3049 $subdir = $name[
"lastname"].
"_".$name[
"firstname"].
"_".$name[
"login"].
"_".$name[
"user_id"];
3056 $tmpzipfile = $tmpdir.
"/multi_feedback.zip";
3074 include_once(
"./Modules/Exercise/exceptions/class.ilExerciseException.php");
3075 if (!is_file($a_file[
"tmp_name"]))
3080 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
3082 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
3087 $subdir =
"notfound";
3088 foreach ($subdirs as $s => $j)
3090 if ($j[
"type"] ==
"dir" && substr($s, 0, 14) ==
"multi_feedback")
3096 if (!is_dir($mfu.
"/".$subdir))
3114 if ($a_user_id == 0)
3116 $a_user_id = $ilUser->getId();
3119 $mf_files = array();
3123 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
3125 $mems = $exmem->getMembers();
3128 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
3130 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
3134 $subdir =
"notfound";
3135 foreach ($subdirs as $s => $j)
3137 if ($j[
"type"] ==
"dir" && substr($s, 0, 14) ==
"multi_feedback")
3144 foreach ($items as $k => $i)
3147 if ($i[
"type"] ==
"dir" && !in_array($k, array(
".",
"..")))
3150 $parts = explode(
"_", $i[
"entry"]);
3151 $user_id = (int) $parts[count($parts) - 1];
3152 if (in_array($user_id, $mems))
3157 foreach ($files as $k2 => $f)
3160 if ($f[
"type"] ==
"file" && substr($k2, 0, 1) !=
".")
3162 $mf_files[] = array(
3163 "lastname" => $name[
"lastname"],
3164 "firstname" => $name[
"firstname"],
3165 "login" => $name[
"login"],
3166 "user_id" => $name[
"user_id"],
3167 "full_path" => $mfu.
"/".$subdir.
"/".$k.
"/".$k2,
3187 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
3189 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
3203 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
3205 $fstorage->create();
3207 $team_map = array();
3210 foreach ($mf_files as $f)
3212 $user_id = $f[
"user_id"];
3213 $file_path = $f[
"full_path"];
3214 $file_name = $f[
"file"];
3217 if ($a_files[$user_id][md5($file_name)] !=
"")
3223 if (!array_key_exists($user_id, $team_map))
3226 $team_map[$user_id][
"team_id"] =
"t".$team_id;
3228 $team_map[$user_id][
"noti_rec_ids"] = array();
3231 $team_map[$user_id][
"noti_rec_ids"][] = $team_user_id;
3235 $feedback_id = $team_map[$user_id][
"team_id"];
3236 $noti_rec_ids = $team_map[$user_id][
"noti_rec_ids"];
3240 $feedback_id = $user_id;
3241 $noti_rec_ids = array($user_id);
3246 $fb_path = $fstorage->getFeedbackPath($feedback_id);
3247 $target = $fb_path.
"/".$file_name;
3248 if (is_file($target))
3253 rename($file_path, $target);
3257 $exc->sendFeedbackFileNotification($file_name, $noti_rec_ids,
3258 (
int) $this->
getId());
3274 global $ilAppEventHandler;
3276 $dl_id = $this->
getId().
"0";
3277 $fbdl_id = $this->
getId().
"1";
3279 $context_ids = array($dl_id, $fbdl_id);
3282 if($a_event !=
"delete")
3284 include_once
"Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php";
3290 $app->setSubtitle(
"cal_exc_deadline");
3292 $app->setFullday(
false);
3303 $app->setSubtitle(
"cal_exc_peer_review_deadline");
3305 $app->setFullday(
false);
3313 include_once
"Modules/Exercise/classes/class.ilObjExercise.php";
3316 $ilAppEventHandler->raise(
'Modules/Exercise',
3317 $a_event.
'Assignment',
3320 'obj_id' => $exc->getId(),
3321 'context_ids' => $context_ids,
3322 'appointments' => $apps));
3330 foreach($data as
$row)
3332 if($a_exclude_ass_id && $row[
"id"] == $a_exclude_ass_id)
3341 if($a_user_id && !array_key_exists($a_user_id, $map))
3351 $user_team_id = $map[$a_user_id];
3352 $user_team = array();
3353 foreach($map as $user_id => $team_id)
3355 if($user_id != $a_user_id &&
3356 $user_team_id == $team_id)
3358 $user_team[] = $user_id;
3366 $res[$row[
"id"]] = array(
3367 "title" => $row[
"title"],
3368 "teams" =>
sizeof(array_flip($map)),
3373 $res[$row[
"id"]][
"user_team"] = $user_team;
3383 public function adoptTeams($a_source_ass_id, $a_user_id = null, $a_exc_ref_id = null)
3388 foreach(self::getAssignmentTeamMap($a_source_ass_id) as $user_id => $team_id)
3390 $teams[$team_id][] = $user_id;
3392 if($a_user_id && $user_id == $a_user_id)
3394 $old_team = $team_id;
3401 if(!$old_team || $this->
getTeamId($a_user_id))
3409 foreach($teams as $team_id => $user_ids)
3411 if(!$old_team || $team_id == $old_team)
3415 foreach($user_ids as $user_id)
3417 if(!array_key_exists($user_id, $current_map))
3419 $missing[] = $user_id;
3423 if(
sizeof($missing))
3426 $first = array_shift($missing);
3427 $team_id = $this->
getTeamId($first,
true);
3435 foreach($missing as $user_id)