4 require_once
'Modules/Test/classes/class.ilTestSkillQuestionAssignmentList.php';
5 require_once
'Modules/Test/classes/class.ilTestSkillLevelThresholdList.php';
6 require_once
'Services/Skill/classes/class.ilBasicSkill.php';
67 $this->skillQuestionAssignmentList->setTestId($this->testOBJ->getTestId());
70 $this->skillLevelThresholdList->setTestId($this->testOBJ->getTestId());
72 $this->questions = array();
73 $this->maxPointsByQuestion = array();
78 $this->skillQuestionAssignmentList->loadFromDb();
79 $this->skillLevelThresholdList->loadFromDb();
110 $this->reachedPointsByQuestion = array();
111 $this->skillPointAccounts = array();
112 $this->reachedSkillLevels = array();
117 foreach($this->testOBJ->getTestQuestions() as $question)
119 $this->questions[] = $question[
'question_id'];
121 $this->maxPointsByQuestion[ $question[
'question_id'] ] = $question[
'points'];
127 $testResults = $this->testOBJ->getTestResult($activeId,
$pass,
true);
128 foreach($testResults as $key =>
$result)
130 if($key ===
'pass' || $key ===
'test')
135 $this->reachedPointsByQuestion[
$result[
'qid'] ] = $result[
'reached'];
141 foreach($this->questions as $questionId)
143 $maxTestPoints = $this->maxPointsByQuestion[$questionId];
144 $reachedTestPoints = $this->reachedPointsByQuestion[$questionId];
146 $assignments = $this->skillQuestionAssignmentList->getAssignmentsByQuestionId($questionId);
148 foreach($assignments as $assignment)
151 $assignment->getSkillPoints(), $maxTestPoints, $reachedTestPoints
155 $assignment->getSkillBaseId(), $assignment->getSkillTrefId(), $reachedSkillPoints
163 if( $reachedTestPoints < 0 )
165 $reachedTestPoints = 0;
170 if( $maxTestPoints > 0 )
172 $factor = $reachedTestPoints / $maxTestPoints;
175 return ($skillPoints * $factor);
180 $skillKey = $skillBaseId.
':'.$skillTrefId;
182 if( !isset($this->skillPointAccounts[$skillKey]) )
184 $this->skillPointAccounts[$skillKey] = 0;
187 $this->skillPointAccounts[$skillKey] += $reachedSkillPoints;
192 foreach($this->skillPointAccounts as $skillKey => $skillPoints)
194 list($skillBaseId, $skillTrefId) = explode(
':', $skillKey);
197 $levels = $skill->getLevelData();
199 $reachedLevelId = null;
201 foreach($levels as $level)
203 $threshold = $this->skillLevelThresholdList->getThreshold($skillBaseId, $skillTrefId, $level[
'id']);
210 $reachedLevelId = $level[
'id'];
212 if( $skillPoints <= $threshold->getThreshold() )
218 if( $reachedLevelId )
220 $this->reachedSkillLevels[] = array(
221 'usrId' => $userId,
'sklBaseId' => $skillBaseId,
222 'sklTrefId' => $skillTrefId,
'sklLevelId' => $reachedLevelId
233 $reachedSkillLevel[
'usrId'], $reachedSkillLevel[
'sklBaseId'],
234 $reachedSkillLevel[
'sklTrefId'], $reachedSkillLevel[
'sklLevelId']
250 $reachedLevels = array();
254 $reachedLevels[$reachedLevel[
'sklBaseId']] = array(
255 $reachedLevel[
'sklTrefId'] => $reachedLevel[
'sklLevelId']
259 return $reachedLevels;
264 $uniqueSkills = array();
266 foreach($this->skillQuestionAssignmentList->getUniqueAssignedSkills() as $skill)
268 $uniqueSkills[] = array(
269 'base_skill_id' => (
int)$skill[
'skill_base_id'],
270 'tref_id' => (
int)$skill[
'skill_tref_id']
274 return $uniqueSkills;
279 $this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId);
284 $matchingSkillProfiles = array();
286 include_once(
"./Services/Skill/classes/class.ilSkillProfile.php");
289 foreach ($usersProfiles as $profileData)
292 $assignedSkillLevels = $profile->getSkillLevels();
294 foreach($assignedSkillLevels as $assignedSkillLevel)
296 $skillBaseId = $assignedSkillLevel[
'base_skill_id'];
297 $skillTrefId = $assignedSkillLevel[
'tref_id'];
299 if( $this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId) )
301 $matchingSkillProfiles[$profileData[
'id']] = $profile->getTitle();
306 return $matchingSkillProfiles;
311 $noProfileMatchingSkills = $this->skillQuestionAssignmentList->getUniqueAssignedSkills();
313 foreach($availableSkillProfiles as $skillProfileId => $skillProfileTitle)
316 $assignedSkillLevels = $profile->getSkillLevels();
318 foreach($assignedSkillLevels as $assignedSkillLevel)
320 $skillBaseId = $assignedSkillLevel[
'base_skill_id'];
321 $skillTrefId = $assignedSkillLevel[
'tref_id'];
323 if( $this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId) )
325 unset($noProfileMatchingSkills[
"{$skillBaseId}:{$skillTrefId}"]);
330 return count($noProfileMatchingSkills);