76 public function __construct($a_id = 0, $a_call_by_reference =
true)
80 $this->db = $DIC->database();
81 $this->app_event_handler = $DIC[
"ilAppEventHandler"];
82 $this->lng = $DIC->language();
83 $this->
user = $DIC->user();
86 $this->webFilesystem = $DIC->filesystem()->web();
89 $this->mandatory_manager = $DIC->exercise()->internal()->service()->getMandatoryAssignmentManager($this);
101 $this->mandatory_manager = $DIC->exercise()->internal()->service()->getMandatoryAssignmentManager($this);
105 public function setDate($a_hour, $a_minutes, $a_day, $a_month, $a_year)
107 $this->hour = (int) $a_hour;
108 $this->minutes = (int) $a_minutes;
109 $this->day = (int) $a_day;
110 $this->month = (int) $a_month;
111 $this->year = (int) $a_year;
112 $this->timestamp = mktime($this->hour, $this->minutes, 0, $this->month, $this->day, $this->year);
121 $this->timestamp = $a_timestamp;
125 $this->instruction = $a_instruction;
139 $this->pass_mode = $a_val;
149 return $this->pass_mode;
159 $this->pass_nr = $a_val;
169 return $this->pass_nr;
179 $this->show_submissions = $a_val;
189 return $this->show_submissions;
199 $this->nr_random_mand = $a_val;
220 return $this->hour == (int) date(
"H", $this->timestamp) and
221 $this->minutes == (int) date(
"i", $this->timestamp) and
222 $this->day == (int) date(
"d", $this->timestamp) and
223 $this->month == (int) date(
"m", $this->timestamp) and
224 $this->year == (int) date(
"Y", $this->timestamp);
229 return $this->tutor_feedback & self::TUTOR_FEEDBACK_TEXT;
234 return $this->tutor_feedback & self::TUTOR_FEEDBACK_MAIL;
239 return $this->tutor_feedback & self::TUTOR_FEEDBACK_FILE;
249 $this->tutor_feedback = $a_value;
256 $ilDB->insert(
"exc_data", array(
257 "obj_id" => array(
"integer", $this->
getId()),
259 "time_stamp" => array(
"integer", $this->
getTimestamp()),
260 "pass_mode" => array(
"text", $this->
getPassMode()),
262 "pass_nr" => array(
"text", $this->
getPassNr()),
278 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree =
false)
283 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
288 $new_obj->saveData();
299 $crit_cat_map = array();
301 $new_id = $crit_cat->cloneObject($new_obj->getId());
302 $crit_cat_map[$crit_cat->getId()] = $new_id;
310 $obj_settings->cloneSettings($new_obj->getId());
311 unset($obj_settings);
320 $this->webFilesystem,
325 $cloneAction->cloneCertificate($this, $new_obj);
337 $orgu_object_settings->update();
348 public function delete()
354 if (!parent::delete()) {
358 $ilDB->manipulate(
"DELETE FROM exc_data " .
359 "WHERE obj_id = " .
$ilDB->quote($this->getId(),
"integer"));
366 $ilAppEventHandler->raise(
369 array(
'obj_id' => $this->
getId())
381 $query =
"SELECT * FROM exc_data " .
382 "WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
385 while ($row =
$ilDB->fetchObject(
$res)) {
388 $pm = ($row->pass_mode ==
"")
391 $this->setPassMode($pm);
393 if ($row->pass_mode ==
"nr") {
419 $ilDB->update(
"exc_data", array(
421 "time_stamp" => array(
"integer", $this->
getTimestamp()),
422 "pass_mode" => array(
"text", $this->
getPassMode()),
423 "pass_nr" => array(
"integer", $this->
getPassNr()),
429 "obj_id" => array(
"integer", $this->
getId())
445 $lng->loadLanguageModule(
"exc");
458 $body .=
$lng->txt(
"exc_edit_until") .
": ";
460 ?
$lng->txt(
"exc_no_deadline_specified")
468 $file_names = array();
470 $files = $storage->getFiles();
473 foreach ($files as $file) {
474 $mfile_obj->copyAttachmentFile($file[
"fullpath"], $file[
"name"]);
475 $file_names[] = $file[
"name"];
480 $recipients = array();
481 foreach ($a_members as $member_id) {
483 $recipients[] = $tmp_obj->getLogin();
486 $recipients = implode(
",", $recipients);
490 $errors = $tmp_mail_obj->enqueue(
498 unset($tmp_mail_obj);
501 if (
sizeof($file_names)) {
502 $mfile_obj->unlinkFiles($file_names);
507 foreach ($a_members as $member_id) {
509 $member_status->setSent(
true);
510 $member_status->update();
519 public function determinStatusOfUser($a_user_id = 0)
525 if ($a_user_id == 0) {
531 $passed_all_mandatory =
true;
532 $failed_a_mandatory =
false;
537 foreach ($ass as
$a) {
538 $stat = $a->getMemberStatus($a_user_id)->getStatus();
540 if ($mandatory && ($stat ==
"failed" || $stat ==
"notgraded")) {
541 $passed_all_mandatory =
false;
543 if ($mandatory && ($stat ==
"failed")) {
544 $failed_a_mandatory =
true;
546 if ($stat ==
"passed") {
549 if ($stat ==
"notgraded") {
554 if (count($ass) == 0) {
555 $passed_all_mandatory =
false;
559 $overall_stat =
"notgraded";
560 if ($failed_a_mandatory) {
561 $overall_stat =
"failed";
562 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
563 $overall_stat =
"passed";
565 } elseif ($this->
getPassMode() == self::PASS_MODE_NR) {
567 $overall_stat =
"notgraded";
568 if ($failed_a_mandatory || ($cnt_passed + $cnt_notgraded < $min_nr)) {
569 $overall_stat =
"failed";
570 } elseif ($passed_all_mandatory && $cnt_passed >= $min_nr) {
571 $overall_stat =
"passed";
573 } elseif ($this->
getPassMode() == self::PASS_MODE_RANDOM) {
574 $overall_stat =
"notgraded";
575 if ($failed_a_mandatory) {
576 $overall_stat =
"failed";
577 } elseif ($passed_all_mandatory && $cnt_passed > 0) {
578 $overall_stat =
"passed";
583 "overall_status" => $overall_stat,
584 "failed_a_mandatory" => $failed_a_mandatory);
597 if ($a_user_id == 0) {
601 $st = $this->determinStatusOfUser($a_user_id);
606 $st[
"overall_status"]
615 if (!is_object($this->members_obj)) {
619 $mems = $this->members_obj->getMembers();
620 foreach ($mems as $mem) {
633 $excel->addSheet($this->lng->txt(
"exc_status"));
642 $excel->setCell($row, 0, $this->lng->txt(
"name"));
643 foreach ($ass_data as $ass) {
644 $excel->setCell($row, $cnt++, ($cnt / 2) .
" - ". $this->lng->txt(
"exc_tbl_status"));
645 $excel->setCell($row, $cnt++, (($cnt - 1) / 2) .
" - ". $this->lng->txt(
"exc_tbl_mark"));
647 $excel->setCell($row, $cnt++, $this->lng->txt(
"exc_total_exc"));
648 $excel->setCell($row, $cnt++, $this->lng->txt(
"exc_mark"));
649 $excel->setCell($row++, $cnt, $this->lng->txt(
"exc_comment_for_learner"));
650 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
655 $filtered_members =
$GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
656 'edit_submissions_grades',
657 'edit_submissions_grades',
659 (array) $mem_obj->getMembers()
662 foreach ((array) $filtered_members as $user_id) {
667 foreach ($mems as $user_id =>
$d) {
671 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
674 foreach ($ass_data as $ass) {
675 $status = $ass->getMemberStatus($user_id)->getStatus();
676 $mark = $ass->getMemberStatus($user_id)->getMark();
677 $excel->setCell($row, $col++, $this->lng->txt(
"exc_" . $status));
678 $excel->setCell($row, $col++, $mark);
683 $excel->setCell($row, $col++, $this->lng->txt(
"exc_" . $status));
687 $excel->setCell($row, $col++, $marks_obj->getMark());
688 $excel->setCell($row++, $col, $marks_obj->getComment());
696 $excel->addSheet($this->lng->txt(
"exc_mark"));
700 $excel->setCell($row, 0, $this->lng->txt(
"name"));
701 foreach ($ass_data as $ass) {
702 $excel->setCell($row, $cnt++, $cnt - 1);
704 $excel->setCell($row++, $cnt++, $this->lng->txt(
"exc_total_exc"));
705 $excel->setBold(
"A1:" . $excel->getColumnCoord($cnt) .
"1");
709 foreach ($mems as $user_id =>
$d) {
714 $excel->setCell($row, $col++,
$d[
"lastname"] .
", " .
$d[
"firstname"] .
" [" .
$d[
"login"] .
"]");
717 foreach ($ass_data as $ass) {
718 $excel->setCell($row, $col++, $ass->getMemberStatus($user_id)->getMark());
726 $excel->sendToClient($exc_name);
734 $user_ids = $a_user_id;
735 if (!is_array($user_ids)) {
736 $user_ids = array($user_ids);
739 $type = (bool) $a_is_text_feedback
744 $not->setType(
$type);
745 $not->setAssignmentId($a_ass_id);
746 $not->setObjId($this->
getId());
750 $not->setRecipients($user_ids);
778 $this->completion_by_submission = (bool) $bool;
785 $a_has_submitted = (bool) $a_has_submitted;
787 foreach ($a_user_ids as $user_id) {
789 $member_status->setReturned($a_has_submitted);
790 $member_status->update();
797 foreach ($a_user_ids as $user_id) {
798 $status =
'notgraded';
799 if ($a_has_submitted) {
800 if (!is_array($a_valid_submissions) ||
801 $a_valid_submissions[$user_id]) {
807 $member_status->setStatus($status);
808 $member_status->update();
823 $ilDB = $DIC->database();
825 $set =
$ilDB->query(
"SELECT obj_id, status FROM exc_members" .
826 " WHERE usr_id = " .
$ilDB->quote($a_user_id,
"integer") .
827 " AND (status = " .
$ilDB->quote(
"passed",
"text") .
828 " OR status = " .
$ilDB->quote(
"failed",
"text") .
")");
831 while ($row =
$ilDB->fetchAssoc($set)) {
832 $all[$row[
"obj_id"]] = ($row[
"status"] ==
"passed");
846 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
857 $this->certificate_visibility = $a_value;
870 $affectedRows =
$ilDB->manipulateF(
871 "UPDATE exc_data SET certificate_visibility = %s WHERE obj_id = %s",
872 array(
'integer',
'integer'),
873 array($a_value, $this->
getId())
885 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
setActive($a_status)
Set active for object.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
getMemberStatus($a_user_id=null)
Stores object activation status of orgunit position settings.
static removeForObject($type, $id)
Remove all notifications for given object.
getPassMode()
Get pass mode (all | nr)
static deleteByParent($a_parent_id)
setNrMandatoryRandom($a_val)
Set number of mandatory assignments in random pass mode.
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.
static getInstance()
Get instance.
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 _getContainerSettings($a_id)
getNrMandatoryRandom()
Get number of mandatory assignments in random pass mode.
static getInstancesByExercise($a_exc_id)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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.
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.
__construct(Container $dic, ilPlugin $plugin)
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
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static _writeContainerSetting($a_id, $a_keyword, $a_value)
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
setPassNr($a_val)
Set number of assignments that must be passed to pass the exercise.