ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.SkillUserLevelManager.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 namespace ILIAS\Skill\Level;
23 
29 {
30  protected \ilSkillLevelRepository $level_repo;
31  protected \ilSkillUserLevelRepository $user_level_repo;
32  protected \ilSkillObjectAdapterInterface $obj_adapter;
33 
34  public function __construct(
35  \ilSkillLevelRepository $a_level_repo = null,
36  \ilSkillUserLevelRepository $a_user_level_repo = null,
37  \ilSkillObjectAdapterInterface $a_obj_adapter = null
38  ) {
39  global $DIC;
40 
41  $this->level_repo = ($a_level_repo) ?: $DIC->skills()->internal()->repo()->getLevelRepo();
42  $this->user_level_repo = ($a_user_level_repo) ?: $DIC->skills()->internal()->repo()->getUserLevelRepo();
43  $this->obj_adapter = ($a_obj_adapter) ?: new \ilSkillObjectAdapter();
44  }
45 
46  public function writeSkillLevel(
47  int $user_id,
48  int $a_level_id,
49  int $a_trigger_ref_id,
50  int $a_tref_id,
51  bool $a_self_eval,
52  string $a_unique_identifier,
53  float $a_next_level_fulfilment
54  ): void {
55  $skill_id = $this->level_repo->lookupLevelSkillId($a_level_id);
56  $trigger_ref_id = $a_trigger_ref_id;
57  $trigger_obj_id = $this->obj_adapter->getObjIdForRefId($trigger_ref_id);
58  $trigger_title = $this->obj_adapter->getTitleForObjId($trigger_obj_id);
59  $trigger_type = $this->obj_adapter->getTypeForObjId($trigger_obj_id);
60 
61  //next level percentage fulfilment value must be >=0 and <1
62  if (!($a_next_level_fulfilment >= 0) || !($a_next_level_fulfilment < 1)) {
63  throw new \UnexpectedValueException(
64  "Next level fulfilment must be equal to or greater than 0 and less than 1, '" .
65  $a_next_level_fulfilment . "' given."
66  );
67  }
68 
69  $status_date = "";
70  $update = false;
71 
72  // self evaluations will update, if the last self evaluation is on the same day
73  if ($a_self_eval && $this->user_level_repo->hasRecentSelfEvaluation(
74  $trigger_obj_id,
75  $user_id,
76  $skill_id,
77  $a_tref_id,
78  $trigger_ref_id
79  )) {
80  $status_date = $this->user_level_repo->hasRecentSelfEvaluation(
81  $trigger_obj_id,
82  $user_id,
83  $skill_id,
84  $a_tref_id,
85  $trigger_ref_id
86  );
87  if ($status_date != "") {
88  $update = true;
89  }
90  }
91 
92  $this->user_level_repo->writeUserSkillLevelStatus(
93  $skill_id,
94  $trigger_ref_id,
95  $trigger_obj_id,
96  $trigger_title,
97  $trigger_type,
98  $update,
99  $status_date,
100  $a_level_id,
101  $user_id,
102  $a_tref_id,
103  $a_self_eval,
104  $a_unique_identifier,
105  $a_next_level_fulfilment
106  );
107  }
108 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(\ilSkillLevelRepository $a_level_repo=null, \ilSkillUserLevelRepository $a_user_level_repo=null, \ilSkillObjectAdapterInterface $a_obj_adapter=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
writeSkillLevel(int $user_id, int $a_level_id, int $a_trigger_ref_id, int $a_tref_id, bool $a_self_eval, string $a_unique_identifier, float $a_next_level_fulfilment)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...