68 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
73 $this->db =
$DIC->database();
74 $this->app_event_handler =
$DIC[
"ilAppEventHandler"];
75 $this->
lng = $DIC->language();
76 $this->
user = $DIC->user();
79 $this->webFilesystem =
$DIC->filesystem()->web();
80 $this->service =
$DIC->exercise()->internal();
83 $this->mandatory_manager = $this->service->domain()->assignment()->mandatoryAssignments($this);
89 public function setId(
int $a_id): void
93 $this->mandatory_manager = $this->service->domain()->assignment()->mandatoryAssignments($this);
103 $this->hour = $a_hour;
104 $this->minutes = $a_minutes;
106 $this->month = $a_month;
107 $this->year = $a_year;
108 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
119 $this->timestamp = $a_timestamp;
123 string $a_instruction
125 $this->instruction = $a_instruction;
130 return $this->instruction;
138 $this->pass_mode = $a_val;
143 return $this->pass_mode;
151 $this->pass_nr = $a_val;
156 return $this->pass_nr;
164 $this->show_submissions = $a_val;
169 return $this->show_submissions;
177 $this->nr_random_mand = $a_val;
182 return $this->nr_random_mand;
187 return $this->hour == (
int) date(
"H", $this->timestamp) and
188 $this->minutes == (
int) date(
"i", $this->timestamp) and
189 $this->day == (
int) date(
"d", $this->timestamp) and
190 $this->month == (
int) date(
"m", $this->timestamp) and
191 $this->year == (
int) date(
"Y", $this->timestamp);
196 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
201 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
206 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
211 return $this->tutor_feedback;
216 $this->tutor_feedback = $a_value;
223 $ilDB->insert(
"exc_data", array(
224 "obj_id" => array(
"integer", $this->
getId()),
225 "instruction" => array(
"clob", $this->getInstruction()),
226 "time_stamp" => array(
"integer", $this->getTimestamp()),
227 "pass_mode" => array(
"text", $this->getPassMode()),
228 "nr_mandatory_random" => array(
"integer", $this->getNrMandatoryRandom()),
229 "pass_nr" => array(
"text", $this->getPassNr()),
230 "show_submissions" => array(
"integer", (
int) $this->getShowSubmissions()),
231 'compl_by_submission' => array(
'integer', (
int) $this->isCompletionBySubmissionEnabled()),
232 "certificate_visibility" => array(
"integer", $this->getCertificateVisibility()),
233 "tfeedback" => array(
"integer", $this->getTutorFeedback())
247 public function cloneObject(
int $a_target_id,
int $a_copy_id = 0,
bool $a_omit_tree =
false): ?
ilObject
253 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
254 $new_obj->setInstruction($this->getInstruction());
255 $new_obj->setTimestamp($this->getTimestamp());
256 $new_obj->setPassMode($this->getPassMode());
257 $new_obj->setNrMandatoryRandom($this->getNrMandatoryRandom());
258 $new_obj->saveData();
259 $new_obj->setPassNr($this->getPassNr());
260 $new_obj->setShowSubmissions($this->getShowSubmissions());
261 $new_obj->setCompletionBySubmission($this->isCompletionBySubmissionEnabled());
262 $new_obj->setTutorFeedback($this->getTutorFeedback());
263 $new_obj->setCertificateVisibility($this->getCertificateVisibility());
265 $this->cloneMetaData($new_obj);
269 $new_obj->saveCertificateVisibility($this->getCertificateVisibility());
272 $crit_cat_map = array();
274 $new_id = $crit_cat->cloneObject($new_obj->getId());
275 $crit_cat_map[$crit_cat->getId()] = $new_id;
283 $obj_settings->cloneSettings($new_obj->getId());
284 unset($obj_settings);
296 $cloneAction->cloneCertificate($this, $new_obj);
305 $orgu_object_settings->setActive(
308 $orgu_object_settings->update();
316 public function delete():
bool
319 $ilAppEventHandler = $this->app_event_handler;
322 if (!parent::delete()) {
326 $em = $this->service->domain()->exercise($this->
getId());
334 $this->deleteMetaData();
336 $ilDB->manipulate(
"DELETE FROM exc_data " .
337 "WHERE obj_id = " .
$ilDB->quote($this->getId(),
"integer"));
343 $ilAppEventHandler->raise(
344 'components/ILIAS/Exercise',
346 array(
'obj_id' => $this->
getId())
362 $query =
"SELECT * FROM exc_data " .
363 "WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
366 while ($row =
$ilDB->fetchObject(
$res)) {
367 $this->setInstruction((
string) $row->instruction);
368 $this->setTimestamp((
int) $row->time_stamp);
369 $pm = ($row->pass_mode ==
"")
372 $this->setPassMode((
string) $pm);
373 $this->setShowSubmissions((
bool) $row->show_submissions);
374 if ($row->pass_mode ==
"nr") {
375 $this->setPassNr((
int) $row->pass_nr);
377 $this->setNrMandatoryRandom((
int) $row->nr_mandatory_random);
378 $this->setCompletionBySubmission($row->compl_by_submission == 1);
379 $this->setCertificateVisibility((
int) $row->certificate_visibility);
380 $this->setTutorFeedback((
int) $row->tfeedback);
388 $id = parent::create();
389 $this->createMetaData();
402 $ilDB->update(
"exc_data", array(
403 "instruction" => array(
"clob", $this->getInstruction()),
404 "time_stamp" => array(
"integer", $this->getTimestamp()),
405 "pass_mode" => array(
"text", $this->getPassMode()),
406 "pass_nr" => array(
"integer", $this->getPassNr()),
407 "nr_mandatory_random" => array(
"integer", $this->getNrMandatoryRandom()),
408 "show_submissions" => array(
"integer", (
int) $this->getShowSubmissions()),
409 'compl_by_submission' => array(
'integer', (
int) $this->isCompletionBySubmissionEnabled()),
410 'tfeedback' => array(
'integer', $this->getTutorFeedback()),
412 "obj_id" => array(
"integer", $this->
getId())
415 $this->updateAllUsersStatus();
416 $this->updateMetaData();
429 public function sendAssignment(
ilExAssignment $a_ass, array $a_members): void
432 $ilUser = $this->user;
434 $lng->loadLanguageModule(
"exc");
447 $body .=
$lng->txt(
"exc_edit_until") .
": ";
449 ?
$lng->txt(
"exc_no_deadline_specified")
453 $body .= ilLink::_getLink($this->getRefId(),
"exc");
456 $if = $this->service->domain()->assignment()->instructionFiles($a_ass->
getId());
457 $files = $if->getFiles();
459 if (count($files) > 0) {
461 foreach ($if->getFiles() as $file) {
462 $file_names[] = $file[
"name"];
463 $mfile_obj->storeAsAttachment(
465 $if->getStream($file[
"rid"])->getContents()
471 $recipients = array();
472 foreach ($a_members as $member_id) {
475 $recipients[] = $tmp_obj->getLogin();
478 $recipients = implode(
",", $recipients);
481 $tmp_mail_obj =
new ilMail($ilUser->getId());
482 $tmp_mail_obj->enqueue(
490 unset($tmp_mail_obj);
493 if (count($file_names) && $mfile_obj) {
494 $mfile_obj->unlinkFiles($file_names);
499 foreach ($a_members as $member_id) {
501 $member_status->setSent(
true);
502 $member_status->update();
510 public function determinStatusOfUser(
int $a_user_id = 0): array
512 $ilUser = $this->user;
514 $mandatory_manager = $this->mandatory_manager;
516 if ($a_user_id == 0) {
517 $a_user_id = $ilUser->getId();
522 $passed_all_mandatory =
true;
523 $failed_a_mandatory =
false;
528 foreach ($ass as
$a) {
529 $stat =
$a->getMemberStatus($a_user_id)->getStatus();
531 if ($mandatory && ($stat ==
"failed" || $stat ==
"notgraded")) {
532 $passed_all_mandatory =
false;
534 if ($mandatory && ($stat ==
"failed")) {
535 $failed_a_mandatory =
true;
537 if ($stat ==
"passed") {
540 if ($stat ==
"notgraded") {
545 if (count($ass) == 0) {
546 $passed_all_mandatory =
false;
548 $overall_stat =
"notgraded";
549 if ($this->getPassMode() == self::PASS_MODE_ALL) {
550 $overall_stat =
"notgraded";
551 if ($failed_a_mandatory) {
552 $overall_stat =
"failed";
553 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
554 $overall_stat =
"passed";
556 } elseif ($this->getPassMode() == self::PASS_MODE_NR) {
557 $min_nr = $this->getPassNr();
558 $overall_stat =
"notgraded";
559 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr)) {
560 $overall_stat =
"failed";
561 } elseif ($passed_all_mandatory && $cnt_passed >= $min_nr) {
562 $overall_stat =
"passed";
564 } elseif ($this->getPassMode() == self::PASS_MODE_RANDOM) {
565 $overall_stat =
"notgraded";
566 if ($failed_a_mandatory) {
567 $overall_stat =
"failed";
568 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
569 $overall_stat =
"passed";
574 "overall_status" => $overall_stat,
575 "failed_a_mandatory" => $failed_a_mandatory);
584 $ilUser = $this->user;
586 if ($a_user_id == 0) {
587 $a_user_id = $ilUser->getId();
590 $st = $this->determinStatusOfUser($a_user_id);
595 $st[
"overall_status"]
605 if (!isset($this->members_obj)) {
609 $mems = $this->members_obj->getMembers();
610 foreach ($mems as $mem) {
611 $this->updateUserStatus($mem);
625 $excel->addSheet($this->
lng->txt(
"exc_status"));
633 $excel->setCell($row, 0, $this->
lng->txt(
"name"));
634 foreach ($ass_data as $ass) {
635 $excel->setCell($row, $cnt++, ($cnt / 2) .
" - " . $this->
lng->txt(
"exc_tbl_status"));
636 $excel->setCell($row, $cnt++, (($cnt - 1) / 2) .
" - " . $this->
lng->txt(
"exc_tbl_mark"));
638 $excel->setCell($row, $cnt++, $this->
lng->txt(
"exc_total_exc"));
639 $excel->setCell($row, $cnt++, $this->
lng->txt(
"exc_mark"));
640 $excel->setCell($row++, $cnt, $this->
lng->txt(
"exc_comment_for_learner"));
641 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
646 $filtered_members =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
647 'edit_submissions_grades',
648 'edit_submissions_grades',
650 $mem_obj->getMembers()
653 foreach ((array) $filtered_members as
$user_id) {
662 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
665 foreach ($ass_data as $ass) {
666 $status = $ass->getMemberStatus(
$user_id)->getStatus();
667 $mark = $ass->getMemberStatus(
$user_id)->getMark();
668 $excel->setCell($row, $col++, $this->
lng->txt(
"exc_" . $status));
669 $excel->setCell($row, $col++, $mark);
674 $excel->setCell($row, $col++, $this->
lng->txt(
"exc_" . $status));
678 $excel->setCell($row, $col++, $marks_obj->getMark());
679 $excel->setCell($row++, $col, $marks_obj->getComment());
687 $excel->addSheet($this->
lng->txt(
"exc_mark"));
691 $excel->setCell($row, 0, $this->
lng->txt(
"name"));
692 foreach ($ass_data as $ass) {
693 $excel->setCell($row, $cnt++, $cnt - 1);
695 $excel->setCell($row++, $cnt++, $this->
lng->txt(
"exc_total_exc"));
696 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
705 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
708 foreach ($ass_data as $ass) {
709 $excel->setCell($row, $col++, $ass->getMemberStatus(
$user_id)->getMark());
717 $excel->sendToClient($exc_name);
724 return $this->completion_by_submission;
730 $this->completion_by_submission = $bool;
741 bool $a_has_submitted,
742 ?array $a_valid_submissions =
null
746 $member_status->setReturned($a_has_submitted);
747 $member_status->update();
753 if ($this->isCompletionBySubmissionEnabled()) {
755 $status =
'notgraded';
756 if ($a_has_submitted) {
757 if (!is_array($a_valid_submissions) ||
764 $member_status->setStatus($status);
765 $member_status->update();
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") .
")");
787 while ($row =
$ilDB->fetchAssoc($set)) {
788 $all[$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
799 return (strlen($this->certificate_visibility) !== 0) ? $this->certificate_visibility : 0;
807 $this->certificate_visibility = $a_value;
819 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
820 array(
'integer',
'integer'),
821 array($a_value, $this->
getId())
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
foreach($mandatory_scripts as $file) $timestamp
Manages random mandatory assignments of an exercise.
isMandatoryForUser(int $ass_id, int $user_id)
Exercise internal service.
Indicates that the directory is missing or not found.
Indicates that a file is missing or not found.
Indicates general problems with the input or output operations.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
static _getContainerSettings(int $a_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static cloneAssignmentsOfExercise(int $a_old_exc_id, int $a_new_exc_id, array $a_crit_cat_map)
Clone assignments of exercise.
static getInstancesByExercise(int $a_exc_id)
getMemberStatus(?int $a_user_id=null)
static getInstancesByParentId(int $a_parent_id)
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 _writeReturned(int $a_obj_id, int $a_user_id, int $a_status)
Write returned status.
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
static getASCIIFilename(string $a_filename)
static _lookupMark(int $a_usr_id, int $a_obj_id)
const TYPE_EXERCISE_SUBMISSION
static removeForObject(int $type, int $id)
Remove all notifications for given object.
ilExerciseMembers $members_obj
saveCertificateVisibility(int $a_value)
const TUTOR_FEEDBACK_TEXT
static _lookupFinishedUserExercises(int $a_user_id)
Get all finished exercises for user.
setDate(int $a_hour, int $a_minutes, int $a_day, int $a_month, int $a_year)
create()
note: title, description and type should be set when this function is called
updateAllUsersStatus()
Update status of all users.
const TUTOR_FEEDBACK_MAIL
const TUTOR_FEEDBACK_FILE
setPassMode(string $a_val)
setShowSubmissions(bool $a_val)
int $certificate_visibility
setCertificateVisibility(int $a_value)
updateUserStatus(int $a_user_id=0)
Update exercise status of user.
bool $completion_by_submission
setTimestamp(int $a_timestamp)
processExerciseStatus(ilExAssignment $a_ass, array $a_user_ids, bool $a_has_submitted, ?array $a_valid_submissions=null)
setTutorFeedback(int $a_value)
exportGradesExcel()
Exports grades as excel.
Filesystem $webFilesystem
setCompletionBySubmission(bool $bool)
getCertificateVisibility()
setNrMandatoryRandom(int $a_val)
isCompletionBySubmissionEnabled()
setInstruction(string $a_instruction)
MandatoryAssignmentsManager $mandatory_manager
static _lookupName(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
The filesystem interface provides the public interface for the Filesystem service API consumer.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples