ILIAS  release_8 Revision v8.24
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}
Manages random mandatory assignments of an exercise (business logic)
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:62
static getInstancesByExercise(int $a_exc_id)
Class ilObjExercise.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$i
Definition: metadata.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...