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