ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSCORM2004PageGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
6include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
7require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
8
22{
23 protected $glossary_links = array();
24 protected $scorm_mode = "preview";
26
30 function __construct($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_slm_id = 0,
31 $a_glo_id = 0)
32 {
33 global $tpl, $ilCtrl;
34
35 $this->glo_id = $a_glo_id;
36 $this->slm_id = $a_slm_id;
37
38 $a_parent_type = "sahs";
39
40 parent::__construct($a_parent_type, $a_id, $a_old_nr);
41 $this->getPageObject()->setGlossaryId($this->glo_id);
42
43 $this->setIntLinkReturn(
44 $ilCtrl->getLinkTargetByClass("ilobjscorm2004learningmodulegui", "showTree",
45 "", false, false));
46 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
47 $this->enableNotes(true, $this->slm_id);
48 }
49
55 function setGlossaryOverviewInfo($a_ov_id, $a_sco)
56 {
57 $this->glossary_ov_id = $a_ov_id;
58 $this->sco = $a_sco;
59 }
60
67 {
68 return $this->glossary_ov_id;
69 }
70
74 function executeCommand()
75 {
76 global $ilCtrl;
77
78 $next_class = $this->ctrl->getNextClass($this);
79 $cmd = $this->ctrl->getCmd();
80
81 switch($next_class)
82 {
83 case 'ilmdeditorgui':
84 return parent::executeCommand();
85 break;
86
87 case "ilpageobjectgui":
88die("ilSCORM2004PageGUI forwarding to ilpageobjectgui error.");
89 return;
90
91 default:
92 $html = parent::executeCommand();
93 return $html;
94 }
95 }
96
102 function setSCORM2004Page($a_scpage)
103 {
104 $this->setPageObject($a_scpage);
105 }
106
113 {
114 return $this->getPageObject();
115 }
116
117 /*function preview()
118 {
119 global $ilCtrl;
120
121 $wtpl = new ilTemplate("tpl....html",
122 true, true, "Modules/Scorm2004");
123
124 $wtpl->setVariable("PAGE", parent::preview());
125 return $wtpl->get();
126 }*/
127
132 {
133 $q_ids = $this->getPageObject()->getQuestionIds();
134
135 $html = array();
136 if (count($q_ids) > 0)
137 {
138 foreach ($q_ids as $q_id)
139 {
140 include_once("./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
141 $q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
142 $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
143 $q_gui->outAdditionalOutput();
144 $html[$q_id] = $q_gui->getPreview(TRUE);
145 }
146 }
147
148 return $html;
149 }
150
151
159 {
160 if ($this->scorm_mode == "preview")
161 {
162 // parent::initSelfAssessmentRendering(); // todo: not called anymore
163 }
164 }
165
172 function selfAssessmentRendering($a_output)
173 {
174 if ($this->scorm_mode == "preview")
175 {
176 $a_output = parent::selfAssessmentRendering($a_output);
177 }
178
179 return $a_output;
180 }
181
185 function showPage($a_mode = "preview")
186 {
187 global $tpl, $ilCtrl;
188
189 $this->scorm_mode = $a_mode;
190
191 $this->setTemplateOutput(false);
192
193 $output = parent::showPage();
194
195 return $output;
196 }
197
202 {
203 $int_links = $this->getPageObject()->getInternalLinks(true);
204 $this->glossary_links = $int_links;
205//var_dump($int_links);
206
207// key is il__git_18:GlossaryItem:Glossary::4 => id is il__git_18_4,
208
209 $link_info = "<IntLinkInfos>";
210 $targetframe = "None";
211 $ltarget = "";
212 foreach ($int_links as $int_link)
213 {
214 $onclick = "";
215 $target = $int_link["Target"];
216 $targetframe = "None";
217 if (substr($target, 0, 4) == "il__")
218 {
219 $target_arr = explode("_", $target);
220 $target_id = $target_arr[count($target_arr) - 1];
221 $type = $int_link["Type"];
222
223 switch($type)
224 {
225 case "GlossaryItem":
226 $ltarget = "";
227 //$href = "./goto.php?target=git_".$target_id;
228 $href = "#";
229 $onclick = 'OnClick="return false;"';
230 $anc_par = 'Anchor=""';
231 $targetframe = "Glossary";
232 break;
233
234 case "File":
235 $ltarget = "";
236 if ($this->getOutputMode() == "offline")
237 {
238 if (ilObject::_lookupType($target_id) == "file")
239 {
240 include_once("./Modules/File/classes/class.ilObjFile.php");
241 $href = "./files/file_".$target_id."/".ilObjFile::_lookupFileName($target_id);
242 $ltarget = "_blank";
243 }
244 }
245 else
246 {
247 $href = str_replace("&", "&amp;", $this->determineFileDownloadLink())."&amp;file_id=il__file_".$target_id;
248//echo htmlentities($href);
249 }
250
251 $anc_par = 'Anchor=""';
252 $targetframe = "None"; //???
253 break;
254
255 }
256 $link_info.="<IntLinkInfo $onclick Target=\"$target\" Type=\"$type\" ".$anc_par." ".
257 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
258 }
259 }
260 $link_info.= "</IntLinkInfos>";
261 $this->setLinkXML($link_info);
262//var_dump($link_info);
263 }
264
269 function postOutputProcessing($a_output)
270 {
271//var_dump($this->glossary_links);
272 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
273
274 if ($this->scorm_mode != "export")
275 {
276 $tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
277 }
278 else
279 {
281 }
282 $glossary = false;
283
284 $overlays = array();
285
286 // overlay for sco glossary
287 if ($this->getGlossaryOverviewId() != "" && $this->getOutputMode() != "edit")
288 {
289 $ovov = $overlays[$this->getGlossaryOverviewId()] = new ilOverlayGUI($this->getGlossaryOverviewId());
290// $ovov->setFixedCenter(true);
291 $ovov->setAutoHide(false);
292 $ovov->setCloseElementId("glo_ov_close");
293 if ($this->getGlossaryOverviewId() != "")
294 {
295 if ($this->scorm_mode != "export" ||
296 $this->getOutputMode() == IL_PAGE_PREVIEW)
297 {
298 $overlays[$this->getGlossaryOverviewId()]->add();
299 }
300 else
301 {
302 $tpl->setCurrentBlock("add_script");
303 $tpl->setVariable("ADD_SCRIPT", "il.Util.addOnLoad(function () {".$overlays[$this->getGlossaryOverviewId()]->getOnLoadCode()."});");
304 $tpl->parseCurrentBlock();
305 }
306 }
307 }
308
309 if ($this->getOutputMode() != "edit")
310 {
311 if (is_array($this->glossary_links))
312 {
313 foreach ($this->glossary_links as $k => $e)
314 {
315 // glossary link
316 if ($e["Type"] == "GlossaryItem")
317 {
318 $karr = explode(":", $k);
319 $link_id = $karr[0]."_".$this->getPageObject()->getId()."_".$karr[4];
320 //$ov_id = "ov".$karr[0]."_".$karr[4];
321 $ov_id = "ov".$karr[0];
322 $cl_id = "ov".$karr[0]."cl";
323 $glov_id = "ov".$karr[0]."ov";
324 $term_id_arr = explode("_", $karr[0]);
325 $term_id = $term_id_arr[count($term_id_arr) - 1];
326
327 // get overlay html from glossary term
328 include_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
329 $id_arr = explode("_", $karr[0]);
330 $term_gui = new ilGlossaryTermGUI($id_arr[count($id_arr) - 1]);
331 $html = $term_gui->getOverlayHTML($cl_id, ($this->getGlossaryOverviewId() != "")
332 ? $glov_id
333 : "",
335 $tpl->setCurrentBlock("entry");
336 $tpl->setVariable("CONTENT", $html);
337 $tpl->setVariable("OVERLAY_ID", $ov_id);
338
339 $glossary = true;
340
341 // first time the term is used
342 if (!isset($overlays[$ov_id]))
343 {
344 $overlays[$ov_id] = new ilOverlayGUI($ov_id);
345 $overlays[$ov_id]->setAnchor($link_id);
346 $overlays[$ov_id]->setTrigger($link_id, "click", $link_id);
347 $overlays[$ov_id]->setAutoHide(false);
348 $overlays[$ov_id]->setCloseElementId($cl_id);
349 if ($this->scorm_mode != "export" ||
350 $this->getOutputMode() == IL_PAGE_PREVIEW)
351 {
352 $overlays[$ov_id]->add();
353 }
354 else
355 {
356 $tpl->setVariable("SCRIPT", "il.Util.addOnLoad(function () {".$overlays[$ov_id]->getOnLoadCode()."});");
357 }
358 }
359 else
360 {
361 if ($this->scorm_mode != "export" ||
362 $this->getOutputMode() == IL_PAGE_PREVIEW)
363 {
364 $overlays[$ov_id]->addTrigger($link_id, "click", $link_id);
365 }
366 else
367 {
368 $tpl->setVariable("SCRIPT",
369 "il.Util.addOnLoad(function () {".$overlays[$ov_id]->getTriggerOnLoadCode($link_id, "click", $link_id)."});");
370 }
371 }
372
373 if ($this->getGlossaryOverviewId() != "")
374 {
375 if ($this->scorm_mode != "export" ||
376 $this->getOutputMode() == IL_PAGE_PREVIEW)
377 {
378 //$overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", null);
379 $overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", $ov_id, false, "tl", "tl");
380 //$overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", null, true);
381 $overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl");
382 }
383 else
384 {
385 $tpl->setVariable("SCRIPT2",
386 "il.Util.addOnLoad(function () {".
387 $overlays[$this->getGlossaryOverviewId()]->getTriggerOnLoadCode($glov_id, "click", $ov_id, false, "tl", "tl")."});");
388 $tpl->setVariable("SCRIPT3",
389 "il.Util.addOnLoad(function () {".
390 $overlays[$ov_id]->getTriggerOnLoadCode("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl")."});");
391 }
392 }
393
394 $tpl->parseCurrentBlock();
395 }
396 }
397 }
398
399 if ($glossary && $this->scorm_mode != "export")
400 {
401 $ret = $a_output.$tpl->get();
402 if ($this->getGlossaryOverviewId() != "")
403 {
405 }
406 return $ret;
407 }
408 }
409
410 return $a_output;
411 }
412
416 static function initExport()
417 {
418 self::$export_glo_tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
419 }
420
424 static function getGlossaryHTML($a_sco)
425 {
426 $ret = self::$export_glo_tpl->get();
427
429
430 return $ret;
431 }
432
433}
434?>
An exception for terminatinating execution or to throw for unit testing.
const IL_PAGE_PREVIEW
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
GUI class for glossary terms.
static _lookupFileName($a_id)
static getAffectiveLocalization($a_id)
Get affective localization.
static _lookupType($a_id, $a_reference=false)
lookup object type
This is a utility class for the yui overlays.
Class ilPageObjectGUI.
setPageObject($a_pg_obj)
Set Page Object.
determineFileDownloadLink()
Determine file download link.
getPageObject()
Get Page Object.
setTemplateOutput($a_output=true)
enableNotes($a_enabled, $a_parent_id)
Class ilSCORM2004Page GUI class.
initSelfAssessmentRendering()
Init question handling.
selfAssessmentRendering($a_output)
Self assessment question rendering.
setSCORM2004Page($a_scpage)
Set SCORM2004 Page Object.
getGlossaryOverviewId()
Get glossary overview id.
getQuestionHtmlOfPage()
Get question html for page.
setGlossaryOverviewInfo($a_ov_id, $a_sco)
Set glossary overview id.
static initExport()
Init export.
showPage($a_mode="preview")
Show the page.
executeCommand()
execute command
__construct($a_parent_type, $a_id=0, $a_old_nr=0, $a_slm_id=0, $a_glo_id=0)
Constructor.
getSCORM2004Page()
Get SCORM2004 Page Object.
postOutputProcessing($a_output)
Post output processing:
static getGlossaryHTML($a_sco)
Get glossary html (only in export mode)
setDefaultLinkXml()
Set standard link xml (currently only glossaries)
static getGloOverviewOv($a_sco)
des
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
$target_id
Definition: goto.php:51
$target_arr
Definition: goto.php:49
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35