Skip to content

Commit

Permalink
Tracking: Adds LP percentage support for LP MODE COLLECTION
Browse files Browse the repository at this point in the history
  • Loading branch information
chlulei committed Nov 20, 2024
1 parent 0e06d38 commit db64b80
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
28 changes: 15 additions & 13 deletions components/ILIAS/Tracking/classes/class.ilLPTableBaseGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,19 +758,21 @@ protected function isPercentageAvailable(int $a_obj_id): bool
$mode = $olp->getCurrentMode();
if (in_array(
$mode,
array(ilLPObjSettings::LP_MODE_TLT,
ilLPObjSettings::LP_MODE_VISITS,
ilLPObjSettings::LP_MODE_SCORM,
ilLPObjSettings::LP_MODE_LTI_OUTCOME,
ilLPObjSettings::LP_MODE_CMIX_COMPLETED,
ilLPObjSettings::LP_MODE_CMIX_COMPL_WITH_FAILED,
ilLPObjSettings::LP_MODE_CMIX_PASSED,
ilLPObjSettings::LP_MODE_CMIX_PASSED_WITH_FAILED,
ilLPObjSettings::LP_MODE_CMIX_COMPLETED_OR_PASSED,
ilLPObjSettings::LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED,
ilLPObjSettings::LP_MODE_VISITED_PAGES,
ilLPObjSettings::LP_MODE_TEST_PASSED
)
[
ilLPObjSettings::LP_MODE_TLT,
ilLPObjSettings::LP_MODE_VISITS,
ilLPObjSettings::LP_MODE_SCORM,
ilLPObjSettings::LP_MODE_LTI_OUTCOME,
ilLPObjSettings::LP_MODE_CMIX_COMPLETED,
ilLPObjSettings::LP_MODE_CMIX_COMPL_WITH_FAILED,
ilLPObjSettings::LP_MODE_CMIX_PASSED,
ilLPObjSettings::LP_MODE_CMIX_PASSED_WITH_FAILED,
ilLPObjSettings::LP_MODE_CMIX_COMPLETED_OR_PASSED,
ilLPObjSettings::LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED,
ilLPObjSettings::LP_MODE_VISITED_PAGES,
ilLPObjSettings::LP_MODE_TEST_PASSED,
ilLPObjSettings::LP_MODE_COLLECTION
]
)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,21 @@ public static function _lookupInProgressForObject(
$a_user_ids
);
}

public function determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj = null): int
{
$status_info = self::_getStatusInfo($a_obj_id);
if (empty($status_info)) {
return 0;
}
$passed = 0;
foreach ($status_info['collections'] as $item_ref_id) {
$obj_id = ilObject::_lookupObjId($item_ref_id);
if (ilLPStatusWrapper::_determineStatus($obj_id, $a_usr_id) === self::LP_STATUS_COMPLETED_NUM) {
$passed++;
}
}
$percentage = (int) ((100.0 / $status_info["num_collections"]) * $passed);
return $percentage;
}
}

0 comments on commit db64b80

Please sign in to comment.