00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00037 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
00038 include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
00039
00040 class ilLPListOfSettingsGUI extends ilLearningProgressBaseGUI
00041 {
00042 function ilLPListOfSettingsGUI($a_mode,$a_ref_id)
00043 {
00044 parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id);
00045
00046 $this->obj_settings = new ilLPObjSettings($this->getObjId());
00047 }
00048
00052 function &executeCommand()
00053 {
00054 switch($this->ctrl->getNextClass())
00055 {
00056 default:
00057 $cmd = $this->__getDefaultCommand();
00058 $this->$cmd();
00059
00060 }
00061 return true;
00062 }
00063
00064 function show()
00065 {
00066
00067
00068 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_obj_settings.html','Services/Tracking');
00069
00070 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this));
00071 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00072 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('tracking_settings'));
00073 $this->tpl->setVariable("TXT_TRACKING_SETTINGS", $this->lng->txt("tracking_settings"));
00074
00075 $this->tpl->setVariable("TXT_ACTIVATE_TRACKING", $this->lng->txt("trac_activated"));
00076 $this->tpl->setVariable("ACTIVATED_IMG_OK",$activated = ilObjUserTracking::_enabledLearningProgress()
00077 ? ilUtil::getImagePath('icon_ok.gif')
00078 : ilUtil::getImagePath('icon_not_ok.gif'));
00079 $this->tpl->setVariable("ACTIVATED_STATUS",$activated ? $this->lng->txt('yes') : $this->lng->txt('no'));
00080
00081 $this->tpl->setVariable("TXT_USER_RELATED_DATA", $this->lng->txt("trac_anonymized"));
00082 $this->tpl->setVariable("ANONYMIZED_IMG_OK",$anonymized = !ilObjUserTracking::_enabledUserRelatedData()
00083 ? ilUtil::getImagePath('icon_ok.gif')
00084 : ilUtil::getImagePath('icon_not_ok.gif'));
00085 $this->tpl->setVariable("ANONYMIZED_STATUS",$anonymized ? $this->lng->txt('no') : $this->lng->txt('yes'));
00086
00087 $this->tpl->setVariable("TXT_VALID_REQUEST",$this->lng->txt('trac_valid_request'));
00088 $this->tpl->setVariable("INFO_VALID_REQUEST",$this->lng->txt('info_valid_request'));
00089 $this->tpl->setVariable("SECONDS",$this->lng->txt('seconds'));
00090 $this->tpl->setVariable("VAL_SECONDS",ilObjUserTracking::_getValidTimeSpan());
00091
00092
00093 $this->tpl->setVariable("TXT_MODE",$this->lng->txt('trac_modus'));
00094
00095 $this->tpl->setVariable("MODE",ilUtil::formSelect($this->obj_settings->getMode(),
00096 'modus',
00097 $this->obj_settings->getValidModes(),
00098 false,true));
00099
00100 if($this->obj_settings->getMode() == LP_MODE_VISITS)
00101 {
00102 $this->tpl->setCurrentBlock("visits");
00103 $this->tpl->setVariable("TXT_VISITS",$this->lng->txt('trac_num_visits'));
00104 $this->tpl->setVariable("NUM_VISITS",$this->obj_settings->getVisits());
00105 $this->tpl->setVariable("INFO_VISITS",$this->lng->txt('trac_visits_info'));
00106 $this->tpl->parseCurrentBlock();
00107 }
00108
00109 $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
00110
00111
00112 $this->__showTablesByMode();
00113 }
00114
00115 function saveSettings()
00116 {
00117 $this->__addInfo();
00118 $this->obj_settings->setMode($_POST['modus']);
00119 if((int) $_POST['visits'])
00120 {
00121 $this->obj_settings->setVisits((int) $_POST['visits']);
00122 }
00123 $this->obj_settings->update();
00124 $this->show();
00125 }
00126
00127 function assign()
00128 {
00129 if(!$_POST['item_ids'] and !$_POST['event_ids'])
00130 {
00131 sendInfo($this->lng->txt('select_one'));
00132 $this->show();
00133 return false;
00134 }
00135 if(count($_POST['item_ids']))
00136 {
00137 include_once 'Services/Tracking/classes/class.ilLPCollections.php';
00138 $lp_collections = new ilLPCollections($this->getObjId());
00139 foreach($_POST['item_ids'] as $ref_id)
00140 {
00141 $lp_collections->add($ref_id);
00142 }
00143 }
00144 if($_POST['event_ids'])
00145 {
00146 include_once 'Services/Tracking/classes/class.ilLPEventCollections.php';
00147 $event_collections = new ilLPEventCollections($this->getObjId());
00148 foreach($_POST['event_ids'] as $event_id)
00149 {
00150 $event_collections->add($event_id);
00151 }
00152 }
00153 sendInfo($this->lng->txt('trac_settings_saved'));
00154 $this->show();
00155 }
00156
00157 function deassign()
00158 {
00159 if(!$_POST['item_ids'] and !$_POST['event_ids'])
00160 {
00161 sendInfo($this->lng->txt('select_one'));
00162 $this->show();
00163 return false;
00164 }
00165 if(count($_POST['item_ids']))
00166 {
00167 include_once 'Services/Tracking/classes/class.ilLPCollections.php';
00168 $lp_collections = new ilLPCollections($this->getObjId());
00169 foreach($_POST['item_ids'] as $ref_id)
00170 {
00171 $lp_collections->delete($ref_id);
00172 }
00173 }
00174 if($_POST['event_ids'])
00175 {
00176 include_once 'Services/Tracking/classes/class.ilLPEventCollections.php';
00177 $event_collections = new ilLPEventCollections($this->getObjId());
00178 foreach($_POST['event_ids'] as $event_id)
00179 {
00180 $event_collections->delete($event_id);
00181 }
00182 }
00183 sendInfo($this->lng->txt('trac_settings_saved'));
00184 $this->show();
00185 }
00186
00187 function __showTablesByMode()
00188 {
00189 switch($this->obj_settings->getMode())
00190 {
00191 case LP_MODE_COLLECTION:
00192
00193 $this->__showCollectionTable();
00194 break;
00195
00196 case LP_MODE_SCORM:
00197
00198 $this->__showSCOTable();
00199 break;
00200
00201 }
00202 return true;
00203 }
00204
00205 function __showSCOTable()
00206 {
00207 global $ilObjDataCache,$tree;
00208
00209 include_once 'Services/Tracking/classes/class.ilLPCollections.php';
00210 include_once 'content/classes/SCORM/class.ilSCORMItem.php';
00211
00212
00213 if(!$items = ilLPCollections::_getPossibleSAHSItems($this->getObjId()))
00214 {
00215 sendInfo($this->lng->txt('trac_no_sahs_items_found'));
00216 return false;
00217 }
00218
00219 $lp_collections = new ilLPCollections($this->getObjId());
00220 $tpl =& new ilTemplate('tpl.trac_collections.html',true,true,'Services/Tracking');
00221
00222
00223 $tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('trac_lp_determination'));
00224 $tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00225
00226 $tpl->setVariable("TABLE_TITLE", $this->lng->txt('trac_lp_determination'));
00227 $tpl->setVariable("TABLE_INFO", $this->lng->txt('trac_lp_determination_info_sco'));
00228
00229
00230
00231 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00232 $tpl->setVariable("BTN_ASSIGN",$this->lng->txt('trac_collection_assign'));
00233 $tpl->setVariable("BTN_DEASSIGN",$this->lng->txt('trac_collection_deassign'));
00234
00235
00236 $counter = 0;
00237
00238 $tpl->addBlockFile('MATERIALS','materials','tpl.trac_collections_sco_row.html','Services/Tracking');
00239 $counter = 0;
00240 foreach($items as $obj_id => $data)
00241 {
00242 $tpl->setCurrentBlock("materials");
00243 $tpl->setVariable("COLL_TITLE",$data['title']);
00244 $tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00245 $tpl->setVariable("CHECK_TRAC",ilUtil::formCheckbox(0,'item_ids[]',$obj_id));
00246
00247
00248 $tpl->setVariable("ASSIGNED_IMG_OK",$lp_collections->isAssigned($obj_id)
00249 ? ilUtil::getImagePath('icon_ok.gif')
00250 : ilUtil::getImagePath('icon_not_ok.gif'));
00251 $tpl->setVariable("ASSIGNED_STATUS",$lp_collections->isAssigned($obj_id)
00252 ? $this->lng->txt('trac_assigned')
00253 : $this->lng->txt('trac_not_assigned'));
00254
00255
00256 $tpl->parseCurrentBlock();
00257 }
00258 $tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00259 $tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
00260 $this->tpl->setVariable("COLLECTION_TABLE",$tpl->get());
00261 }
00262
00263
00264
00265
00266 function __showCollectionTable()
00267 {
00268 global $ilObjDataCache,$tree;
00269
00270 include_once 'Services/Tracking/classes/class.ilLPCollections.php';
00271 include_once 'Services/Tracking/classes/class.ilLPEventCollections.php';
00272 include_once 'course/classes/Event/class.ilEvent.php';
00273 include_once 'classes/class.ilLink.php';
00274 include_once 'classes/class.ilFrameTargetInfo.php';
00275
00276
00277 $events = ilEvent::_getEvents($this->getObjId());
00278
00279 $lp_collections = new ilLPCollections($this->getObjId());
00280
00281 $tpl =& new ilTemplate('tpl.trac_collections.html',true,true,'Services/Tracking');
00282
00283 $tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('trac_lp_determination'));
00284 $tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_trac.gif'));
00285
00286 $tpl->setVariable("TABLE_TITLE",$this->lng->txt('trac_lp_determination'));
00287 $tpl->setVariable("TABLE_INFO",$this->lng->txt('trac_lp_determination_info_crs'));
00288 $tpl->setVariable("ITEM_DESC",$this->lng->txt('trac_crs_items'));
00289 $tpl->setVariable("ITEM_ASSIGNED",$this->lng->txt('trac_assigned'));
00290
00291 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00292 $tpl->setVariable("BTN_ASSIGN",$this->lng->txt('trac_collection_assign'));
00293 $tpl->setVariable("BTN_DEASSIGN",$this->lng->txt('trac_collection_deassign'));
00294
00295
00296 if(!ilLPCollections::_getCountPossibleItems($this->getRefId()) and !count($events))
00297 {
00298 $tpl->setCurrentBlock("no_items");
00299 $tpl->setVariable("NO_ITEM_MESSAGE",$this->lng->txt('trac_no_items'));
00300 $tpl->parseCurrentBlock();
00301 }
00302
00303
00304 if(count($events))
00305 {
00306 $tpl->setCurrentBlock("header_materials");
00307 $tpl->setVariable("TXT_HEADER_MATERIALS",$this->lng->txt('crs_materials'));
00308 $tpl->parseCurrentBlock();
00309 }
00310 $tpl->addBlockFile('MATERIALS','materials','tpl.trac_collections_row.html','Services/Tracking');
00311 $counter = 0;
00312
00313 foreach(ilLPCollections::_getPossibleItems($this->getRefId()) as $ref_id)
00314 {
00315 $obj_id = $ilObjDataCache->lookupObjId($ref_id);
00316 $type = $ilObjDataCache->lookupType($obj_id);
00317
00318 $anonymized = $this->__checkItemAnonymized($obj_id,$type);
00319
00320 $tpl->setCurrentBlock("materials");
00321
00322
00323 $tpl->setVariable("COLL_MODE",
00324 $this->lng->txt('trac_mode').": ".
00325 ilLPObjSettings::_mode2Text(ilLPObjSettings::_lookupMode($obj_id)));
00326 if($anonymized)
00327 {
00328 $tpl->setVariable("ANONYMIZED",$this->lng->txt('trac_anonymized_info_short'));
00329 }
00330 $tpl->setVariable("COLL_LINK",ilLink::_getLink($ref_id,$ilObjDataCache->lookupType($obj_id)));
00331 $tpl->setVariable("COLL_FRAME",ilFrameTargetInfo::_getFrame('MainContent',$ilObjDataCache->lookupType($obj_id)));
00332 $tpl->setVariable("COLL_DESC",$ilObjDataCache->lookupDescription($obj_id));
00333 $tpl->setVariable("COLL_TITLE",$ilObjDataCache->lookupTitle($obj_id));
00334 $tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00335
00336 if(!$anonymized)
00337 {
00338 $tpl->setVariable("CHECK_TRAC",ilUtil::formCheckbox(0,'item_ids[]',$ref_id));
00339 }
00340
00341 $path = $this->__formatPath($tree->getPathFull($ref_id),$ref_id);
00342 $tpl->setVariable("COLL_PATH",$this->lng->txt('path').": ".$path);
00343
00344
00345 $tpl->setVariable("ASSIGNED_IMG_OK",$lp_collections->isAssigned($ref_id)
00346 ? ilUtil::getImagePath('icon_ok.gif')
00347 : ilUtil::getImagePath('icon_not_ok.gif'));
00348 $tpl->setVariable("ASSIGNED_STATUS",$lp_collections->isAssigned($ref_id)
00349 ? $this->lng->txt('trac_assigned')
00350 : $this->lng->txt('trac_not_assigned'));
00351
00352
00353 $tpl->parseCurrentBlock();
00354 }
00355
00356 $event_collections = new ilLPEventCollections($this->getObjId());
00357
00358
00359 if(count($events))
00360 {
00361 $tpl->setCurrentBlock("header_events");
00362 $tpl->setVariable("TXT_HEADER_NAME",$this->lng->txt('events'));
00363 $tpl->parseCurrentBlock();
00364 }
00365 $tpl->addBlockFile('EVENT','event','tpl.trac_collections_event_row.html','Services/Tracking');
00366 foreach($events as $event_obj)
00367 {
00368 $tpl->setCurrentBlock("event");
00369 $tpl->setVariable("EVENT_COLL_DESC",$event_obj->getDescription());
00370 $tpl->setVariable("EVENT_COLL_TITLE",$event_obj->getTitle());
00371 $tpl->setVariable("EVENT_ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00372 $tpl->setVariable("EVENT_CHECK_TRAC",ilUtil::formCheckbox(0,'event_ids[]',$event_obj->getEventId()));
00373
00374 $tpl->setVariable("EVENT_ASSIGNED_IMG_OK",$event_collections->isAssigned($event_obj->getEventId())
00375 ? ilUtil::getImagePath('icon_ok.gif')
00376 : ilUtil::getImagePath('icon_not_ok.gif'));
00377 $tpl->setVariable("EVENT_ASSIGNED_STATUS",$event_collections->isAssigned($event_obj->getEventId())
00378 ? $this->lng->txt('trac_assigned')
00379 : $this->lng->txt('trac_not_assigned'));
00380 $tpl->parseCurrentBlock();
00381 }
00382
00383 $tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
00384 $tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
00385
00386 $this->tpl->setVariable("COLLECTION_TABLE",$tpl->get());
00387 }
00388 function __addInfo()
00389 {
00390 $message = $this->lng->txt('trac_settings_saved');
00391
00392 if($this->obj_settings->getMode() == $_POST['modus'])
00393 {
00394 sendInfo($message);
00395 return true;
00396 }
00397
00398 switch($_POST['modus'])
00399 {
00400 case LP_MODE_COLLECTION:
00401 $message .= '<br />';
00402 $message .= $this->lng->txt('trac_edit_collection');
00403 break;
00404
00405 case LP_MODE_VISITS:
00406 $message .= '<br />';
00407 $message .= $this->lng->txt('trac_edit_visits');
00408 break;
00409
00410
00411 default:
00412 ;
00413 }
00414 sendInfo($message);
00415
00416 return true;
00417 }
00418
00419 function __formatPath($a_path_arr,$a_ref_id)
00420 {
00421 global $tree;
00422 #$path = $this->__formatPath($tree->getPathFull($ref_id));
00423 #$tpl->setVariable("COLL_PATH",$this->lng->txt('path').": ".$path);
00424 $counter = 0;
00425 foreach($a_path_arr as $data)
00426 {
00427 if(!$tree->isGrandChild($this->getRefId(),$data['ref_id']))
00428 {
00429 continue;
00430 }
00431 if($a_ref_id == $data['ref_id'])
00432 {
00433 break;
00434 }
00435 if($counter++)
00436 {
00437 $path .= " -> ";
00438 }
00439 $path .= $data['title'];
00440 }
00441
00442 return $path;
00443 }
00444
00445 function __checkItemAnonymized($a_obj_id,$a_type)
00446 {
00447 switch($a_type)
00448 {
00449 case 'tst':
00450 include_once 'assessment/classes/class.ilObjTest.php';
00451
00452 if(ilObjTest::_lookupTestType($a_obj_id) == TYPE_SELF_ASSESSMENT)
00453 {
00454 return true;
00455 }
00456 return false;
00457
00458 default:
00459 return false;
00460 }
00461 }
00462 }
00463 ?>