4 require_once
"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);
189 if (!$this->members_obj->isAssigned($user_id))
191 $this->members_obj->assignMember($user_id);
205 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
215 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
221 $this->file_obj->unlinkFiles($a_files);
235 $ilDB->insert(
"exc_data", array(
236 "obj_id" => array(
"integer", $this->
getId()),
238 "time_stamp" => array(
"integer", $this->
getTimestamp()),
239 "pass_mode" => array(
"text", $this->
getPassMode()),
240 "pass_nr" => array(
"text", $this->
getPassNr()),
264 $new_obj->saveData();
273 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
280 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
282 $obj_settings->cloneSettings($new_obj->getId());
283 unset($obj_settings);
312 require_once
"./Services/Utilities/classes/class.ilUtil.php";
326 if (!parent::delete())
331 $ilDB->manipulate(
"DELETE FROM exc_data ".
332 "WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer"));
340 include_once
"./Services/Notification/classes/class.ilNotification.php";
356 function notify($a_event,$a_ref_id,$a_node_id,$a_params = 0)
369 $query =
"SELECT * FROM exc_data ".
370 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
373 while(
$row = $ilDB->fetchObject(
$res))
377 $pm = (
$row->pass_mode ==
"")
380 $this->setPassMode($pm);
382 if (
$row->pass_mode ==
"nr")
420 $ilDB->update(
"exc_data", array(
422 "time_stamp" => array(
"integer", $this->
getTimestamp()),
423 "pass_mode" => array(
"text", $this->
getPassMode()),
424 "pass_nr" => array(
"integer", $this->
getPassNr()),
428 "obj_id" => array(
"integer", $this->
getId())
435 #$this->members_obj->update();
444 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
447 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
449 $files = $storage->getFiles();
453 include_once
"./classes/class.ilFileDataMail.php";
458 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
459 $file_names[] = $file[
"name"];
463 include_once
"Services/Mail/classes/class.ilMail.php";
466 $message = $tmp_mail_obj->sendMail(
469 count($file_names) ? $file_names : array(),array(
"normal"));
471 unset($tmp_mail_obj);
473 if(count($file_names))
475 $mfile_obj->unlinkFiles($file_names);
481 foreach($a_members as $member_id => $value)
499 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
500 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
502 $set = $ilDB->query($q);
503 if ($rec = $ilDB->fetchAssoc($set))
514 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
517 $body = $ass->getInstruction();
519 $body .= $lng->txt(
"exc_edit_until") .
": ".
522 $body .= ILIAS_HTTP_PATH.
525 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
534 if ($a_ass_title !=
"")
536 $subject.=
": ".$a_ass_title;
544 foreach($a_members as $member_id => $value)
547 $tmp_members[] = $tmp_obj->getLogin();
552 return implode(
',',$tmp_members ? $tmp_members : array());
559 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
589 global
$lng, $ilUser;
595 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
602 foreach ($filearray[
"file"] as $key =>
$filename)
605 $a_http_post_files[
"type"] =
"other";
606 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][$key].
"/".
$filename;
607 $a_http_post_files[
"error"] = 0;
608 $a_http_post_files[
"size"] = filesize($filearray[
"path"][$key].
"/".
$filename);
610 if ($storageMethod ==
"deliverFile")
612 $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id,
true);
614 else if ($storageMethod ==
"storeUploadedFile")
616 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
646 $ex_pos = strrpos($a_filename,
"/exercise/");
649 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
660 if (is_array($a_array))
662 foreach ($a_array as $k => $v)
664 if ($v[
"filename"] !=
"")
683 $a_user_id = $ilUser->getId();
686 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
689 $passed_all_mandatory =
true;
690 $failed_a_mandatory =
false;
693 $passed_at_least_one =
false;
698 if ($a[
"mandatory"] && ($stat ==
"failed" || $stat ==
"notgraded"))
700 $passed_all_mandatory =
false;
702 if ($a[
"mandatory"] && ($stat ==
"failed"))
704 $failed_a_mandatory =
true;
706 if ($stat ==
"passed")
710 if ($stat ==
"notgraded")
716 if (count($ass) == 0)
718 $passed_all_mandatory =
false;
724 $overall_stat =
"notgraded";
725 if ($failed_a_mandatory)
728 $overall_stat =
"failed";
730 else if ($passed_all_mandatory && $cnt_passed > 0)
733 $overall_stat =
"passed";
740 $overall_stat =
"notgraded";
742 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
745 $overall_stat =
"failed";
747 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
750 $overall_stat =
"passed";
755 "overall_status" => $overall_stat,
756 "failed_a_mandatory" => $failed_a_mandatory);
771 $a_user_id = $ilUser->getId();
776 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
778 $st[
"overall_status"]);
786 if (!is_object($this->members_obj));
791 $mems = $this->members_obj->getMembers();
792 foreach ($mems as $mem)
803 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
806 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
809 $workbook = $adapter->getWorkbook();
810 $workbook->setVersion(8);
811 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
816 $mainworksheet = $workbook->addWorksheet();
821 foreach ($ass_data as $ass)
823 $mainworksheet->writeString(0, $cnt, $cnt);
830 $getmems = $this->mem_obj->getMembers();
832 foreach ($getmems as $user_id)
840 foreach ($mems as $user_id =>
$d)
845 $mainworksheet->writeString($row_cnt, 0,
850 foreach ($ass_data as $ass)
867 $worksheet2 = $workbook->addWorksheet();
872 foreach ($ass_data as $ass)
874 $worksheet2->writeString(0, $cnt, $cnt);
883 foreach ($mems as $user_id =>
$d)
889 $worksheet2->writeString($row_cnt, 0,
894 foreach ($ass_data as $ass)
896 $worksheet2->writeString($row_cnt, $col_cnt,
902 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
903 $worksheet2->writeString($row_cnt, $col_cnt,
920 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
923 $not->setAssignmentId($a_ass_id);
925 $not->setRecipients(array($a_user_id));
953 $this->completion_by_submission = (bool)$bool;
970 global $ilUser,
$ilDB;
974 include_once
'Modules/Exercise/classes/class.ilExAssignment.php';
976 $res = $ilDB->queryF(
977 'SELECT returned_id FROM exc_returned WHERE obj_id = %s AND user_id = %s AND ass_id = %s',
978 array(
'integer',
'integer',
'integer'),
979 array($this->
getId(), $ilUser->getId(), (int)$ass_id)
982 if($num = $ilDB->numRows(
$res))
1003 $set = $ilDB->query(
"SELECT obj_id, status FROM exc_members".
1004 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
1005 " AND (status = ".$ilDB->quote(
"passed",
"text").
1006 " OR status = ".$ilDB->quote(
"failed",
"text").
")");
1009 while(
$row = $ilDB->fetchAssoc($set))
1011 $all[
$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
1027 $next_id = $ilDB->nextId(
"exc_returned");
1028 $query = sprintf(
"INSERT INTO exc_returned ".
1029 "(returned_id, obj_id, user_id, filetitle, ass_id) ".
1030 "VALUES (%s, %s, %s, %s, %s)",
1031 $ilDB->quote($next_id,
"integer"),
1032 $ilDB->quote($this->
getId(),
"integer"),
1033 $ilDB->quote($user_id,
"integer"),
1034 $ilDB->quote($a_wsp_id,
"text"),
1035 $ilDB->quote($a_ass_id,
"integer")
1037 $ilDB->manipulate(
$query);
1038 if (!$this->members_obj->isAssigned($user_id))
1040 $this->members_obj->assignMember($user_id);
1054 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
1068 $set = $ilDB->query(
"SELECT obj_id, ass_id".
1069 " FROM exc_returned".
1070 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
1071 " AND filetitle = ".$ilDB->quote($a_filetitle,
"text"));
1073 while(
$row = $ilDB->fetchAssoc($set))
1088 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
1099 $this->certificate_visibility = $a_value;
1112 $affectedRows = $ilDB->manipulateF(
"UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
1113 array(
'integer',
'integer'),
1114 array($a_value, $this->
getId())
1127 include_once
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1132 if($certificate_visible != 2)
1135 include_once
'Modules/Exercise/classes/class.ilExerciseMembers.php';
1137 if($certificate_visible == 1 && $status ==
"passed")
1142 else if($certificate_visible == 0 && $status !=
"notgraded")