ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilAICCExplorer.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 /*
25 * Explorer View for AICC Learning Modules
26 *
27 * @version $Id$
28 *
29 * @ingroup ModulesScormAicc
30 */
31 
32 require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
33 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCTree.php");
34 require_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMExplorer.php");
35 
37 {
38 
45  function ilAICCExplorer($a_target, &$a_slm_obj)
46  {
47  parent::ilExplorer($a_target);
48  $this->slm_obj =& $a_slm_obj;
49  $this->tree = new ilAICCTree($a_slm_obj->getId());
50  $this->root_id = $this->tree->readRootId();
51  $this->checkPermissions(false);
52  $this->outputIcons(false);
53  $this->setOrderColumn("");
54  }
55 
56  function getItem($a_node_id) {
57  return new ilAICCUnit($a_node_id);
58  }
59 
61  return "scorm/";
62  }
63 
64  function getNodesToSkip() {
65  return 1;
66  }
67 
68  function isClickable($a_type, $a_id = 0)
69  {
70  if ($a_type=="sbl") {
71  $block_object =& new ilAICCBlock($a_id);
72  return (strlen($block_object->getDescription())>0);
73  }
74 
75  if ($a_type != "sau")
76  {
77  return false;
78  }
79  else
80  {
81  $sc_object =& new ilAICCUnit($a_id);
82  //if ($sc_object->getIdentifierRef() != "")
83  //{
84  return true;
85  //}
86  }
87  return false;
88  }
89 
90  function formatItemTable(&$tpl, $a_id, $a_type)
91  {
92  global $lng;
93 /*
94  if ($a_type != "sau")
95  {
96  return;
97  }
98  else
99  {
100  $sc_object =& new ilAICCUnit($a_id);
101  //if ($sc_object->getIdentifierRef() != "")
102  //{
103  $trdata = $sc_object->getTrackingDataOfUser();
104 
105  // status
106  $status = ($trdata["lesson_status"] == "")
107  ? "not attempted"
108  : $trdata["lesson_status"];
109  $tpl->setCurrentBlock("item_row");
110  $tpl->setVariable("TXT_KEY", $lng->txt("cont_status"));
111  $tpl->setVariable("TXT_VALUE",
112  $lng->txt("cont_sc_stat_".str_replace(" ", "_", $status)));
113  $tpl->parseCurrentBlock();
114 
115  // credits
116  if ($trdata["mastery_score"] != "")
117  {
118  $tpl->setCurrentBlock("item_row");
119  $tpl->setVariable("TXT_KEY", $lng->txt("cont_credits"));
120  $tpl->setVariable("TXT_VALUE", $trdata["mastery_score"]);
121  $tpl->parseCurrentBlock();
122  }
123 
124  // total time
125  if ($trdata["total_time"] != "")
126  {
127  $tpl->setCurrentBlock("item_row");
128  $tpl->setVariable("TXT_KEY", $lng->txt("cont_total_time"));
129  $tpl->setVariable("TXT_VALUE", $trdata["total_time"]);
130  $tpl->parseCurrentBlock();
131  }
132 
133  $tpl->setCurrentBlock("item_table");
134  $tpl->parseCurrentBlock();
135  //}
136  }
137 */
138  }
139 
140 
141 
150  function formatObject($a_node_id,$a_option)
151  {
152  global $lng;
153 
154  if (!isset($a_node_id) or !is_array($a_option))
155  {
156  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
157  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
158  }
159 
160  $tpl = new ilTemplate("tpl.sahs_tree.html", true, true, "Modules/ScormAicc");
161 
162  if ($a_option["c_type"]=="sos")
163  return;
164 
165  if ($a_option["c_type"]=="srs")
166  return;
167 
168  if (is_array($a_option["tab"])) { //test if there are any tabs
169  foreach ($a_option["tab"] as $picture)
170  {
171  $pic = false;
172  if ($picture == 'plus')
173  {
174  $target = $this->createTarget('+',$a_node_id);
175  $tpl->setCurrentBlock("expander");
176  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
177  $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/plus.png"));
178  $tpl->parseCurrentBlock();
179  $pic = true;
180  }
181 
182  if ($picture == 'minus' && $this->show_minus)
183  {
184  $target = $this->createTarget('-',$a_node_id);
185  $tpl->setCurrentBlock("expander");
186  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
187  $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/minus.png"));
188  $tpl->parseCurrentBlock();
189  $pic = true;
190  }
191 
192  if (!$pic)
193  {
194  $picture = 'blank';
195  $tpl->setCurrentBlock("lines");
196  $tpl->setVariable("IMGPATH_LINES", ilUtil::getImagePath("browser/".$picture.".png"));
197  $tpl->parseCurrentBlock();
198  }
199  }
200  }
201 
202  if ($this->output_icons) {
203  if ($this->isClickable($a_option["c_type"], $a_node_id) && !$a_option["c_type"]=="sbl")
204  $this->getOutputIcons($tpl, $a_option, $a_node_id);
205  }
206 
207  if ($this->isClickable($a_option["c_type"], $a_node_id)) // output link
208  {
209  $tpl->setCurrentBlock("link");
210  //$target = (strpos($this->target, "?") === false) ?
211  // $this->target."?" : $this->target."&";
212  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
213  //$tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
214  $frame_target = $this->buildFrameTarget($a_option["c_type"], $a_node_id, $a_option["obj_id"]);
215  if ($frame_target != "")
216  {
217 // if ($this->api == 1)
218 // {
219 // $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
220 // $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
221 // //$tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
222 // $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
223 // }
224 // else
225 // {
226  if ($a_option["c_type"]=="sbl") {
227  $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
228  $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
229  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
230 
231  } else {
232 
233  $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
234  $tpl->setVariable("LINK_TARGET", "javascript:void(0);");
235  $tpl->setVariable("ONCLICK", " onclick=\"parent.APIFRAME.setupApi();parent.APIFRAME.API.IliasLaunchSahs('".$a_node_id."');return false;\"");
236 
237 // }
238  }
239 
240  }
241  $tpl->parseCurrentBlock();
242  }
243  else // output text only
244  {
245  $tpl->setCurrentBlock("text");
246  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
247  $tpl->parseCurrentBlock();
248  }
249  $this->formatItemTable($tpl, $a_node_id, $a_option["c_type"]);
250 
251  $tpl->setCurrentBlock("row");
252  $tpl->parseCurrentBlock();
253 
254  $this->output[] = $tpl->get();
255  }
256 }
257 ?>
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
get frame target (may be overwritten by derived classes)
buildLinkTarget($a_node_id, $a_type)
get link target (may be overwritten by derived classes)
AICC Block.
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
checkPermissions($a_check)
check permissions via rbac
getOutputIcons(&$tpl, $a_option, $a_node_id, $scormtype="sco")
setOrderColumn($a_column)
set the order column public
global $tpl
Definition: ilias.php:8
formatItemTable(&$tpl, $a_id, $a_type)
formatObject($a_node_id, $a_option)
Creates output recursive method private.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
createTarget($a_type, $a_child)
Creates Get Parameter private.
AICC Object Tree.
special template class to simplify handling of ITX/PEAR
redirection script todo: (a better solution should control the processing via a xml file) ...
ilAICCExplorer($a_target, &$a_slm_obj)
Constructor public.
global $lng
Definition: privfeed.php:40
isClickable($a_type, $a_id=0)
outputIcons($a_icons)
output icons
readRootId()
read root id from database