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