19 declare(strict_types=1);
59 $this->skill_level_threshold_list->setTestId($test_id);
104 $this->skill_question_assignment_list->setParentObjId($question_list->
getParentObjId());
105 $this->skill_question_assignment_list->loadFromDb();
107 $this->skill_level_threshold_list->loadFromDb();
115 public function evaluate(array $test_results): void
132 $this->reached_points_by_question = [];
133 $this->skill_point_accounts = [];
134 $this->reached_skill_levels = [];
140 $this->questions[] = $question_data[
'question_id'];
141 $this->max_points_by_question[ $question_data[
'question_id'] ] = $question_data[
'points'];
147 foreach ($test_results as $key => $result) {
148 if ($key ===
'pass' || $key ===
'test') {
152 $this->reached_points_by_question[ $result[
'qid'] ] = $result[
'reached'];
158 foreach ($this->questions as $question_id) {
163 $assignments = $this->skill_question_assignment_list->getAssignmentsByQuestionId($question_id);
165 foreach ($assignments as $assignment) {
166 if ($assignment->hasEvalModeBySolution()) {
168 $assignment->getSolutionComparisonExpressionList()
171 $max_test_points = $this->max_points_by_question[$question_id];
172 $reached_test_points = $this->reached_points_by_question[$question_id];
174 $assignment->getSkillPoints(),
181 $assignment->getSkillBaseId(),
182 $assignment->getSkillTrefId(),
183 $assignment->getMaxSkillPoints(),
184 $reached_skill_points
192 return isset($this->reached_points_by_question[$question_id]);
199 $question_provider->setQuestionId($expression_list->
getQuestionId());
201 foreach ($expression_list->
get() as $expression) {
203 $expression->getExpression()
211 if ($composite_evaluator->evaluate($condition_composite)) {
212 return $expression->getPoints();
221 float $max_test_points,
222 float $reached_test_points
224 if ($reached_test_points < 0) {
225 $reached_test_points = 0;
230 if ($max_test_points > 0) {
231 $factor = $reached_test_points / $max_test_points;
234 return ($skill_points * $factor);
240 int $max_skill_points,
241 float $reached_skill_points
243 $skill_key = $skill_base_id .
':' . $skill_tref_id;
245 if (!isset($this->skill_point_accounts[$skill_key])) {
249 $this->skill_point_accounts[$skill_key]->addBooking($max_skill_points, $reached_skill_points);
254 foreach ($this->skill_point_accounts as $skill_key => $skill_point_account) {
259 list($skill_base_id, $skill_tref_id) = explode(
':', $skill_key);
262 $levels = $skill->getLevelData();
264 $reached_level_id =
null;
265 foreach ($levels as $level) {
266 $threshold = $this->skill_level_threshold_list->getThreshold($skill_base_id, $skill_tref_id, $level[
'id']);
272 if ($skill_point_account->getTotalReachedSkillPercent() < $threshold->getThreshold()) {
276 $reached_level_id = $level[
'id'];
279 $this->reached_skill_levels[] = [
280 'sklBaseId' => $skill_base_id,
'sklTrefId' => $skill_tref_id,
'sklLevelId' => $reached_level_id
293 $this->
invokeSkillLevelTrigger((
int) $reached_skill_level[
'sklLevelId'], (
int) $reached_skill_level[
'sklTrefId']);
295 if ($reached_skill_level[
'sklTrefId'] > 0) {
296 $this->skill_personal_service->addPersonalSkill($this->
getUserId(), (
int) $reached_skill_level[
'sklTrefId']);
298 $this->skill_personal_service->addPersonalSkill($this->
getUserId(), (
int) $reached_skill_level[
'sklBaseId']);
302 $this->skill_profile_service->writeCompletionEntryForAllProfiles($this->
getUserId());
319 "refId={$this->refId} / usrId={$this->getUserId()} / levelId={$skill_level_id} / trefId={$skill_tref_id}" 325 $skills_matching_num_answers_barrier = [];
327 foreach ($this->skill_point_accounts as $skillKey => $skillPointAccount) {
329 list($skillBaseId, $skillTrefId) = explode(
':', $skillKey);
331 $skills_matching_num_answers_barrier[$skillKey] = [
332 'base_skill_id' => (
int) $skillBaseId,
333 'tref_id' => (
int) $skillTrefId
338 return $skills_matching_num_answers_barrier;
345 foreach ($this->skill_question_assignment_list->getUniqueAssignedSkills() as $skill) {
346 $skillKey = $skill[
'skill_base_id'] .
':' . $skill[
'skill_tref_id'];
348 $unique_skills[$skillKey] = [
349 'base_skill_id' => (
int) $skill[
'skill_base_id'],
350 'tref_id' => (
int) $skill[
'skill_tref_id']
354 return $unique_skills;
359 $this->skill_question_assignment_list->isAssignedSkill($skill_base_id, $skill_tref_id);
364 $matching_skill_profiles = [];
365 $users_profiles = $this->skill_profile_service->getProfilesOfUser($this->
getUserId());
366 foreach ($users_profiles as $profile_data) {
367 $assigned_skill_levels = $this->skill_profile_service->getSkillLevels($profile_data->getId());
369 foreach ($assigned_skill_levels as $assigned_skill_level) {
370 $skill_base_id = $assigned_skill_level->getBaseSkillId();
371 $skill_tref_id = $assigned_skill_level->getTrefId();
373 if ($this->skill_question_assignment_list->isAssignedSkill($skill_base_id, $skill_tref_id)) {
374 $matching_skill_profiles[$profile_data->getId()] = $profile_data->getTitle();
379 return $matching_skill_profiles;
384 $no_profile_matching_skills = $this->skill_question_assignment_list->getUniqueAssignedSkills();
386 foreach (array_keys($available_skill_profiles) as $skill_profile_id) {
387 $assigned_skill_levels = $this->skill_profile_service->getSkillLevels(
388 $this->skill_profile_service->getProfile($skill_profile_id)->getId()
391 foreach ($assigned_skill_levels as $assigned_skill_level) {
392 $skill_base_id = $assigned_skill_level->getBaseSkillId();
393 $skill_tref_id = $assigned_skill_level->getTrefId();
395 if ($this->skill_question_assignment_list->isAssignedSkill($skill_base_id, $skill_tref_id)) {
396 unset($no_profile_matching_skills[
"{$skill_base_id}:{$skill_tref_id}"]);
401 return $no_profile_matching_skills !== [];
evaluateSkillPointAccounts()
initTestQuestionData(ilAssQuestionList $question_list)
__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 $skill_question_assignment_list
array $reached_points_by_question
determineReachedSkillPointsWithSolutionCompare(ilAssQuestionSolutionComparisonExpressionList $expression_list)
getAssignedSkillMatchingSkillProfiles()
invokeSkillLevelTrigger(int $skill_level_id, int $skill_tref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
array $reached_skill_levels
array $max_points_by_question
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="")
ilTestSkillLevelThresholdList $skill_level_threshold_list
evaluate(array $test_results)
drawUpSkillPointAccounts()
bookToSkillPointAccount(int $skill_base_id, int $skill_tref_id, int $max_skill_points, float $reached_skill_points)
getNumRequiredBookingsForSkillTriggering()
init(ilAssQuestionList $question_list)
int $num_required_bookings_for_skill_triggering
getSkillsInvolvedByAssignment()
calculateReachedSkillPointsFromTestPoints(int $skill_points, float $max_test_points, float $reached_test_points)
array $skill_point_accounts
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setActiveId(int $active_id)
doesNumBookingsExceedRequiredBookingsBarrier(ilTestSkillPointAccount $skillPointAccount)
noProfileMatchingAssignedSkillExists(array $available_skill_profiles)
initTestResultData(array $test_results)
getSkillsMatchingNumAnswersBarrier()
setNumRequiredBookingsForSkillTriggering(int $num_required_bookings_for_skill_triggering)
isAnsweredQuestion(int $question_id)
isAssignedSkill($skill_base_id, $skill_tref_id)