ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilScormLP.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "Services/Object/classes/class.ilObjectLP.php";
6 
14 class ilScormLP extends ilObjectLP
15 {
19  protected $precondition_cache = null;
20 
21  public static function getDefaultModes($a_lp_active)
22  {
23  return array(
26  );
27  }
28 
29  public function getDefaultMode()
30  {
32  }
33 
34  public function getValidModes()
35  {
36  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
37  $subtype = ilObjSAHSLearningModule::_lookupSubType($this->obj_id);
38  if ($subtype != "scorm2004") {
39  if ($this->checkSCORMPreconditions()) {
40  return array(ilLPObjSettings::LP_MODE_SCORM);
41  }
42 
43  include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfSCOs.php";
44  $collection = new ilLPCollectionOfSCOs($this->obj_id, ilLPObjSettings::LP_MODE_SCORM);
45  if (sizeof($collection->getPossibleItems())) {
48  }
50  } else {
51  if ($this->checkSCORMPreconditions()) {
52  return array(ilLPObjSettings::LP_MODE_SCORM,
54  }
55 
56  include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfSCOs.php";
57  $collection = new ilLPCollectionOfSCOs($this->obj_id, ilLPObjSettings::LP_MODE_SCORM);
58  if (sizeof($collection->getPossibleItems())) {
62  }
63 
66  }
67  }
68 
69  public function getCurrentMode()
70  {
71  if ($this->checkSCORMPreconditions()) {
73  }
74  return parent::getCurrentMode();
75  }
76 
81  protected function checkSCORMPreconditions()
82  {
83  if (!is_null($this->precondition_cache)) {
85  }
86 
87  $this->precondition_cache =
88  ilConditionHandler::getNumberOfConditionsOfTrigger('sahs', $this->obj_id) > 0 ?
89  true :
90  false;
92  }
93 
94  protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
95  {
96  global $DIC;
97  $ilDB = $DIC['ilDB'];
98 
99  // subtype
100  $types = array();
101  $set = $ilDB->query("SELECT id,c_type" .
102  " FROM sahs_lm" .
103  " WHERE " . $ilDB->in("id", $a_obj_ids, "", "integer"));
104  while ($row = $ilDB->fetchAssoc($set)) {
105  $types[$row["c_type"]][] = $row["id"];
106  }
107 
108  // 2004
109  if (isset($types["scorm2004"])) {
110  $set = $ilDB->query("SELECT obj_id" .
111  " FROM sahs_user" .
112  " WHERE " . $ilDB->in("obj_id", $types["scorm2004"], "", "integer") .
113  " AND user_id = " . $ilDB->quote($a_usr_id, "integer"));
114  while ($row = $ilDB->fetchAssoc($set)) {
115  $a_res[$row["obj_id"]] = true;
116  }
117  }
118 
119  // 1.2
120  if (isset($types["scorm"])) {
121  $set = $ilDB->query("SELECT obj_id" .
122  " FROM scorm_tracking" .
123  " WHERE " . $ilDB->in("obj_id", $types["scorm"], "", "integer") .
124  " AND user_id = " . $ilDB->quote($a_usr_id, "integer") .
125  " AND lvalue = " . $ilDB->quote("cmi.core.lesson_status", "text"));
126  while ($row = $ilDB->fetchAssoc($set)) {
127  $a_res[$row["obj_id"]] = true;
128  }
129  }
130  }
131 
132  public function getMailTemplateId()
133  {
134  include_once './Modules/ScormAicc/classes/class.ilScormMailTemplateLPContext.php';
136  }
137 }
global $DIC
Definition: saml.php:7
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
static isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
$row
global $ilDB
checkSCORMPreconditions()
static getNumberOfConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
static getDefaultModes($a_lp_active)