4 require_once
"./Services/Object/classes/class.ilObject.php";
5 require_once
"./Modules/Exercise/classes/class.ilFileDataExercise.php";
6 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
55 $this->
ilObject($a_id,$a_call_by_reference);
59 function setDate($a_hour,$a_minutes,$a_day,$a_month,$a_year)
61 $this->hour = (int) $a_hour;
62 $this->minutes = (int) $a_minutes;
63 $this->day = (int) $a_day;
64 $this->month = (int) $a_month;
65 $this->year = (int) $a_year;
66 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
75 $this->timestamp = $a_timestamp;
79 $this->instruction = $a_instruction;
93 $this->pass_mode = $a_val;
103 return $this->pass_mode;
113 $this->pass_nr = $a_val;
123 return $this->pass_nr;
133 $this->show_submissions = $a_val;
143 return $this->show_submissions;
154 return $this->hour == (int) date(
"H",$this->timestamp) and
155 $this->minutes == (int) date(
"i",$this->timestamp) and
156 $this->day == (int) date(
"d",$this->timestamp) and
157 $this->month == (int) date(
"m",$this->timestamp) and
158 $this->year == (int) date(
"Y",$this->timestamp);
165 function deliverFile($a_http_post_files, $a_ass_id, $user_id, $unzip =
false)
169 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
171 $deliver_result = $storage->deliverFile($a_http_post_files, $user_id, $unzip);
175 $next_id = $ilDB->nextId(
"exc_returned");
176 $query = sprintf(
"INSERT INTO exc_returned ".
177 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id) ".
178 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
179 $ilDB->quote($next_id,
"integer"),
180 $ilDB->quote($this->
getId(),
"integer"),
181 $ilDB->quote($user_id,
"integer"),
182 $ilDB->quote($deliver_result[
"fullname"],
"text"),
183 $ilDB->quote($a_http_post_files[
"name"],
"text"),
184 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
186 $ilDB->quote($a_ass_id,
"integer")
188 $ilDB->manipulate(
$query);
194 $user_ids = array($user_id);
202 foreach($user_ids as $user_id)
204 if (!$this->members_obj->isAssigned($user_id))
206 $this->members_obj->assignMember($user_id);
221 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
231 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
237 $this->file_obj->unlinkFiles($a_files);
251 $ilDB->insert(
"exc_data", array(
252 "obj_id" => array(
"integer", $this->
getId()),
254 "time_stamp" => array(
"integer", $this->
getTimestamp()),
255 "pass_mode" => array(
"text", $this->
getPassMode()),
256 "pass_nr" => array(
"text", $this->
getPassNr()),
280 $new_obj->saveData();
289 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
296 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
298 $obj_settings->cloneSettings($new_obj->getId());
299 unset($obj_settings);
321 $user_ids = array($user_id);
324 foreach($user_ids as $user_id)
338 require_once
"./Services/Utilities/classes/class.ilUtil.php";
352 if (!parent::delete())
357 $ilDB->manipulate(
"DELETE FROM exc_data ".
358 "WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer"));
366 include_once
"./Services/Notification/classes/class.ilNotification.php";
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")
446 $ilDB->update(
"exc_data", array(
448 "time_stamp" => array(
"integer", $this->
getTimestamp()),
449 "pass_mode" => array(
"text", $this->
getPassMode()),
450 "pass_nr" => array(
"integer", $this->
getPassNr()),
454 "obj_id" => array(
"integer", $this->
getId())
461 #$this->members_obj->update();
470 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
473 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
475 $files = $storage->getFiles();
479 include_once
"./Services/Mail/classes/class.ilFileDataMail.php";
484 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
485 $file_names[] = $file[
"name"];
489 include_once
"Services/Mail/classes/class.ilMail.php";
492 $message = $tmp_mail_obj->sendMail(
495 count($file_names) ? $file_names : array(),array(
"normal"));
497 unset($tmp_mail_obj);
499 if(count($file_names))
501 $mfile_obj->unlinkFiles($file_names);
507 foreach($a_members as $member_id => $value)
525 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
526 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
528 $set = $ilDB->query($q);
529 if ($rec = $ilDB->fetchAssoc($set))
540 $lng->loadLanguageModule(
"exc");
542 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
545 $body = $ass->getInstruction();
547 if ($ass->getDeadline() == 0)
549 $body .= $lng->txt(
"exc_edit_until") .
": ".
550 $lng->txt(
"exc_no_deadline_specified");
554 $body .= $lng->txt(
"exc_edit_until") .
": ".
558 $body .= ILIAS_HTTP_PATH.
561 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
570 if ($a_ass_title !=
"")
572 $subject.=
": ".$a_ass_title;
580 foreach($a_members as $member_id => $value)
583 $tmp_members[] = $tmp_obj->getLogin();
588 return implode(
',',$tmp_members ? $tmp_members : array());
595 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
631 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
638 foreach ($filearray[
"file"] as $key =>
$filename)
641 $a_http_post_files[
"type"] =
"other";
642 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][$key].
"/".
$filename;
643 $a_http_post_files[
"error"] = 0;
644 $a_http_post_files[
"size"] = filesize($filearray[
"path"][$key].
"/".
$filename);
646 if ($storageMethod ==
"deliverFile")
648 $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id,
true);
650 else if ($storageMethod ==
"storeUploadedFile")
652 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
681 $ex_pos = strrpos($a_filename,
"/exercise/");
684 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
695 if (is_array($a_array))
697 foreach ($a_array as $k => $v)
699 if ($v[
"filename"] !=
"")
718 $a_user_id = $ilUser->getId();
721 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
724 $passed_all_mandatory =
true;
725 $failed_a_mandatory =
false;
728 $passed_at_least_one =
false;
733 if ($a[
"mandatory"] && ($stat ==
"failed" || $stat ==
"notgraded"))
735 $passed_all_mandatory =
false;
737 if ($a[
"mandatory"] && ($stat ==
"failed"))
739 $failed_a_mandatory =
true;
741 if ($stat ==
"passed")
745 if ($stat ==
"notgraded")
751 if (count($ass) == 0)
753 $passed_all_mandatory =
false;
759 $overall_stat =
"notgraded";
760 if ($failed_a_mandatory)
763 $overall_stat =
"failed";
765 else if ($passed_all_mandatory && $cnt_passed > 0)
768 $overall_stat =
"passed";
775 $overall_stat =
"notgraded";
777 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
780 $overall_stat =
"failed";
782 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
785 $overall_stat =
"passed";
790 "overall_status" => $overall_stat,
791 "failed_a_mandatory" => $failed_a_mandatory);
806 $a_user_id = $ilUser->getId();
811 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
813 $st[
"overall_status"]);
821 if (!is_object($this->members_obj));
826 $mems = $this->members_obj->getMembers();
827 foreach ($mems as $mem)
838 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
841 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
844 $workbook = $adapter->getWorkbook();
845 $workbook->setVersion(8);
846 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
851 $mainworksheet = $workbook->addWorksheet();
856 foreach ($ass_data as $ass)
858 $mainworksheet->writeString(0, $cnt, $cnt);
865 $getmems = $this->mem_obj->getMembers();
867 foreach ($getmems as $user_id)
875 foreach ($mems as $user_id =>
$d)
880 $mainworksheet->writeString($row_cnt, 0,
885 foreach ($ass_data as $ass)
902 $worksheet2 = $workbook->addWorksheet();
907 foreach ($ass_data as $ass)
909 $worksheet2->writeString(0, $cnt, $cnt);
918 foreach ($mems as $user_id =>
$d)
924 $worksheet2->writeString($row_cnt, 0,
929 foreach ($ass_data as $ass)
931 $worksheet2->writeString($row_cnt, $col_cnt,
937 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
938 $worksheet2->writeString($row_cnt, $col_cnt,
955 $user_ids = $a_user_id;
956 if(!is_array($user_ids))
958 $user_ids = array($user_ids);
961 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
964 $not->setAssignmentId($a_ass_id);
966 $not->setRecipients($user_ids);
994 $this->completion_by_submission = (bool)$bool;
1015 include_once
'Modules/Exercise/classes/class.ilExAssignment.php';
1021 $user_ids = array($ilUser->getId());
1024 $res = $ilDB->query(
1025 'SELECT returned_id'.
1026 ' FROM exc_returned'.
1027 ' WHERE obj_id = '.$ilDB->quote($this->getId(),
'integer').
1028 ' AND ass_id = '.$ilDB->quote($ass_id,
'integer').
1029 ' AND '.$ilDB->in(
'user_id', $user_ids,
'',
'integer')
1032 if($ilDB->numRows(
$res))
1038 $status =
'notgraded';
1040 foreach($user_ids as $user_id)
1057 $set = $ilDB->query(
"SELECT obj_id, status FROM exc_members".
1058 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
1059 " AND (status = ".$ilDB->quote(
"passed",
"text").
1060 " OR status = ".$ilDB->quote(
"failed",
"text").
")");
1063 while(
$row = $ilDB->fetchAssoc($set))
1065 $all[
$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
1081 $next_id = $ilDB->nextId(
"exc_returned");
1082 $query = sprintf(
"INSERT INTO exc_returned ".
1083 "(returned_id, obj_id, user_id, filetitle, ass_id) ".
1084 "VALUES (%s, %s, %s, %s, %s)",
1085 $ilDB->quote($next_id,
"integer"),
1086 $ilDB->quote($this->
getId(),
"integer"),
1087 $ilDB->quote($user_id,
"integer"),
1088 $ilDB->quote($a_wsp_id,
"text"),
1089 $ilDB->quote($a_ass_id,
"integer")
1091 $ilDB->manipulate(
$query);
1092 if (!$this->members_obj->isAssigned($user_id))
1094 $this->members_obj->assignMember($user_id);
1108 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
1122 $set = $ilDB->query(
"SELECT obj_id, ass_id".
1123 " FROM exc_returned".
1124 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
1125 " AND filetitle = ".$ilDB->quote($a_filetitle,
"text"));
1127 while(
$row = $ilDB->fetchAssoc($set))
1142 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
1153 $this->certificate_visibility = $a_value;
1166 $affectedRows = $ilDB->manipulateF(
"UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
1167 array(
'integer',
'integer'),
1168 array($a_value, $this->
getId())
1181 include_once
"Services/Certificate/classes/class.ilCertificate.php";
1186 if($certificate_visible != 2)
1189 include_once
'Modules/Exercise/classes/class.ilExerciseMembers.php';
1191 if($certificate_visible == 1 && $status ==
"passed")
1196 else if($certificate_visible == 0 && $status !=
"notgraded")
1218 $grp_id = $tree->checkForParentType($this->ref_id,
"grp");
1223 $crs_id = $tree->checkForParentType($this->ref_id,
"crs");
1245 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
1250 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
1255 if($members && $members->getCountParticipants() < 100)
1257 return $members->getParticipants();