69 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
74 $this->db = $DIC->database();
75 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
76 $this->
lng = $DIC->language();
77 $this->
user = $DIC->user();
80 $this->webFilesystem = $DIC->filesystem()->web();
81 $this->service = $DIC->exercise()->internal();
84 $this->mandatory_manager = $this->service->domain()->assignment()->mandatoryAssignments($this);
90 public function setId(
int $a_id): void
94 $this->mandatory_manager = $this->service->domain()->assignment()->mandatoryAssignments($this);
104 $this->hour = $a_hour;
105 $this->minutes = $a_minutes;
107 $this->month = $a_month;
108 $this->year = $a_year;
109 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
120 $this->timestamp = $a_timestamp;
124 string $a_instruction
126 $this->instruction = $a_instruction;
139 $this->pass_mode = $a_val;
152 $this->pass_nr = $a_val;
165 $this->show_submissions = $a_val;
178 $this->nr_random_mand = $a_val;
188 return $this->hour == (
int) date(
"H", $this->timestamp) and
189 $this->minutes == (
int) date(
"i", $this->timestamp) and
190 $this->day == (
int) date(
"d", $this->timestamp) and
191 $this->month == (
int) date(
"m", $this->timestamp) and
192 $this->year == (
int) date(
"Y", $this->timestamp);
197 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
202 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
207 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
217 $this->tutor_feedback = $a_value;
224 $ilDB->insert(
"exc_data", array(
225 "obj_id" => array(
"integer", $this->
getId()),
227 "time_stamp" => array(
"integer", $this->
getTimestamp()),
228 "pass_mode" => array(
"text", $this->
getPassMode()),
230 "pass_nr" => array(
"text", $this->
getPassNr()),
248 public function cloneObject(
int $a_target_id,
int $a_copy_id = 0,
bool $a_omit_tree =
false): ?
ilObject 254 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
259 $new_obj->saveData();
273 $crit_cat_map = array();
275 $new_id = $crit_cat->cloneObject($new_obj->getId());
276 $crit_cat_map[$crit_cat->getId()] = $new_id;
284 $obj_settings->cloneSettings($new_obj->getId());
285 unset($obj_settings);
295 $this->webFilesystem,
299 $cloneAction->cloneCertificate($this, $new_obj);
311 $orgu_object_settings->update();
319 public function delete():
bool 325 if (!parent::delete()) {
329 $em = $this->service->domain()->exercise($this->
getId());
339 $ilDB->manipulate(
"DELETE FROM exc_data " .
340 "WHERE obj_id = " .
$ilDB->quote($this->getId(),
"integer"));
346 $ilAppEventHandler->raise(
349 array(
'obj_id' => $this->
getId())
365 $query =
"SELECT * FROM exc_data " .
366 "WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
369 while ($row =
$ilDB->fetchObject(
$res)) {
372 $pm = ($row->pass_mode ==
"")
375 $this->setPassMode((
string) $pm);
377 if ($row->pass_mode ==
"nr") {
391 $id = parent::create();
405 $ilDB->update(
"exc_data", array(
407 "time_stamp" => array(
"integer", $this->
getTimestamp()),
408 "pass_mode" => array(
"text", $this->
getPassMode()),
409 "pass_nr" => array(
"integer", $this->
getPassNr()),
415 "obj_id" => array(
"integer", $this->
getId())
432 public function sendAssignment(
ilExAssignment $a_ass, array $a_members):
void 450 $body .=
$lng->
txt(
"exc_edit_until") .
": ";
452 ?
$lng->
txt(
"exc_no_deadline_specified")
456 $body .= ilLink::_getLink($this->
getRefId(),
"exc");
460 $file_names = array();
466 foreach ($files as $file) {
467 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
468 $file_names[] = $file[
"name"];
473 $recipients = array();
474 foreach ($a_members as $member_id) {
477 $recipients[] = $tmp_obj->getLogin();
480 $recipients = implode(
",", $recipients);
483 $tmp_mail_obj =
new ilMail($ilUser->getId());
484 $tmp_mail_obj->enqueue(
492 unset($tmp_mail_obj);
495 if (count($file_names) && $mfile_obj) {
496 $mfile_obj->unlinkFiles($file_names);
501 foreach ($a_members as $member_id) {
503 $member_status->setSent(
true);
504 $member_status->update();
512 public function determinStatusOfUser(
int $a_user_id = 0): array
518 if ($a_user_id == 0) {
519 $a_user_id = $ilUser->getId();
524 $passed_all_mandatory =
true;
525 $failed_a_mandatory =
false;
530 foreach ($ass as
$a) {
531 $stat = $a->getMemberStatus($a_user_id)->getStatus();
533 if ($mandatory && ($stat ==
"failed" || $stat ==
"notgraded")) {
534 $passed_all_mandatory =
false;
536 if ($mandatory && ($stat ==
"failed")) {
537 $failed_a_mandatory =
true;
539 if ($stat ==
"passed") {
542 if ($stat ==
"notgraded") {
547 if (count($ass) == 0) {
548 $passed_all_mandatory =
false;
550 $overall_stat =
"notgraded";
552 $overall_stat =
"notgraded";
553 if ($failed_a_mandatory) {
554 $overall_stat =
"failed";
555 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
556 $overall_stat =
"passed";
558 } elseif ($this->
getPassMode() == self::PASS_MODE_NR) {
560 $overall_stat =
"notgraded";
561 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr)) {
562 $overall_stat =
"failed";
563 } elseif ($passed_all_mandatory && $cnt_passed >= $min_nr) {
564 $overall_stat =
"passed";
566 } elseif ($this->
getPassMode() == self::PASS_MODE_RANDOM) {
567 $overall_stat =
"notgraded";
568 if ($failed_a_mandatory) {
569 $overall_stat =
"failed";
570 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
571 $overall_stat =
"passed";
576 "overall_status" => $overall_stat,
577 "failed_a_mandatory" => $failed_a_mandatory);
588 if ($a_user_id == 0) {
589 $a_user_id = $ilUser->
getId();
592 $st = $this->determinStatusOfUser($a_user_id);
597 $st[
"overall_status"]
607 if (!isset($this->members_obj)) {
611 $mems = $this->members_obj->getMembers();
612 foreach ($mems as $mem) {
627 $excel->addSheet($this->
lng->txt(
"exc_status"));
635 $excel->setCell($row, 0, $this->
lng->txt(
"name"));
636 foreach ($ass_data as $ass) {
637 $excel->setCell($row, $cnt++, ($cnt / 2) .
" - " . $this->
lng->txt(
"exc_tbl_status"));
638 $excel->setCell($row, $cnt++, (($cnt - 1) / 2) .
" - " . $this->
lng->txt(
"exc_tbl_mark"));
640 $excel->setCell($row, $cnt++, $this->
lng->txt(
"exc_total_exc"));
641 $excel->setCell($row, $cnt++, $this->
lng->txt(
"exc_mark"));
642 $excel->setCell($row++, $cnt, $this->
lng->txt(
"exc_comment_for_learner"));
643 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
648 $filtered_members =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
649 'edit_submissions_grades',
650 'edit_submissions_grades',
652 $mem_obj->getMembers()
655 foreach ((array) $filtered_members as $user_id) {
660 foreach ($mems as $user_id =>
$d) {
664 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
667 foreach ($ass_data as $ass) {
668 $status = $ass->getMemberStatus($user_id)->getStatus();
669 $mark = $ass->getMemberStatus($user_id)->getMark();
670 $excel->setCell($row, $col++, $this->
lng->txt(
"exc_" . $status));
671 $excel->setCell($row, $col++, $mark);
676 $excel->setCell($row, $col++, $this->
lng->txt(
"exc_" . $status));
680 $excel->setCell($row, $col++, $marks_obj->getMark());
681 $excel->setCell($row++, $col, $marks_obj->getComment());
689 $excel->addSheet($this->
lng->txt(
"exc_mark"));
693 $excel->setCell($row, 0, $this->
lng->txt(
"name"));
694 foreach ($ass_data as $ass) {
695 $excel->setCell($row, $cnt++, $cnt - 1);
697 $excel->setCell($row++, $cnt++, $this->
lng->txt(
"exc_total_exc"));
698 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
702 foreach ($mems as $user_id =>
$d) {
707 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
710 foreach ($ass_data as $ass) {
711 $excel->setCell($row, $col++, $ass->getMemberStatus($user_id)->getMark());
719 $excel->sendToClient($exc_name);
732 $this->completion_by_submission = $bool;
743 bool $a_has_submitted,
744 array $a_valid_submissions = null
746 foreach ($a_user_ids as $user_id) {
748 $member_status->setReturned($a_has_submitted);
749 $member_status->update();
756 foreach ($a_user_ids as $user_id) {
757 $status =
'notgraded';
758 if ($a_has_submitted) {
759 if (!is_array($a_valid_submissions) ||
760 $a_valid_submissions[$user_id]) {
766 $member_status->setStatus($status);
767 $member_status->update();
781 $ilDB = $DIC->database();
783 $set =
$ilDB->query(
"SELECT obj_id, status FROM exc_members" .
784 " WHERE usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
785 " AND (status = " .
$ilDB->quote(
"passed",
"text") .
786 " OR status = " .
$ilDB->quote(
"failed",
"text") .
")");
789 while ($row =
$ilDB->fetchAssoc($set)) {
790 $all[$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
801 return (strlen($this->certificate_visibility) !== 0) ? $this->certificate_visibility : 0;
809 $this->certificate_visibility = $a_value;
821 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
822 array(
'integer',
'integer'),
823 array($a_value, $this->
getId())
static _writeStatus(int $a_obj_id, int $a_user_id, string $a_status)
Write user status This information is determined by the assignment status and saved redundantly in th...
static cloneAssignmentsOfExercise(int $a_old_exc_id, int $a_new_exc_id, array $a_crit_cat_map)
Clone assignments of exercise.
setActive(bool $a_status)
Set active for object.
isMandatoryForUser(int $ass_id, int $user_id)
static _writeReturned(int $a_obj_id, int $a_user_id, int $a_status)
Write returned status.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
MandatoryAssignmentsManager $mandatory_manager
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getCertificateVisibility()
setCompletionBySubmission(bool $bool)
This class handles all operations on files (attachments) in directory ilias_data/mail.
Filesystem $webFilesystem
setPassMode(string $a_val)
getMemberStatus(?int $a_user_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
int $certificate_visibility
static _lookupName(int $a_user_id)
lookup user name
Exercise internal service.
static getInstancesByParentId(int $a_parent_id)
setTimestamp(int $a_timestamp)
loadLanguageModule(string $a_module)
Load language module.
setCertificateVisibility(int $a_value)
static getASCIIFilename(string $a_filename)
const TUTOR_FEEDBACK_FILE
const TUTOR_FEEDBACK_TEXT
updateAllUsersStatus()
Update status of all users.
ilAppEventHandler $app_event_handler
cloneMetaData(ilObject $target_obj)
Copy meta data.
updateUserStatus(int $a_user_id=0)
Update exercise status of user.
const TUTOR_FEEDBACK_MAIL
static _lookupFinishedUserExercises(int $a_user_id)
Get all finished exercises for user.
ilExerciseMembers $members_obj
processExerciseStatus(ilExAssignment $a_ass, array $a_user_ids, bool $a_has_submitted, array $a_valid_submissions=null)
saveCertificateVisibility(int $a_value)
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
const TYPE_EXERCISE_SUBMISSION
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static getInstancesByExercise(int $a_exc_id)
isCompletionBySubmissionEnabled()
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupMark(int $a_usr_id, int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
bool $completion_by_submission
setNrMandatoryRandom(int $a_val)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setShowSubmissions(bool $a_val)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static removeForObject(int $type, int $id)
Remove all notifications for given object.
exportGradesExcel()
Exports grades as excel.
Manages random mandatory assignments of an exercise.
setInstruction(string $a_instruction)
setDate(int $a_hour, int $a_minutes, int $a_day, int $a_month, int $a_year)
static _getContainerSettings(int $a_id)
setTutorFeedback(int $a_value)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)