4 require_once
"./Services/Object/classes/class.ilObject.php";
5 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
54 $this->
ilObject($a_id,$a_call_by_reference);
58 function setDate($a_hour,$a_minutes,$a_day,$a_month,$a_year)
60 $this->hour = (int) $a_hour;
61 $this->minutes = (int) $a_minutes;
62 $this->day = (int) $a_day;
63 $this->month = (int) $a_month;
64 $this->year = (int) $a_year;
65 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
74 $this->timestamp = $a_timestamp;
78 $this->instruction = $a_instruction;
92 $this->pass_mode = $a_val;
102 return $this->pass_mode;
112 $this->pass_nr = $a_val;
122 return $this->pass_nr;
132 $this->show_submissions = $a_val;
142 return $this->show_submissions;
153 return $this->hour == (int) date(
"H",$this->timestamp) and
154 $this->minutes == (int) date(
"i",$this->timestamp) and
155 $this->day == (int) date(
"d",$this->timestamp) and
156 $this->month == (int) date(
"m",$this->timestamp) and
157 $this->year == (int) date(
"Y",$this->timestamp);
164 function deliverFile($a_http_post_files, $a_ass_id, $user_id, $unzip =
false)
168 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
170 $deliver_result = $storage->deliverFile($a_http_post_files, $user_id, $unzip);
174 $next_id = $ilDB->nextId(
"exc_returned");
175 $query = sprintf(
"INSERT INTO exc_returned ".
176 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id) ".
177 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
178 $ilDB->quote($next_id,
"integer"),
179 $ilDB->quote($this->
getId(),
"integer"),
180 $ilDB->quote($user_id,
"integer"),
181 $ilDB->quote($deliver_result[
"fullname"],
"text"),
182 $ilDB->quote($a_http_post_files[
"name"],
"text"),
183 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
185 $ilDB->quote($a_ass_id,
"integer")
187 $ilDB->manipulate(
$query);
193 $user_ids = array($user_id);
201 foreach($user_ids as $user_id)
203 if (!$this->members_obj->isAssigned($user_id))
205 $this->members_obj->assignMember($user_id);
220 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
230 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
236 $this->file_obj->unlinkFiles($a_files);
250 $ilDB->insert(
"exc_data", array(
251 "obj_id" => array(
"integer", $this->
getId()),
253 "time_stamp" => array(
"integer", $this->
getTimestamp()),
254 "pass_mode" => array(
"text", $this->
getPassMode()),
255 "pass_nr" => array(
"text", $this->
getPassNr()),
279 $new_obj->saveData();
288 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
292 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
294 $obj_settings->cloneSettings($new_obj->getId());
295 unset($obj_settings);
317 $user_ids = array($user_id);
320 foreach($user_ids as $user_id)
334 require_once
"./Services/Utilities/classes/class.ilUtil.php";
345 global
$ilDB, $ilAppEventHandler;
348 if (!parent::delete())
353 $ilDB->manipulate(
"DELETE FROM exc_data ".
354 "WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer"));
362 include_once
"./Services/Notification/classes/class.ilNotification.php";
365 $ilAppEventHandler->raise(
'Modules/Exercise',
367 array(
'obj_id'=>$this->
getId()));
382 function notify($a_event,$a_ref_id,$a_node_id,$a_params = 0)
395 $query =
"SELECT * FROM exc_data ".
396 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
399 while(
$row = $ilDB->fetchObject(
$res))
403 $pm = (
$row->pass_mode ==
"")
406 $this->setPassMode($pm);
408 if (
$row->pass_mode ==
"nr")
442 $ilDB->update(
"exc_data", array(
444 "time_stamp" => array(
"integer", $this->
getTimestamp()),
445 "pass_mode" => array(
"text", $this->
getPassMode()),
446 "pass_nr" => array(
"integer", $this->
getPassNr()),
450 "obj_id" => array(
"integer", $this->
getId())
457 #$this->members_obj->update();
466 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
469 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
471 $files = $storage->getFiles();
475 include_once
"./Services/Mail/classes/class.ilFileDataMail.php";
480 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
481 $file_names[] = $file[
"name"];
485 include_once
"Services/Mail/classes/class.ilMail.php";
488 $message = $tmp_mail_obj->sendMail(
491 count($file_names) ? $file_names : array(),array(
"normal"));
493 unset($tmp_mail_obj);
495 if(count($file_names))
497 $mfile_obj->unlinkFiles($file_names);
503 foreach($a_members as $member_id => $value)
521 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
522 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
524 $set = $ilDB->query($q);
525 if ($rec = $ilDB->fetchAssoc($set))
536 $lng->loadLanguageModule(
"exc");
538 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
541 $body = $ass->getInstruction();
543 if ($ass->getDeadline() == 0)
545 $body .= $lng->txt(
"exc_edit_until") .
": ".
546 $lng->txt(
"exc_no_deadline_specified");
550 $body .= $lng->txt(
"exc_edit_until") .
": ".
554 $body .= ILIAS_HTTP_PATH.
557 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
566 if ($a_ass_title !=
"")
568 $subject.=
": ".$a_ass_title;
576 foreach($a_members as $member_id => $value)
579 $tmp_members[] = $tmp_obj->getLogin();
584 return implode(
',',$tmp_members ? $tmp_members : array());
602 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
609 foreach ($filearray[
"file"] as $key =>
$filename)
612 $a_http_post_files[
"type"] =
"other";
613 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][$key].
"/".
$filename;
614 $a_http_post_files[
"error"] = 0;
615 $a_http_post_files[
"size"] = filesize($filearray[
"path"][$key].
"/".
$filename);
617 if ($storageMethod ==
"deliverFile")
619 $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id,
true);
621 else if ($storageMethod ==
"storeUploadedFile")
623 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
652 $ex_pos = strrpos($a_filename,
"/exercise/");
655 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
666 if (is_array($a_array))
668 foreach ($a_array as $k => $v)
670 if ($v[
"filename"] !=
"")
689 $a_user_id = $ilUser->getId();
692 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
695 $passed_all_mandatory =
true;
696 $failed_a_mandatory =
false;
699 $passed_at_least_one =
false;
704 if ($a[
"mandatory"] && ($stat ==
"failed" || $stat ==
"notgraded"))
706 $passed_all_mandatory =
false;
708 if ($a[
"mandatory"] && ($stat ==
"failed"))
710 $failed_a_mandatory =
true;
712 if ($stat ==
"passed")
716 if ($stat ==
"notgraded")
722 if (count($ass) == 0)
724 $passed_all_mandatory =
false;
730 $overall_stat =
"notgraded";
731 if ($failed_a_mandatory)
734 $overall_stat =
"failed";
736 else if ($passed_all_mandatory && $cnt_passed > 0)
739 $overall_stat =
"passed";
746 $overall_stat =
"notgraded";
748 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
751 $overall_stat =
"failed";
753 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
756 $overall_stat =
"passed";
761 "overall_status" => $overall_stat,
762 "failed_a_mandatory" => $failed_a_mandatory);
777 $a_user_id = $ilUser->getId();
782 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
784 $st[
"overall_status"]);
792 if (!is_object($this->members_obj));
797 $mems = $this->members_obj->getMembers();
798 foreach ($mems as $mem)
809 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
812 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
815 $workbook = $adapter->getWorkbook();
816 $workbook->setVersion(8);
817 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
822 $mainworksheet = $workbook->addWorksheet();
827 foreach ($ass_data as $ass)
829 $mainworksheet->writeString(0, $cnt, $cnt);
836 $getmems = $this->mem_obj->getMembers();
838 foreach ($getmems as $user_id)
846 foreach ($mems as $user_id =>
$d)
851 $mainworksheet->writeString($row_cnt, 0,
856 foreach ($ass_data as $ass)
873 $worksheet2 = $workbook->addWorksheet();
878 foreach ($ass_data as $ass)
880 $worksheet2->writeString(0, $cnt, $cnt);
889 foreach ($mems as $user_id =>
$d)
895 $worksheet2->writeString($row_cnt, 0,
900 foreach ($ass_data as $ass)
902 $worksheet2->writeString($row_cnt, $col_cnt,
908 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
909 $worksheet2->writeString($row_cnt, $col_cnt,
926 $user_ids = $a_user_id;
927 if(!is_array($user_ids))
929 $user_ids = array($user_ids);
932 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
934 $type = (bool)$a_is_text_feedback
939 $not->setType(
$type);
940 $not->setAssignmentId($a_ass_id);
941 $not->setObjId($this->
getId());
946 $not->setRecipients($user_ids);
974 $this->completion_by_submission = (bool)$bool;
995 include_once
'Modules/Exercise/classes/class.ilExAssignment.php';
1001 $user_ids = array($ilUser->getId());
1004 $res = $ilDB->query(
1005 'SELECT returned_id'.
1006 ' FROM exc_returned'.
1007 ' WHERE obj_id = '.$ilDB->quote($this->getId(),
'integer').
1008 ' AND ass_id = '.$ilDB->quote($ass_id,
'integer').
1009 ' AND '.$ilDB->in(
'user_id', $user_ids,
'',
'integer')
1012 if($ilDB->numRows(
$res))
1018 $status =
'notgraded';
1020 foreach($user_ids as $user_id)
1037 $set = $ilDB->query(
"SELECT obj_id, status FROM exc_members".
1038 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
1039 " AND (status = ".$ilDB->quote(
"passed",
"text").
1040 " OR status = ".$ilDB->quote(
"failed",
"text").
")");
1043 while(
$row = $ilDB->fetchAssoc($set))
1045 $all[
$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
1062 $next_id = $ilDB->nextId(
"exc_returned");
1063 $query = sprintf(
"INSERT INTO exc_returned ".
1064 "(returned_id, obj_id, user_id, filetitle, ass_id, ts, atext) ".
1065 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1066 $ilDB->quote($next_id,
"integer"),
1067 $ilDB->quote($this->
getId(),
"integer"),
1068 $ilDB->quote($user_id,
"integer"),
1069 $ilDB->quote($a_wsp_id,
"text"),
1070 $ilDB->quote($a_ass_id,
"integer"),
1072 $ilDB->quote($a_text,
"text")
1074 $ilDB->manipulate(
$query);
1075 if (!$this->members_obj->isAssigned($user_id))
1077 $this->members_obj->assignMember($user_id);
1097 $ilDB->manipulate(
"DELETE FROM exc_returned".
1098 " WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer").
1099 " AND user_id = ".$ilDB->quote($user_id,
"integer").
1100 " AND ass_id = ".$ilDB->quote($a_ass_id,
"integer").
1101 " AND returned_id = ".$ilDB->quote($a_returned_id,
"integer"));
1144 $ilDB->manipulate(
"UPDATE exc_returned".
1145 " SET atext = ".$ilDB->quote($a_text,
"text").
1146 ", ts = ".$ilDB->quote(
ilUtil::now(),
"timestamp").
1147 " WHERE returned_id = ".$ilDB->quote(
$id,
"integer"));
1157 $set = $ilDB->query(
"SELECT obj_id".
1158 " FROM exc_returned".
1159 " WHERE returned_id = ".$ilDB->quote($a_returned_id,
"integer"));
1160 $row = $ilDB->fetchAssoc($set);
1161 return (
int)
$row[
"obj_id"];
1171 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
1185 $set = $ilDB->query(
"SELECT obj_id, ass_id".
1186 " FROM exc_returned".
1187 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
1188 " AND filetitle = ".$ilDB->quote($a_filetitle,
"text"));
1190 while(
$row = $ilDB->fetchAssoc($set))
1205 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
1216 $this->certificate_visibility = $a_value;
1229 $affectedRows = $ilDB->manipulateF(
"UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
1230 array(
'integer',
'integer'),
1231 array($a_value, $this->
getId())
1244 include_once
"Services/Certificate/classes/class.ilCertificate.php";
1249 if($certificate_visible != 2)
1252 include_once
'Modules/Exercise/classes/class.ilExerciseMembers.php';
1254 if($certificate_visible == 1 && $status ==
"passed")
1259 else if($certificate_visible == 0 && $status !=
"notgraded")
1276 return (
bool)$exc_set->get(
"add_to_pd",
true);