45 $this->
setType(self::TYPE_UPLOAD);
81 $this->exc_id = $a_val;
101 $this->start_time = $a_val;
121 $this->deadline = $a_val;
141 $this->instruction = $a_val;
161 $this->title = $a_val;
181 $this->mandatory = $a_val;
201 $this->order_nr = $a_val;
223 $this->type = (int)$a_value;
225 if($this->type == self::TYPE_UPLOAD_TEAM)
250 if(in_array((
int)$a_value, array(self::TYPE_UPLOAD, self::TYPE_BLOG,
251 self::TYPE_PORTFOLIO, self::TYPE_UPLOAD_TEAM, self::TYPE_TEXT)))
265 $this->peer = (bool)$a_value;
285 $this->peer_min = (int)$a_value;
305 $this->peer_dl = $a_val;
325 $this->feedback_file = (string)$a_value;
345 $this->feedback_cron = (string)$a_value;
365 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
366 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
368 while ($rec = $ilDB->fetchAssoc($set))
400 $next_id = $ilDB->nextId(
"exc_assignment");
401 $ilDB->insert(
"exc_assignment", array(
402 "id" => array(
"integer", $next_id),
404 "time_stamp" => array(
"integer", $this->
getDeadline()),
406 "title" => array(
"text", $this->
getTitle()),
407 "start_time" => array(
"integer", $this->
getStartTime()),
408 "order_nr" => array(
"integer", $this->
getOrderNr()),
410 "type" => array(
"integer", $this->
getType()),
417 $this->
setId($next_id);
419 $exc->updateAllUsersStatus();
430 $ilDB->update(
"exc_assignment",
433 "time_stamp" => array(
"integer", $this->
getDeadline()),
435 "title" => array(
"text", $this->
getTitle()),
436 "start_time" => array(
"integer", $this->
getStartTime()),
437 "order_nr" => array(
"integer", $this->
getOrderNr()),
439 "type" => array(
"integer", $this->
getType()),
447 "id" => array(
"integer", $this->
getId()),
450 $exc->updateAllUsersStatus();
462 $ilDB->manipulate(
"DELETE FROM exc_assignment WHERE ".
463 " id = ".$ilDB->quote($this->getId(),
"integer")
466 $exc->updateAllUsersStatus();
471 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
473 $path = $storage->getGlobalFeedbackPath();
479 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
481 $path = $storage->getGlobalFeedbackPath();
483 if(@move_uploaded_file($a_file[
"tmp_name"],
$path.
"/".$a_file[
"name"]))
496 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
498 $path = $storage->getGlobalFeedbackPath();
510 $set = $ilDB->query(
"SELECT * FROM exc_assignment ".
511 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer").
512 " ORDER BY order_nr ASC");
516 while ($rec = $ilDB->fetchAssoc($set))
521 "exc_id" => $rec[
"exc_id"],
522 "deadline" => $rec[
"time_stamp"],
523 "instruction" => $rec[
"instruction"],
524 "title" => $rec[
"title"],
525 "start_time" => $rec[
"start_time"],
526 "order_val" => $order_val,
527 "mandatory" => $rec[
"mandatory"],
528 "type" => $rec[
"type"],
529 "peer" => $rec[
"peer"],
530 "peer_min" => $rec[
"peer_min"],
531 "peer_dl" => $rec[
"peer_dl"],
532 "fb_file" => $rec[
"fb_file"],
533 "fb_cron" => $rec[
"fb_cron"],
549 foreach ($ass_data as
$d)
553 $new_ass->setExerciseId($a_new_exc_id);
554 $new_ass->setTitle($d[
"title"]);
555 $new_ass->setDeadline($d[
"deadline"]);
556 $new_ass->setInstruction($d[
"instruction"]);
557 $new_ass->setMandatory($d[
"mandatory"]);
558 $new_ass->setOrderNr($d[
"order_val"]);
559 $new_ass->setStartTime($d[
"start_time"]);
560 $new_ass->setType($d[
"type"]);
561 $new_ass->setPeerReview($d[
"peer"]);
562 $new_ass->setPeerReviewMin($d[
"peer_min"]);
563 $new_ass->setPeerReviewDeadline($d[
"peer_dl"]);
564 $new_ass->setFeedbackFile($d[
"fb_file"]);
565 $new_ass->setFeedbackCron($d[
"fb_cron"]);
569 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
574 if (is_dir($old_storage->getPath()))
576 ilUtil::rCopy($old_storage->getPath(), $new_storage->getPath());
586 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
588 return $storage->getFiles();
598 $set = $ilDB->query(
"SELECT MAX(order_nr) mnr FROM exc_assignment ".
599 " WHERE exc_id = ".$ilDB->quote($a_exc_id,
"integer")
601 while ($rec = $ilDB->fetchAssoc($set))
603 return (
int) $rec[
"mnr"];
617 $query =
"SELECT id FROM exc_assignment ".
618 "WHERE start_time <= ".$ilDB->quote(time(),
'integer').
' '.
619 "AND time_stamp >= ".$ilDB->quote(time(),
'integer').
' '.
620 "AND id = ".$ilDB->quote($a_ass_id,
'integer');
623 return $res->numRows() ?
true :
false;
630 private static function lookup($a_id, $a_field)
634 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_assignment ".
635 " WHERE id = ".$ilDB->quote($a_id,
"integer")
638 $rec = $ilDB->fetchAssoc($set);
640 return $rec[$a_field];
666 $result_order = array();
669 foreach ($a_order as $k => $v)
672 $ilDB->manipulate(
$t =
"UPDATE exc_assignment SET ".
673 " order_nr = ".$ilDB->quote($nr,
"integer").
674 " WHERE id = ".$ilDB->quote((
int) $k,
"integer").
675 " AND exc_id = ".$ilDB->quote((
int) $a_ex_id,
"integer")
688 $set = $ilDB->query(
"SELECT id FROM exc_assignment ".
689 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
690 " ORDER BY time_stamp ASC"
693 while ($rec = $ilDB->fetchAssoc($set))
695 $ilDB->manipulate(
"UPDATE exc_assignment SET ".
696 " order_nr = ".$ilDB->quote($nr,
"integer").
697 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
710 $set = $ilDB->query(
"SELECT count(*) cntm FROM exc_assignment ".
711 " WHERE exc_id = ".$ilDB->quote($a_ex_id,
"integer").
712 " AND mandatory = ".$ilDB->quote(1,
"integer")
714 $rec = $ilDB->fetchAssoc($set);
729 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM exc_mem_ass_status ".
730 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
731 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
733 $rec = $ilDB->fetchAssoc($set);
735 return $rec[$a_field];
745 $ilDB->manipulate(
"UPDATE exc_mem_ass_status SET ".
746 " ".$a_field.
" = ".$ilDB->quote($a_value, $a_type).
747 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
748 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer")
780 "u_comment", $a_value,
"text");
797 "mark", $a_value,
"text");
820 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
821 "SET status = %s, status_time= %s ".
822 " WHERE ass_id = %s AND usr_id = %s AND status <> %s ",
823 array(
"text",
"timestamp",
"integer",
"integer",
"text"),
824 array($a_status,
ilUtil::now(), $a_ass_id, $a_user_id, $a_status));
869 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
870 "SET sent = %s, status_time= %s, sent_time = %s ".
871 " WHERE ass_id = %s AND usr_id = %s ",
872 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
874 $a_ass_id, $a_user_id));
906 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
907 "SET returned = %s, status_time= %s ".
908 " WHERE ass_id = %s AND usr_id = %s",
909 array(
"integer",
"timestamp",
"integer",
"integer"),
911 $a_ass_id, $a_user_id));
943 $ilDB->manipulateF(
"UPDATE exc_mem_ass_status ".
944 "SET feedback = %s, status_time= %s, feedback_time = %s ".
945 " WHERE ass_id = %s AND usr_id = %s",
946 array(
"integer",
"timestamp",
"timestamp",
"integer",
"integer"),
948 $a_ass_id, $a_user_id));
1011 $user_ids = array($a_user_id);
1014 $result = $ilDB->query(
"SELECT returned_id FROM exc_returned".
1015 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1016 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1017 return $ilDB->numRows(
$result);
1027 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1030 $query =
"SELECT * FROM exc_returned WHERE ass_id = ".
1031 $ilDB->quote($a_ass_id,
"integer");
1034 while(
$row = $ilDB->fetchAssoc(
$res))
1037 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
1038 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
1039 $delivered[] =
$row;
1044 return $delivered ? $delivered : array();
1057 $user_ids = array($a_user_id);
1060 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1063 $result = $ilDB->query(
"SELECT * FROM exc_returned".
1064 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1065 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1067 $delivered_files = array();
1072 if($a_filter_empty_filename && !
$row[
"filename"])
1076 $row[
"owner_id"] =
$row[
"user_id"];
1078 $row[
"timestamp14"] = substr(
$row[
"ts"], 0, 4).
1079 substr(
$row[
"ts"], 5, 2).substr(
$row[
"ts"], 8, 2).
1080 substr(
$row[
"ts"], 11, 2).substr(
$row[
"ts"], 14, 2).
1081 substr(
$row[
"ts"], 17, 2);
1082 $row[
"filename"] = $fs->getAbsoluteSubmissionPath().
1083 "/".$row[
"user_id"].
"/".basename(
$row[
"filename"]);
1084 array_push($delivered_files,
$row);
1089 return $delivered_files;
1099 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1102 if (count($file_id_array))
1116 $user_ids = array($a_user_id);
1119 $result = $ilDB->query(
"SELECT * FROM exc_returned".
1120 " WHERE ".$ilDB->in(
"returned_id", $file_id_array,
false,
"integer").
1121 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1125 $result_array = array();
1129 array_push($result_array,
$row);
1133 $ilDB->manipulate(
"DELETE FROM exc_returned".
1134 " WHERE ".$ilDB->in(
"returned_id", $file_id_array,
false,
"integer").
1135 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1138 foreach ($result_array as $key => $value)
1140 if($value[
"filename"])
1148 $filename = $fs->getAbsoluteSubmissionPath().
1149 "/".$value[
"user_id"].
"/".basename($value[
"filename"]);
1167 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1169 $delete_ids = array();
1172 $set = $ilDB->query(
"SELECT * FROM exc_returned ".
1173 " WHERE obj_id = ".$ilDB->quote($a_exc_id,
"integer").
1174 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
1176 while ($rec = $ilDB->fetchAssoc($set))
1178 $ass =
new self($rec[
"ass_id"]);
1183 if(
sizeof($team) > 1)
1185 $new_owner = array_pop($team);
1186 while($new_owner == $a_user_id &&
sizeof($team))
1188 $new_owner = array_pop($team);
1191 $ilDB->manipulate(
"UPDATE exc_returned".
1192 " SET user_id = ".$ilDB->quote($new_owner,
"integer").
1193 " WHERE returned_id = ".$ilDB->quote($rec[
"returned_id"],
"integer")
1201 $delete_ids[] = $rec[
"returned_id"];
1206 $filename = $fs->getAbsoluteSubmissionPath().
1207 "/".$a_user_id.
"/".basename($rec[
"filename"]);
1217 $ilDB->manipulate(
"DELETE FROM exc_returned".
1218 " WHERE ".$ilDB->in(
"returned_id", $delete_ids,
"",
"integer"));
1223 foreach(self::getAssignmentDataOfExercise($a_exc_id) as $item)
1227 $ass_ids[] = $item[
"id"];
1231 $ilDB->manipulate(
$d =
"DELETE FROM il_exc_team WHERE ".
1232 "user_id = ".$ilDB->quote($a_user_id,
"integer").
1233 " AND ".$ilDB->in(
"ass_id", $ass_ids,
"",
"integer")
1242 function deliverReturnedFiles($a_exc_id, $a_ass_id, $a_user_id, $a_only_new =
false, $a_peer_review_mask_filename =
false)
1252 $user_ids = array($a_user_id);
1259 $q =
"SELECT download_time FROM exc_usr_tutor WHERE ".
1260 " ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" AND ".
1261 $ilDB->in(
"usr_id", $user_ids,
"",
"integer").
" AND ".
1262 " tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer");
1263 $lu_set = $ilDB->query($q);
1264 if ($lu_rec = $ilDB->fetchAssoc($lu_set))
1266 if ($lu_rec[
"download_time"] > 0)
1268 $and_str =
" AND ts > ".$ilDB->quote($lu_rec[
"download_time"],
"timestamp");
1273 foreach($user_ids as $user_id)
1278 if($a_peer_review_mask_filename)
1282 foreach($this->ass->getPeerReviewsByGiver($ilUser->getId()) as $idx => $item)
1284 if($item[
"peer_id"] == $a_user_id)
1292 $query =
"SELECT * FROM exc_returned".
1293 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1294 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer").
1298 $count = $ilDB->numRows(
$result);
1303 switch(self::lookupType($a_ass_id))
1305 case self::TYPE_BLOG:
1306 case self::TYPE_PORTFOLIO:
1310 $row[
"filetitle"][
"firstname"].
" ".
1311 $row[
"filetitle"][
"lastname"].
" (".
1312 $row[
"filetitle"][
"login"].
").zip";
1319 if($a_peer_review_mask_filename)
1321 $suffix = array_pop(explode(
".",
$row[
"filetitle"]));
1326 $row[
"filename"],
$row[
"filetitle"]);
1328 else if ($count > 0)
1330 $array_files = array();
1334 $src = basename(
$row[
"filename"]);
1335 if($a_peer_review_mask_filename)
1337 $suffix = array_pop(explode(
".", $src));
1339 "_".(++$seq).
".".$suffix;
1341 $array_files[
$row[
"user_id"]][] = array($src, $tgt);
1345 $array_files[
$row[
"user_id"]][] = $src;
1349 ($is_team ? null : $a_user_id), $is_team);
1367 $ilDB->manipulateF(
"DELETE FROM exc_usr_tutor ".
1368 "WHERE ass_id = %s AND usr_id = %s AND tutor_id = %s",
1369 array(
"integer",
"integer",
"integer"),
1370 array($a_ass_id, $a_user_id, $ilUser->getId()));
1372 $ilDB->manipulateF(
"INSERT INTO exc_usr_tutor (ass_id, obj_id, usr_id, tutor_id, download_time) VALUES ".
1373 "(%s, %s, %s, %s, %s)",
1374 array(
"integer",
"integer",
"integer",
"integer",
"timestamp"),
1375 array($a_ass_id, $a_exc_id, $a_user_id, $ilUser->getId(),
ilUtil::now()));
1385 if (count($array_file_id))
1393 $user_ids = array($a_user_id);
1396 $result = $ilDB->query(
"SELECT * FROM exc_returned WHERE ".
1397 $ilDB->in(
"returned_id", $array_file_id,
false,
"integer").
1398 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer"));
1401 $array_found = array();
1405 array_push($array_found,
$row);
1407 if (count($array_found) == 1)
1410 if(is_numeric($array_found[0][
"filetitle"]))
1418 $ass->getTitle().
" - ".
1419 $user_data[
"firstname"].
" ".
1420 $user_data[
"lastname"].
" (".
1421 $user_data[
"login"].
").zip";
1426 $array_found[0][
"filename"], $array_found[0][
"filetitle"]);
1430 $filenames = array();
1431 foreach ($array_found as $value)
1433 $filenames[$value[
"user_id"]][] = basename($value[
"filename"]);
1436 $filenames, ($is_team ? null : $a_user_id), $is_team);
1447 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1450 $filename = $fs->getAbsoluteSubmissionPath().
1453 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1462 $a_user_id, $a_multi_user =
false)
1464 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1467 require_once
"./Services/Utilities/classes/class.ilUtil.php";
1473 $tmpzipfile = $tmpfile .
".zip";
1479 $deliverFilename = str_replace(
" ",
"_", $assTitle);
1480 if ($a_user_id > 0 && !$a_multi_user)
1483 $deliverFilename .=
"_".$userName[
"lastname"].
"_".$userName[
"firstname"];
1487 $deliverFilename .=
"_files";
1489 $orgDeliverFilename = trim($deliverFilename);
1492 chdir($tmpdir.
"/".$deliverFilename);
1495 $parsed_files = $duplicates = array();
1496 foreach ($array_filenames as $user_id => $files)
1498 $pathname = $fs->getAbsoluteSubmissionPath().
"/".$user_id;
1503 if(is_array($filename))
1505 $newFilename = $filename[1];
1506 $filename = $filename[0];
1511 $newFilename = trim($filename);
1512 $pos = strpos($newFilename ,
"_");
1515 $newFilename = substr($newFilename, $pos + 1);
1518 $chkName = strtolower($newFilename);
1519 if(array_key_exists($chkName, $duplicates))
1521 $suffix = strrpos($newFilename,
".");
1522 $newFilename = substr($newFilename, 0, $suffix).
1523 " (".(++$duplicates[$chkName]).
")".
1524 substr($newFilename, $suffix);
1528 $duplicates[$chkName] = 1;
1531 $newFilename = $tmpdir.DIRECTORY_SEPARATOR.$deliverFilename.DIRECTORY_SEPARATOR.$newFilename;
1533 $oldFilename = $pathname.DIRECTORY_SEPARATOR.$filename;
1534 if (!copy ($oldFilename, $newFilename))
1536 echo
'Could not copy '.$oldFilename.
' to '.$newFilename;
1538 touch($newFilename, filectime($oldFilename));
1561 global
$lng, $ilObjDataCache, $ilias;
1563 include_once
"./Services/Utilities/classes/class.ilUtil.php";
1564 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1571 $savepath = $storage->getAbsoluteSubmissionPath();
1579 if (!is_dir($savepath))
1585 chdir($storage->getTempPath());
1595 foreach ($members as
$id => $object) {
1596 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
1599 if ($dirsize > disk_free_space($tmpdir)) {
1610 foreach ($members as
$id => $user)
1612 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
1613 if (!is_dir($sourcedir))
1618 trim($userName[
"firstname"]).
"_".trim($userName[
"login"]).
"_".$userName[
"user_id"]);
1629 $cache[$directory] = $directory;
1631 $sourcefiles = scandir($sourcedir);
1632 $duplicates = array();
1633 foreach ($sourcefiles as $sourcefile) {
1634 if ($sourcefile ==
"." || $sourcefile ==
"..")
1639 $targetfile = trim(basename($sourcefile));
1640 $pos = strpos($targetfile,
"_");
1643 $targetfile= substr($targetfile, $pos + 1);
1647 if(array_key_exists($targetfile, $duplicates))
1649 $suffix = strrpos($targetfile,
".");
1650 $targetfile = substr($targetfile, 0, $suffix).
1651 " (".(++$duplicates[$targetfile]).
")".
1652 substr($targetfile, $suffix);
1656 $duplicates[$targetfile] = 1;
1659 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
1660 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
1662 if (!copy ($sourcefile, $targetfile))
1665 $ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
1666 $ilias->error_obj->MESSAGE);
1671 touch($targetfile, filectime($sourcefile));
1678 unlink($targetfile);
1686 $tmpzipfile = $tmpfile .
".zip";
1695 ? strtolower($lng->txt(
"exc_assignment"))
1696 : $assTitle).
".zip",
"",
false,
true);
1707 $ilDB->manipulate(
"UPDATE exc_mem_ass_status".
1708 " SET notice = ".$ilDB->quote($a_notice,
"text").
1709 ",status_time= ".$ilDB->quote(
ilUtil::now(),
"timestamp").
1710 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1711 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
1712 " AND ".$ilDB->equalsNot(
"notice", $a_notice,
"text",
true));
1722 $query =
"SELECT DISTINCT(usr_id) as ud FROM exc_mem_ass_status ".
1723 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1727 while(
$row = $ilDB->fetchObject(
$res))
1729 $usr_ids[] =
$row->ud;
1732 return $usr_ids ? $usr_ids : array();
1750 $user_ids = array($a_user_id);
1755 $q =
"SELECT obj_id,user_id,ts FROM exc_returned".
1756 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1757 " AND ".$ilDB->in(
"user_id", $user_ids,
"",
"integer").
1758 " ORDER BY ts DESC";
1760 $usr_set = $ilDB->query($q);
1762 $array = $ilDB->fetchAssoc($usr_set);
1763 if ($array[
"ts"]==NULL)
1780 $q =
"SELECT count(*) AS cnt FROM exc_mem_ass_status".
1781 " WHERE NOT sent_time IS NULL".
1782 " AND ass_id = ".$ilDB->quote($a_ass_id,
"integer").
" ".
1784 $set = $ilDB->query($q);
1785 $rec = $ilDB->fetchAssoc($set);
1787 if ($rec[
"cnt"] > 0)
1809 $user_ids = array($member_id);
1812 $q=
"SELECT exc_mem_ass_status.status_time, exc_returned.ts ".
1813 "FROM exc_mem_ass_status, exc_returned ".
1814 "WHERE exc_mem_ass_status.status_time < exc_returned.ts ".
1815 "AND NOT exc_mem_ass_status.status_time IS NULL ".
1816 "AND exc_returned.ass_id = exc_mem_ass_status.ass_id ".
1817 "AND exc_returned.user_id = exc_mem_ass_status.usr_id ".
1818 "AND exc_returned.ass_id=".$ilDB->quote($ass_id,
"integer").
1819 " AND ".$ilDB->in(
"exc_returned.user_id", $user_ids,
"",
"integer");
1821 $usr_set = $ilDB->query($q);
1823 $array = $ilDB->fetchAssoc($usr_set);
1825 if (count($array)==0)
1848 $user_ids = array($member_id);
1851 $q =
"SELECT exc_returned.returned_id AS id ".
1852 "FROM exc_usr_tutor, exc_returned ".
1853 "WHERE exc_returned.ass_id = exc_usr_tutor.ass_id ".
1854 " AND exc_returned.user_id = exc_usr_tutor.usr_id ".
1855 " AND exc_returned.ass_id = ".$ilDB->quote($ass_id,
"integer").
1856 " AND ".$ilDB->in(
"exc_returned.user_id", $user_ids,
"",
"integer").
1857 " AND exc_usr_tutor.tutor_id = ".$ilDB->quote($ilUser->getId(),
"integer").
1858 " AND exc_usr_tutor.download_time < exc_returned.ts ";
1860 $new_up_set = $ilDB->query($q);
1863 while ($new_up_rec = $ilDB->fetchAssoc($new_up_set))
1865 $new_up[] = $new_up_rec[
"id"];
1881 $set = $ilDB->query(
"SELECT ud.usr_id, ud.lastname, ud.firstname, ud.login".
1882 " FROM exc_members excm".
1883 " JOIN usr_data ud ON (ud.usr_id = excm.usr_id)".
1884 " WHERE excm.obj_id = ".$ilDB->quote($a_exc_id,
"integer"));
1885 while($rec = $ilDB->fetchAssoc($set))
1887 $mem[$rec[
"usr_id"]] =
1889 "name" => $rec[
"lastname"].
", ".$rec[
"firstname"],
1890 "login" => $rec[
"login"],
1891 "usr_id" => $rec[
"usr_id"],
1892 "lastname" => $rec[
"lastname"],
1893 "firstname" => $rec[
"firstname"]
1897 $q =
"SELECT * FROM exc_mem_ass_status ".
1898 "WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
1899 $set = $ilDB->query($q);
1900 while($rec = $ilDB->fetchAssoc($set))
1902 if (isset($mem[$rec[
"usr_id"]]))
1904 $mem[$rec[
"usr_id"]][
"sent_time"] = $rec[
"sent_time"];
1906 $mem[$rec[
"usr_id"]][
"status_time"] = $rec[
"status_time"];
1907 $mem[$rec[
"usr_id"]][
"feedback_time"] = $rec[
"feedback_time"];
1908 $mem[$rec[
"usr_id"]][
"notice"] = $rec[
"notice"];
1909 $mem[$rec[
"usr_id"]][
"status"] = $rec[
"status"];
1923 foreach ($ass_data as $ass)
1926 $ilDB->replace(
"exc_mem_ass_status", array(
1927 "ass_id" => array(
"integer", $ass[
"id"]),
1928 "usr_id" => array(
"integer", $a_user_id)
1930 "status" => array(
"text",
"notgraded")
1942 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
1944 $mems = $exmem->getMembers();
1946 foreach ($mems as $mem)
1948 $ilDB->replace(
"exc_mem_ass_status", array(
1949 "ass_id" => array(
"integer", $a_ass_id),
1950 "usr_id" => array(
"integer", $mem)
1952 "status" => array(
"text",
"notgraded")
1963 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
1966 $storage->uploadAssignmentFiles($a_files);
1986 $sql =
"SELECT id FROM il_exc_team".
1987 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
1988 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
1989 $set = $ilDB->query($sql);
1990 $row = $ilDB->fetchAssoc($set);
1993 if(!
$id && $a_create_on_demand)
1995 $id = $ilDB->nextId(
"il_exc_team");
1997 $fields = array(
"id" => array(
"integer",
$id),
1998 "ass_id" => array(
"integer", $this->
getId()),
1999 "user_id" => array(
"integer", $a_user_id));
2000 $ilDB->insert(
"il_exc_team", $fields);
2022 $sql =
"SELECT user_id".
2023 " FROM il_exc_team".
2024 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2025 " AND id = ".$ilDB->quote($a_team_id,
"integer");
2026 $set = $ilDB->query($sql);
2027 while(
$row = $ilDB->fetchAssoc($set))
2029 $ids[] =
$row[
"user_id"];
2046 $sql =
"SELECT user_id".
2047 " FROM il_exc_team".
2048 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer");
2049 $set = $ilDB->query($sql);
2050 while(
$row = $ilDB->fetchAssoc($set))
2052 $ids[] =
$row[
"user_id"];
2070 if(!in_array($a_user_id, $members))
2072 $fields = array(
"id" => array(
"integer", $a_team_id),
2073 "ass_id" => array(
"integer", $this->
getId()),
2074 "user_id" => array(
"integer", $a_user_id));
2075 $ilDB->insert(
"il_exc_team", $fields);
2095 $sql =
"DELETE FROM il_exc_team".
2096 " WHERE ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2097 " AND id = ".$ilDB->quote($a_team_id,
"integer").
2098 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
2099 $ilDB->manipulate($sql);
2123 $set = $ilDB->query(
"SELECT user_id".
2124 " FROM il_exc_team".
2125 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2126 " AND id = ". $ilDB->quote($team_id,
"integer"));
2127 while(
$row = $ilDB->fetchAssoc($set))
2129 $ids[] =
$row[
"user_id"];
2147 $result = $ilDB->query(
"SELECT type".
2148 " FROM exc_assignment".
2149 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
2152 if(
$type[
"type"] == self::TYPE_UPLOAD_TEAM)
2154 $set = $ilDB->query(
"SELECT id".
2155 " FROM il_exc_team".
2156 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2157 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
2158 $team_id = $ilDB->fetchAssoc($set);
2159 return $team_id[
"id"];
2175 $sql =
"SELECT * FROM il_exc_team".
2176 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
2177 $set = $ilDB->query($sql);
2178 while(
$row = $ilDB->fetchAssoc($set))
2180 $map[
$row[
"user_id"]] = $row[
"id"];
2193 public static function writeTeamLog($a_team_id, $a_action, $a_details = null)
2198 "team_id" => array(
"integer", $a_team_id),
2199 "user_id" => array(
"integer", $ilUser->getId()),
2200 "action" => array(
"integer", $a_action),
2201 "details" => array(
"text", $a_details),
2202 "tstamp" => array(
"integer", time())
2205 $ilDB->insert(
"il_exc_team_log", $fields);
2220 $sql =
"SELECT * FROM il_exc_team_log".
2221 " WHERE team_id = ".$ilDB->quote($a_team_id,
"integer").
2222 " ORDER BY tstamp DESC";
2223 $set = $ilDB->query($sql);
2224 while(
$row = $ilDB->fetchAssoc($set))
2243 if($ilUser->getId() == $a_user_id)
2248 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
2250 $ntf->setLangModules(array(
"exc"));
2251 $ntf->setRefId($a_exc_ref_id);
2252 $ntf->setChangedByUserId($ilUser->getId());
2253 $ntf->setSubjectLangId(
'exc_team_notification_subject_'.$a_action);
2254 $ntf->setIntroductionLangId(
'exc_team_notification_body_'.$a_action);
2255 $ntf->addAdditionalInfo(
"exc_assignment", $this->
getTitle());
2256 $ntf->setGotoLangId(
'exc_team_notification_link');
2257 $ntf->setReasonLangId(
'exc_team_notification_reason');
2258 $ntf->sendMail(array($a_user_id));
2266 $result[
"files"][
"count"] =
"---";
2268 $ilCtrl->setParameter($a_parent_obj,
"ass_id", $a_ass_id);
2283 $last_sub =
"<b>".$last_sub.
"</b>";
2285 $result[
"last_submission"][
"txt"] = $lng->txt(
"exc_last_submission");
2286 $result[
"last_submission"][
"value"] = $last_sub;
2297 $result[
"files"][
"txt"] = $lng->txt(
"exc_files_returned");
2300 if (count($new) > 0)
2302 $sub_cnt.=
" ".sprintf($lng->txt(
"cnt_new"),count($new));
2304 $result[
"files"][
"count"] = $sub_cnt;
2307 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2311 $result[
"files"][
"download_url"] =
2312 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2314 if (count($new) <= 0)
2316 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2320 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_all");
2324 if (count($new) > 0)
2326 $result[
"files"][
"download_new_url"] =
2327 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadNewReturned");
2329 $result[
"files"][
"download_new_txt"] = $lng->txt(
"exc_download_new");
2335 $result[
"files"][
"txt"] =$lng->txt(
"exc_blog_returned");
2339 $blogs = array_pop($blogs);
2340 if($blogs && substr($blogs[
"filename"], -1) !=
"/")
2342 $result[
"files"][
"count"] = 1;
2344 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2345 $result[
"files"][
"download_url"] =
2346 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2347 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2349 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2355 $result[
"files"][
"txt"] = $lng->txt(
"exc_portfolio_returned");
2359 $portfolios = array_pop($portfolios);
2360 if($portfolios && substr($portfolios[
"filename"], -1) !=
"/")
2362 $result[
"files"][
"count"] = 1;
2364 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2365 $result[
"files"][
"download_url"] =
2366 $ilCtrl->getLinkTarget($a_parent_obj,
"downloadReturned");
2367 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2369 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_download_files");
2375 $result[
"files"][
"txt"] = $lng->txt(
"exc_files_returned_text");
2379 $result[
"files"][
"count"] = 1;
2381 $files = array_shift($files);
2382 if(trim($files[
"atext"]))
2387 $ilCtrl->setParameter($a_parent_obj,
"grd", (($a_parent_cmd ==
"members") ? 1 : 2));
2389 $ilCtrl->setParameter($a_parent_obj,
"member_id", $a_user_id);
2390 $result[
"files"][
"download_url"] =
2391 $ilCtrl->getLinkTarget($a_parent_obj,
"showAssignmentText");
2392 $ilCtrl->setParameter($a_parent_obj,
"member_id",
"");
2393 $ilCtrl->setParameter($a_parent_obj,
"grd",
"");
2395 $result[
"files"][
"download_txt"] = $lng->txt(
"exc_text_assignment_show");
2414 $set = $ilDB->query(
"SELECT count(*) cnt".
2415 " FROM exc_assignment_peer".
2416 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer"));
2417 $cnt = $ilDB->fetchAssoc($set);
2420 $user_ids = array();
2421 $set = $ilDB->query(
"SELECT DISTINCT(user_id)".
2422 " FROM exc_returned".
2423 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer"));
2424 while(
$row = $ilDB->fetchAssoc($set))
2426 $user_ids[] =
$row[
"user_id"];
2430 if(
sizeof($user_ids) < 2)
2435 $rater_ids = $user_ids;
2439 for($loop = 0; $loop < $max; $loop++)
2441 $run_ids = array_combine($user_ids, $user_ids);
2443 foreach($rater_ids as $rater_id)
2445 $possible_peer_ids = $run_ids;
2448 unset($possible_peer_ids[$rater_id]);
2451 if(array_key_exists($rater_id, $matrix))
2453 $possible_peer_ids = array_diff($possible_peer_ids, $matrix[$rater_id]);
2457 if(!
sizeof($possible_peer_ids))
2460 $run_ids = array_combine($user_ids, $user_ids);
2463 $possible_peer_ids = $run_ids;
2466 unset($possible_peer_ids[$rater_id]);
2469 if(array_key_exists($rater_id, $matrix))
2471 $possible_peer_ids = array_diff($possible_peer_ids, $matrix[$rater_id]);
2476 if(
sizeof($possible_peer_ids))
2478 $peer_id = array_rand($possible_peer_ids);
2479 if(!array_key_exists($rater_id, $matrix))
2481 $matrix[$rater_id] = array();
2483 $matrix[$rater_id][] = $peer_id;
2487 unset($run_ids[$peer_id]);
2491 foreach($matrix as $rater_id => $peer_ids)
2493 foreach($peer_ids as $peer_id)
2495 $ilDB->manipulate(
"INSERT INTO exc_assignment_peer".
2496 " (ass_id, giver_id, peer_id)".
2497 " VALUES (".$ilDB->quote($this->getId(),
"integer").
2498 ", ".$ilDB->quote($rater_id,
"integer").
2499 ", ".$ilDB->quote($peer_id,
"integer").
")");
2515 $set = $ilDB->query(
"SELECT *".
2516 " FROM exc_assignment_peer".
2517 " WHERE giver_id = ".$ilDB->quote($a_user_id,
"integer").
2518 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2519 " ORDER BY peer_id");
2520 while(
$row = $ilDB->fetchAssoc($set))
2535 include_once
'./Services/Rating/classes/class.ilRating.php';
2537 $set = $ilDB->query(
"SELECT *".
2538 " FROM exc_assignment_peer".
2539 " WHERE peer_id = ".$ilDB->quote($a_user_id,
"integer").
2540 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer").
2541 " ORDER BY peer_id");
2542 while(
$row = $ilDB->fetchAssoc($set))
2548 if(trim(
$row[
"pcomment"]))
2555 "ass",
$row[
"peer_id"],
"peer",
$row[
"giver_id"]));
2573 include_once
'./Services/Rating/classes/class.ilRating.php';
2575 $set = $ilDB->query(
"SELECT *".
2576 " FROM exc_assignment_peer".
2577 " WHERE ass_id = ".$ilDB->quote($this->getId(),
"integer").
2578 " ORDER BY peer_id");
2579 while(
$row = $ilDB->fetchAssoc($set))
2582 "ass",
$row[
"peer_id"],
"peer",
$row[
"giver_id"]));
2599 $set = $ilDB->query(
"SELECT ass_id".
2600 " FROM exc_assignment_peer".
2601 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2602 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2603 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer"));
2604 $row = $ilDB->fetchAssoc($set);
2605 return (
bool)
$row[
"ass_id"];
2612 $ilDB->manipulate(
"UPDATE exc_assignment_peer".
2613 " SET tstamp = ".$ilDB->quote(
ilUtil::now(),
"timestamp").
2614 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2615 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2616 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer"));
2623 $ilDB->manipulate(
"UPDATE exc_assignment_peer".
2624 " SET tstamp = ".$ilDB->quote(
ilUtil::now(),
"timestamp").
2625 ", pcomment = ".$ilDB->quote($a_comment,
"text").
2626 " WHERE giver_id = ".$ilDB->quote($ilUser->getId(),
"integer").
2627 " AND peer_id = ".$ilDB->quote($a_peer_id,
"integer").
2628 " AND ass_id = ".$ilDB->quote($this->
getId(),
"integer"));
2637 include_once
'./Services/Rating/classes/class.ilRating.php';
2639 $set = $ilDB->query(
"SELECT *".
2640 " FROM exc_assignment_peer".
2641 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer").
2642 " AND giver_id = ".$ilDB->quote($ilUser->getId(),
"integer"));
2643 while(
$row = $ilDB->fetchAssoc($set))
2645 if(trim(
$row[
"pcomment"]))
2652 "ass",
$row[
"peer_id"],
"peer",
$row[
"giver_id"]));
2668 $set = $ilDB->query(
"SELECT COUNT(DISTINCT(user_id)) cnt".
2669 " FROM exc_returned".
2670 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer"));
2671 $cnt = $ilDB->fetchAssoc($set);
2672 $cnt = (int)$cnt[
"cnt"];
2680 $a_min = min($cnt-1, $a_min);
2682 return max(0, $a_min-self::countGivenFeedback($a_ass_id));
2691 $set = $ilDB->query(
"SELECT id,fb_file FROM exc_assignment".
2692 " WHERE fb_cron = ".$ilDB->quote(1,
"integer").
2693 " AND time_stamp IS NOT NULL".
2694 " AND time_stamp > ".$ilDB->quote(0,
"integer").
2695 " AND time_stamp < ".$ilDB->quote(time(),
"integer").
2696 " AND fb_cron_done = ".$ilDB->quote(0,
"integer"));
2697 while(
$row = $ilDB->fetchAssoc($set))
2699 if(trim(
$row[
"fb_file"]))
2712 $ass =
new self($a_ass_id);
2715 if(!$ass->hasFeedbackCron() || !$ass->getFeedbackFile())
2721 $set = $ilDB->query(
"SELECT fb_cron_done".
2722 " FROM exc_assignment".
2723 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
2724 $row = $ilDB->fetchAssoc($set);
2725 if(
$row[
"fb_cron_done"])
2730 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
2732 $ntf->setLangModules(array(
"exc"));
2733 $ntf->setObjId($ass->getExerciseId());
2734 $ntf->setSubjectLangId(
"exc_feedback_notification_subject");
2735 $ntf->setIntroductionLangId(
"exc_feedback_notification_body");
2736 $ntf->addAdditionalInfo(
"exc_assignment", $ass->getTitle());
2737 $ntf->setGotoLangId(
"exc_feedback_notification_link");
2738 $ntf->setReasonLangId(
"exc_feedback_notification_reason");
2740 include_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
2743 $ilDB->manipulate(
"UPDATE exc_assignment".
2744 " SET fb_cron_done = ".$ilDB->quote(1,
"integer").
2745 " WHERE id = ".$ilDB->quote($a_ass_id,
"integer"));
2762 $deliverFilename = trim(str_replace(
" ",
"_", $this->
getTitle().
"_".$this->
getId()));
2764 $deliverFilename =
"multi_feedback_".$deliverFilename;
2773 $mfdir = $tmpdir.
"/".$deliverFilename;
2777 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
2779 $mems = $exmem->getMembers();
2781 foreach ($mems as $mem)
2784 $subdir = $name[
"lastname"].
"_".$name[
"firstname"].
"_".$name[
"login"].
"_".$name[
"user_id"];
2791 $tmpzipfile = $tmpdir.
"/multi_feedback.zip";
2809 include_once(
"./Modules/Exercise/exceptions/class.ilExerciseException.php");
2810 if (!is_file($a_file[
"tmp_name"]))
2815 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2817 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
2822 $subdir =
"notfound";
2823 foreach ($subdirs as $s => $j)
2825 if ($j[
"type"] ==
"dir" && substr($s, 0, 14) ==
"multi_feedback")
2831 if (!is_dir($mfu.
"/".$subdir))
2849 if ($a_user_id == 0)
2851 $a_user_id = $ilUser->getId();
2854 $mf_files = array();
2858 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
2860 $mems = $exmem->getMembers();
2863 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2865 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
2869 $subdir =
"notfound";
2870 foreach ($subdirs as $s => $j)
2872 if ($j[
"type"] ==
"dir" && substr($s, 0, 14) ==
"multi_feedback")
2879 foreach ($items as $k => $i)
2882 if ($i[
"type"] ==
"dir" && !in_array($k, array(
".",
"..")))
2885 $parts = explode(
"_", $i[
"entry"]);
2886 $user_id = (int) $parts[count($parts) - 1];
2887 if (in_array($user_id, $mems))
2892 foreach ($files as $k2 => $f)
2895 if ($f[
"type"] ==
"file" && substr($k2, 0, 1) !=
".")
2897 $mf_files[] = array(
2898 "lastname" => $name[
"lastname"],
2899 "firstname" => $name[
"firstname"],
2900 "login" => $name[
"login"],
2901 "user_id" => $name[
"user_id"],
2902 "full_path" => $mfu.
"/".$subdir.
"/".$k.
"/".$k2,
2922 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2924 $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
2938 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
2940 $fstorage->create();
2942 $team_map = array();
2945 foreach ($mf_files as $f)
2947 $user_id = $f[
"user_id"];
2948 $file_path = $f[
"full_path"];
2949 $file_name = $f[
"file"];
2952 if ($a_files[$user_id][md5($file_name)] !=
"")
2958 if (!array_key_exists($user_id, $team_map))
2961 $team_map[$user_id][
"team_id"] =
"t".$team_id;
2963 $team_map[$user_id][
"noti_rec_ids"] = array();
2966 $team_map[$user_id][
"noti_rec_ids"][] = $team_user_id;
2970 $feedback_id = $team_map[$user_id][
"team_id"];
2971 $noti_rec_ids = $team_map[$user_id][
"noti_rec_ids"];
2975 $feedback_id = $user_id;
2976 $noti_rec_ids = array($user_id);
2981 $fb_path = $fstorage->getFeedbackPath($feedback_id);
2982 $target = $fb_path.
"/".$file_name;
2983 if (is_file($target))
2988 rename($file_path, $target);
2993 $exc->sendFeedbackFileNotification($file_name, $noti_rec_ids,
2994 (
int) $this->
getId());