ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHACPPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php");
25 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCObjectGUI.php");
26 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCPresentationGUI.php");
27 
28 
40 {
41  var $ilias;
42  var $slm;
43  var $tpl;
44  var $lng;
45 
47  {
48  global $ilias, $tpl, $lng, $ilCtrl;;
49 
50  $this->ilias =& $ilias;
51  $this->tpl =& $tpl;
52  $this->lng =& $lng;
53  $this->ctrl =& $ilCtrl;
54 
55  $cmd = (!empty($_GET["cmd"])) ? $_GET["cmd"] : "frameset";
56 
57  // Todo: check lm id
58  $this->slm =& new ilObjHACPLearningModule($_GET["ref_id"], true);
59  }
60 
64  function &executeCommand()
65  {
66  global $ilAccess, $ilLog;
67 
68  $next_class = $this->ctrl->getNextClass($this);
69  $cmd = $this->ctrl->getCmd("frameset");
70 
71  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))
72  {
73  $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->WARNING);
74  }
75 
76  switch($next_class)
77  {
78  default:
79  $this->$cmd();
80  }
81  }
82 
86  function explorer($a_target = "sahs_content")
87  {
88  $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
89 
90  require_once("./Modules/ScormAicc/classes/HACP/class.ilHACPExplorer.php");
91  $exp = new ilHACPExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
92  $exp->setTargetGet("obj_id");
93  $exp->setFrameTarget($a_target);
94  //$exp->setFiltered(true);
95 
96  if ($_GET["scexpand"] == "")
97  {
98  $mtree = new ilSCORMTree($this->slm->getId());
99  $expanded = $mtree->readRootId();
100  }
101  else
102  {
103  $expanded = $_GET["scexpand"];
104  }
105  $exp->setExpand($expanded);
106 
107  $exp->forceExpandAll(true, false);
108 
109  // build html-output
110  //666$exp->setOutput(0);
111  $exp->setOutput(0);
112 
113  $output = $exp->getOutput();
114 
115  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
116  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
117  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
118  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
119  $this->tpl->setVariable("EXPLORER",$output);
120  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, $_GET["cmd"])."&frame=".$_GET["frame"].
121  "&ref_id=".$this->slm->getRefId()."&scexpand=".$_GET["scexpand"]);
122  $this->tpl->parseCurrentBlock();
123  $this->tpl->show();
124  }
125 
126  function launchSahs()
127  {
128  echo "launchSahs";
129  exit;
130 
131  global $ilUser, $ilDB;
132 
133  $sahs_id = ($_GET["sahs_id"] == "")
134  ? $_POST["sahs_id"]
135  : $_GET["sahs_id"];
136  $ref_id = ($_GET["ref_id"] == "")
137  ? $_POST["ref_id"]
138  : $_GET["ref_id"];
139 
140  $this->slm =& new ilObjAICCLearningModule($ref_id, true);
141 
142  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
143  $unit =& new ilAICCUnit($sahs_id);
144 
145  //guess the url to be able to launch most contents
146  $url=$unit->getCommand_line();
147  if (strlen($url)==0)
148  $url=$unit->getFilename();
149  if (strcasecmp(substr($unit->getFilename(),0,4),"http")!=0)
150  $url=$unit->slm->getDataDirectory("output")."/".$url;
151  if (strlen($unit->getWebLaunch())>0)
152  $url.="?".$unit->getWebLaunch();
153 
154 /*
155  if (strcasecmp(substr($unit->getFilename(),0,4),"http")==0)
156  $href=$unit->getFilename();
157  else
158  $href=$this->slm->getDataDirectory("output")."/".$unit->getFilename();
159 */
160  $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
161  $this->tpl->setVariable("HREF", $url);
162 // $this->tpl->setVariable("LAUNCH_DATA", $unit->getDataFromLms());
163  $this->tpl->setVariable("MAST_SCORE", $unit->getMasteryScore());
164  $this->tpl->setVariable("MAX_TIME", $unit->getMaxTimeAllowed());
165  $this->tpl->setVariable("LIMIT_ACT", $unit->getTimeLimitAction());
166  if($ilUser->getFirstName() == "Joe") // for test purpose
167  {
168  $this->tpl->setCurrentBlock("credit");
169  $this->tpl->setVariable("CREDIT_MODE", "normal");
170  $this->tpl->parseCurrentBlock();
171  }
172  $query = "SELECT * FROM scorm_tracking WHERE".
173  " user_id = ".$ilDB->quote($ilUser->getId()).
174  " AND sco_id = ".$ilDB->quote($sahs_id).
175  " AND obj_id = ".$ilDB->quote($this->slm->getId());
176 
177 
178  $val_set = $ilDB->query($query);
179  $re_value = array();
180  while($val_rec = $val_set->fetchRow(DB_FETCHMODE_ASSOC))
181  {
182  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
183  $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
184  $val_rec["rvalue"] = str_replace("\n", "%n%", $val_rec["rvalue"]);
185  $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
186  }
187 
188  foreach($re_value as $var => $value)
189  {
190  switch ($var)
191  {
192  case "cmi.core.lesson_location":
193  case "cmi.core.lesson_status":
194  case "cmi.core.entry":
195  case "cmi.core.score.raw":
196  case "cmi.core.score.max":
197  case "cmi.core.score.min":
198  case "cmi.core.total_time":
199  case "cmi.core.exit":
200  case "cmi.suspend_data":
201  case "cmi.comments":
202  case "cmi.student_preference.audio":
203  case "cmi.student_preference.language":
204  case "cmi.student_preference.speed":
205  case "cmi.student_preference.text":
206  $this->setSingleVariable($var, $value);
207  break;
208 
209  case "cmi.objectives._count":
210  $this->setSingleVariable($var, $value);
211  $this->setArray("cmi.objectives", $value, "id", $re_value);
212  $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
213  $this->setArray("cmi.objectives", $value, "score.max", $re_value);
214  $this->setArray("cmi.objectives", $value, "score.min", $re_value);
215  $this->setArray("cmi.objectives", $value, "status", $re_value);
216  break;
217 
218  case "cmi.interactions._count":
219  $this->setSingleVariable($var, $value);
220  $this->setArray("cmi.interactions", $value, "id", $re_value);
221  for($i=0; $i<$value; $i++)
222  {
223  $var2 = "cmi.interactions.".$i.".objectives._count";
224  if (isset($v_array[$var2]))
225  {
226  $cnt = $v_array[$var2];
227  $this->setArray("cmi.interactions.".$i.".objectives",
228  $cnt, "id", $re_value);
229  /*
230  $this->setArray("cmi.interactions.".$i.".objectives",
231  $cnt, "score.raw", $re_value);
232  $this->setArray("cmi.interactions.".$i.".objectives",
233  $cnt, "score.max", $re_value);
234  $this->setArray("cmi.interactions.".$i.".objectives",
235  $cnt, "score.min", $re_value);
236  $this->setArray("cmi.interactions.".$i.".objectives",
237  $cnt, "status", $re_value);*/
238  }
239  }
240  $this->setArray("cmi.interactions", $value, "time", $re_value);
241  $this->setArray("cmi.interactions", $value, "type", $re_value);
242  for($i=0; $i<$value; $i++)
243  {
244  $var2 = "cmi.interactions.".$i.".correct_responses._count";
245  if (isset($v_array[$var2]))
246  {
247  $cnt = $v_array[$var2];
248  $this->setArray("cmi.interactions.".$i.".correct_responses",
249  $cnt, "pattern", $re_value);
250  $this->setArray("cmi.interactions.".$i.".correct_responses",
251  $cnt, "weighting", $re_value);
252  }
253  }
254  $this->setArray("cmi.interactions", $value, "student_response", $re_value);
255  $this->setArray("cmi.interactions", $value, "result", $re_value);
256  $this->setArray("cmi.interactions", $value, "latency", $re_value);
257  break;
258  }
259  }
260 
261  global $lng;
262  $this->tpl->setCurrentBlock("switch_icon");
263  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
264  $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
265  $this->tpl->setVariable("SCO_ALT",
266  $lng->txt("cont_status").": "
267  .$lng->txt("cont_sc_stat_running")
268  );
269  $this->tpl->parseCurrentBlock();
270 
271  // lesson mode
272  $lesson_mode = $this->slm->getDefaultLessonMode();
273  if ($this->slm->getAutoReview())
274  {
275  if ($re_value["cmi.core.lesson_status"] == "completed" ||
276  $re_value["cmi.core.lesson_status"] == "passed" ||
277  $re_value["cmi.core.lesson_status"] == "failed")
278  {
279  $lesson_mode = "review";
280  }
281  }
282  $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
283 
284  // credit mode
285  if ($lesson_mode == "normal")
286  {
287  $this->tpl->setVariable("CREDIT_MODE",
288  str_replace("_", " ", $this->slm->getCreditMode()));
289  }
290  else
291  {
292  $this->tpl->setVariable("CREDIT_MODE", "no-credit");
293  }
294 
295  // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
296  $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
297  if (!isset($re_value["cmi.core.total_time"]))
298  {
299  $unit->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
300  }
301  if (!isset($re_value["cmi.core.lesson_status"]))
302  {
303  $unit->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
304  }
305  if (!isset($re_value["cmi.core.entry"]))
306  {
307  $unit->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
308  }
309 
310  $this->tpl->show();
311  }
312 
313 
314 }
315 ?>