4 require_once
"./Services/Object/classes/class.ilObject.php";
5 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
66 public function __construct($a_id = 0, $a_call_by_reference =
true)
70 $this->db = $DIC->database();
71 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
72 $this->lng = $DIC->language();
73 $this->
user = $DIC->user();
76 $this->webFilesystem = $DIC->filesystem()->web();
78 parent::__construct($a_id, $a_call_by_reference);
82 public function setDate($a_hour, $a_minutes, $a_day, $a_month, $a_year)
84 $this->hour = (int) $a_hour;
85 $this->minutes = (int) $a_minutes;
86 $this->day = (int) $a_day;
87 $this->month = (int) $a_month;
88 $this->year = (int) $a_year;
89 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
98 $this->timestamp = $a_timestamp;
102 $this->instruction = $a_instruction;
116 $this->pass_mode = $a_val;
126 return $this->pass_mode;
136 $this->pass_nr = $a_val;
146 return $this->pass_nr;
156 $this->show_submissions = $a_val;
166 return $this->show_submissions;
177 return $this->hour == (int) date(
"H", $this->timestamp)
and 178 $this->minutes == (int) date(
"i", $this->timestamp)
and 179 $this->day == (int) date(
"d", $this->timestamp)
and 180 $this->month == (int) date(
"m", $this->timestamp)
and 181 $this->year == (int) date(
"Y", $this->timestamp);
186 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
191 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
196 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
206 $this->tutor_feedback = $a_value;
213 $ilDB->insert(
"exc_data", array(
214 "obj_id" => array(
"integer", $this->
getId()),
216 "time_stamp" => array(
"integer", $this->
getTimestamp()),
217 "pass_mode" => array(
"text", $this->
getPassMode()),
218 "pass_nr" => array(
"text", $this->
getPassNr()),
234 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree =
false)
239 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
243 $new_obj->saveData();
254 $crit_cat_map = array();
255 include_once(
"./Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php");
257 $new_id = $crit_cat->cloneObject($new_obj->getId());
258 $crit_cat_map[$crit_cat->getId()] = $new_id;
262 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
266 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
268 $obj_settings->cloneSettings($new_obj->getId());
269 unset($obj_settings);
278 $this->webFilesystem,
283 $cloneAction->cloneCertificate($this, $new_obj);
294 public function delete()
300 if (!parent::delete()) {
304 $ilDB->manipulate(
"DELETE FROM exc_data " .
305 "WHERE obj_id = " .
$ilDB->quote($this->getId(),
"integer"));
307 include_once
"Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
311 include_once
"./Services/Notification/classes/class.ilNotification.php";
314 $ilAppEventHandler->raise(
317 array(
'obj_id' => $this->
getId())
329 $query =
"SELECT * FROM exc_data " .
330 "WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
336 $pm = (
$row->pass_mode ==
"")
339 $this->setPassMode($pm);
341 if (
$row->pass_mode ==
"nr") {
366 $ilDB->update(
"exc_data", array(
368 "time_stamp" => array(
"integer", $this->
getTimestamp()),
369 "pass_mode" => array(
"text", $this->
getPassMode()),
370 "pass_nr" => array(
"integer", $this->
getPassNr()),
375 "obj_id" => array(
"integer", $this->
getId())
391 $lng->loadLanguageModule(
"exc");
404 $body .=
$lng->txt(
"exc_edit_until") .
": ";
406 ?
$lng->txt(
"exc_no_deadline_specified")
410 include_once
"Services/Link/classes/class.ilLink.php";
415 $file_names = array();
416 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
418 $files = $storage->getFiles();
420 include_once
"./Services/Mail/classes/class.ilFileDataMail.php";
422 foreach ($files as $file) {
423 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
424 $file_names[] = $file[
"name"];
429 $recipients = array();
430 foreach ($a_members as $member_id) {
432 $recipients[] = $tmp_obj->getLogin();
435 $recipients = implode(
",", $recipients);
438 include_once
"Services/Mail/classes/class.ilMail.php";
440 $errors = $tmp_mail_obj->sendMail(
449 unset($tmp_mail_obj);
452 if (
sizeof($file_names)) {
453 $mfile_obj->unlinkFiles($file_names);
458 foreach ($a_members as $member_id) {
460 $member_status->setSent(
true);
461 $member_status->update();
474 if ($a_user_id == 0) {
478 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
481 $passed_all_mandatory =
true;
482 $failed_a_mandatory =
false;
485 $passed_at_least_one =
false;
487 foreach ($ass as $a) {
488 $stat = $a->getMemberStatus($a_user_id)->getStatus();
489 if ($a->getMandatory() && ($stat ==
"failed" || $stat ==
"notgraded")) {
490 $passed_all_mandatory =
false;
492 if ($a->getMandatory() && ($stat ==
"failed")) {
493 $failed_a_mandatory =
true;
495 if ($stat ==
"passed") {
498 if ($stat ==
"notgraded") {
503 if (count($ass) == 0) {
504 $passed_all_mandatory =
false;
509 $overall_stat =
"notgraded";
510 if ($failed_a_mandatory) {
512 $overall_stat =
"failed";
513 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
515 $overall_stat =
"passed";
520 $overall_stat =
"notgraded";
522 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr)) {
524 $overall_stat =
"failed";
525 } elseif ($passed_all_mandatory && $cnt_passed >= $min_nr) {
527 $overall_stat =
"passed";
532 "overall_status" => $overall_stat,
533 "failed_a_mandatory" => $failed_a_mandatory);
546 if ($a_user_id == 0) {
552 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
556 $st[
"overall_status"]
565 if (!is_object($this->members_obj)) {
569 $mems = $this->members_obj->getMembers();
570 foreach ($mems as $mem) {
580 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
583 include_once
"./Services/Excel/classes/class.ilExcel.php";
585 $excel->addSheet($this->lng->txt(
"exc_status"));
594 $excel->setCell(
$row, 0, $this->lng->txt(
"name"));
595 foreach ($ass_data as $ass) {
596 $excel->setCell(
$row, $cnt++, ($cnt / 2) .
" - ". $this->lng->txt(
"exc_tbl_status"));
597 $excel->setCell(
$row, $cnt++, (($cnt - 1) / 2) .
" - ". $this->lng->txt(
"exc_tbl_mark"));
599 $excel->setCell(
$row, $cnt++, $this->lng->txt(
"exc_total_exc"));
600 $excel->setCell(
$row, $cnt++, $this->lng->txt(
"exc_mark"));
601 $excel->setCell(
$row++, $cnt, $this->lng->txt(
"exc_comment_for_learner"));
602 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
607 $filtered_members =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
608 'edit_submissions_grades',
609 'edit_submissions_grades',
611 (array) $mem_obj->getMembers()
614 foreach ((array) $filtered_members as $user_id) {
619 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
620 foreach ($mems as $user_id =>
$d) {
624 $excel->setCell(
$row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
627 foreach ($ass_data as $ass) {
628 $status = $ass->getMemberStatus($user_id)->getStatus();
629 $mark = $ass->getMemberStatus($user_id)->getMark();
630 $excel->setCell(
$row, $col++, $this->lng->txt(
"exc_" . $status));
631 $excel->setCell(
$row, $col++, $mark);
636 $excel->setCell(
$row, $col++, $this->lng->txt(
"exc_" . $status));
640 $excel->setCell(
$row, $col++, $marks_obj->getMark());
641 $excel->setCell(
$row++, $col, $marks_obj->getComment());
649 $excel->addSheet($this->lng->txt(
"exc_mark"));
653 $excel->setCell(
$row, 0, $this->lng->txt(
"name"));
654 foreach ($ass_data as $ass) {
655 $excel->setCell(
$row, $cnt++, $cnt - 1);
657 $excel->setCell(
$row++, $cnt++, $this->lng->txt(
"exc_total_exc"));
658 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
662 foreach ($mems as $user_id =>
$d) {
667 $excel->setCell(
$row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
670 foreach ($ass_data as $ass) {
671 $excel->setCell(
$row, $col++, $ass->getMemberStatus($user_id)->getMark());
679 $excel->sendToClient($exc_name);
687 $user_ids = $a_user_id;
688 if (!is_array($user_ids)) {
689 $user_ids = array($user_ids);
692 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
694 $type = (bool) $a_is_text_feedback
699 $not->setType(
$type);
700 $not->setAssignmentId($a_ass_id);
701 $not->setObjId($this->
getId());
705 $not->setRecipients($user_ids);
733 $this->completion_by_submission = (bool) $bool;
740 $a_has_submitted = (bool) $a_has_submitted;
742 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
743 foreach ($a_user_ids as $user_id) {
745 $member_status->setReturned($a_has_submitted);
746 $member_status->update();
753 foreach ($a_user_ids as $user_id) {
754 $status =
'notgraded';
755 if ($a_has_submitted) {
756 if (!is_array($a_valid_submissions) ||
757 $a_valid_submissions[$user_id]) {
763 $member_status->setStatus($status);
764 $member_status->update();
779 $ilDB = $DIC->database();
781 $set =
$ilDB->query(
"SELECT obj_id, status FROM exc_members" .
782 " WHERE usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
783 " AND (status = " .
$ilDB->quote(
"passed",
"text") .
784 " OR status = " .
$ilDB->quote(
"failed",
"text") .
")");
788 $all[
$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
802 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
813 $this->certificate_visibility = $a_value;
826 $affectedRows =
$ilDB->manipulateF(
827 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
828 array(
'integer',
'integer'),
829 array($a_value, $this->
getId())
841 return (
bool) $exc_set->get(
"add_to_pd",
true);
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _lookupName($a_user_id)
lookup user name
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
getMemberStatus($a_user_id=null)
determinStatusOfUser($a_user_id=0)
Determine status of user.
static removeForObject($type, $id)
Remove all notifications for given object.
getPassMode()
Get pass mode (all | nr)
static deleteByParent($a_parent_id)
getCertificateVisibility()
Returns the visibility settings of the certificate.
getId()
Get assignment id.
getDeadline()
Get deadline (timestamp)
setDate($a_hour, $a_minutes, $a_day, $a_month, $a_year)
const TYPE_FEEDBACK_TEXT_ADDED
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
setInstruction($a_instruction)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static _writeStatus($a_obj_id, $a_user_id, $a_status)
Write user status.
getShowSubmissions()
Get whether submissions of learners should be shown to other learners after deadline.
const TYPE_FEEDBACK_FILE_ADDED
static _writeReturned($a_obj_id, $a_user_id, $a_status)
Write returned status.
setCertificateVisibility($a_value)
Sets the visibility settings of the certificate.
const TUTOR_FEEDBACK_FILE
const TUTOR_FEEDBACK_TEXT
updateAllUsersStatus()
Update status of all users.
getExerciseId()
Get exercise id.
const TUTOR_FEEDBACK_MAIL
foreach($_POST as $key=> $value) $res
setPassMode($a_val)
Set pass mode (all | nr)
getId()
get object id public
setTimestamp($a_timestamp)
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
static getInstancesByExercise($a_exc_id)
getTitle()
get object title public
const TYPE_EXERCISE_SUBMISSION
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
setTutorFeedback($a_value)
$completion_by_submission
sendFeedbackFileNotification($a_feedback_file, $a_user_id, $a_ass_id, $a_is_text_feedback=false)
Send feedback file notification to user.
hasAddToDesktop()
Add to desktop after hand-in.
static cloneAssignmentsOfExercise($a_old_exc_id, $a_new_exc_id, array $a_crit_cat_map)
Clone assignments of exercise.
update($pash, $contents, Config $config)
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
static _lookupFinishedUserExercises($a_user_id)
Get all exercises for user.
updateUserStatus($a_user_id=0)
Update exercise status of user.
setShowSubmissions($a_val)
Set whether submissions of learners should be shown to other learners after deadline.
static getInstancesByParentId($a_parent_id)
getInstruction()
Get instruction.
sendAssignment(ilExAssignment $a_ass, $a_members)
send exercise per mail to members
saveCertificateVisibility($a_value)
Saves the visibility settings of the certificate.
getRefId()
get reference id public
exportGradesExcel()
Exports grades as excel.
getPassNr()
Get number of assignments that must be passed to pass the exercise.
static _lookupMark($a_usr_id, $a_obj_id)
processExerciseStatus(ilExAssignment $a_ass, array $a_user_ids, $a_has_submitted, array $a_valid_submissions=null)
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone exercise (no member data)
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setPassNr($a_val)
Set number of assignments that must be passed to pass the exercise.