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";
43 $this->
ilObject($a_id,$a_call_by_reference);
47 function setDate($a_hour,$a_minutes,$a_day,$a_month,$a_year)
49 $this->hour = (int) $a_hour;
50 $this->minutes = (int) $a_minutes;
51 $this->day = (int) $a_day;
52 $this->month = (int) $a_month;
53 $this->year = (int) $a_year;
54 $this->timestamp = mktime($this->hour,$this->minutes,0,$this->month,$this->day,$this->year);
63 $this->timestamp = $a_timestamp;
67 $this->instruction = $a_instruction;
81 $this->pass_mode = $a_val;
91 return $this->pass_mode;
101 $this->pass_nr = $a_val;
111 return $this->pass_nr;
121 $this->show_submissions = $a_val;
131 return $this->show_submissions;
142 return $this->hour == (int) date(
"H",$this->timestamp) and
143 $this->minutes == (int) date(
"i",$this->timestamp) and
144 $this->day == (int) date(
"d",$this->timestamp) and
145 $this->month == (int) date(
"m",$this->timestamp) and
146 $this->year == (int) date(
"Y",$this->timestamp);
153 function deliverFile($a_http_post_files, $a_ass_id, $user_id, $unzip =
false)
157 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
159 $deliver_result = $storage->deliverFile($a_http_post_files, $user_id, $unzip);
163 $next_id = $ilDB->nextId(
"exc_returned");
164 $query = sprintf(
"INSERT INTO exc_returned ".
165 "(returned_id, obj_id, user_id, filename, filetitle, mimetype, ts, ass_id) ".
166 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
167 $ilDB->quote($next_id,
"integer"),
168 $ilDB->quote($this->
getId(),
"integer"),
169 $ilDB->quote($user_id,
"integer"),
170 $ilDB->quote($deliver_result[
"fullname"],
"text"),
171 $ilDB->quote($a_http_post_files[
"name"],
"text"),
172 $ilDB->quote($deliver_result[
"mimetype"],
"text"),
174 $ilDB->quote($a_ass_id,
"integer")
176 $ilDB->manipulate(
$query);
177 if (!$this->members_obj->isAssigned($user_id))
179 $this->members_obj->assignMember($user_id);
193 if ($unzipUploadedFile && preg_match(
"/zip/", $a_http_post_files[
"type"]) == 1)
203 $this->file_obj->storeUploadedFile($a_http_post_files,
true);
209 $this->file_obj->unlinkFiles($a_files);
223 $ilDB->insert(
"exc_data", array(
224 "obj_id" => array(
"integer", $this->
getId()),
226 "time_stamp" => array(
"integer", $this->
getTimestamp()),
227 "pass_mode" => array(
"text", $this->
getPassMode()),
228 "pass_nr" => array(
"text", $this->
getPassNr()),
250 $new_obj->saveData();
256 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
263 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
265 $obj_settings->cloneSettings($new_obj->getId());
266 unset($obj_settings);
295 require_once
"./Services/Utilities/classes/class.ilUtil.php";
309 if (!parent::delete())
314 $ilDB->manipulate(
"DELETE FROM exc_data ".
315 "WHERE obj_id = ".$ilDB->quote($this->getId(),
"integer"));
323 include_once
"./Services/Notification/classes/class.ilNotification.php";
339 function notify($a_event,$a_ref_id,$a_node_id,$a_params = 0)
352 $query =
"SELECT * FROM exc_data ".
353 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
356 while(
$row = $ilDB->fetchObject(
$res))
360 $pm = (
$row->pass_mode ==
"")
363 $this->setPassMode($pm);
365 if (
$row->pass_mode ==
"nr")
401 $ilDB->update(
"exc_data", array(
403 "time_stamp" => array(
"integer", $this->
getTimestamp()),
404 "pass_mode" => array(
"text", $this->
getPassMode()),
405 "pass_nr" => array(
"integer", $this->
getPassNr()),
408 "obj_id" => array(
"integer", $this->
getId())
415 #$this->members_obj->update();
424 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
426 $files = $storage->getFiles();
430 include_once
"./classes/class.ilFileDataMail.php";
435 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
436 $file_names[] = $file[
"name"];
440 include_once
"Services/Mail/classes/class.ilMail.php";
443 $message = $tmp_mail_obj->sendMail(
446 count($file_names) ? $file_names : array(),array(
"normal"));
448 unset($tmp_mail_obj);
450 if(count($file_names))
452 $mfile_obj->unlinkFiles($file_names);
458 foreach($a_members as $member_id => $value)
476 "WHERE obj_id= ".$ilDB->quote($exc_id,
"integer").
477 " AND usr_id= ".$ilDB->quote($member_id,
"integer");
479 $set = $ilDB->query($q);
480 if ($rec = $ilDB->fetchAssoc($set))
491 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
494 $body = $ass->getInstruction();
496 $body .= $lng->txt(
"exc_edit_until") .
": ".
499 $body .= ILIAS_HTTP_PATH.
502 "_".$this->getRefId().
"&client_id=".CLIENT_ID;
514 foreach($a_members as $member_id => $value)
517 $tmp_members[] = $tmp_obj->getLogin();
522 return implode(
',',$tmp_members ? $tmp_members : array());
529 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
559 global
$lng, $ilUser;
565 include_once (
"Services/Utilities/classes/class.ilFileUtils.php");
572 foreach ($filearray[
"file"] as $key =>
$filename)
575 $a_http_post_files[
"type"] =
"other";
576 $a_http_post_files[
"tmp_name"] = $filearray[
"path"][$key].
"/".
$filename;
577 $a_http_post_files[
"error"] = 0;
578 $a_http_post_files[
"size"] = filesize($filearray[
"path"][$key].
"/".
$filename);
580 if ($storageMethod ==
"deliverFile")
582 $this->$storageMethod($a_http_post_files, $a_ass_id, $ilUser->id,
true);
584 else if ($storageMethod ==
"storeUploadedFile")
586 $this->file_obj->$storageMethod($a_http_post_files,
true,
true);
616 $ex_pos = strrpos($a_filename,
"/exercise/");
619 $a_filename = CLIENT_DATA_DIR.substr($a_filename, $ex_pos);
630 if (is_array($a_array))
632 foreach ($a_array as $k => $v)
634 if ($v[
"filename"] !=
"")
653 $a_user_id = $ilUser->getId();
656 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
659 $passed_all_mandatory =
true;
660 $failed_a_mandatory =
false;
663 $passed_at_least_one =
false;
668 if ($a[
"mandatory"] && ($stat ==
"failed" || $stat ==
"notgraded"))
670 $passed_all_mandatory =
false;
672 if ($a[
"mandatory"] && ($stat ==
"failed"))
674 $failed_a_mandatory =
true;
676 if ($stat ==
"passed")
680 if ($stat ==
"notgraded")
686 if (count($ass) == 0)
688 $passed_all_mandatory =
false;
694 $overall_stat =
"notgraded";
695 if ($failed_a_mandatory)
698 $overall_stat =
"failed";
700 else if ($passed_all_mandatory && $cnt_passed > 0)
703 $overall_stat =
"passed";
710 $overall_stat =
"notgraded";
712 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr))
715 $overall_stat =
"failed";
717 else if ($passed_all_mandatory && $cnt_passed >= $min_nr)
720 $overall_stat =
"passed";
725 "overall_status" => $overall_stat,
726 "failed_a_mandatory" => $failed_a_mandatory);
741 $a_user_id = $ilUser->getId();
746 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
748 $st[
"overall_status"]);
756 if (!is_object($this->members_obj));
761 $mems = $this->members_obj->getMembers();
762 foreach ($mems as $mem)
773 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
776 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
779 $workbook = $adapter->getWorkbook();
780 $workbook->setVersion(8);
781 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
786 $mainworksheet = $workbook->addWorksheet();
791 foreach ($ass_data as $ass)
793 $mainworksheet->writeString(0, $cnt, $cnt);
800 $getmems = $this->mem_obj->getMembers();
802 foreach ($getmems as $user_id)
810 foreach ($mems as $user_id =>
$d)
815 $mainworksheet->writeString($row_cnt, 0,
820 foreach ($ass_data as $ass)
837 $worksheet2 = $workbook->addWorksheet();
842 foreach ($ass_data as $ass)
844 $worksheet2->writeString(0, $cnt, $cnt);
853 foreach ($mems as $user_id =>
$d)
859 $worksheet2->writeString($row_cnt, 0,
864 foreach ($ass_data as $ass)
866 $worksheet2->writeString($row_cnt, $col_cnt,
872 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
873 $worksheet2->writeString($row_cnt, $col_cnt,
890 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
893 $not->setAssignmentId($a_ass_id);
895 $not->setRecipients(array($a_user_id));