ILIAS  eassessment Revision 61809
 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 
173  $val_set = $ilDB->queryF('
174  SELECT * FROM scorm_tracking
175  WHERE user_id = %s
176  AND sco_id = %s
177  AND obj_id = %s',
178  array('integer','integer','integer'),
179  array($ilUser->getId(),$sahs_id,$this->slm->getId()));
180 
181  $re_value = array();
182 
183  while($val_rec = $ilDB->fetchAssoc($val_set))
184 
185  {
186  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
187  $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
188  $val_rec["rvalue"] = str_replace("\n", "%n%", $val_rec["rvalue"]);
189  $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
190  }
191 
192  foreach($re_value as $var => $value)
193  {
194  switch ($var)
195  {
196  case "cmi.core.lesson_location":
197  case "cmi.core.lesson_status":
198  case "cmi.core.entry":
199  case "cmi.core.score.raw":
200  case "cmi.core.score.max":
201  case "cmi.core.score.min":
202  case "cmi.core.total_time":
203  case "cmi.core.exit":
204  case "cmi.suspend_data":
205  case "cmi.comments":
206  case "cmi.student_preference.audio":
207  case "cmi.student_preference.language":
208  case "cmi.student_preference.speed":
209  case "cmi.student_preference.text":
210  $this->setSingleVariable($var, $value);
211  break;
212 
213  case "cmi.objectives._count":
214  $this->setSingleVariable($var, $value);
215  $this->setArray("cmi.objectives", $value, "id", $re_value);
216  $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
217  $this->setArray("cmi.objectives", $value, "score.max", $re_value);
218  $this->setArray("cmi.objectives", $value, "score.min", $re_value);
219  $this->setArray("cmi.objectives", $value, "status", $re_value);
220  break;
221 
222  case "cmi.interactions._count":
223  $this->setSingleVariable($var, $value);
224  $this->setArray("cmi.interactions", $value, "id", $re_value);
225  for($i=0; $i<$value; $i++)
226  {
227  $var2 = "cmi.interactions.".$i.".objectives._count";
228  if (isset($v_array[$var2]))
229  {
230  $cnt = $v_array[$var2];
231  $this->setArray("cmi.interactions.".$i.".objectives",
232  $cnt, "id", $re_value);
233  /*
234  $this->setArray("cmi.interactions.".$i.".objectives",
235  $cnt, "score.raw", $re_value);
236  $this->setArray("cmi.interactions.".$i.".objectives",
237  $cnt, "score.max", $re_value);
238  $this->setArray("cmi.interactions.".$i.".objectives",
239  $cnt, "score.min", $re_value);
240  $this->setArray("cmi.interactions.".$i.".objectives",
241  $cnt, "status", $re_value);*/
242  }
243  }
244  $this->setArray("cmi.interactions", $value, "time", $re_value);
245  $this->setArray("cmi.interactions", $value, "type", $re_value);
246  for($i=0; $i<$value; $i++)
247  {
248  $var2 = "cmi.interactions.".$i.".correct_responses._count";
249  if (isset($v_array[$var2]))
250  {
251  $cnt = $v_array[$var2];
252  $this->setArray("cmi.interactions.".$i.".correct_responses",
253  $cnt, "pattern", $re_value);
254  $this->setArray("cmi.interactions.".$i.".correct_responses",
255  $cnt, "weighting", $re_value);
256  }
257  }
258  $this->setArray("cmi.interactions", $value, "student_response", $re_value);
259  $this->setArray("cmi.interactions", $value, "result", $re_value);
260  $this->setArray("cmi.interactions", $value, "latency", $re_value);
261  break;
262  }
263  }
264 
265  global $lng;
266  $this->tpl->setCurrentBlock("switch_icon");
267  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
268  $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
269  $this->tpl->setVariable("SCO_ALT",
270  $lng->txt("cont_status").": "
271  .$lng->txt("cont_sc_stat_running")
272  );
273  $this->tpl->parseCurrentBlock();
274 
275  // lesson mode
276  $lesson_mode = $this->slm->getDefaultLessonMode();
277  if ($this->slm->getAutoReview())
278  {
279  if ($re_value["cmi.core.lesson_status"] == "completed" ||
280  $re_value["cmi.core.lesson_status"] == "passed" ||
281  $re_value["cmi.core.lesson_status"] == "failed")
282  {
283  $lesson_mode = "review";
284  }
285  }
286  $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
287 
288  // credit mode
289  if ($lesson_mode == "normal")
290  {
291  $this->tpl->setVariable("CREDIT_MODE",
292  str_replace("_", " ", $this->slm->getCreditMode()));
293  }
294  else
295  {
296  $this->tpl->setVariable("CREDIT_MODE", "no-credit");
297  }
298 
299  // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
300  $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
301  if (!isset($re_value["cmi.core.total_time"]))
302  {
303  $unit->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
304  }
305  if (!isset($re_value["cmi.core.lesson_status"]))
306  {
307  $unit->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
308  }
309  if (!isset($re_value["cmi.core.entry"]))
310  {
311  $unit->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
312  }
313 
314  $this->tpl->show();
315  }
316 
317 
318 }
319 ?>