ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.MandatoryAssignmentsManager.php
Go to the documentation of this file.
1<?php
2
20
29{
30 protected \ilObjExercise $exc;
31 protected int $exc_id;
32 protected \ilObjUser $user;
37 protected array $assignments;
42
46 public function __construct(
49 ) {
50 $this->exc = $exc;
51 $this->exc_id = $this->exc->getId();
52 $this->rand_ass_manager = $rand_ass_manager;
53 $this->assignments = \ilExAssignment::getInstancesByExercise($exc->getId());
54
55 $this->set_to_mandatory_assignments = array_filter($this->assignments, function ($i) {
57 if ($i->getMandatory()) {
58 return true;
59 }
60 return false;
61 });
62 }
63
70 public function getMandatoryAssignmentsOfUser(
71 int $user_id
72 ): array {
73 if ($this->rand_ass_manager->isActivated()) {
74 return $this->rand_ass_manager->getMandatoryAssignmentsOfUser($user_id);
75 }
76 return array_map(function ($i) {
78 return $i->getId();
80 }
81
82 // Is assignment mandatory for a user?
83 public function isMandatoryForUser(int $ass_id, int $user_id): bool
84 {
85 return (in_array($ass_id, $this->getMandatoryAssignmentsOfUser($user_id)));
86 }
87}
__construct(int $id, int $exc_id, string $title, int $order_nr, int $type, string $instructions, bool $mandatory, int $deadline_mode, int $deadline, int $deadline2, int $relative_deadline, int $rel_deadline_last_submission)
Definition: Assignment.php:41
Manages random mandatory assignments of an exercise (business logic)
static getInstancesByExercise(int $a_exc_id)
Class ilObjExercise.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))