ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004PageGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 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 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
25 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
26 require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
27 
41 {
42  protected $glossary_links = array();
43  protected $scorm_mode = "preview";
45 
49  function __construct($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_slm_id = 0,
50  $a_glo_id = 0)
51  {
52  global $tpl, $ilCtrl;
53 
54  $this->glo_id = $a_glo_id;
55 
56  parent::__construct($a_parent_type, $a_id, $a_old_nr);
57 
58 
59  $this->setEnabledMaps(false);
60  $this->setPreventHTMLUnmasking(false);
61  // $this->setEnabledInternalLinks(false);
62  //if ($this->glo_id > 0)
63  //{
64  $this->setEnabledInternalLinks(true);
65  //}
66  $this->setEnabledSelfAssessment(true);
67  $this->setEnabledPCTabs(true);
68 
69  $this->getPageConfig()->addIntLinkFilter(array("StructureObject",
70  "StructureObject_New", "PageObject", "PageObject_FAQ", "PageObject_New",
71  "GlossaryItem_New",
72  "Media", "Media_FAQ", "Media_Media", "Media_New",
73  "RepositoryItem"));
74  if ($a_glo_id <= 0)
75  {
76  $this->getPageConfig()->addIntLinkFilter(array("GlossaryItem"));
77  }
78  $this->setIntLinkHelpDefault("File", 0);
79  $this->setIntLinkReturn(
80  $ilCtrl->getLinkTargetByClass("ilobjscorm2004learningmodulegui", "showTree",
81  "", false, false));
82  $this->slm_id = $a_slm_id;
83  $this->enableNotes(true, $this->slm_id);
84  }
85 
86  function initPageObject($a_parent_type, $a_id, $a_old_nr)
87  {
88  $page = new ilSCORM2004Page($a_id, $a_old_nr);
89  $page->setGlossaryId($this->glo_id);
90  $this->setPageObject($page);
91  }
92 
98  function setGlossaryOverviewInfo($a_ov_id, $a_sco)
99  {
100  $this->glossary_ov_id = $a_ov_id;
101  $this->sco = $a_sco;
102  }
103 
110  {
111  return $this->glossary_ov_id;
112  }
113 
117  function &executeCommand()
118  {
119  global $ilCtrl;
120 
121  $next_class = $this->ctrl->getNextClass($this);
122  $cmd = $this->ctrl->getCmd();
123 
124  switch($next_class)
125  {
126  case 'ilmdeditorgui':
127  return parent::executeCommand();
128  break;
129 
130  case "ilpageobjectgui":
131  $page_gui = new ilPageObjectGUI("sahs",
132  $this->getPageObject()->getId(), $this->getPageObject()->old_nr);
133  $page_gui->setEnabledPCTabs(true);
134  $html = $ilCtrl->forwardCommand($page_gui);
135  return $html;
136 
137  default:
138  $html = parent::executeCommand();
139  return $html;
140  }
141  }
142 
148  function setSCORM2004Page($a_scpage)
149  {
150  $this->setPageObject($a_scpage);
151  }
152 
158  function getSCORM2004Page()
159  {
160  return $this->getPageObject();
161  }
162 
163  /*function preview()
164  {
165  global $ilCtrl;
166 
167  $wtpl = new ilTemplate("tpl....html",
168  true, true, "Modules/Scorm2004");
169 
170  $wtpl->setVariable("PAGE", parent::preview());
171  return $wtpl->get();
172  }*/
173 
178  {
179  $q_ids = $this->getPageObject()->getQuestionIds();
180 
181  $html = array();
182  if (count($q_ids) > 0)
183  {
184  foreach ($q_ids as $q_id)
185  {
186  include_once("./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
187  $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id);
188  $q_gui->outAdditionalOutput();
189  $html[$q_id] = $q_gui->getPreview(TRUE);
190  }
191  }
192 
193  return $html;
194  }
195 
196 
197  // moved to parent
198  //function getQuestionJsOfPage($a_no_interaction = false)
199 
207  {
208  if ($this->scorm_mode == "preview")
209  {
211  }
212  }
213 
220  function selfAssessmentRendering($a_output)
221  {
222  if ($this->scorm_mode == "preview")
223  {
224  $a_output = parent::selfAssessmentRendering($a_output);
225  }
226 
227  return $a_output;
228  }
229 
233  function showPage($a_mode = "preview")
234  {
235  global $tpl, $ilCtrl;
236 
237  $this->scorm_mode = $a_mode;
238 
239  $this->setTemplateOutput(false);
240 
241  $output = parent::showPage();
242 
243  return $output;
244  }
245 
249  function setDefaultLinkXml()
250  {
251  $int_links = $this->getPageObject()->getInternalLinks(true);
252  $this->glossary_links = $int_links;
253 //var_dump($int_links);
254 
255 // key is il__git_18:GlossaryItem:Glossary::4 => id is il__git_18_4,
256 
257  $link_info = "<IntLinkInfos>";
258  $targetframe = "None";
259  $ltarget = "";
260  foreach ($int_links as $int_link)
261  {
262  $onclick = "";
263  $target = $int_link["Target"];
264  $targetframe = "None";
265  if (substr($target, 0, 4) == "il__")
266  {
267  $target_arr = explode("_", $target);
268  $target_id = $target_arr[count($target_arr) - 1];
269  $type = $int_link["Type"];
270 
271  switch($type)
272  {
273  case "GlossaryItem":
274  $ltarget = "";
275  //$href = "./goto.php?target=git_".$target_id;
276  $href = "#";
277  $onclick = 'OnClick="return false;"';
278  $anc_par = 'Anchor=""';
279  $targetframe = "Glossary";
280  break;
281 
282  case "File":
283  $ltarget = "";
284  if ($this->getOutputMode() == "offline")
285  {
286  if (ilObject::_lookupType($target_id) == "file")
287  {
288  include_once("./Modules/File/classes/class.ilObjFile.php");
289  $href = "./files/file_".$target_id."/".ilObjFile::_lookupFileName($target_id);
290  $ltarget = "_blank";
291  }
292  }
293  else
294  {
295  $href = str_replace("&", "&amp;", $this->determineFileDownloadLink())."&amp;file_id=il__file_".$target_id;
296 //echo htmlentities($href);
297  }
298 
299  $anc_par = 'Anchor=""';
300  $targetframe = "None"; //???
301  break;
302 
303  }
304  $link_info.="<IntLinkInfo $onclick Target=\"$target\" Type=\"$type\" ".$anc_par." ".
305  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
306  }
307  }
308  $link_info.= "</IntLinkInfos>";
309  $this->setLinkXML($link_info);
310 //var_dump($link_info);
311  }
312 
317  function postOutputProcessing($a_output)
318  {
319 //var_dump($this->glossary_links);
320  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
321 
322  if ($this->scorm_mode != "export")
323  {
324  $tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
325  }
326  else
327  {
329  }
330  $glossary = false;
331 
332  $overlays = array();
333 
334  // overlay for sco glossary
335  if ($this->getGlossaryOverviewId() != "")
336  {
337  $ovov = $overlays[$this->getGlossaryOverviewId()] = new ilOverlayGUI($this->getGlossaryOverviewId());
338 // $ovov->setFixedCenter(true);
339  $ovov->setAutoHide(false);
340  $ovov->setCloseElementId("glo_ov_close");
341  if ($this->getGlossaryOverviewId() != "")
342  {
343  if ($this->scorm_mode != "export" ||
344  $this->getOutputMode() == IL_PAGE_PREVIEW)
345  {
346  $overlays[$this->getGlossaryOverviewId()]->add();
347  }
348  else
349  {
350  $tpl->setCurrentBlock("add_script");
351  $tpl->setVariable("ADD_SCRIPT", "ilAddOnLoad(function () {".$overlays[$this->getGlossaryOverviewId()]->getOnLoadCode()."});");
352  $tpl->parseCurrentBlock();
353  }
354  }
355  }
356 
357  if (is_array($this->glossary_links))
358  {
359  foreach ($this->glossary_links as $k => $e)
360  {
361  // glossary link
362  if ($e["Type"] == "GlossaryItem")
363  {
364  $karr = explode(":", $k);
365  $link_id = $karr[0]."_".$this->getPageObject()->getId()."_".$karr[4];
366  //$ov_id = "ov".$karr[0]."_".$karr[4];
367  $ov_id = "ov".$karr[0];
368  $cl_id = "ov".$karr[0]."cl";
369  $glov_id = "ov".$karr[0]."ov";
370  $term_id_arr = explode("_", $karr[0]);
371  $term_id = $term_id_arr[count($term_id_arr) - 1];
372 
373  // get overlay html from glossary term
374  include_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
375  $id_arr = explode("_", $karr[0]);
376  $term_gui =& new ilGlossaryTermGUI($id_arr[count($id_arr) - 1]);
377  $html = $term_gui->getOverlayHTML($cl_id, ($this->getGlossaryOverviewId() != "")
378  ? $glov_id
379  : "");
380  $tpl->setCurrentBlock("entry");
381  $tpl->setVariable("CONTENT", $html);
382  $tpl->setVariable("OVERLAY_ID", $ov_id);
383 
384  $glossary = true;
385 
386  // first time the term is used
387  if (!isset($overlays[$ov_id]))
388  {
389  $overlays[$ov_id] = new ilOverlayGUI($ov_id);
390  $overlays[$ov_id]->setAnchor($link_id);
391  $overlays[$ov_id]->setTrigger($link_id, "onclick", $link_id);
392  $overlays[$ov_id]->setAutoHide(false);
393  $overlays[$ov_id]->setCloseElementId($cl_id);
394  if ($this->scorm_mode != "export" ||
395  $this->getOutputMode() == IL_PAGE_PREVIEW)
396  {
397  $overlays[$ov_id]->add();
398  }
399  else
400  {
401  $tpl->setVariable("SCRIPT", "ilAddOnLoad(function () {".$overlays[$ov_id]->getOnLoadCode()."});");
402  }
403  }
404  else
405  {
406  if ($this->scorm_mode != "export" ||
407  $this->getOutputMode() == IL_PAGE_PREVIEW)
408  {
409  $overlays[$ov_id]->addTrigger($link_id, "click", $link_id);
410  }
411  else
412  {
413  $tpl->setVariable("SCRIPT",
414  "ilAddOnLoad(function () {".$overlays[$ov_id]->getTriggerOnLoadCode($link_id, "click", $link_id)."});");
415  }
416  }
417 
418  if ($this->getGlossaryOverviewId() != "")
419  {
420  if ($this->scorm_mode != "export" ||
421  $this->getOutputMode() == IL_PAGE_PREVIEW)
422  {
423  //$overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", null);
424  $overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", $ov_id, false, "tl", "tl");
425  //$overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", null, true);
426  $overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl");
427  }
428  else
429  {
430  $tpl->setVariable("SCRIPT2",
431  "ilAddOnLoad(function () {".
432  $overlays[$this->getGlossaryOverviewId()]->getTriggerOnLoadCode($glov_id, "click", $ov_id, false, "tl", "tl")."});");
433  $tpl->setVariable("SCRIPT3",
434  "ilAddOnLoad(function () {".
435  $overlays[$ov_id]->getTriggerOnLoadCode("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl")."});");
436  }
437  }
438 
439  $tpl->parseCurrentBlock();
440  }
441  }
442  }
443 
444  if ($glossary && $this->scorm_mode != "export")
445  {
446  $ret = $a_output.$tpl->get();
447  if ($this->getGlossaryOverviewId() != "")
448  {
450  }
451  return $ret;
452  }
453 
454  return $a_output;
455  }
456 
460  static function initExport()
461  {
462  self::$export_glo_tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
463  }
464 
468  static function getGlossaryHTML($a_sco)
469  {
470  $ret = self::$export_glo_tpl->get();
471 
473 
474  return $ret;
475  }
476 
477 }
478 ?>