ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAICCPresentationGUI.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.ilObjAICCLearningModule.php");
25 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCObjectGUI.php");
26 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMPresentationGUI.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 ilObjAICCLearningModule($_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 
83  function view()
84  {
85  $sc_gui_object =& ilAICCObjectGUI::getInstance($_GET["obj_id"]);
86 
87  if(is_object($sc_gui_object))
88  {
89  $sc_gui_object->view();
90  }
91 
92  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
93  $this->tpl->show();
94  }
95 
99  function explorer($a_target = "sahs_content")
100  {
101  $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
102 
103  require_once("././Modules/ScormAicc/classes/AICC/class.ilAICCExplorer.php");
104  $exp = new ilAICCExplorer(
105  $this->ctrl->getLinkTarget($this, "view"), $this->slm);
106  $exp->setTargetGet("obj_id");
107  $exp->setFrameTarget($a_target);
108  //$exp->setFiltered(true);
109 
110  if ($_GET["scexpand"] == "")
111  {
112  $mtree = new ilSCORMTree($this->slm->getId());
113  $expanded = $mtree->readRootId();
114  }
115  else
116  {
117  $expanded = $_GET["scexpand"];
118  }
119  $exp->setExpand($expanded);
120 
121  $exp->forceExpandAll(true, false);
122 
123  // build html-output
124  //666$exp->setOutput(0);
125  $exp->setOutput(0);
126 
127  $output = $exp->getOutput();
128 
129  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
130  $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
131  $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
132  $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
133  $this->tpl->setVariable("EXPLORER",$output);
134  $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, $_GET["cmd"])."&frame=".$_GET["frame"].
135  "&ref_id=".$this->slm->getRefId()."&scexpand=".$_GET["scexpand"]);
136  $this->tpl->parseCurrentBlock();
137  $this->tpl->show();
138  }
139 
140  function launchSahs()
141  {
142  global $ilUser, $ilDB;
143 
144  $sahs_id = ($_GET["sahs_id"] == "")
145  ? $_POST["sahs_id"]
146  : $_GET["sahs_id"];
147  $ref_id = ($_GET["ref_id"] == "")
148  ? $_POST["ref_id"]
149  : $_GET["ref_id"];
150 
151  $this->slm =& new ilObjAICCLearningModule($ref_id, true);
152 
153  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
154  $unit =& new ilAICCUnit($sahs_id);
155 
156  //guess the url
157  $url=$unit->getCommand_line();
158  if (strlen($url)==0)
159  $url=$unit->getFilename();
160  if (strcasecmp(substr($unit->getFilename(),0,4),"http")!=0)
161  $url=$this->slm->getDataDirectory("output")."/".$url;
162  if (strlen($unit->getWebLaunch())>0)
163  $url.="?".$unit->getWebLaunch();
164 /*
165  if (strcasecmp(substr($unit->getFilename(),0,4),"http")==0)
166  $href=$unit->getFilename();
167  else
168  $href=$this->slm->getDataDirectory("output")."/".$unit->getFilename();
169 */
170  $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
171  $this->tpl->setVariable("HREF", $url);
172 // $this->tpl->setVariable("LAUNCH_DATA", $unit->getDataFromLms());
173  $this->tpl->setVariable("MAST_SCORE", $unit->getMasteryScore());
174  $this->tpl->setVariable("MAX_TIME", $unit->getMaxTimeAllowed());
175  $this->tpl->setVariable("LIMIT_ACT", $unit->getTimeLimitAction());
176  if($ilUser->getFirstName() == "Joe") // for test purpose
177  {
178  $this->tpl->setCurrentBlock("credit");
179  $this->tpl->setVariable("CREDIT_MODE", "normal");
180  $this->tpl->parseCurrentBlock();
181  }
182 
183  $val_set = $ilDB->queryF('
184  SELECT * FROM scorm_tracking
185  WHERE user_id = %s
186  AND sco_id = %s
187  AND obj_id = %s',
188  array('integer','integer','integer'),
189  array($ilUser->getId(),$sahs_id,$this->slm->getId()));
190 
191  $re_value = array();
192 
193  while($val_rec = $ilDB->fetchAssoc($val_set))
194  {
195  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
196  $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
197  $val_rec["rvalue"] = str_replace("\n", "%n%", $val_rec["rvalue"]);
198  $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
199  }
200 
201  foreach($re_value as $var => $value)
202  {
203  switch ($var)
204  {
205  case "cmi.core.lesson_location":
206  case "cmi.core.lesson_status":
207  case "cmi.core.entry":
208  case "cmi.core.score.raw":
209  case "cmi.core.score.max":
210  case "cmi.core.score.min":
211  case "cmi.core.total_time":
212  case "cmi.core.exit":
213  case "cmi.suspend_data":
214  case "cmi.comments":
215  case "cmi.student_preference.audio":
216  case "cmi.student_preference.language":
217  case "cmi.student_preference.speed":
218  case "cmi.student_preference.text":
219  $this->setSingleVariable($var, $value);
220  break;
221 
222  case "cmi.objectives._count":
223  $this->setSingleVariable($var, $value);
224  $this->setArray("cmi.objectives", $value, "id", $re_value);
225  $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
226  $this->setArray("cmi.objectives", $value, "score.max", $re_value);
227  $this->setArray("cmi.objectives", $value, "score.min", $re_value);
228  $this->setArray("cmi.objectives", $value, "status", $re_value);
229  break;
230 
231  case "cmi.interactions._count":
232  $this->setSingleVariable($var, $value);
233  $this->setArray("cmi.interactions", $value, "id", $re_value);
234  for($i=0; $i<$value; $i++)
235  {
236  $var2 = "cmi.interactions.".$i.".objectives._count";
237  if (isset($v_array[$var2]))
238  {
239  $cnt = $v_array[$var2];
240  $this->setArray("cmi.interactions.".$i.".objectives",
241  $cnt, "id", $re_value);
242  /*
243  $this->setArray("cmi.interactions.".$i.".objectives",
244  $cnt, "score.raw", $re_value);
245  $this->setArray("cmi.interactions.".$i.".objectives",
246  $cnt, "score.max", $re_value);
247  $this->setArray("cmi.interactions.".$i.".objectives",
248  $cnt, "score.min", $re_value);
249  $this->setArray("cmi.interactions.".$i.".objectives",
250  $cnt, "status", $re_value);*/
251  }
252  }
253  $this->setArray("cmi.interactions", $value, "time", $re_value);
254  $this->setArray("cmi.interactions", $value, "type", $re_value);
255  for($i=0; $i<$value; $i++)
256  {
257  $var2 = "cmi.interactions.".$i.".correct_responses._count";
258  if (isset($v_array[$var2]))
259  {
260  $cnt = $v_array[$var2];
261  $this->setArray("cmi.interactions.".$i.".correct_responses",
262  $cnt, "pattern", $re_value);
263  $this->setArray("cmi.interactions.".$i.".correct_responses",
264  $cnt, "weighting", $re_value);
265  }
266  }
267  $this->setArray("cmi.interactions", $value, "student_response", $re_value);
268  $this->setArray("cmi.interactions", $value, "result", $re_value);
269  $this->setArray("cmi.interactions", $value, "latency", $re_value);
270  break;
271  }
272  }
273 
274  global $lng;
275  $this->tpl->setCurrentBlock("switch_icon");
276  $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
277  $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.gif"));
278  $this->tpl->setVariable("SCO_ALT",
279  $lng->txt("cont_status").": "
280  .$lng->txt("cont_sc_stat_running")
281  );
282  $this->tpl->parseCurrentBlock();
283 
284  // lesson mode
285  $lesson_mode = $this->slm->getDefaultLessonMode();
286  if ($this->slm->getAutoReview())
287  {
288  if ($re_value["cmi.core.lesson_status"] == "completed" ||
289  $re_value["cmi.core.lesson_status"] == "passed" ||
290  $re_value["cmi.core.lesson_status"] == "failed")
291  {
292  $lesson_mode = "review";
293  }
294  }
295  $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
296 
297  // credit mode
298  if ($lesson_mode == "normal")
299  {
300  $this->tpl->setVariable("CREDIT_MODE",
301  str_replace("_", " ", $this->slm->getCreditMode()));
302  }
303  else
304  {
305  $this->tpl->setVariable("CREDIT_MODE", "no-credit");
306  }
307 
308  // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
309  $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
310 
311  if (!isset($re_value["cmi.core.total_time"]))
312  {
313  $unit->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
314  }
315  if (!isset($re_value["cmi.core.lesson_status"]))
316  {
317  $unit->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
318  }
319  if (!isset($re_value["cmi.core.entry"]))
320  {
321  $unit->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
322  }
323 
324  $this->tpl->show();
325  }
326 
327 }
328 ?>