ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSCORMLearningModuleGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "classes/class.ilObjectGUI.php";
6 require_once("classes/class.ilFileSystemGUI.php");
7 require_once("classes/class.ilTabsGUI.php");
8 require_once("Services/User/classes/class.ilObjUser.php");
9 
10 require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php");
11 require_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
12 
27 {
33  function ilObjSCORMLearningModuleGUI($a_data,$a_id,$a_call_by_reference, $a_prepare_output = true)
34  {
35  global $lng;
36 
37  $lng->loadLanguageModule("content");
38  $lng->loadLanguageModule("search");
39 
40  $this->type = "sahs";
41  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
42  #$this->tabs_gui =& new ilTabsGUI();
43  }
44 
48  function assignObject()
49  {
50  if ($this->id != 0)
51  {
52  if ($this->call_by_reference)
53  {
54  $this->object =& new ilObjSCORMLearningModule($this->id, true);
55  }
56  else
57  {
58  $this->object =& new ilObjSCORMLearningModule($this->id, false);
59  }
60  }
61  }
62 
66  function properties()
67  {
68  global $rbacsystem, $tree, $tpl;
69 
70  // edit button
71  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
72 
73  // view link
74  $this->tpl->setCurrentBlock("btn_cell");
75  $this->tpl->setVariable("BTN_LINK",
76  "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=".$this->object->getRefID());
77  $this->tpl->setVariable("BTN_TARGET"," target=\"ilContObj".$this->object->getID()."\" ");
78  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("view"));
79  $this->tpl->parseCurrentBlock();
80 
81  if (ilObjSAHSLearningModule::_lookupSubType($this->object->getID()) == "scorm") {
82  // upload new version
83  $this->tpl->setCurrentBlock("btn_cell");
84  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "newModuleVersion"));
85  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("cont_sc_new_version"));
86  $this->tpl->parseCurrentBlock();
87  }
88 
89  // scorm lm properties
90  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sahs_properties.html", "Modules/ScormAicc");
91  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
92  $this->tpl->setVariable("TXT_PROPERTIES", $this->lng->txt("cont_lm_properties"));
93 
94  // online
95  $this->tpl->setVariable("TXT_ONLINE", $this->lng->txt("cont_online"));
96  $this->tpl->setVariable("CBOX_ONLINE", "cobj_online");
97  $this->tpl->setVariable("VAL_ONLINE", "y");
98  if ($this->object->getOnline())
99  {
100  $this->tpl->setVariable("CHK_ONLINE", "checked");
101  }
102 
103  // api adapter name
104  $this->tpl->setVariable("TXT_API_ADAPTER", $this->lng->txt("cont_api_adapter"));
105  $this->tpl->setVariable("VAL_API_ADAPTER", $this->object->getAPIAdapterName());
106 
107  // api functions prefix
108  $this->tpl->setVariable("TXT_API_PREFIX", $this->lng->txt("cont_api_func_prefix"));
109  $this->tpl->setVariable("VAL_API_PREFIX", $this->object->getAPIFunctionsPrefix());
110 
111  // default lesson mode
112  $this->tpl->setVariable("TXT_LESSON_MODE", $this->lng->txt("cont_def_lesson_mode"));
113  $lesson_modes = array("normal" => $this->lng->txt("cont_sc_less_mode_normal"),
114  "browse" => $this->lng->txt("cont_sc_less_mode_browse"));
115  $sel_lesson = ilUtil::formSelect($this->object->getDefaultLessonMode(),
116  "lesson_mode", $lesson_modes, false, true);
117  $this->tpl->setVariable("SEL_LESSON_MODE", $sel_lesson);
118 
119  // credit mode
120  $this->tpl->setVariable("TXT_CREDIT_MODE", $this->lng->txt("cont_credit_mode"));
121  $credit_modes = array("credit" => $this->lng->txt("cont_credit_on"),
122  "no_credit" => $this->lng->txt("cont_credit_off"));
123  $sel_credit = ilUtil::formSelect($this->object->getCreditMode(),
124  "credit_mode", $credit_modes, false, true);
125  $this->tpl->setVariable("SEL_CREDIT_MODE", $sel_credit);
126 
127  // auto review mode
128  $this->tpl->setVariable("TXT_AUTO_REVIEW", $this->lng->txt("cont_sc_auto_review"));
129  $this->tpl->setVariable("CBOX_AUTO_REVIEW", "auto_review");
130  $this->tpl->setVariable("VAL_AUTO_REVIEW", "y");
131  if ($this->object->getAutoReview())
132  {
133  $this->tpl->setVariable("CHK_AUTO_REVIEW", "checked");
134  }
135 
136  // max attempts
137  $this->tpl->setVariable("MAX_ATTEMPTS", $this->lng->txt("cont_sc_max_attempt"));
138  $this->tpl->setVariable("VAL_MAX_ATTEMPT", $this->object->getMaxAttempt());
139 
140  // version
141  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("cont_sc_version"));
142  $this->tpl->setVariable("VAL_VERSION", $this->object->getModuleVersion());
143 
144  //unlimited session
145  $this->tpl->setVariable("TXT_SESSION", $this->lng->txt("cont_sc_usession"));
146  $this->tpl->setVariable("CBOX_SESSION", "cobj_session");
147  $this->tpl->setVariable("VAL_SESSION", "y");
148  if ($this->object->getSession())
149  {
150  $this->tpl->setVariable("CHK_SESSION", "checked");
151  }
152 
153  // auto continue
154  $this->tpl->setVariable("TXT_AUTO_CONTINUE", $this->lng->txt("cont_sc_auto_continue"));
155  $this->tpl->setVariable("CBOX_AUTO_CONTINUE", "auto_continue");
156  $this->tpl->setVariable("VAL_AUTO_CONTINUE", "y");
157  if ($this->object->getAutoContinue())
158  {
159  $this->tpl->setVariable("CHK_AUTO_CONTINUE", "checked");
160  }
161 
162  //debug
163  $this->tpl->setVariable("TXT_DEBUG", $this->lng->txt("cont_debug"));
164  $this->tpl->setVariable("CBOX_DEBUG", "cobj_debug");
165  $this->tpl->setVariable("VAL_DEBUG", "y");
166  if ($this->object->getDebug())
167  {
168  $this->tpl->setVariable("CHK_DEBUG", "checked");
169  }
170 
171 
172  $this->tpl->setCurrentBlock("commands");
173  $this->tpl->setVariable("BTN_NAME", "saveProperties");
174  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
175  $this->tpl->parseCurrentBlock();
176 
177  }
178 
182  function newModuleVersion()
183  {
184 
187 
188  // display import form
189  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_new_version_import.html", "Modules/ScormAicc");
190 
191  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_slm.gif'));
192  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
193 
194  $this->ctrl->setParameter($this, "new_type", "sahs");
195  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
196 
197  $this->tpl->setVariable("BTN_NAME", "newModuleVersionUpload");
198  $this->tpl->setVariable("TARGET", ' target="'.
199  ilFrameTargetInfo::_getFrame("MainContent").'" ');
200 
201  $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
202 
203  if ($type == "scorm2004") {
204  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm2004"));
205  } else {
206  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("lm_type_scorm"));
207  }
208 
209  include_once 'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
211  {
213  foreach($files as $file)
214  {
215  $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
216  $this->tpl->setCurrentBlock("option_uploaded_file");
217  $this->tpl->setVariable("UPLOADED_FILENAME", $file);
218  $this->tpl->setVariable("TXT_UPLOADED_FILENAME", $file);
219  $this->tpl->parseCurrentBlock();
220  }
221  $this->tpl->setCurrentBlock("select_uploaded_file");
222  $this->tpl->setVariable("TXT_SELECT_FROM_UPLOAD_DIR", $this->lng->txt("cont_select_from_upload_dir"));
223  $this->tpl->setVariable("TXT_UPLOADED_FILE", $this->lng->txt("cont_uploaded_file"));
224  $this->tpl->parseCurrentBlock();
225  }
226 
227  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
228  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
229  $this->tpl->setVariable("TXT_IMPORT_LM", $this->lng->txt("import_sahs"));
230  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
231 
232  // gives out the limit as a little notice
233  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." ".$this->getMaxFileSize());
234  }
235 
236  function getMaxFileSize()
237  {
238 
239  // get the value for the maximal uploadable filesize from the php.ini (if available)
240  $umf=get_cfg_var("upload_max_filesize");
241  // get the value for the maximal post data from the php.ini (if available)
242  $pms=get_cfg_var("post_max_size");
243 
244  //convert from short-string representation to "real" bytes
245  $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
246 
247  $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
248  $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
249 
250  if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
251  if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
252 
253  // use the smaller one as limit
254  $max_filesize=min($umf, $pms);
255 
256  if (!$max_filesize) $max_filesize=max($umf, $pms);
257 
258  //format for display in mega-bytes
259  return $max_filesize=sprintf("%.1f MB",$max_filesize/1024/1024);
260  }
261 
262 
264  {
265  global $_FILES, $rbacsystem;
266 
267  $unzip = PATH_TO_UNZIP;
268  $tocheck = "imsmanifest.xml";
269 
270  include_once 'Services/FileSystemStorage/classes/class.ilUploadFiles.php';
271 
272  // check create permission before because the uploaded file will be copied
273  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
274  {
275  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING);
276  }
277  elseif ($_FILES["scormfile"]["name"])
278  {
279  // check if file was uploaded
280  $source = $_FILES["scormfile"]["tmp_name"];
281  if (($source == 'none') || (!$source))
282  {
283  ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
284  $this->newModuleVersion();
285  return;
286  }
287  }
288  elseif ($_POST["uploaded_file"])
289  {
290  // check if the file is in the ftp directory and readable
291  if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
292  {
293  $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"),$this->ilias->error_obj->MESSAGE);
294  }
295 
296  // copy the uploaded file to the client web dir to analyze the imsmanifest
297  // the copy will be moved to the lm directory or deleted
298  $source = CLIENT_WEB_DIR . "/" . $_POST["uploaded_file"];
299  ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $source);
300  $source_is_copy = true;
301  }
302  else
303  {
304  ilUtil::sendInfo($this->lng->txt("upload_error_file_not_found"),true);
305  $this->newModuleVersion();
306  return;
307  }
308  // fim.
309 
310  //unzip the imsmanifest-file from new uploaded file
311  $pathinfo = pathinfo($source);
312  $dir = $pathinfo["dirname"];
313  $file = $pathinfo["basename"];
314  $cdir = getcwd();
315  chdir($dir);
316 
317  //we need more flexible unzip here than ILIAS standard classes allow
318  $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($source)." ".$tocheck;
319  exec($unzipcmd);
320  chdir($cdir);
321  $tmp_file = $dir."/".$tocheck.".".$_GET["ref_id"];
322 
323  rename($dir."/".$tocheck,$tmp_file);
324  $new_manifest = file_get_contents($tmp_file);
325 
326  //remove temp file
327  unlink($tmp_file);
328 
329  //get old manifest file
330  $old_manifest = file_get_contents($this->object->getDataDirectory()."/".$tocheck);
331 
332  //reload fixed version of file
333  $check ='/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
334  $replace="xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
335  $reload_manifest = preg_replace($check, $replace, $new_manifest);
336 
337  //do testing for converted versions as well as earlier ILIAS version messed up utf8 conversion
338  if (strcmp($new_manifest,$old_manifest) == 0 || strcmp(utf8_encode($new_manifest),$old_manifest) == 0 ||
339  strcmp ($reload_manifest, $old_manifest) == 0 || strcmp(utf8_encode($reload_manifest),$old_manifest) == 0 ){
340 
341  //get exisiting module version
342  $module_version = $this->object->getModuleVersion();
343 
344  if ($_FILES["scormfile"]["name"])
345  {
346  //build targetdir in lm_data
347  $file_path = $this->object->getDataDirectory()."/".$_FILES["scormfile"]["name"].".".$module_version;
348 
349  //move to data directory and add subfix for versioning
350  ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"],$_FILES["scormfile"]["name"], $file_path);
351  }
352  else
353  {
354  //build targetdir in lm_data
355  $file_path = $this->object->getDataDirectory()."/".$_POST["uploaded_file"].".".$module_version;
356 
357  // move the already copied file to the lm_data directory
358  rename($source, $file_path);
359  }
360 
361  //unzip and replace old extracted files
362  ilUtil::unzip($file_path, true);
363  ilUtil::renameExecutables($this->object->getDataDirectory()); //(security)
364 
365  //increase module version
366  $this->object->setModuleVersion($module_version+1);
367  $this->object->update();
368 
369  //redirect to properties and display success
370  ilUtil::sendInfo( $this->lng->txt("cont_new_module_added"), true);
371  ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=".$_GET["ref_id"]);
372  exit;
373  }
374  else
375  {
376  if ($source_is_copy)
377  {
378  unlink($source);
379  }
380 
381  ilUtil::sendInfo($this->lng->txt("cont_invalid_new_module"),true);
382  $this->newModuleVersion();
383  }
384 
385  }
386 
390  function saveProperties()
391  {
392  $this->object->setOnline(ilUtil::yn2tf($_POST["cobj_online"]));
393  $this->object->setAutoReview(ilUtil::yn2tf($_POST["auto_review"]));
394  $this->object->setAPIAdapterName($_POST["api_adapter"]);
395  $this->object->setAPIFunctionsPrefix($_POST["api_func_prefix"]);
396  $this->object->setCreditMode($_POST["credit_mode"]);
397  $this->object->setDefaultLessonMode($_POST["lesson_mode"]);
398  $this->object->setMaxAttempt($_POST["max_attempt"]);
399  $this->object->setSession(ilUtil::yn2tf($_POST["cobj_session"]));
400  $this->object->setDebug(ilUtil::yn2tf($_POST["cobj_debug"]));
401  $this->object->setAutoContinue(ilUtil::yn2tf($_POST["auto_continue"]));
402  $this->object->update();
403  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
404  $this->ctrl->redirect($this, "properties");
405  }
406 
407 
413  {
414 
415  global $ilTabs;
416 
417  include_once "./Services/Table/classes/class.ilTableGUI.php";
418 
419  $this->setSubTabs();
420 
421  $ilTabs->setSubTabActive("cont_tracking_bysco");
422  $ilTabs->setTabActive("cont_tracking_data");
423 
424 
425  // load template for table
426  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
427  // load template for table content data
428  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_items_sco.html", "Modules/ScormAicc");
429 
430  $num = 1;
431 
432  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
433 
434  // create table
435  $tbl = new ilTableGUI();
436 
437  // title & header columns
438  $tbl->setTitle($this->lng->txt("cont_tracking_items"));
439 
440  $tbl->setHeaderNames(array($this->lng->txt("title")));
441 
442  $header_params = array("ref_id" => $this->ref_id, "cmd" => $_GET["cmd"],
443  "cmdClass" => get_class($this), "baseClass"=>"ilSAHSEditGUI");
444  $cols = array("title");
445  $tbl->setHeaderVars($cols, $header_params);
446  $tbl->setColumnWidth(array("100%"));
447 
448  // control
449  $tbl->setOrderColumn($_GET["sort_by"]);
450  $tbl->setOrderDirection($_GET["sort_order"]);
451  $tbl->setLimit($_GET["limit"]);
452  $tbl->setOffset($_GET["offset"]);
453  $tbl->setMaxCount($this->maxcount);
454 
455  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
456  //$this->showActions(true);
457 
458  // footer
459  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
460  #$tbl->disable("footer");
461 
462  //$items = $this->object->getTrackingItems();
463  $items = $this->object->getTrackedItems();
464 
465  $item_array = array();
466  foreach($items as $item)
467  {
468  $tmp['title'] = $item->getTitle();
469  $tmp['id'] = $item->getId();
470 
471  $item_array[] = $tmp;
472  }
473 
474  $items = ilUtil::sortArray($item_array, $_GET["sort_by"], $_GET["sort_order"]);
475  $tbl->setMaxCount(count($items));
476  $items = array_slice($items, $_GET["offset"], $_GET["limit"]);
477 
478 
479  $tbl->render();
480  if (count($items) > 0)
481  {
482  foreach ($items as $item)
483  {
484  $this->tpl->setCurrentBlock("tbl_content");
485  $this->tpl->setVariable("TXT_ITEM_TITLE", $item['title']);
486  $this->ctrl->setParameter($this, "obj_id", $item['id']);
487  $this->tpl->setVariable("LINK_ITEM",
488  $this->ctrl->getLinkTarget($this, "showTrackingItemSco"));
489 
490  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
491  $this->tpl->setVariable("CSS_ROW", $css_row);
492  $this->tpl->parseCurrentBlock();
493  }
494  } //if is_array
495  else
496  {
497  $this->tpl->setCurrentBlock("notfound");
498  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
499  $this->tpl->setVariable("NUM_COLS", $num);
500  $this->tpl->parseCurrentBlock();
501  }
502  }
503 
507  function showTrackingItems()
508  {
509 
510  global $ilTabs;
511 
512  include_once "./Services/Table/classes/class.ilTableGUI.php";
513 
514  $this->setSubTabs();
515 
516  $ilTabs->setSubTabActive("cont_tracking_byuser");
517  $ilTabs->setTabActive("cont_tracking_data");
518 
519  //set search
520 
521  if ($_POST["search_string"] != "")
522  {
523  $_SESSION["scorm_search_string"] = trim($_POST["search_string"]);
524  } else if (isset($_POST["search_string"]) && $_POST["search_string"] == "") {
525  unset($_SESSION["scorm_search_string"]);
526  }
527 
528 
529  // load template for search additions
530  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl_scorm_track_items_search.html","Modules/ScormAicc");
531  // load template for table
532  $this->tpl->addBlockfile("USR_TABLE", "usr_table", "tpl.table.html");
533  // load template for table content data
534  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_items.html", "Modules/ScormAicc");
535 
536  $num = 6;
537 
538  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
539 
540  // create table
541  $tbl = new ilTableGUI();
542 
543  // title & header columns
544  if (isset($_SESSION["scorm_search_string"])) {
545  $tbl->setTitle($this->lng->txt("cont_tracking_items").' - Aktive Suche: "'.$_SESSION["scorm_search_string"].'"');
546  } else {
547  $tbl->setTitle($this->lng->txt("cont_tracking_items"));
548  }
549 
550 // $tbl->setHeaderNames(array("",$this->lng->txt("name"), $this->lng->txt("last_access"),$this->lng->txt("status"), $this->lng->txt("attempts"), $this->lng->txt("version") ));
551  $tbl->setHeaderNames(array("",$this->lng->txt("name"), $this->lng->txt("last_access"), $this->lng->txt("attempts"), $this->lng->txt("version") ));
552 
553  $header_params = $this->ctrl->getParameterArray($this, "showTrackingItems");
554 
555  $tbl->setColumnWidth(array("1%", "35%", "20%", "15%","15%","15%"));
556 
557  // $cols = array("user_id","username","last_access","status","attempts","version");
558  $cols = array("user_id","username","last_access","attempts","version");
559 
560  $tbl->setHeaderVars($cols, $header_params);
561 
562  //set defaults
563  $_GET["sort_order"] = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
564  $_GET["sort_by"] = $_GET["sort_by"] ? $_GET["sort_by"] : "username";
565 
566  // control
567  $tbl->setOrderColumn($_GET["sort_by"]);
568  $tbl->setOrderDirection($_GET["sort_order"]);
569  $tbl->setLimit($_GET["limit"]);
570  $tbl->setOffset($_GET["offset"]);
571  $tbl->setMaxCount($this->maxcount);
572 
573  $this->tpl->setVariable("COLUMN_COUNTS", 6);
574 
575  // delete button
576  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
577  $this->tpl->setCurrentBlock("tbl_action_btn");
578  $this->tpl->setVariable("BTN_NAME", "deleteTrackingForUser");
579  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
580  $this->tpl->parseCurrentBlock();
581 
582  // decrease attempts
583  $this->tpl->setCurrentBlock("tbl_action_btn");
584  $this->tpl->setVariable("BTN_NAME", "decreaseAttempts");
585  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("decrease_attempts"));
586  $this->tpl->parseCurrentBlock();
587 
588  // export aggregated data for selected users
589  $this->tpl->setCurrentBlock("tbl_action_btn");
590  $this->tpl->setVariable("BTN_NAME", "exportSelected");
591  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("export"));
592  $this->tpl->parseCurrentBlock();
593 
594  // add search and export all
595  // export aggregated data for all users
596  $this->tpl->setVariable("EXPORT_ACTION",$this->ctrl->getFormAction($this));
597 
598  $this->tpl->setVariable("EXPORT_ALL_VALUE", $this->lng->txt('cont_export_all'));
599  $this->tpl->setVariable("EXPORT_ALL_NAME", "exportAll");
600  $this->tpl->setVariable("IMPORT_VALUE", $this->lng->txt('import'));
601  $this->tpl->setVariable("IMPORT_NAME", "Import");
602 
603  $this->tpl->setVariable("SEARCH_TXT_SEARCH",$this->lng->txt('search'));
604  $this->tpl->setVariable("SEARCH_ACTION",$this->ctrl->getFormAction($this));
605  $this->tpl->setVariable("SEARCH_NAME",'showTrackingItems');
606  if (isset($_SESSION["scorm_search_string"])) {
607  $this->tpl->setVariable("STYLE",'display:inline;');
608  } else {
609  $this->tpl->setVariable("STYLE",'display:none;');
610  }
611  $this->tpl->setVariable("SEARCH_VAL", $_SESSION["scorm_search_string"]);
612  $this->tpl->setVariable("SEARCH_VALUE",$this->lng->txt('search_users'));
613  $this->tpl->parseCurrentBlock();
614 
615  // footer
616  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
617 
618  $items = $this->object->getTrackedUsers($_SESSION["scorm_search_string"]);
619  $tbl->setMaxCount(count($items));
620 
621  $items = ilUtil::sortArray($items ,$_GET["sort_by"],$_GET["sort_order"]);
622  $items = array_slice($items, $_GET["offset"], $_GET["limit"]);
623 
624  $tbl->render();
625 
626  if (count($items) > 0)
627  {
628  foreach ($items as $item)
629  {
630  if (ilObject::_exists($item["user_id"]) && ilObject::_lookUpType($item["user_id"])=="usr")
631  {
632  $this->tpl->setCurrentBlock("tbl_content");
633  $this->tpl->setVariable("VAL_USERNAME",$item["username"]);
634  $this->tpl->setVariable("VAL_LAST", $item["last_access"]);
635  $this->tpl->setVariable("VAL_ATTEMPT",$item["attempts"]);
636  $this->tpl->setVariable("VAL_VERSION", $item["version"]);
637  // $this->tpl->setVariable("VAL_STATUS", $item["status"]);
638  $this->ctrl->setParameter($this, "user_id", $item["user_id"]);
639  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
640  $this->tpl->setVariable("LINK_ITEM",
641  $this->ctrl->getLinkTarget($this, "showTrackingItem"));
642  $this->tpl->setVariable("CHECKBOX_ID", $item["user_id"]);
643  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
644  $this->tpl->setVariable("CSS_ROW", $css_row);
645  $this->tpl->parseCurrentBlock();
646  }
647  }
648  $this->tpl->setCurrentBlock("selectall");
649  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
650  $this->tpl->setVariable("CSS_ROW", $css_row);
651  $this->tpl->parseCurrentBlock();
652 
653  } //if is_array
654  else
655  {
656  $this->tpl->setCurrentBlock("notfound");
657  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
658  $this->tpl->setVariable("NUM_COLS", $num);
659  $this->tpl->parseCurrentBlock();
660  }
661 
662  }
663 
664 
665  function resetSearch() {
666  unset($_SESSION["scorm_search_string"]);
667  $this->ctrl->redirect($this, "showTrackingItems");
668  }
669 
670 
675  {
676 
677  if(!isset($_POST["user"]))
678  {
679  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
680  }
681  // SAVE POST VALUES
682  $_SESSION["scorm_user_delete"] = $_POST["user"];
683 
684  unset($this->data);
685  $this->data["cols"] = array("type","title", "description");
686 
687  foreach($_POST["user"] as $id)
688  {
689  if (ilObject::_exists($id) && ilObject::_lookUpType($id)=="usr" ) {
690  $user = new ilObjUser($id);
691  $this->data["data"]["$id"] = array(
692  "type" => "sahs",
693  "title" => $user->getLastname().", ".$user->getFirstname(),
694  "desc" => $this->lng->txt("cont_trackinging_data")
695  );
696  }
697  }
698 
699  $this->data["buttons"] = array( "cancelDelete" => $this->lng->txt("cancel"),
700  "confirmedDelete" => $this->lng->txt("confirm"));
701 
702  $this->getTemplateFile("confirm");
703 
704  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
705 
706  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
707 
708  // BEGIN TABLE HEADER
709  foreach ($this->data["cols"] as $key)
710  {
711  $this->tpl->setCurrentBlock("table_header");
712  $this->tpl->setVariable("TEXT",$this->lng->txt($key));
713  $this->tpl->parseCurrentBlock();
714  }
715  // END TABLE HEADER
716 
717  // BEGIN TABLE DATA
718  $counter = 0;
719 
720  foreach($this->data["data"] as $key => $value)
721  {
722  // BEGIN TABLE CELL
723  foreach($value as $key => $cell_data)
724  {
725  $this->tpl->setCurrentBlock("table_cell");
726 
727  // CREATE TEXT STRING
728  if($key == "type")
729  {
730  $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
731  }
732  else
733  {
734  $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
735  }
736  $this->tpl->parseCurrentBlock();
737  }
738 
739  $this->tpl->setCurrentBlock("table_row");
740  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
741  $this->tpl->parseCurrentBlock();
742  // END TABLE CELL
743  }
744  // END TABLE DATA
745 
746  // BEGIN OPERATION_BTN
747  foreach($this->data["buttons"] as $name => $value)
748  {
749  $this->tpl->setCurrentBlock("operation_btn");
750  $this->tpl->setVariable("BTN_NAME",$name);
751  $this->tpl->setVariable("BTN_VALUE",$value);
752  $this->tpl->parseCurrentBlock();
753  }
754  }
758  function cancelDelete()
759  {
760  session_unregister("scorm_user_delete");
761  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
762  $this->ctrl->redirect($this, "showTrackingItems");
763  }
764 
765  function confirmedDelete()
766  {
767  global $ilDB, $ilUser;
768 
769 
770  foreach ($_SESSION["scorm_user_delete"] as $user)
771  {
772  $ret = $ilDB->manipulateF('
773  DELETE FROM scorm_tracking
774  WHERE user_id = %s
775  AND obj_id = %s',
776  array('integer','integer'),
777  array($user,$this->object->getID()));
778 
779  }
780 
781  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
782  ilLPStatusWrapper::_updateStatus($this->object->getId(), $user);
783 
784  $this->ctrl->redirect($this, "showTrackingItems");
785  }
786 
790  function cancel()
791  {
792  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
793  $this->ctrl->redirect($this, "properties");
794  }
795 
796 
801  function import()
802  {
803  if (!isset($_POST["type"])) {
804  //show form
805  $this->importForm();
806  } else {
807  //
808  // check if file was uploaded
809  $source = $_FILES["datafile"]["tmp_name"];
810  if (($source == 'none') || (!$source))
811  {
812  ilUtil::sendInfo($this->lng->txt("No file selected!"),true);
813  $this->importForm();
814  } else {
815  $error = $this->object->importTrackingData($source);
816  switch ($error) {
817  case 0 :
818  ilUtil::sendInfo($this->lng->txt("Trackingdata imported"),true);
819  $this->ctrl->redirect($this, "showTrackingItems");
820  break;
821  case -1 :
822  ilUtil::sendInfo($this->lng->txt("Invalid import file"),true);
823  $this->importForm();
824  break;
825  }
826  }
827  }
828  }
829 
830 
831  function importForm(){
832 
835 
836  // display import form
837  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_tracking_data_import.html", "Modules/ScormAicc");
838 
839  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_slm.gif'));
840  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
841 
842  $this->ctrl->setParameter($this, "new_type", "sahs");
843  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
844 
845  $this->tpl->setVariable("BTN_NAME", "import");
846  $this->tpl->setVariable("TARGET", ' target="'.
847  ilFrameTargetInfo::_getFrame("MainContent").'" ');
848 
849  $this->tpl->setVariable("TXT_SELECT_LMTYPE", $this->lng->txt("type"));
850 
851  $this->tpl->setVariable("TXT_TYPE","CSV");
852 
853  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
854  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
855  $this->tpl->setVariable("TXT_IMPORT_TRACKING", $this->lng->txt("cont_import_tracking"));
856  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
857  // gives out the limit as a little notice
858  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice")." ".$this->getMaxFileSize());
859  }
860 
861 
862  function exportAll(){
863  $this->export(1);
864  }
865 
866  function exportSelected()
867  {
868  if (!isset($_POST["user"]))
869  {
870  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
871  $this->ctrl->redirect($this, "showTrackingItems");
872  } else {
873  $this->export(0);
874  }
875  }
876 
877  function export($a_export_all = 0)
878  {
879  if (!isset($_POST["export_type"])) {
880  //show form
881  $this->exportOptions($a_export_all,$_POST["user"]);
882  } else {
883  if (isset($_POST["cancel"])) {
884  $this->ctrl->redirect($this, "showTrackingItems");
885  } else {
886  $a_export_all = $_POST["export_all"];
887  if ($_POST["export_type"]=="raw") {
888  $this->object->exportSelectedRaw($a_export_all, unserialize(stripslashes($_POST["user"])));
889  } else {
890  $this->object->exportSelected($a_export_all, unserialize(stripslashes($_POST["user"])));
891  }
892  }
893  }
894  }
895 
896 
897  function exportOptions($a_export_all=0, $a_users)
898  {
901 
902  // display import form
903  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_tracking_data_export.html", "Modules/ScormAicc");
904 
905  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_slm.gif'));
906  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_sahs"));
907 
908  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("cont_export_options"));
909 
910  $this->ctrl->setParameter($this, "new_type", "sahs");
911  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
912 
913  $this->tpl->setVariable("BTN_NAME", "export");
914 
915  $this->tpl->setVariable("TARGET", ' target="'.
916  ilFrameTargetInfo::_getFrame("MainContent").'" ');
917 
918  $this->tpl->setVariable("TXT_SELECT_TYPE", $this->lng->txt("cont_export_type"));
919  $this->tpl->setVariable("TXT_EXPORT_RAW", $this->lng->txt("cont_export_raw"));
920  $this->tpl->setVariable("TXT_EXPORT_SUCCESS", $this->lng->txt("cont_export_success"));
921  $this->tpl->setVariable("TXT_EXPORT_TRACKING", $this->lng->txt("cont_export_tracking"));
922 
923  $this->tpl->setVariable("TXT_EXPORT", $this->lng->txt("export"));
924  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
925  $this->tpl->setVariable("VAL_USER", htmlentities(serialize($a_users)));
926  $this->tpl->setVariable("VAL_EXPORTALL",$a_export_all);
927 
928 
929  }
930 
931 
932  function decreaseAttempts()
933  {
934  global $ilDB, $ilUser;
935 
936  if (!isset($_POST["user"]))
937  {
938  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
939  }
940 
941  foreach ($_POST["user"] as $user)
942  {
943  //first check if there is a package_attempts entry
944 
945  //get existing account - sco id is always 0
946  $val_set = $ilDB->queryF('
947  SELECT * FROM scorm_tracking
948  WHERE user_id = %s
949  AND sco_id = %s
950  AND lvalue = %s
951  AND obj_id = %s',
952  array('integer','integer','text','integer'),
953  array($user,0,'package_attempts',$this->object->getID()));
954 
955  $val_rec = $ilDB->fetchAssoc($val_set);
956 
957  $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
958  if ($val_rec["rvalue"] != null && $val_rec["rvalue"] != 0)
959  {
960  $new_rec = $val_rec["rvalue"]-1;
961  //decrease attempt by 1
962  if($res = $ilDB->numRows($val_set) > 0)
963  {
964  $ilDB->update('scorm_tracking',
965  array(
966  'rvalue' => array('clob', $new_rec)
967  ),
968  array(
969  'user_id' => array('integer', $user),
970  'sco_id' => array('integer', 0),
971  'obj_id' => array('integer', $this->object->getId()),
972  'lvalue' => array('text', 'package_attempts')
973  )
974  );
975  }
976  else
977  {
978  $ilDB->insert('scorm_tracking', array(
979  'rvalue' => array('clob', $new_rec),
980  'user_id' => array('integer', $user),
981  'sco_id' => array('integer', 0),
982  'obj_id' => array('integer', $this->object->getId()),
983  'lvalue' => array('text', 'package_attempts')
984  ));
985  }
986 
987  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
988  ilLPStatusWrapper::_updateStatus($this->object->getId(), $user);
989  }
990  }
991 
992  //$this->ctrl->saveParameter($this, "cdir");
993  $this->ctrl->redirect($this, "showTrackingItems");
994  }
995 
996 
1000  function showTrackingItem()
1001  {
1002  global $ilTabs;
1003 
1004  include_once "./Services/Table/classes/class.ilTableGUI.php";
1005 
1006  $this->setSubTabs();
1007  $ilTabs->setTabActive("cont_tracking_data");
1008  $ilTabs->setSubTabActive("cont_tracking_byuser");
1009 
1010  // load template for table
1011  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1012  // load template for table content data
1013  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_item.html", "Modules/ScormAicc");
1014 
1015 
1016  $num = 2;
1017 
1018  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
1019 
1020  // create table
1021  $tbl = new ilTableGUI();
1022 
1023  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
1024  $sc_item =& new ilSCORMItem($_GET["obj_id"]);
1025 
1026  // title & header columns
1027  $user = new ilObjUser( $_GET["user_id"]);
1028  $tbl->setTitle($user->getLastname().", ".$user->getFirstname());
1029 
1030  $tbl->setHeaderNames(array($this->lng->txt("title"),
1031  $this->lng->txt("cont_status"), $this->lng->txt("cont_time"),
1032  $this->lng->txt("cont_score")));
1033 
1034  $header_params = array("ref_id" => $this->ref_id, "cmd" => $_GET["cmd"],
1035  "cmdClass" => get_class($this), "obj_id" => $_GET["obj_id"], "baseClass"=>"ilSAHSEditGUI", 'user_id'=>$_GET["user_id"]);
1036  $cols = array("title", "status", "time", "score");
1037  $tbl->setHeaderVars($cols, $header_params);
1038  //$tbl->setColumnWidth(array("25%",));
1039 
1040  // control
1041  $tbl->setOrderColumn($_GET["sort_by"]);
1042  $tbl->setOrderDirection($_GET["sort_order"]);
1043  $tbl->setLimit($_GET["limit"]);
1044  $tbl->setOffset($_GET["offset"]);
1045  $tbl->setMaxCount($this->maxcount);
1046 
1047  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1048  //$this->showActions(true);
1049 
1050  // footer
1051  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1052  #$tbl->disable("footer");
1053 
1054  $tr_data = $this->object->getTrackingDataAgg($_GET["user_id"]);
1055 
1056 
1057  $tr_data = ilUtil::sortArray($tr_data, $_GET["sort_by"], $_GET["sort_order"]);
1058  $tbl->setMaxCount(count($tr_data));
1059  $tr_data = array_slice($tr_data, $_GET["offset"], $_GET["limit"]);
1060 
1061  $tbl->render();
1062  if (count($tr_data) > 0)
1063  {
1064  foreach ($tr_data as $data)
1065  {
1066  $this->tpl->setCurrentBlock("tbl_content");
1067  $this->tpl->setVariable("VAL_TITLE", $data["title"]);
1068  $this->ctrl->setParameter($this, "user_id", $_GET["user_id"]);
1069  $this->ctrl->setParameter($this, "obj_id", $data["sco_id"]);
1070 
1071  $this->tpl->setVariable("LINK_SCO",
1072  $this->ctrl->getLinkTarget($this, "showTrackingItemPerUser"));
1073  $this->tpl->setVariable("VAL_TIME", $data["time"]);
1074  $this->tpl->setVariable("VAL_STATUS", $data["status"]);
1075  $this->tpl->setVariable("VAL_SCORE", $data["score"]);
1076 
1077  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1078  $this->tpl->setVariable("CSS_ROW", $css_row);
1079  $this->tpl->parseCurrentBlock();
1080 
1081  }
1082  } //if is_array
1083  else
1084  {
1085  $this->tpl->setCurrentBlock("notfound");
1086  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1087  $this->tpl->setVariable("NUM_COLS", $num);
1088  $this->tpl->parseCurrentBlock();
1089  }
1090  }
1091 
1092 
1097  {
1098  global $ilTabs;
1099 
1100  include_once "./Services/Table/classes/class.ilTableGUI.php";
1101 
1102  $this->setSubTabs();
1103  $ilTabs->setTabActive("cont_tracking_data");
1104  $ilTabs->setSubTabActive("cont_tracking_bysco");
1105 
1106  // load template for table
1107  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1108  // load template for table content data
1109  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_item_sco.html", "Modules/ScormAicc");
1110 
1111  $num = 2;
1112 
1113  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
1114 
1115  // create table
1116  $tbl = new ilTableGUI();
1117 
1118  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
1119  $sc_item =& new ilSCORMItem($_GET["obj_id"]);
1120 
1121  // title & header columns
1122  $tbl->setTitle($sc_item->getTitle());
1123 
1124  $tbl->setHeaderNames(array($this->lng->txt("name"),
1125  $this->lng->txt("cont_status"), $this->lng->txt("cont_time"),
1126  $this->lng->txt("cont_score")));
1127 
1128  $header_params = $this->ctrl->getParameterArray($this, "showTrackingItemSco");
1129  $header_params['obj_id'] = (int) $_GET['obj_id'];
1130 
1131  $cols = array("name", "status", "time", "score");
1132  $tbl->setHeaderVars($cols, $header_params);
1133  //$tbl->setColumnWidth(array("25%",));
1134 
1135  // control
1136  $tbl->setOrderColumn($_GET["sort_by"]);
1137  $tbl->setOrderDirection($_GET["sort_order"]);
1138  $tbl->setLimit($_GET["limit"]);
1139  $tbl->setOffset($_GET["offset"]);
1140  $tbl->setMaxCount($this->maxcount);
1141 
1142  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1143  //$this->showActions(true);
1144 
1145  // footer
1146  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1147  #$tbl->disable("footer");
1148 
1149  $tr_data = $this->object->getTrackingDataAggSco($_GET["obj_id"]);
1150 
1151  $tmp = array();
1152  foreach($tr_data as $data)
1153  {
1154  $name = ilObjUser::_lookupName($data['user_id']);
1155  $data['name'] = $name['lastname'].', '.$name['firstname'];
1156 
1157  $tmp[] = $data;
1158  }
1159  $tr_data = $tmp;
1160 
1161  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
1162  $tbl->setMaxCount(count($tr_data));
1163 
1164  $tr_data = ilUtil::sortArray($tr_data ,$_GET["sort_by"],$_GET["sort_order"]);
1165 
1166  $tr_data = array_slice($tr_data, $_GET["offset"], $_GET["limit"]);
1167 
1168  $tbl->render();
1169  if (count($tr_data) > 0)
1170  {
1171  foreach ($tr_data as $data)
1172  {
1173  if (ilObject::_exists($data["user_id"]))
1174  {
1175  $this->tpl->setCurrentBlock("tbl_content");
1176  $user = new ilObjUser($data["user_id"]);
1177  $this->tpl->setVariable("VAL_USERNAME", $user->getLastname().", ".
1178  $user->getFirstname());
1179  $this->ctrl->setParameter($this, "user_id", $data["user_id"]);
1180  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1181  $this->tpl->setVariable("LINK_USER",
1182  $this->ctrl->getLinkTarget($this, "showTrackingItemPerUser"));
1183  $this->tpl->setVariable("VAL_TIME", $data["time"]);
1184  $this->tpl->setVariable("VAL_STATUS", $data["status"]);
1185  $this->tpl->setVariable("VAL_SCORE", $data["score"]);
1186 
1187  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1188  $this->tpl->setVariable("CSS_ROW", $css_row);
1189  $this->tpl->parseCurrentBlock();
1190  }
1191  }
1192  } //if is_array
1193  else
1194  {
1195  $this->tpl->setCurrentBlock("notfound");
1196  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1197  $this->tpl->setVariable("NUM_COLS", $num);
1198  $this->tpl->parseCurrentBlock();
1199  }
1200  }
1201 
1206  {
1207  global $ilTabs;
1208 
1209  $ilTabs->setTabActive("cont_tracking_data");
1210 
1211  include_once "./Services/Table/classes/class.ilTableGUI.php";
1212 
1213  // load template for table
1214  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1215  // load template for table content data
1216  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.scorm_track_item_per_user.html", "Modules/ScormAicc");
1217 
1218  $num = 2;
1219 
1220  $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
1221 
1222  // create table
1223  $tbl = new ilTableGUI();
1224 
1225  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
1226  $sc_item =& new ilSCORMItem($_GET["obj_id"]);
1227  $user = new ilObjUser($_GET["user_id"]);
1228 
1229  // title & header columns
1230  $tbl->setTitle($sc_item->getTitle()." - ".$user->getLastname().", ".$user->getFirstname());
1231 
1232  $tbl->setHeaderNames(array($this->lng->txt("cont_lvalue"), $this->lng->txt("cont_rvalue")));
1233 
1234  $header_params = array("ref_id" => $this->ref_id, "cmd" => $_GET["cmd"],
1235  "cmdClass" => get_class($this), "obj_id" => $_GET["obj_id"],
1236  "user_id" => $_GET["user_id"],"baseClass"=>"ilSAHSEditGUI");
1237  $cols = array("lvalue", "rvalue");
1238  $tbl->setHeaderVars($cols, $header_params);
1239  //$tbl->setColumnWidth(array("25%",));
1240 
1241  // control
1242  $tbl->setOrderColumn($_GET["sort_by"]);
1243  $tbl->setOrderDirection($_GET["sort_order"]);
1244  $tbl->setLimit($_GET["limit"]);
1245  $tbl->setOffset($_GET["offset"]);
1246  $tbl->setMaxCount($this->maxcount);
1247 
1248  //$this->tpl->setVariable("COLUMN_COUNTS",count($this->data["cols"]));
1249  //$this->showActions(true);
1250 
1251  // footer
1252  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1253  #$tbl->disable("footer");
1254 
1255  $tr_data = $this->object->getTrackingDataPerUser($_GET["obj_id"], $_GET["user_id"]);
1256 
1257  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
1258  $tbl->setMaxCount(count($tr_data));
1259  $tr_data = array_slice($tr_data, $_GET["offset"], $_GET["limit"]);
1260 
1261  $tbl->render();
1262  if (count($tr_data) > 0)
1263  {
1264  foreach ($tr_data as $data)
1265  {
1266  $this->tpl->setCurrentBlock("tbl_content");
1267  $this->tpl->setVariable("VAR", $data["lvalue"]);
1268  $this->tpl->setVariable("VAL", $data["rvalue"]);
1269 
1270  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1271  $this->tpl->setVariable("CSS_ROW", $css_row);
1272  $this->tpl->parseCurrentBlock();
1273  }
1274  } //if is_array
1275  else
1276  {
1277  $this->tpl->setCurrentBlock("notfound");
1278  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1279  $this->tpl->setVariable("NUM_COLS", $num);
1280  $this->tpl->parseCurrentBlock();
1281  }
1282  }
1283 
1284  //setTabs
1285  function setSubTabs()
1286  {
1287  global $lng, $ilTabs, $ilCtrl;
1288 
1289  $ilTabs->addSubTabTarget("cont_tracking_byuser",
1290  $this->ctrl->getLinkTarget($this, "showTrackingItems"), array("edit", ""),
1291  get_class($this));
1292 
1293  $ilTabs->addSubTabTarget("cont_tracking_bysco",
1294  $this->ctrl->getLinkTarget($this, "showTrackingItemsBySco"), array("edit", ""),
1295  get_class($this));
1296  }
1297 
1298 } // END class.ilObjSCORMLearningModule
1299 ?>