3 declare(strict_types=0);
28 $all_page_ids = self::getLMPages($a_obj_id);
29 foreach (self::getVisitedPages(
31 ) as $user_id => $user_page_ids) {
32 if (!(
bool)
sizeof(array_diff($all_page_ids, $user_page_ids))) {
45 $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
49 $status = self::LP_STATUS_IN_PROGRESS_NUM;
51 if (self::hasVisitedAllPages($a_obj_id, $a_usr_id)) {
52 $status = self::LP_STATUS_COMPLETED_NUM;
66 $all_page_ids =
sizeof(self::getLMPages($a_obj_id));
70 $user_page_ids =
sizeof(self::getVisitedPages($a_obj_id, $a_usr_id));
71 return (
int) floor($user_page_ids / $all_page_ids * 100);
78 $all_page_ids = self::getLMPages($a_obj_id);
79 if (!
sizeof($all_page_ids)) {
82 $user_page_ids = self::getVisitedPages($a_obj_id, $a_user_id);
83 return !(bool) array_diff($all_page_ids, $user_page_ids);
86 protected static function getLMPages(
int $a_obj_id): array
95 "SELECT lm_data.obj_id" .
97 " JOIN lm_tree ON (lm_tree.child = lm_data.obj_id)" .
98 " WHERE lm_tree.lm_id = " .
$ilDB->quote($a_obj_id,
"integer") .
99 " AND lm_data.type = " .
$ilDB->quote(
"pg",
"text")
101 while ($row =
$ilDB->fetchAssoc($set)) {
112 ?
int $a_user_id = null
116 $ilDB = $DIC[
'ilDB'];
120 $all_page_ids = self::getLMPages($a_obj_id);
121 if (!
sizeof($all_page_ids)) {
125 $sql =
"SELECT obj_id, usr_id" .
126 " FROM lm_read_event" .
127 " WHERE " .
$ilDB->in(
"obj_id", $all_page_ids,
"",
"integer");
130 $sql .=
" AND usr_id = " .
$ilDB->quote($a_user_id,
"integer");
133 $set =
$ilDB->query($sql);
134 while ($row =
$ilDB->fetchAssoc($set)) {
135 $res[(
int) $row[
"usr_id"]][] = (
int) $row[
"obj_id"];
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static getLMPages(int $a_obj_id)
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
static getVisitedPages(int $a_obj_id, ?int $a_user_id=null)
static lookupUsersInProgress(int $a_obj_id)
static _getCompleted(int $a_obj_id)
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)
static hasVisitedAllPages(int $a_obj_id, int $a_user_id)
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getInProgress(int $a_obj_id)
static _lookupType(int $id, bool $reference=false)