ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCORM2004Sco.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
6 
18 {
19  protected $hide_obj_page = false;
20 
26  public function __construct($a_slm_object, $a_id = 0)
27  {
28  global $DIC;
29 
30  $this->db = $DIC->database();
31  parent::__construct($a_slm_object, $a_id);
32  $this->setType("sco");
33  }
34 
38  public function setHideObjectivePage($a_val)
39  {
40  $this->hide_obj_page = $a_val;
41  }
42 
46  public function getHideObjectivePage()
47  {
48  return $this->hide_obj_page;
49  }
50 
54  public function create($a_upload = false, $a_template = false)
55  {
56  $ilDB = $this->db;
57 
58  parent::create($a_upload, $a_template);
59  if (!$a_template) {
60  $obj = new ilSCORM2004Objective($this->getId());
61  // $obj->setObjectiveID("Objective SCO ".$this->getId());
62  $obj->setId("local_obj_" . $this->getID() . "_0");
63  $obj->update();
64  }
65  $ilDB->manipulate("INSERT INTO sahs_sc13_sco " .
66  "(id, hide_obj_page) VALUES (" .
67  $ilDB->quote($this->getId(), "integer") . "," .
68  $ilDB->quote($this->getHideObjectivePage(), "integer") .
69  ")");
70  }
71 
72 
73 
77  public function read()
78  {
79  $ilDB = $this->db;
80 
81  parent::read();
82  $set = $ilDB->query(
83  "SELECT * FROM sahs_sc13_sco WHERE " .
84  " id = " . $ilDB->quote($this->getId(), "integer")
85  );
86  $rec = $ilDB->fetchAssoc($set);
87  $this->setHideObjectivePage($rec["hide_obj_page"]);
88  }
89 
93  public function update()
94  {
95  $ilDB = $this->db;
96 
98  $ilDB->manipulate(
99  "UPDATE sahs_sc13_sco SET " .
100  " hide_obj_page = " . $ilDB->quote($this->getHideObjectivePage(), "integer") .
101  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
102  );
103  }
104 
108  public function delete($a_delete_meta_data = true)
109  {
110  $ilDB = $this->db;
111 
112  parent::delete($a_delete_meta_data);
113  $ilDB->manipulate(
114  "DELETE FROM sahs_sc13_sco WHERE "
115  . " id = " . $ilDB->quote($this->getId(), "integer")
116  );
117  }
118 
122  public function copy($a_target_slm)
123  {
124  $sco = new ilSCORM2004Sco($a_target_slm);
125  $sco->setTitle($this->getTitle());
126  $sco->setHideObjectivePage($this->getHideObjectivePage());
127  if ($this->getSLMId() != $a_target_slm->getId()) {
128  $sco->setImportId("il__sco_" . $this->getId());
129  }
130  $sco->setSLMId($a_target_slm->getId());
131  $sco->setType($this->getType());
132  $sco->setDescription($this->getDescription());
133  $sco->create(true);
134  $a_copied_nodes[$this->getId()] = $sco->getId();
135 
136  // copy meta data
137  include_once("Services/MetaData/classes/class.ilMD.php");
138  $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
139  $new_md = $md->cloneMD($a_target_slm->getId(), $sco->getId(), $this->getType());
140 
141  return $sco;
142  }
143 
149  public function getMainObjectiveText()
150  {
151  $objectives = $this->getObjectives();
152 
153  foreach ($objectives as $ob) {
154  // map info
155  $mappings = $ob->getMappings();
156  $mapinfo = null;
157  foreach ($mappings as $map) {
158  $mapinfo .= $map->getTargetObjectiveID();
159  }
160 
161  if ($mapinfo == null) {
162  $mapinfo = "local";
163  } else {
164  $mapinfo = "global to " . $mapinfo;
165  }
166 
167  if ($mapinfo == "local") {
168  return $ob->getObjectiveID();
169  }
170  }
171  }
172 }
getMainObjectiveText()
Get main objective.
Class ilSCORM2004Sco.
global $DIC
Definition: saml.php:7
getSLMId()
Get ID of parent Scorm Learning Module Object.
create($a_upload=false, $a_template=false)
Create sco.
getDescription()
Get description.
__construct($a_slm_object, $a_id=0)
Constructor.
copy($a_target_slm)
Copy sco.
update($pash, $contents, Config $config)
setHideObjectivePage($a_val)
Set hide objective page.
read()
Read data from database.
global $ilDB
Class ilSCORM2004Asset.
getHideObjectivePage()
Get hide objective page.
setType($a_type)
Set type.
Class ilSCORM2004Objective.