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