ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilTestSkillEvaluationGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
38 {
40 
41  public const SKILL_PROFILE_PARAM = 'skill_profile';
42  public const CMD_SHOW = 'show';
43 
47 
48  protected bool $noSkillProfileOptionEnabled = false;
49  protected array $availableSkillProfiles = [];
50  protected array $available_skills = [];
52 
53  public function __construct(
54  private readonly ilObjTest $test_obj,
55  private readonly ilCtrlInterface $ctrl,
56  private readonly ilGlobalTemplateInterface $tpl,
57  private readonly ilLanguage $lng,
58  private readonly ilDBInterface $db,
59  private readonly TestLogger $logger,
60  private readonly SkillService $skills_service,
61  private readonly RequestDataCollector $testrequest
62  ) {
63  }
64 
69  {
70  return $this->questionList;
71  }
72 
76  public function setQuestionList($questionList)
77  {
78  $this->questionList = $questionList;
79  }
80 
85  {
87  }
88 
92  public function setObjectiveOrientedContainer($objectiveOrientedContainer)
93  {
94  $this->objectiveOrientedContainer = $objectiveOrientedContainer;
95  }
96 
97  public function executeCommand()
98  {
99  $cmd = $this->ctrl->getCmd(self::CMD_SHOW) . 'Cmd';
100  $this->$cmd();
101  }
102 
103  protected function init(bool $skill_profile_enabled): void
104  {
105  $this->testPassesSelector = new ilTestPassesSelector($this->db, $this->test_obj);
106  $this->testPassesSelector->setActiveId($this->testSession->getActiveId());
107  $this->testPassesSelector->setLastFinishedPass($this->testSession->getLastFinishedPass());
108 
109  $skillEvaluation = new ilTestSkillEvaluation(
110  $this->db,
111  $this->logger,
112  $this->test_obj->getTestId(),
113  $this->test_obj->getRefId(),
114  $this->skills_service->profile(),
115  $this->skills_service->personal()
116  );
117 
118  $skillEvaluation->setUserId($this->getTestSession()->getUserId());
119  $skillEvaluation->setActiveId($this->getTestSession()->getActiveId());
120 
121  $skillEvaluation->setNumRequiredBookingsForSkillTriggering(
122  $this->test_obj->getGlobalSettings()->getSkillTriggeringNumberOfAnswers()
123  );
124 
125  $skillEvaluation->init($this->getQuestionList());
126 
127  $availableSkillProfiles = $skillEvaluation->getAssignedSkillMatchingSkillProfiles();
129  $skillEvaluation->noProfileMatchingAssignedSkillExists($availableSkillProfiles)
130  );
131  $this->setAvailableSkillProfiles($availableSkillProfiles);
132 
133  // should be reportedPasses - yes - indeed, skill level status will not respect - avoid confuse here
134  $evaluationPasses = $this->testPassesSelector->getExistingPasses();
135 
136  $availableSkills = [];
137 
138  foreach ($evaluationPasses as $evalPass) {
139  $testResults = $this->test_obj->getTestResult($this->getTestSession()->getActiveId(), $evalPass, true);
140 
141  $skillEvaluation->setPass($evalPass);
142  $skillEvaluation->evaluate($testResults);
143 
144  if ($skill_profile_enabled && self::INVOLVE_SKILLS_BELOW_NUM_ANSWERS_BARRIER_FOR_GAP_ANALASYS) {
145  $skills = $skillEvaluation->getSkillsInvolvedByAssignment();
146  } else {
147  $skills = $skillEvaluation->getSkillsMatchingNumAnswersBarrier();
148  }
149 
150  $availableSkills = array_merge($availableSkills, $skills);
151  }
152 
153  $this->setAvailableSkills(array_values($availableSkills));
154  }
155 
156  private function showCmd()
157  {
158  $skill_profile_selected = $this->testrequest->isset(self::SKILL_PROFILE_PARAM);
159  $selected_skill_profile = $this->testrequest->int(self::SKILL_PROFILE_PARAM);
160 
161  $this->init($skill_profile_selected);
162 
163  $personal_skills_gui = new ilPersonalSkillsGUI();
164  $personal_skills_gui->setGapAnalysisActualStatusModePerObject(
165  $this->test_obj->getId(),
166  $this->lng->txt('tst_test_result')
167  );
168  $personal_skills_gui->setTriggerObjectsFilter([$this->test_obj->getId()]);
169  $personal_skills_gui->setHistoryView(true);
170  $personal_skills_gui->setProfileId($selected_skill_profile);
171 
172  $this->tpl->setContent(
173  $this->buildEvaluationToolbarGUI($selected_skill_profile)->getHTML()
174  . $personal_skills_gui->getGapAnalysisHTML(
175  $this->getTestSession()->getUserId(),
177  )
178  );
179  }
180 
181  private function buildEvaluationToolbarGUI(int $selectedSkillProfileId): ilTestSkillEvaluationToolbarGUI
182  {
183  if (!$this->noSkillProfileOptionEnabled && $selectedSkillProfileId === null) {
184  $selectedSkillProfileId = key($this->availableSkillProfiles) ?? 0;
185  }
186 
187  $gui = new ilTestSkillEvaluationToolbarGUI($this->ctrl, $this->lng);
188  $gui->setAvailableSkillProfiles($this->availableSkillProfiles);
189  $gui->setNoSkillProfileOptionEnabled($this->noSkillProfileOptionEnabled);
190  $gui->setSelectedEvaluationMode($selectedSkillProfileId);
191  $gui->build();
192  return $gui;
193  }
194 
195  public function setTestSession(ilTestSession $testSession): void
196  {
197  $this->testSession = $testSession;
198  }
199 
200  public function getTestSession(): ilTestSession
201  {
202  return $this->testSession;
203  }
204 
205  public function setNoSkillProfileOptionEnabled(bool $noSkillProfileOptionEnabled): void
206  {
207  $this->noSkillProfileOptionEnabled = $noSkillProfileOptionEnabled;
208  }
209 
210  public function setAvailableSkillProfiles(array $availableSkillProfiles): void
211  {
212  $this->availableSkillProfiles = $availableSkillProfiles;
213  }
214 
215  public function setAvailableSkills(array $availableSkills): void
216  {
217  $this->available_skills = $availableSkills;
218  }
219 }
setAvailableSkillProfiles(array $availableSkillProfiles)
setAvailableSkills(array $availableSkills)
__construct(private readonly ilObjTest $test_obj, private readonly ilCtrlInterface $ctrl, private readonly ilGlobalTemplateInterface $tpl, private readonly ilLanguage $lng, private readonly ilDBInterface $db, private readonly TestLogger $logger, private readonly SkillService $skills_service, private readonly RequestDataCollector $testrequest)
buildEvaluationToolbarGUI(int $selectedSkillProfileId)
init(bool $skill_profile_enabled)
setObjectiveOrientedContainer($objectiveOrientedContainer)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Personal skills GUI class.
setNoSkillProfileOptionEnabled(bool $noSkillProfileOptionEnabled)
ilTestObjectiveOrientedContainer $objectiveOrientedContainer
global $lng
Definition: privfeed.php:31
setTestSession(ilTestSession $testSession)