4 require_once
"./Services/Object/classes/class.ilObject.php";
5 require_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
61 public function __construct($a_id = 0, $a_call_by_reference =
true)
65 $this->db = $DIC->database();
66 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
67 $this->lng = $DIC->language();
68 $this->
user = $DIC->user();
71 parent::__construct($a_id, $a_call_by_reference);
75 public function setDate($a_hour, $a_minutes, $a_day, $a_month, $a_year)
77 $this->hour = (int) $a_hour;
78 $this->minutes = (int) $a_minutes;
79 $this->day = (int) $a_day;
80 $this->month = (int) $a_month;
81 $this->year = (int) $a_year;
82 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
91 $this->timestamp = $a_timestamp;
95 $this->instruction = $a_instruction;
109 $this->pass_mode = $a_val;
119 return $this->pass_mode;
129 $this->pass_nr = $a_val;
139 return $this->pass_nr;
149 $this->show_submissions = $a_val;
159 return $this->show_submissions;
170 return $this->hour == (int)
date(
"H", $this->timestamp) and
171 $this->minutes == (int)
date(
"i", $this->timestamp) and
172 $this->day == (int)
date(
"d", $this->timestamp) and
173 $this->month == (int)
date(
"m", $this->timestamp) and
174 $this->year == (int)
date(
"Y", $this->timestamp);
179 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
184 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
189 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
199 $this->tutor_feedback = $a_value;
227 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree =
false)
232 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
236 $new_obj->saveData();
247 $crit_cat_map =
array();
248 include_once(
"./Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php");
250 $new_id = $crit_cat->cloneObject($new_obj->getId());
251 $crit_cat_map[$crit_cat->getId()] = $new_id;
255 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
259 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
261 $obj_settings->cloneSettings($new_obj->getId());
262 unset($obj_settings);
265 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
266 include_once
"./Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
269 $cert->cloneCertificate($newcert);
280 public function delete()
286 if (!parent::delete()) {
290 $ilDB->manipulate(
"DELETE FROM exc_data " .
291 "WHERE obj_id = " .
$ilDB->quote($this->getId(),
"integer"));
293 include_once
"Modules/Exercise/classes/class.ilExcCriteriaCatalogue.php";
297 include_once
"./Services/Notification/classes/class.ilNotification.php";
300 $ilAppEventHandler->raise(
315 $query =
"SELECT * FROM exc_data " .
316 "WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
322 $pm = (
$row->pass_mode ==
"")
325 $this->setPassMode($pm);
327 if (
$row->pass_mode ==
"nr") {
377 $lng->loadLanguageModule(
"exc");
390 $body .=
$lng->txt(
"exc_edit_until") .
": ";
392 ?
$lng->txt(
"exc_no_deadline_specified")
396 include_once
"Services/Link/classes/class.ilLink.php";
401 $file_names =
array();
402 include_once(
"./Modules/Exercise/classes/class.ilFSStorageExercise.php");
404 $files = $storage->getFiles();
406 include_once
"./Services/Mail/classes/class.ilFileDataMail.php";
408 foreach ($files as
$file) {
409 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
410 $file_names[] = $file[
"name"];
415 $recipients =
array();
416 foreach ($a_members as $member_id) {
418 $recipients[] = $tmp_obj->getLogin();
421 $recipients = implode(
",", $recipients);
424 include_once
"Services/Mail/classes/class.ilMail.php";
435 unset($tmp_mail_obj);
438 if (
sizeof($file_names)) {
439 $mfile_obj->unlinkFiles($file_names);
444 foreach ($a_members as $member_id) {
446 $member_status->setSent(
true);
447 $member_status->update();
460 if ($a_user_id == 0) {
464 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
467 $passed_all_mandatory =
true;
468 $failed_a_mandatory =
false;
471 $passed_at_least_one =
false;
473 foreach ($ass as $a) {
474 $stat = $a->getMemberStatus($a_user_id)->getStatus();
475 if ($a->getMandatory() && ($stat ==
"failed" || $stat ==
"notgraded")) {
476 $passed_all_mandatory =
false;
478 if ($a->getMandatory() && ($stat ==
"failed")) {
479 $failed_a_mandatory =
true;
481 if ($stat ==
"passed") {
484 if ($stat ==
"notgraded") {
489 if (count($ass) == 0) {
490 $passed_all_mandatory =
false;
495 $overall_stat =
"notgraded";
496 if ($failed_a_mandatory) {
498 $overall_stat =
"failed";
499 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
501 $overall_stat =
"passed";
506 $overall_stat =
"notgraded";
508 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr)) {
510 $overall_stat =
"failed";
511 } elseif ($passed_all_mandatory && $cnt_passed >= $min_nr) {
513 $overall_stat =
"passed";
518 "overall_status" => $overall_stat,
519 "failed_a_mandatory" => $failed_a_mandatory);
532 if ($a_user_id == 0) {
538 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
542 $st[
"overall_status"]
551 if (!is_object($this->members_obj)) {
555 $mems = $this->members_obj->getMembers();
556 foreach ($mems as $mem) {
566 include_once(
"./Modules/Exercise/classes/class.ilExAssignment.php");
569 include_once
"./Services/Excel/classes/class.ilExcel.php";
571 $excel->addSheet($this->lng->txt(
"exc_status"));
580 $excel->setCell(
$row, 0, $this->lng->txt(
"name"));
581 foreach ($ass_data as $ass) {
582 $excel->setCell(
$row, $cnt++, $cnt-1);
584 $excel->setCell(
$row, $cnt++, $this->lng->txt(
"exc_total_exc"));
585 $excel->setCell(
$row, $cnt++, $this->lng->txt(
"exc_mark"));
586 $excel->setCell(
$row++, $cnt, $this->lng->txt(
"exc_comment_for_learner"));
587 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
592 $filtered_members =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
593 'etit_submissions_grades',
594 'edit_submissions_grades',
596 (
array) $mem_obj->getMembers()
599 foreach ((
array) $filtered_members as $user_id) {
604 include_once
'Services/Tracking/classes/class.ilLPMarks.php';
605 foreach ($mems as $user_id =>
$d) {
609 $excel->setCell(
$row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
612 foreach ($ass_data as $ass) {
613 $status = $ass->getMemberStatus($user_id)->getStatus();
614 $excel->setCell(
$row, $col++, $this->lng->txt(
"exc_" . $status));
619 $excel->setCell(
$row, $col++, $this->lng->txt(
"exc_" . $status));
623 $excel->setCell(
$row, $col++, $marks_obj->getMark());
624 $excel->setCell(
$row++, $col, $marks_obj->getComment());
632 $excel->addSheet($this->lng->txt(
"exc_mark"));
636 $excel->setCell(
$row, 0, $this->lng->txt(
"name"));
637 foreach ($ass_data as $ass) {
638 $excel->setCell(
$row, $cnt++, $cnt-1);
640 $excel->setCell(
$row++, $cnt++, $this->lng->txt(
"exc_total_exc"));
641 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
645 foreach ($mems as $user_id =>
$d) {
650 $excel->setCell(
$row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
653 foreach ($ass_data as $ass) {
654 $excel->setCell(
$row, $col++, $ass->getMemberStatus($user_id)->getMark());
662 $excel->sendToClient($exc_name);
670 $user_ids = $a_user_id;
671 if (!is_array($user_ids)) {
672 $user_ids =
array($user_ids);
675 include_once(
"./Modules/Exercise/classes/class.ilExerciseMailNotification.php");
677 $type = (bool) $a_is_text_feedback
682 $not->setType(
$type);
683 $not->setAssignmentId($a_ass_id);
684 $not->setObjId($this->
getId());
688 $not->setRecipients($user_ids);
716 $this->completion_by_submission = (bool) $bool;
723 $a_has_submitted = (bool) $a_has_submitted;
725 include_once(
"./Modules/Exercise/classes/class.ilExerciseMembers.php");
726 foreach ($a_user_ids as $user_id) {
728 $member_status->setReturned($a_has_submitted);
729 $member_status->update();
736 foreach ($a_user_ids as $user_id) {
737 $status =
'notgraded';
738 if ($a_has_submitted) {
739 if (!is_array($a_valid_submissions) ||
740 $a_valid_submissions[$user_id]) {
746 $member_status->setStatus($status);
747 $member_status->update();
762 $ilDB = $DIC->database();
764 $set =
$ilDB->query(
"SELECT obj_id, status FROM exc_members" .
765 " WHERE usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
766 " AND (status = " .
$ilDB->quote(
"passed",
"text") .
767 " OR status = " .
$ilDB->quote(
"failed",
"text") .
")");
771 $all[
$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
785 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
796 $this->certificate_visibility = $a_value;
809 $affectedRows =
$ilDB->manipulateF(
810 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
811 array(
'integer',
'integer'),
825 include_once
"Services/Certificate/classes/class.ilCertificate.php";
829 if ($certificate_visible != 2) {
831 include_once
'Modules/Exercise/classes/class.ilExerciseMembers.php';
833 if ($certificate_visible == 1 && $status ==
"passed") {
837 elseif ($certificate_visible == 0 && $status !=
"notgraded") {
853 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.
This class handles all operations on files (attachments) in directory ilias_data/mail.
getId()
Get assignment id.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 _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.
catch(Exception $e) $message
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.
This class handles base functions for mail handling.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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
Create styles array
The data for the language used.
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.
static isObjectActive($a_obj_id)
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.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
getPassNr()
Get number of assignments that must be passed to pass the exercise.
static _lookupMark($a_usr_id, $a_obj_id)
hasUserCertificate($a_user_id)
Check if given user has certificate to show/download.
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
Exercise certificate adapter.
setPassNr($a_val)
Set number of assignments that must be passed to pass the exercise.