ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilScormLP.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27class ilScormLP extends ilObjectLP
28{
29 protected ?bool $precondition_cache = null;
30
34 public static function getDefaultModes(bool $a_lp_active): array
35 {
36 return array(
39 );
40 }
41
42 public function getDefaultMode(): int
43 {
45 }
46
47 public function getValidModes(): array
48 {
49 $subtype = ilObjSAHSLearningModule::_lookupSubType($this->obj_id);
50 if ($subtype !== 'scorm2004') {
51 if ($this->checkSCORMPreconditions()) {
53 }
54
55 $collection = new ilLPCollectionOfSCOs($this->obj_id, ilLPObjSettings::LP_MODE_SCORM);
56 if (count($collection->getPossibleItems()) > 0) {
57 return [
60 ];
61 }
62
64 }
65
66 if ($this->checkSCORMPreconditions()) {
67 return [
70 ];
71 }
72
73 $collection = new ilLPCollectionOfSCOs($this->obj_id, ilLPObjSettings::LP_MODE_SCORM);
74 if (count($collection->getPossibleItems()) > 0) {
75 return [
79 ];
80 }
81
82 return [
85 ];
86 }
87
92 public function getCurrentMode(): int
93 {
94 // if ($this->checkSCORMPreconditions()) {
95 // return ilLPObjSettings::LP_MODE_SCORM;
96 // }
97 return parent::getCurrentMode();
98 }
99
100 protected function checkSCORMPreconditions(): bool
101 {
102 if (is_bool($this->precondition_cache)) {
104 }
105
106 $this->precondition_cache = ilConditionHandler::getNumberOfConditionsOfTrigger(
107 'sahs',
108 $this->obj_id
109 ) > 0;
110
112 }
113
114 protected static function isLPMember(array &$a_res, int $a_usr_id, array $a_obj_ids): bool
115 {
116 global $DIC;
117
118 $ilDB = $DIC->database();
119
120 // subtype
121 $types = array();
122 $set = $ilDB->query("SELECT id,c_type" .
123 " FROM sahs_lm" .
124 " WHERE " . $ilDB->in("id", $a_obj_ids, false, "integer"));
125 while ($row = $ilDB->fetchAssoc($set)) {
126 $types[$row["c_type"]][] = $row["id"];
127 }
128
129 // 2004
130 if (isset($types["scorm2004"])) {
131 $set = $ilDB->query("SELECT obj_id" .
132 " FROM sahs_user" .
133 " WHERE " . $ilDB->in("obj_id", $types["scorm2004"], false, "integer") .
134 " AND user_id = " . $ilDB->quote($a_usr_id, "integer"));
135 while ($row = $ilDB->fetchAssoc($set)) {
136 return true;
137 }
138 }
139
140 // 1.2
141 if (isset($types["scorm"])) {
142 $set = $ilDB->query("SELECT obj_id" .
143 " FROM scorm_tracking" .
144 " WHERE " . $ilDB->in("obj_id", $types["scorm"], false, "integer") .
145 " AND user_id = " . $ilDB->quote($a_usr_id, "integer") .
146 " AND lvalue = " . $ilDB->quote("cmi.core.lesson_status", "text"));
147 while ($row = $ilDB->fetchAssoc($set)) {
148 return true;
149 }
150 }
151 return false;
152 }
153
154 public function getMailTemplateId(): string
155 {
157 }
158}
static getNumberOfConditionsOfTrigger(string $a_trigger_obj_type, int $a_trigger_id)
get all conditions of trigger object
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
Base class for object lp connectors.
static getDefaultModes(bool $a_lp_active)
static isLPMember(array &$a_res, int $a_usr_id, array $a_obj_ids)
Find (lp-relevant) members for given object ids.
bool $precondition_cache
getCurrentMode()
AK, 14Sep2018: This looks strange, the mode is auto-activated if this object is used as a preconditio...
global $DIC
Definition: shib_login.php:26