19 declare(strict_types=1);
59 $this->skillLevelThresholdList->setTestId($test_id);
104 $this->skillQuestionAssignmentList->setParentObjId($questionList->
getParentObjId());
105 $this->skillQuestionAssignmentList->loadFromDb();
107 $this->skillLevelThresholdList->loadFromDb();
115 public function evaluate(array $test_results): void
132 $this->reachedPointsByQuestion = [];
133 $this->skillPointAccounts = [];
134 $this->reachedSkillLevels = [];
140 $this->questions[] = $questionData[
'question_id'];
142 $this->maxPointsByQuestion[ $questionData[
'question_id'] ] = $questionData[
'points'];
151 foreach ($testResults as $key => $result) {
152 if ($key ===
'pass' || $key ===
'test') {
156 $this->reachedPointsByQuestion[ $result[
'qid'] ] = $result[
'reached'];
162 foreach ($this->questions as $question_id) {
167 $assignments = $this->skillQuestionAssignmentList->getAssignmentsByQuestionId($question_id);
169 foreach ($assignments as $assignment) {
170 if ($assignment->hasEvalModeBySolution()) {
172 $assignment->getSolutionComparisonExpressionList()
175 $maxTestPoints = $this->maxPointsByQuestion[$question_id];
176 $reachedTestPoints = $this->reachedPointsByQuestion[$question_id];
179 $assignment->getSkillPoints(),
186 $assignment->getSkillBaseId(),
187 $assignment->getSkillTrefId(),
188 $assignment->getMaxSkillPoints(),
189 $reached_skill_points
197 return isset($this->reachedPointsByQuestion[$questionId]);
204 $question_provider->setQuestionId($expression_list->
getQuestionId());
206 foreach ($expression_list->
get() as $expression) {
208 $expression->getExpression()
216 if ($composite_evaluator->evaluate($condition_composite)) {
217 return $expression->getPoints();
226 if ($reached_test_points < 0) {
227 $reached_test_points = 0;
232 if ($max_test_points > 0) {
233 $factor = $reached_test_points / $max_test_points;
236 return ($skill_points * $factor);
241 $skill_key = $skill_base_id .
':' . $skill_tref_id;
243 if (!isset($this->skillPointAccounts[$skill_key])) {
247 $this->skillPointAccounts[$skill_key]->addBooking($max_skill_points, $reached_skill_points);
252 foreach ($this->skillPointAccounts as $skill_key => $skill_point_account) {
257 list($skill_base_id, $skill_tref_id) = explode(
':', $skill_key);
260 $levels = $skill->getLevelData();
262 $reached_level_id =
null;
263 foreach ($levels as $level) {
264 $threshold = $this->skillLevelThresholdList->getThreshold($skill_base_id, $skill_tref_id, $level[
'id']);
270 if ($skill_point_account->getTotalReachedSkillPercent() < $threshold->getThreshold()) {
274 $reached_level_id = $level[
'id'];
277 $this->reachedSkillLevels[] = [
278 'sklBaseId' => $skill_base_id,
'sklTrefId' => $skill_tref_id,
'sklLevelId' => $reached_level_id
293 if ($reachedSkillLevel[
'sklTrefId'] > 0) {
294 $this->skill_personal_service->addPersonalSkill($this->
getUserId(), (
int) $reachedSkillLevel[
'sklTrefId']);
296 $this->skill_personal_service->addPersonalSkill($this->
getUserId(), (
int) $reachedSkillLevel[
'sklBaseId']);
300 $this->skill_profile_service->writeCompletionEntryForAllProfiles($this->
getUserId());
317 "refId={$this->refId} / usrId={$this->getUserId()} / levelId={$skillLevelId} / trefId={$skillTrefId}" 323 $skillsMatchingNumAnswersBarrier = [];
325 foreach ($this->skillPointAccounts as $skillKey => $skillPointAccount) {
327 list($skillBaseId, $skillTrefId) = explode(
':', $skillKey);
329 $skillsMatchingNumAnswersBarrier[$skillKey] = [
330 'base_skill_id' => (
int) $skillBaseId,
331 'tref_id' => (
int) $skillTrefId
336 return $skillsMatchingNumAnswersBarrier;
343 foreach ($this->skillQuestionAssignmentList->getUniqueAssignedSkills() as $skill) {
344 $skillKey = $skill[
'skill_base_id'] .
':' . $skill[
'skill_tref_id'];
346 $uniqueSkills[$skillKey] = [
347 'base_skill_id' => (
int) $skill[
'skill_base_id'],
348 'tref_id' => (
int) $skill[
'skill_tref_id']
352 return $uniqueSkills;
357 $this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId);
362 $matchingSkillProfiles = [];
364 $usersProfiles = $this->skill_profile_service->getProfilesOfUser($this->
getUserId());
366 foreach ($usersProfiles as $profileData) {
367 $assignedSkillLevels = $this->skill_profile_service->getSkillLevels($profileData->getId());
369 foreach ($assignedSkillLevels as $assignedSkillLevel) {
370 $skillBaseId = $assignedSkillLevel->getBaseSkillId();
371 $skillTrefId = $assignedSkillLevel->getTrefId();
373 if ($this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId)) {
374 $matchingSkillProfiles[$profileData->getId()] = $profileData->getTitle();
379 return $matchingSkillProfiles;
384 $noProfileMatchingSkills = $this->skillQuestionAssignmentList->getUniqueAssignedSkills();
386 foreach ($availableSkillProfiles as $skillProfileId => $skillProfileTitle) {
387 $profile = $this->skill_profile_service->getProfile($skillProfileId);
388 $assignedSkillLevels = $this->skill_profile_service->getSkillLevels($profile->getId());
390 foreach ($assignedSkillLevels as $assignedSkillLevel) {
391 $skillBaseId = $assignedSkillLevel->getBaseSkillId();
392 $skillTrefId = $assignedSkillLevel->getTrefId();
394 if ($this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId)) {
395 unset($noProfileMatchingSkills[
"{$skillBaseId}:{$skillTrefId}"]);
400 return $noProfileMatchingSkills !== [];
init(ilAssQuestionList $questionList)
evaluateSkillPointAccounts()
setNumRequiredBookingsForSkillTriggering(int $numRequiredBookingsForSkillTriggering)
__construct(private ilDBInterface $db, private TestLogger $logger, int $test_id, private int $refId, private SkillProfileService $skill_profile_service, private SkillPersonalService $skill_personal_service)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilAssQuestionSkillAssignmentList $skillQuestionAssignmentList
determineReachedSkillPointsWithSolutionCompare(ilAssQuestionSolutionComparisonExpressionList $expression_list)
invokeSkillLevelTrigger(int $skillLevelId, int $skillTrefId)
getAssignedSkillMatchingSkillProfiles()
isAnsweredQuestion($questionId)
calculateReachedSkillPointsFromTestPoints($skill_points, $max_test_points, $reached_test_points)
int $numRequiredBookingsForSkillTriggering
ilTestSkillLevelThresholdList $skillLevelThresholdList
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isAssignedSkill($skillBaseId, $skillTrefId)
initTestResultData($testResults)
array $reachedPointsByQuestion
bookToSkillPointAccount($skill_base_id, $skill_tref_id, $max_skill_points, $reached_skill_points)
static writeUserSkillLevelStatus(int $a_level_id, int $a_user_id, int $a_trigger_ref_id, int $a_tref_id=0, int $a_status=ilBasicSkill::ACHIEVED, bool $a_force=false, bool $a_self_eval=false, string $a_unique_identifier="", float $a_next_level_fulfilment=0.0, string $trigger_user_id="")
evaluate(array $test_results)
drawUpSkillPointAccounts()
getNumRequiredBookingsForSkillTriggering()
array $maxPointsByQuestion
array $skillPointAccounts
getSkillsInvolvedByAssignment()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initTestQuestionData(ilAssQuestionList $questionList)
doesNumBookingsExceedRequiredBookingsBarrier(ilTestSkillPointAccount $skillPointAccount)
noProfileMatchingAssignedSkillExists(array $availableSkillProfiles)
array $reachedSkillLevels
getSkillsMatchingNumAnswersBarrier()