00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00038 class ilCourseContentInterface
00039 {
00040 var $cci_course_obj;
00041 var $cci_course_id;
00042 var $cci_ref_id;
00043 var $cci_client_class;
00044
00045 var $chi_obj;
00046
00047
00048 function ilCourseContentInterface(&$client_class,$a_ref_id)
00049 {
00050 global $lng,$tpl,$ilCtrl,$tree,$ilUser,$ilTabs;
00051
00052 $this->lng =& $lng;
00053 $this->tpl =& $tpl;
00054 $this->ctrl =& $ilCtrl;
00055 $this->tree =& $tree;
00056 $this->ilUser =& $ilUser;
00057 $this->tabs_gui =& $ilTabs;
00058
00059 $this->cci_ref_id = $a_ref_id;
00060 $this->cci_read();
00061 $this->cci_client_class = strtolower(get_class($client_class));
00062
00063 $this->cci_client_obj =& $client_class;
00064 $this->cci_course_obj =& ilObjectFactory::getInstanceByRefId($this->cci_course_id);
00065 $this->cci_course_obj->initCourseItemObject($this->cci_ref_id);
00066
00067 $this->lng->loadLanguageModule('crs');
00068
00069 return true;
00070 }
00071
00072 function &executeCommand()
00073 {
00074 global $rbacsystem;
00075
00076 $next_class = $this->ctrl->getNextClass($this);
00077 $cmd = $this->ctrl->getCmd();
00078
00079
00080 switch($next_class)
00081 {
00082
00083 case "ilconditionhandlerinterface":
00084 include_once './classes/class.ilConditionHandlerInterface.php';
00085
00086 $new_gui =& new ilConditionHandlerInterface($this,$_GET['item_id']);
00087 $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
00088
00089
00090
00091 $this->ctrl->forwardCommand($new_gui);
00092 break;
00093
00094 default:
00095 if(!$cmd)
00096 {
00097 $cmd = "view";
00098 }
00099 $this->$cmd();
00100
00101 break;
00102 }
00103 return true;
00104 }
00105
00106 function cci_init(&$client_class,$a_ref_id)
00107 {
00108 $this->cci_ref_id = $a_ref_id;
00109 $this->cci_read();
00110 $this->cci_client_class = strtolower(get_class($client_class));
00111
00112 $this->cci_course_obj =& ilObjectFactory::getInstanceByRefId($this->cci_course_id);
00113 $this->cci_course_obj->initCourseItemObject($this->cci_ref_id);
00114
00115 $this->lng->loadLanguageModule('crs');
00116
00117 return true;
00118 }
00119
00120 function cci_objectives_ask_reset()
00121 {
00122 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_ask_reset.html","course");
00123 $this->tabs_gui->setTabActive('content');
00124
00125 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this->cci_client_obj));
00126 $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_reset_sure'));
00127 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00128 $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
00129
00130 return true;
00131 }
00132
00133
00134
00135
00136
00137
00138 function cci_setContainer(&$a_container)
00139 {
00140 $this->container =& $a_container;
00141 }
00142
00143 function cci_view()
00144 {
00145 global $objDefinition;
00146
00147 include_once "./classes/class.ilRepositoryExplorer.php";
00148 include_once "./payment/classes/class.ilPaymentObject.php";
00149 include_once './course/classes/class.ilCourseStart.php';
00150 include_once './classes/class.ilObjectListGUIFactory.php';
00151
00152 global $rbacsystem;
00153 global $ilias;
00154 global $ilUser;
00155
00156 $this->cci_client_obj->showPossibleSubObjects();
00157
00158 $write_perm = $rbacsystem->checkAccess("write",$this->cci_ref_id);
00159 $enabled_objectives = $this->cci_course_obj->enabledObjectiveView();
00160 $view_objectives = ($enabled_objectives and ($this->cci_ref_id == $this->cci_course_obj->getRefId()));
00161
00162
00163 $start_obj =& new ilCourseStart($this->cci_course_obj->getRefId(),$this->cci_course_obj->getId());
00164 if(count($this->starter = $start_obj->getStartObjects()) and
00165 !$start_obj->isFullfilled($ilUser->getId()) and
00166 !$write_perm)
00167 {
00168 $this->cci_start_objects();
00169
00170 return true;
00171 }
00172
00173
00174 if(($view_objectives and !$write_perm) or ($_SESSION['crs_viewmode'] == 'objectives' and $write_perm))
00175 {
00176 $this->cci_objectives();
00177
00178 return true;
00179 }
00180
00181 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_view.html","course");
00182
00183 if($write_perm and $enabled_objectives)
00184 {
00185 $this->tabs_gui->setTabActive('edit_content');
00186 $items = $this->cci_course_obj->items_obj->getAllItems();
00187 }
00188 elseif($write_perm)
00189 {
00190
00191 if (strtolower(get_class($this->container)) == "ilobjcoursegui")
00192 {
00193 $this->tabs_gui->setTabActive('content');
00194 }
00195 $items = $this->cci_course_obj->items_obj->getAllItems();
00196 }
00197 else
00198 {
00199
00200 if (strtolower(get_class($this->container)) == "ilobjcoursegui")
00201 {
00202 $this->tabs_gui->setTabActive('content');
00203 }
00204 $items = $this->cci_course_obj->items_obj->getItems();
00205 }
00206
00207
00208 if(!count($items))
00209 {
00210 sendInfo($this->lng->txt("crs_no_items_found"));
00211 $this->tpl->addBlockFile("CONTENT_TABLE", "content_tab", "tpl.container_page.html");
00212 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this->container));
00213 $this->tpl->setVariable("CONTAINER_PAGE_CONTENT", "");
00214 $this->container->showAdministrationPanel($this->tpl);
00215 return true;
00216 }
00217
00218 $tpl =& new ilTemplate("tpl.table.html", true, true);
00219
00220 $maxcount = count($items);
00221
00222 #$cont_arr = array_slice($items, $_GET["offset"], $_GET["limit"]);
00223
00224 $cont_arr = $items;
00225
00226 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_content_row.html","course");
00227 $cont_num = count($cont_arr);
00228
00229 $this->container->clearAdminCommandsDetermination();
00230
00231
00232 if ($cont_num > 0)
00233 {
00234
00235 $num = 0;
00236 foreach ($cont_arr as $cont_data)
00237 {
00238 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($cont_data['obj_id']);
00239
00240 #if ($rbacsystem->checkAccess('read',$cont_data["ref_id"]) and
00241 # ($conditions_ok or $rbacsystem->checkAccess('write',$cont_data['ref_id'])))
00242
00243 $tpl->setCurrentBlock("tbl_content");
00244
00245
00246
00247
00248
00249 $buyable = ilPaymentObject::_isBuyable($this->cci_ref_id);
00250 if (($rbacsystem->checkAccess('write',$this->cci_ref_id) ||
00251 $buyable == false) &&
00252 $cont_data["activation_unlimited"])
00253 {
00254
00255 $activation = "";
00256 }
00257 else if ($buyable)
00258 {
00259 if (is_array($activation = ilPaymentObject::_getActivation($this->cci_ref_id)))
00260 {
00261 $activation = $this->lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$activation["activation_start"]).
00262 " ".$this->lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$activation["activation_end"]);
00263 }
00264 else
00265 {
00266 $activation = "N/A";
00267 }
00268 }
00269 else
00270 {
00271 $activation = $this->lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$cont_data["activation_start"]).
00272 " ".$this->lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$cont_data["activation_end"]);
00273 }
00274
00275
00276
00277 if (!is_object ($this->list_gui[$cont_data["type"]]))
00278 {
00279 $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($cont_data["type"]);
00280 $item_list_gui->setContainerObject($this->container);
00281
00282
00283 $item_list_gui->enableSubscribe($this->cci_course_obj->getAboStatus());
00284
00285 $this->list_gui[$cont_data["type"]] =& $item_list_gui;
00286 }
00287 else
00288 {
00289 $item_list_gui =& $this->list_gui[$cont_data["type"]];
00290 }
00291
00292
00293 if (!$this->container->isActiveAdministrationPanel())
00294 {
00295 $item_list_gui->enableDelete(false);
00296 $item_list_gui->enableLink(false);
00297 $item_list_gui->enableCut(false);
00298 }
00299
00300
00301 if ($activation != "")
00302 {
00303 $item_list_gui->addCustomProperty($this->lng->txt("activation"), $activation,
00304 false, true);
00305 }
00306
00307 if($write_perm)
00308 {
00309
00310 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"ref_id",$this->cci_client_obj->object->getRefId());
00311 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"item_id",$cont_data["child"]);
00312
00313
00314 $item_list_gui->addCustomCommand(
00315 $this->cci_client_obj->ctrl->getLinkTarget($this->cci_client_obj,"cciEdit"),
00316 "activation");
00317 }
00318
00319 $html = $item_list_gui->getListItemHTML($cont_data['ref_id'],
00320 $cont_data['obj_id'], $cont_data['title'], $cont_data['description']);
00321
00322 $this->container->determineAdminCommands($cont_data['ref_id'],
00323 $item_list_gui->adminCommandsIncluded());
00324
00325 if(strlen($html))
00326 {
00327 $tpl->setVariable("ITEM_HTML", $html);
00328 }
00329
00330
00331 if($write_perm)
00332 {
00333 $images = array();
00334 if($this->cci_course_obj->getOrderType() == $this->cci_course_obj->SORT_MANUAL)
00335 {
00336 if($num != 0)
00337 {
00338 $tmp_array["gif"] = ilUtil::getImagePath("a_up.gif");
00339 $tmp_array["lng"] = $this->lng->txt("crs_move_up");
00340 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"ref_id",
00341 $this->cci_client_obj->object->getRefId());
00342 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"item_id",$cont_data["child"]);
00343 $tmp_array["lnk"] = $this->cci_client_obj->ctrl->getLinkTarget($this->cci_client_obj,"cciMove");
00344 $tmp_array["tar"] = "";
00345
00346 $images[] = $tmp_array;
00347 }
00348 if($num != count($cont_arr) - 1)
00349 {
00350 $tmp_array["gif"] = ilUtil::getImagePath("a_down.gif");
00351 $tmp_array["lng"] = $this->lng->txt("crs_move_down");
00352 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"ref_id",
00353 $this->cci_client_obj->object->getRefId());
00354 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"item_id",-$cont_data["child"]);
00355 $tmp_array["lnk"] = $this->cci_client_obj->ctrl->getLinkTarget($this->cci_client_obj,"cciMove");
00356 $tmp_array["tar"] = "";
00357
00358 $images[] = $tmp_array;
00359 }
00360 }
00361
00362 foreach($images as $key => $image)
00363 {
00364 $tpl->setCurrentBlock("img");
00365 $tpl->setVariable("IMG_TYPE",$image["gif"]);
00366 $tpl->setVariable("IMG_ALT",$image["lng"]);
00367 $tpl->setVariable("IMG_LINK",$image["lnk"]);
00368 $tpl->setVariable("IMG_TARGET",$image["tar"]);
00369 $tpl->parseCurrentBlock();
00370 }
00371 unset($images);
00372
00373 $tpl->setCurrentBlock("options");
00374 $tpl->setVariable("OPT_ROWCOL", ilUtil::switchColor($num,"tblrow1","tblrow2"));
00375 $tpl->parseCurrentBlock();
00376 }
00377
00378 if(strlen($html))
00379 {
00380 if ($this->container->isActiveAdministrationPanel())
00381 {
00382 $tpl->setCurrentBlock("block_row_check");
00383 $tpl->setVariable("ITEM_ID", $cont_data['ref_id']);
00384 $tpl->parseCurrentBlock();
00385
00386 }
00387
00388
00389 $tpl->setVariable("ROWCOL", ilUtil::switchColor($num,"tblrow1","tblrow2"));
00390 $tpl->setVariable("TYPE_IMG", ilUtil::getImagePath("icon_".$cont_data["type"].".gif"));
00391 $tpl->setVariable("ALT_IMG", $this->lng->txt("obj_".$cont_data["type"]));
00392 $tpl->setCurrentBlock("tbl_content");
00393 $tpl->parseCurrentBlock();
00394 $num++;
00395 }
00396 }
00397 }
00398
00399
00400 $tbl = new ilTableGUI();
00401
00402
00403 $tbl->setTitle($this->lng->txt("crs_content"),"icon_crs.gif",$this->lng->txt("courses"));
00404 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00405
00406 if($write_perm)
00407 {
00408 $tbl->setHeaderNames(array($this->lng->txt("type"),$this->lng->txt("title"),
00409 ""));
00410 $tbl->setHeaderVars(array("type","title","options"),
00411 array("ref_id" => $this->cci_course_obj->getRefId(),
00412 "cmdClass" => "ilobjcoursegui",
00413 "cmdNode" => $_GET["cmdNode"]));
00414 $tbl->setColumnWidth(array("1px","100%","24px"));
00415 $tbl->disable("header");
00416 }
00417 else
00418 {
00419 $tbl->setHeaderNames(array($this->lng->txt("type"),$this->lng->txt("title")));
00420 $tbl->setHeaderVars(array("type","title"),
00421 array("ref_id" => $this->cci_course_obj->getRefId(),
00422 "cmdClass" => "ilobjcoursegui",
00423 "cmdNode" => $_GET["cmdNode"]));
00424 $tbl->setColumnWidth(array("1px",""));
00425 $tbl->disable("header");
00426 }
00427
00428 $tbl->setLimit($_GET["limit"]);
00429 $tbl->setOffset($_GET["offset"]);
00430 $tbl->setMaxCount($maxcount);
00431
00432
00433 $tbl->disable("footer");
00434 $tbl->disable('sort');
00435 $tbl->disable("form");
00436
00437
00438 $tbl->setTemplate($tpl);
00439 $tbl->render();
00440
00441 $this->tpl->addBlockFile("CONTENT_TABLE", "content_tab", "tpl.container_page.html");
00442 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this->container));
00443 $this->tpl->setVariable("CONTAINER_PAGE_CONTENT", $tpl->get());
00444
00445 $this->container->showAdministrationPanel($this->tpl);
00446
00447 return true;
00448 }
00449
00450 function cci_start_objects()
00451 {
00452 include_once './course/classes/class.ilCourseLMHistory.php';
00453 include_once './classes/class.ilRepositoryExplorer.php';
00454
00455 global $rbacsystem,$ilias,$ilUser;
00456
00457 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html","course");
00458 #$this->__showButton('view',$this->lng->txt('refresh'));
00459
00460 $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_info_start'));
00461 $this->tpl->setVariable("TBL_TITLE_START",$this->lng->txt('crs_table_start_objects'));
00462 $this->tpl->setVariable("HEADER_NR",$this->lng->txt('crs_nr'));
00463 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
00464 $this->tpl->setVariable("HEADER_EDITED",$this->lng->txt('crs_objective_accomplished'));
00465
00466
00467 $lm_continue =& new ilCourseLMHistory($this->cci_ref_id,$ilUser->getId());
00468 $continue_data = $lm_continue->getLMHistory();
00469
00470 $counter = 0;
00471 foreach($this->starter as $start)
00472 {
00473 $tmp_obj =& ilObjectFactory::getInstanceByRefId($start['item_ref_id']);
00474
00475 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($tmp_obj->getId());
00476
00477 $obj_link = ilRepositoryExplorer::buildLinkTarget($tmp_obj->getRefId(),$tmp_obj->getType());
00478 $obj_frame = ilRepositoryExplorer::buildFrameTarget($tmp_obj->getType(),$tmp_obj->getRefId(),$tmp_obj->getId());
00479 $obj_frame = $obj_frame ? $obj_frame : '';
00480
00481
00482 $obj_frame = $tmp_obj->getType() == 'tst' ? '' : $obj_frame;
00483
00484 $contentObj = false;
00485
00486 if(ilRepositoryExplorer::isClickable($tmp_obj->getType(),$tmp_obj->getRefId(),$tmp_obj->getId()))
00487 {
00488 $this->tpl->setCurrentBlock("start_read");
00489 $this->tpl->setVariable("READ_TITLE_START",$tmp_obj->getTitle());
00490 $this->tpl->setVariable("READ_TARGET_START",$obj_frame);
00491 $this->tpl->setVariable("READ_LINK_START", $obj_link.'&crs_show_result='.$this->cci_ref_id);
00492 $this->tpl->parseCurrentBlock();
00493 }
00494 else
00495 {
00496 $this->tpl->setCurrentBlock("start_visible");
00497 $this->tpl->setVariable("VISIBLE_LINK_START",$tmp_obj->getTitle());
00498 $this->tpl->parseCurrentBlock();
00499 }
00500
00501 if(!$ilias->account->isDesktopItem($tmp_obj->getRefId(),$tmp_obj->getType()) and
00502 ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
00503 {
00504 if ($rbacsystem->checkAccess('read',$tmp_obj->getRefId()))
00505 {
00506 $this->tpl->setCurrentBlock("start_desklink");
00507 #$this->tpl->setVariable("DESK_LINK_START", "repository.php?cmd=addToDeskCourse&ref_id=".$this->cci_ref_id.
00508 # "&item_ref_id=".$tmp_obj->getRefId()."&type=".$tmp_obj->getType());
00509
00510 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$tmp_obj->getRefId());
00511 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$tmp_obj->getRefId());
00512 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$tmp_obj->getType());
00513
00514 $this->tpl->setVariable("DESK_LINK_START",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
00515
00516 $this->tpl->setVariable("TXT_DESK_START", $this->lng->txt("to_desktop"));
00517 $this->tpl->parseCurrentBlock();
00518 }
00519 }
00520
00521
00522 if(isset($continue_data[$tmp_obj->getRefId()]))
00523 {
00524 $this->tpl->setCurrentBlock("start_continuelink");
00525 $this->tpl->setVariable("CONTINUE_LINK_START",'./content/lm_presentation.php?ref_id='.$tmp_obj->getRefId().'&obj_id='.
00526 $continue_data[$tmp_obj->getRefId()]['lm_page_id']);
00527
00528
00529
00530
00531 $target = '';
00532
00533 $this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
00534 $this->tpl->setVariable("TXT_CONTINUE_START",$this->lng->txt('continue_work'));
00535 $this->tpl->parseCurrentBlock();
00536 }
00537
00538
00539 if(strlen($tmp_obj->getDescription()))
00540 {
00541 $this->tpl->setCurrentBlock("start_description");
00542 $this->tpl->setVariable("DESCRIPTION_START",$tmp_obj->getDescription());
00543 $this->tpl->parseCurrentBlock();
00544 }
00545
00546 switch($tmp_obj->getType())
00547 {
00548 case 'tst':
00549 include_once './assessment/classes/class.ilObjTestAccess.php';
00550 $accomplished = ilObjTestAccess::_checkCondition($tmp_obj->getId(),'finished','') ? 'accomplished' : 'not_accomplished';
00551 break;
00552
00553 case 'sahs':
00554 include_once './Services/Tracking/classes/class.ilLPStatusSCORM.php';
00555 $completed = ilLPStatusSCORM::_getCompleted($tmp_obj->getId());
00556 $accomplished = in_array($ilUser->getId(),$completed) ? 'accomplished' : 'not_accomplished';
00557 break;
00558
00559 default:
00560 $accomplished = isset($continue_data[$tmp_obj->getRefId()]) ? 'accomplished' : 'not_accomplished';
00561 break;
00562 }
00563 $this->tpl->setCurrentBlock("start_row");
00564 $this->tpl->setVariable("EDITED_IMG",ilUtil::getImagePath('crs_'.$accomplished.'.gif'));
00565 $this->tpl->setVariable("EDITED_ALT",$this->lng->txt('crs_objective_'.$accomplished));
00566 $this->tpl->setVariable("ROW_CLASS",'option_value');
00567 $this->tpl->setVariable("ROW_CLASS_CENTER",'option_value_center');
00568 $this->tpl->setVariable("OBJ_NR_START",++$counter.'.');
00569 $this->tpl->parseCurrentBlock();
00570 }
00571 return true;
00572 }
00573
00574 function cci_objectives()
00575 {
00576 include_once "./course/classes/class.ilCourseStart.php";
00577
00578 global $rbacsystem,$ilUser,$ilBench;
00579
00580 $ilBench->start('Objectives','Objectives_view');
00581
00582
00583
00584 $ilBench->start('Objectives','Objectives_start_objects');
00585 if(!$_SESSION['objectives_fullfilled'][$this->cci_course_obj->getId()])
00586 {
00587 $start_obj =& new ilCourseStart($this->cci_course_obj->getRefId(),$this->cci_course_obj->getId());
00588 if(count($this->starter = $start_obj->getStartObjects()) and !$start_obj->isFullfilled($ilUser->getId()))
00589 {
00590 $this->cci_start_objects();
00591
00592 return true;
00593 }
00594 $_SESSION['objectives_fullfilled'][$this->cci_course_obj->getId()] = true;
00595 }
00596 $ilBench->stop('Objectives','Objectives_start_objects');
00597
00598 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objective_view.html","course");
00599 $this->__showButton('cciObjectivesAskReset',$this->lng->txt('crs_reset_results'));
00600
00601 $ilBench->start('Objectives','Objectives_read');
00602
00603 $ilBench->start('Objectives','Objectives_read_accomplished');
00604 $this->__readAccomplished();
00605 $ilBench->stop('Objectives','Objectives_read_accomplished');
00606
00607 $ilBench->start('Objectives','Objectives_read_suggested');
00608 $this->__readSuggested();
00609 $ilBench->stop('Objectives','Objectives_read_suggested');
00610
00611 $ilBench->start('Objectives','Objectives_read_status');
00612 $this->__readStatus();
00613 $ilBench->stop('Objectives','Objectives_read_status');
00614
00615 $ilBench->stop('Objectives','Objectives_read');
00616
00617
00618 $this->__showInfo();
00619
00620
00621 $ilBench->start('Objectives','Objectives_objectives');
00622 $this->__showObjectives();
00623 $ilBench->stop('Objectives','Objectives_objectives');
00624
00625
00626 $ilBench->start('Objectives','Objectives_lms');
00627 $this->__showLearningMaterials();
00628 $ilBench->stop('Objectives','Objectives_lms');
00629
00630
00631 $ilBench->start('Objectives','Objectives_tests');
00632 $this->__showTests();
00633 $ilBench->stop('Objectives','Objectives_tests');
00634
00635
00636 $ilBench->start('Objectives','Objectives_or');
00637 $this->__showOtherResources();
00638 $ilBench->stop('Objectives','Objectives_or');
00639
00640 $ilBench->stop('Objectives','Objectives_view');
00641
00642 $ilBench->save();
00643
00644 return true;
00645 }
00646
00647 function cci_edit()
00648 {
00649 global $rbacsystem;
00650
00651 if(!$rbacsystem->checkAccess("write", $this->cci_ref_id))
00652 {
00653 $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
00654 }
00655 if(!isset($_GET["item_id"]))
00656 {
00657 sendInfo($this->lng->txt("crs_no_item_id_given"));
00658 $this->cci_view();
00659
00660 return false;
00661 }
00662
00663 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_editItem.html","course");
00664 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00665
00666
00667
00668 $this->tpl->setCurrentBlock("btn_cell");
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686 $this->cci_client_obj->ctrl->setParameter($this->cci_client_obj,"item_id",$_GET["item_id"]);
00687 $this->tpl->setVariable("FORMACTION",$this->cci_client_obj->ctrl->getFormAction($this->cci_client_obj));
00688
00689 $item_data = $this->cci_course_obj->items_obj->getItem((int) $_GET["item_id"]);
00690
00691 $tmp_obj = ilObjectFactory::getInstanceByRefId($_GET["item_id"]);
00692 $title = $tmp_obj->getTitle();
00693
00694
00695 $activation_unlimited = $_SESSION["error_post_vars"]["crs"]["activation_unlimited"] ?
00696 1 :
00697 (int) $item_data["activation_unlimited"];
00698
00699 $activation_start = $_SESSION["error_post_vars"]["crs"]["activation_start"] ?
00700 $this->cciToUnix($_SESSION["error_post_vars"]["crs"]["activation_start"]) :
00701 $item_data["activation_start"];
00702
00703 $activation_end = $_SESSION["error_post_vars"]["crs"]["activation_end"] ?
00704 $this->cciToUnix($_SESSION["error_post_vars"]["crs"]["activation_end"]) :
00705 $item_data["activation_end"];
00706
00707
00708 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_".$tmp_obj->getType()));
00709 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_".$tmp_obj->getType().".gif"));
00710 $this->tpl->setVariable("TITLE",$title);
00711 $this->tpl->setVariable("TXT_ACTIVATION",$this->lng->txt("activation"));
00712 $this->tpl->setVariable("TXT_ACTIVATION_UNLIMITED",$this->lng->txt("crs_unlimited"));
00713 $this->tpl->setVariable("TXT_ACTIVATION_START",$this->lng->txt("crs_start"));
00714 $this->tpl->setVariable("TXT_ACTIVATION_END",$this->lng->txt("crs_end"));
00715 $this->tpl->setVariable("CMD_SUBMIT","cciUpdate");
00716 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
00717 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("submit"));
00718
00719 $this->tpl->setVariable("ACTIVATION_UNLIMITED",ilUtil::formCheckbox($activation_unlimited,"crs[activation_unlimited]",1));
00720
00721
00722 $this->tpl->setVariable("SELECT_ACTIVATION_START_DAY",$this->cciGetDateSelect("day","crs[activation_start][day]",
00723 date("d",$activation_start)));
00724 $this->tpl->setVariable("SELECT_ACTIVATION_START_MONTH",$this->cciGetDateSelect("month","crs[activation_start][month]",
00725 date("m",$activation_start)));
00726 $this->tpl->setVariable("SELECT_ACTIVATION_START_YEAR",$this->cciGetDateSelect("year","crs[activation_start][year]",
00727 date("Y",$activation_start)));
00728 $this->tpl->setVariable("SELECT_ACTIVATION_START_HOUR",$this->cciGetDateSelect("hour","crs[activation_start][hour]",
00729 date("G",$activation_start)));
00730 $this->tpl->setVariable("SELECT_ACTIVATION_START_MINUTE",$this->cciGetDateSelect("minute","crs[activation_start][minute]",
00731 date("i",$activation_start)));
00732 $this->tpl->setVariable("SELECT_ACTIVATION_END_DAY",$this->cciGetDateSelect("day","crs[activation_end][day]",
00733 date("d",$activation_end)));
00734 $this->tpl->setVariable("SELECT_ACTIVATION_END_MONTH",$this->cciGetDateSelect("month","crs[activation_end][month]",
00735 date("m",$activation_end)));
00736 $this->tpl->setVariable("SELECT_ACTIVATION_END_YEAR",$this->cciGetDateSelect("year","crs[activation_end][year]",
00737 date("Y",$activation_end)));
00738 $this->tpl->setVariable("SELECT_ACTIVATION_END_HOUR",$this->cciGetDateSelect("hour","crs[activation_end][hour]",
00739 date("G",$activation_end)));
00740 $this->tpl->setVariable("SELECT_ACTIVATION_END_MINUTE",$this->cciGetDateSelect("minute","crs[activation_end][minute]",
00741 date("i",$activation_end)));
00742 # $this->cci_client_obj->initConditionHandlerGUI($_GET['item_id']);
00743 # $this->tpl->setVariable("PRECONDITION_TABLE",$this->cci_client_obj->chi_obj->chi_list());
00744
00745 }
00746
00747 function cci_update()
00748 {
00749 if(!isset($_GET["item_id"]))
00750 {
00751 echo "CourseContentInterface: No item_id given!";
00752 exit;
00753 }
00754
00755 $this->cci_course_obj->items_obj->setActivationUnlimitedStatus((bool) $_POST["crs"]["activation_unlimited"]);
00756 $this->cci_course_obj->items_obj->setActivationStart($this->cciToUnix($_POST["crs"]["activation_start"]));
00757 $this->cci_course_obj->items_obj->setActivationEnd($this->cciToUnix($_POST["crs"]["activation_end"]));
00758
00759 if(!$this->cci_course_obj->items_obj->validateActivation())
00760 {
00761 sendInfo($this->cci_course_obj->getMessage());
00762 $this->cci_edit();
00763
00764 return true;
00765 }
00766 $this->cci_course_obj->items_obj->update((int) $_GET["item_id"]);
00767 $this->cci_view();
00768
00769 return true;
00770 }
00771
00772 function cci_move()
00773 {
00774 if($_GET["item_id"] > 0)
00775 {
00776 $this->cci_course_obj->items_obj->moveUp((int) $_GET["item_id"]);
00777 }
00778 else
00779 {
00780 $this->cci_course_obj->items_obj->moveDown((int) -$_GET["item_id"]);
00781 }
00782 sendInfo($this->lng->txt("crs_moved_item"));
00783
00784 $this->cci_view();
00785
00786 return true;
00787 }
00788
00789 function __showHideLinks($a_part)
00790 {
00791 if($_GET['show_hide_'.$a_part] == 1)
00792 {
00793 unset($_SESSION['crs_hide_'.$a_part]);
00794 }
00795 if($_GET['show_hide_'.$a_part] == 2)
00796 {
00797 $_SESSION['crs_hide_'.$a_part] = true;
00798 }
00799
00800 $this->ctrl->setParameter($this->cci_client_obj,'show_hide_'.$a_part,$_SESSION['crs_hide_'.$a_part] ? 1 : 2);
00801 $this->tpl->setVariable("LINK_HIDE_SHOW_".strtoupper($a_part),$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
00802 $this->tpl->setVariable("TXT_HIDE_SHOW_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ?
00803 $this->lng->txt('crs_show_link_'.$a_part) :
00804 $this->lng->txt('crs_hide_link_'.$a_part));
00805
00806 $this->ctrl->setParameter($this->cci_client_obj,'show_hide_'.$a_part,'');
00807
00808 $this->tpl->setVariable("HIDE_SHOW_IMG_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ?
00809 ilUtil::getImagePath('a_down.gif') :
00810 ilUtil::getImagePath('a_up.gif'));
00811
00812 return true;
00813 }
00814
00815 function __getAllLearningMaterials()
00816 {
00817 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00818 {
00819 switch($node['type'])
00820 {
00821 case 'lm':
00822 case 'htlm':
00823 case 'alm':
00824 case 'sahs':
00825 $all_lms[] = $node['ref_id'];
00826 break;
00827 }
00828 }
00829 return $all_lms ? $all_lms : array();
00830 }
00831
00832 function __getAllTests()
00833 {
00834 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00835 {
00836 switch($node['type'])
00837 {
00838 case 'tst':
00839 $tests[] = $node['ref_id'];
00840 break;
00841 }
00842 }
00843 return $tests ? $tests : array();
00844 }
00845
00846 function __getOtherResources()
00847 {
00848 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00849 {
00850 switch($node['type'])
00851 {
00852 case 'lm':
00853 case 'htlm':
00854 case 'sahs':
00855 case 'tst':
00856 continue;
00857
00858 default:
00859 $all_lms[] = $node['ref_id'];
00860 break;
00861 }
00862 }
00863 return $all_lms ? $all_lms : array();
00864 }
00865
00866 function __showInfo()
00867 {
00868 include_once './course/classes/class.ilCourseObjective.php';
00869
00870 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
00871 {
00872 return true;
00873 }
00874
00875 $this->tpl->addBlockfile('INFO_BLOCK','info_block','tpl.crs_objectives_view_info_table.html','course');
00876 $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_info_'.$this->objective_status));
00877
00878 return true;
00879 }
00880
00881
00882 function __showOtherResources()
00883 {
00884 global $ilias,$rbacsystem,$ilObjDataCache;
00885
00886 if(!count($ors = $this->__getOtherResources()))
00887 {
00888 return false;
00889 }
00890
00891 $this->tpl->addBlockfile('RESOURCES_BLOCK','resources_block','tpl.crs_objectives_view_or_table.html','course');
00892 $this->tpl->setVariable("TBL_TITLE_OR",$this->lng->txt('crs_other_resources'));
00893
00894
00895 $this->__showHideLinks('or');
00896
00897 if(isset($_SESSION['crs_hide_or']))
00898 {
00899 return true;
00900 }
00901
00902 $this->tpl->setCurrentBlock("tbl_header_columns_or");
00903 $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","5%");
00904 $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('type'));
00905 $this->tpl->parseCurrentBlock();
00906
00907 $this->tpl->setCurrentBlock("tbl_header_columns_or");
00908 $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","95%");
00909 $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('description'));
00910 $this->tpl->parseCurrentBlock();
00911
00912 $counter = 1;
00913 foreach($ors as $or_id)
00914 {
00915 $obj_id = $ilObjDataCache->lookupObjId($or_id);
00916 $obj_type = $ilObjDataCache->lookupType($obj_id);
00917
00918
00919 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
00920
00921 $obj_link = ilRepositoryExplorer::buildLinkTarget($or_id,$obj_type);
00922 $obj_frame = ilRepositoryExplorer::buildFrameTarget($obj_type,$or_id,$obj_id);
00923 $obj_frame = $obj_frame ? $obj_frame : '';
00924
00925 if(ilRepositoryExplorer::isClickable($obj_type,$or_id,$obj_id))
00926 {
00927 $this->tpl->setCurrentBlock("or_read");
00928 $this->tpl->setVariable("READ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
00929 $this->tpl->setVariable("READ_TARGET_OR",$obj_frame);
00930 $this->tpl->setVariable("READ_LINK_OR", $obj_link);
00931 $this->tpl->parseCurrentBlock();
00932 }
00933 else
00934 {
00935 $this->tpl->setCurrentBlock("or_visible");
00936 $this->tpl->setVariable("VISIBLE_LINK_OR",$ilObjDataCache->lookupTitle($obj_id));
00937 $this->tpl->parseCurrentBlock();
00938 }
00939
00940 if(!$ilias->account->isDesktopItem($or_id,$obj_type) and
00941 ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
00942 {
00943 if ($rbacsystem->checkAccess('read',$or_id))
00944 {
00945 $this->tpl->setCurrentBlock("or_desklink");
00946 #$this->tpl->setVariable("DESK_LINK_OR", "repository.php?cmd=addToDeskCourse&ref_id=".$this->cci_ref_id.
00947 # "&item_ref_id=".$tmp_or->getRefId()."&type=".$tmp_or->getType());
00948
00949 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$or_id);
00950 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$or_id);
00951 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
00952
00953 $this->tpl->setVariable("DESK_LINK_OR",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
00954
00955 $this->tpl->setVariable("TXT_DESK_OR", $this->lng->txt("to_desktop"));
00956 $this->tpl->parseCurrentBlock();
00957 }
00958 }
00959
00960 $this->tpl->setCurrentBlock("or_row");
00961 $this->tpl->setVariable("OBJ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
00962 $this->tpl->setVariable("IMG_TYPE_OR",ilUtil::getImagePath('icon_'.$obj_type.'.gif'));
00963 $this->tpl->setVariable("TXT_IMG_OR",$this->lng->txt('obj_'.$obj_type));
00964 $this->tpl->setVariable("OBJ_CLASS_CENTER_OR",'option_value_center');
00965 $this->tpl->setVariable("OBJ_CLASS_OR",'option_value');
00966 $this->tpl->parseCurrentBlock();
00967
00968 unset($tmp_or);
00969 ++$counter;
00970 }
00971 }
00972
00973
00974 function __showLearningMaterials()
00975 {
00976 global $rbacsystem,$ilias,$ilUser,$ilObjDataCache;
00977
00978 include_once './course/classes/class.ilCourseObjectiveLM.php';
00979 include_once './classes/class.ilRepositoryExplorer.php';
00980 include_once './course/classes/class.ilCourseLMHistory.php';
00981
00982 if(!count($lms = $this->__getAllLearningMaterials()))
00983 {
00984 return false;
00985 }
00986 if($this->details_id)
00987 {
00988 $objectives_lm_obj =& new ilCourseObjectiveLM($this->details_id);
00989 }
00990
00991 $lm_continue =& new ilCourseLMHistory($this->cci_ref_id,$ilUser->getId());
00992 $continue_data = $lm_continue->getLMHistory();
00993
00994 $this->tpl->addBlockfile('LM_BLOCK','lm_block','tpl.crs_objectives_view_lm_table.html','course');
00995 $this->tpl->setVariable("TBL_TITLE_LMS",$this->lng->txt('crs_learning_materials'));
00996
00997
00998 $this->__showHideLinks('lms');
00999
01000 if(isset($_SESSION['crs_hide_lms']))
01001 {
01002 return true;
01003 }
01004
01005 $this->tpl->setCurrentBlock("tbl_header_columns_lms");
01006 $this->tpl->setVariable("TBL_HEADER_WIDTH_LMS","5%");
01007 $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('crs_nr'));
01008 $this->tpl->parseCurrentBlock();
01009
01010 $this->tpl->setCurrentBlock("tbl_header_columns_lms");
01011 $this->tpl->setVariable("TBL_HEADER_WIDTH_LMS","95%");
01012 $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('description'));
01013 $this->tpl->parseCurrentBlock();
01014
01015 $counter = 1;
01016 foreach($lms as $lm_id)
01017 {
01018 $obj_id = $ilObjDataCache->lookupObjId($lm_id);
01019 $obj_type = $ilObjDataCache->lookupType($obj_id);
01020
01021 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
01022
01023 $obj_link = ilRepositoryExplorer::buildLinkTarget($lm_id,$ilObjDataCache->lookupType($obj_id));
01024 $obj_frame = ilRepositoryExplorer::buildFrameTarget($ilObjDataCache->lookupType($obj_id),$lm_id,$obj_id);
01025 $obj_frame = $obj_frame ? $obj_frame : '';
01026 $contentObj = false;
01027
01028 if(ilRepositoryExplorer::isClickable($obj_type,$lm_id,$obj_id))
01029 {
01030 $this->tpl->setCurrentBlock("lm_read");
01031 $this->tpl->setVariable("READ_TITLE_LMS",$ilObjDataCache->lookupTitle($obj_id));
01032 $this->tpl->setVariable("READ_TARGET_LMS",$obj_frame);
01033 $this->tpl->setVariable("READ_LINK_LMS", $obj_link);
01034 $this->tpl->parseCurrentBlock();
01035 }
01036 else
01037 {
01038 $this->tpl->setCurrentBlock("lm_visible");
01039 $this->tpl->setVariable("VISIBLE_LINK_LMS",$ilObjDataCache->lookupTitle($obj_id));
01040 $this->tpl->parseCurrentBlock();
01041 }
01042
01043 if(!$ilias->account->isDesktopItem($lm_id,$obj_type) and
01044 ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
01045 {
01046 if ($rbacsystem->checkAccess('read',$lm_id))
01047 {
01048 $this->tpl->setCurrentBlock("lm_desklink");
01049 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$lm_id);
01050 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$lm_id);
01051 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
01052
01053 $this->tpl->setVariable("DESK_LINK_LMS",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
01054
01055 $this->tpl->setVariable("TXT_DESK_LMS", $this->lng->txt("to_desktop"));
01056 $this->tpl->parseCurrentBlock();
01057 }
01058 }
01059
01060
01061 if(isset($continue_data[$lm_id]))
01062 {
01063 $this->tpl->setCurrentBlock("lm_continuelink");
01064 $this->tpl->setVariable("CONTINUE_LINK_LMS",'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$lm_id.'&obj_id='.
01065 $continue_data[$lm_id]['lm_page_id']);
01066
01067 $target = '';
01068 $this->tpl->setVariable("CONTINUE_LINK_TARGET",$obj_frame);
01069 $this->tpl->setVariable("TXT_CONTINUE_LMS",$this->lng->txt('continue_work'));
01070 $this->tpl->parseCurrentBlock();
01071 }
01072
01073
01074 if(strlen($ilObjDataCache->lookupDescription($obj_id)))
01075 {
01076 $this->tpl->setCurrentBlock("lms_description");
01077 $this->tpl->setVariable("DESCRIPTION_LMS",$ilObjDataCache->lookupDescription($obj_id));
01078 $this->tpl->parseCurrentBlock();
01079 }
01080
01081 if(isset($continue_data["$lm_id"]))
01082 {
01083 $this->tpl->setVariable("TEXT_INFO_LMS",$this->lng->txt('last_access'));
01084 $this->tpl->setVariable("INFO_LMS",date('Y-m-d H:i:s',$continue_data["$lm_id"]['last_access']));
01085 }
01086 else
01087 {
01088 $this->tpl->setVariable("INFO_LMS",$this->lng->txt('not_accessed'));
01089 }
01090
01091 if($this->details_id)
01092 {
01093 $objectives_lm_obj->setLMRefId($lm_id);
01094 if($objectives_lm_obj->checkExists())
01095 {
01096 $objectives_lm_obj =& new ilCourseObjectiveLM($this->details_id);
01097
01098 if($conditions_ok)
01099 {
01100 foreach($objectives_lm_obj->getChapters() as $lm_obj_data)
01101 {
01102 if($lm_obj_data['ref_id'] != $lm_id)
01103 {
01104 continue;
01105 }
01106
01107 include_once './content/classes/class.ilLMObject.php';
01108
01109
01110 $this->tpl->setCurrentBlock("chapters");
01111 $this->tpl->setVariable("TXT_CHAPTER",$this->lng->txt('chapter'));
01112 $this->tpl->setVariable("CHAPTER_LINK_LMS","ilias.php?baseClass=ilLMPresentationGUI&ref_id=".
01113 $lm_obj_data['ref_id'].
01114 '&obj_id='.$lm_obj_data['obj_id']);
01115 $this->tpl->setVariable("CHAPTER_LINK_TARGET_LMS",$obj_frame);
01116 $this->tpl->setVariable("CHAPTER_TITLE",ilLMObject::_lookupTitle($lm_obj_data['obj_id']));
01117 $this->tpl->parseCurrentBlock();
01118 }
01119 }
01120 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center_details');
01121 $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value_details');
01122 }
01123 else
01124 {
01125 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
01126 $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
01127 }
01128 }
01129 else
01130 {
01131 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
01132 $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
01133 }
01134 $this->tpl->setCurrentBlock("lm_row");
01135 $this->tpl->setVariable("OBJ_NR_LMS",$counter.'.');
01136 $this->tpl->parseCurrentBlock();
01137
01138 ++$counter;
01139 }
01140 }
01141
01142 function __showTests()
01143 {
01144 global $ilias,$rbacsystem,$ilObjDataCache;
01145
01146 include_once './course/classes/class.ilCourseObjectiveLM.php';
01147
01148 if(!count($tests = $this->__getAllTests()))
01149 {
01150 return false;
01151 }
01152
01153 $this->tpl->addBlockfile('TEST_BLOCK','test_block','tpl.crs_objectives_view_tst_table.html','course');
01154 $this->tpl->setVariable("TBL_TITLE_TST",$this->lng->txt('tests'));
01155
01156
01157 $this->__showHideLinks('tst');
01158
01159 if(isset($_SESSION['crs_hide_tst']))
01160 {
01161 return true;
01162 }
01163
01164 $this->tpl->setCurrentBlock("tbl_header_columns_tst");
01165 $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","5%");
01166 $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('crs_nr'));
01167 $this->tpl->parseCurrentBlock();
01168
01169 $this->tpl->setCurrentBlock("tbl_header_columns_tst");
01170 $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","95%");
01171 $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('description'));
01172 $this->tpl->parseCurrentBlock();
01173
01174 $counter = 1;
01175 foreach($tests as $tst_id)
01176 {
01177 $obj_id = $ilObjDataCache->lookupObjId($tst_id);
01178 $obj_type = $ilObjDataCache->lookupType($obj_id);
01179
01180 #$tmp_tst = ilObjectFactory::getInstanceByRefId($tst_id);
01181
01182 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
01183
01184 $obj_link = ilRepositoryExplorer::buildLinkTarget($tst_id,$obj_type);
01185 $obj_link = "ilias.php?baseClass=ilObjTestGUI&ref_id=".$tst_id."&cmd=infoScreen";
01186
01187 #$obj_frame = ilRepositoryExplorer::buildFrameTarget($tmp_tst->getType(),$tmp_tst->getRefId(),$tmp_tst->getId());
01188 #$obj_frame = $obj_frame ? $obj_frame : 'bottom';
01189
01190 $obj_frame = '';
01191
01192 if(ilRepositoryExplorer::isClickable($obj_type,$tst_id,$obj_id))
01193 {
01194 $this->tpl->setCurrentBlock("tst_read");
01195 $this->tpl->setVariable("READ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
01196 $this->tpl->setVariable("READ_TARGET_TST",$obj_frame);
01197 $this->tpl->setVariable("READ_LINK_TST", $obj_link.'&crs_show_result='.$this->cci_ref_id);
01198 $this->tpl->parseCurrentBlock();
01199 }
01200 else
01201 {
01202 $this->tpl->setCurrentBlock("tst_visible");
01203 $this->tpl->setVariable("VISIBLE_LINK_TST",$ilObjDataCache->lookupTitle($obj_id));
01204 $this->tpl->parseCurrentBlock();
01205 }
01206
01207 if(!$ilias->account->isDesktopItem($tst_id,$obj_type) and
01208 ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
01209 {
01210 if ($rbacsystem->checkAccess('read',$tst_id))
01211 {
01212 $this->tpl->setCurrentBlock("tst_desklink");
01213 #$this->tpl->setVariable("DESK_LINK_TST", "repository.php?cmd=addToDeskCourse&ref_id=".$this->cci_ref_id.
01214 # "&item_ref_id=".$tmp_tst->getRefId()."&type=".$tmp_tst->getType());
01215
01216 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$tst_id);
01217 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$tst_id);
01218 $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
01219
01220 $this->tpl->setVariable("DESK_LINK_TST",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
01221
01222
01223 $this->tpl->setVariable("TXT_DESK_TST", $this->lng->txt("to_desktop"));
01224 $this->tpl->parseCurrentBlock();
01225 }
01226 }
01227
01228 $this->tpl->setCurrentBlock("tst_row");
01229 $this->tpl->setVariable("OBJ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
01230 $this->tpl->setVariable("OBJ_NR_TST",$counter.'.');
01231
01232 $this->tpl->setVariable("OBJ_CLASS_CENTER_TST",'option_value_center');
01233 $this->tpl->setVariable("OBJ_CLASS_TST",'option_value');
01234 $this->tpl->parseCurrentBlock();
01235
01236 unset($tmp_tst);
01237 ++$counter;
01238 }
01239 }
01240
01241 function __showObjectives()
01242 {
01243 include_once './course/classes/class.ilCourseObjective.php';
01244
01245 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
01246 {
01247 return false;
01248 }
01249
01250 if($_GET['details'])
01251 {
01252 $_SESSION['crs_details_id'] = $_GET['details'];
01253 }
01254 $this->details_id = $_SESSION['crs_details_id'] ? $_SESSION['crs_details_id'] : $objective_ids[0];
01255
01256
01257 switch($this->objective_status)
01258 {
01259 case 'none':
01260 $status = $this->lng->txt('crs_objective_accomplished');
01261 break;
01262
01263 case 'pretest':
01264 case 'pretest_non_suggest':
01265 $status = $this->lng->txt('crs_objective_pretest');
01266 break;
01267
01268 default:
01269 $status = $this->lng->txt('crs_objective_result');
01270 }
01271
01272
01273 $this->tpl->addBlockfile('OBJECTIVE_BLOCK','objective_block','tpl.crs_objectives_view_table.html','course');
01274
01275 $this->tpl->setVariable("TBL_TITLE_OBJECTIVES",$this->lng->txt('crs_objectives'));
01276
01277 $this->__showHideLinks('objectives');
01278
01279 if(isset($_SESSION['crs_hide_objectives']))
01280 {
01281 return true;
01282 }
01283
01284
01285 for($i = 0; $i < 2; ++$i)
01286 {
01287 $this->tpl->setCurrentBlock("tbl_header_columns");
01288 $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","5%");
01289 $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$this->lng->txt('crs_nr'));
01290 $this->tpl->parseCurrentBlock();
01291
01292 $this->tpl->setCurrentBlock("tbl_header_columns");
01293 $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","35%");
01294 $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$this->lng->txt('description'));
01295 $this->tpl->parseCurrentBlock();
01296
01297 $this->tpl->setCurrentBlock("tbl_header_columns");
01298 $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","10%");
01299 $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$status);
01300 $this->tpl->parseCurrentBlock();
01301 }
01302
01303 $max = count($objective_ids) % 2 ? count($objective_ids) + 1 : count($objective_ids);
01304 for($i = 0; $i < $max/2; ++$i)
01305 {
01306 $tmp_objective =& new ilCourseObjective($this->cci_course_obj,$objective_ids[$i]);
01307
01308 $this->tpl->setCurrentBlock("objective_row");
01309
01310 if($this->details_id == $objective_ids[$i])
01311 {
01312 $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value_details');
01313 $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center_details');
01314 }
01315 else
01316 {
01317 $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value');
01318 $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center');
01319 }
01320 $this->tpl->setVariable("OBJ_NR_1_OBJECTIVES",($i + 1).'.');
01321
01322 $this->ctrl->setParameter($this->cci_client_obj,'details',$objective_ids[$i]);
01323 $this->tpl->setVariable("OBJ_LINK_1_OBJECTIVES",$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
01324 $this->tpl->setVariable("OBJ_TITLE_1_OBJECTIVES",$tmp_objective->getTitle());
01325
01326 $img = !$this->suggested["$objective_ids[$i]"] ?
01327 ilUtil::getImagePath('crs_accomplished.gif') :
01328 ilUtil::getImagePath('crs_not_accomplished.gif');
01329
01330 $txt = !$this->suggested["$objective_ids[$i]"] ?
01331 $this->lng->txt('crs_objective_accomplished') :
01332 $this->lng->txt('crs_objective_not_accomplished');
01333
01334 $this->tpl->setVariable("OBJ_STATUS_IMG_1_OBJECTIVES",$img);
01335 $this->tpl->setVariable("OBJ_STATUS_ALT_1_OBJECTIVES",$txt);
01336
01337
01338 if(isset($objective_ids[$i + $max / 2]))
01339 {
01340 $tmp_objective =& new ilCourseObjective($this->cci_course_obj,$objective_ids[$i + $max / 2]);
01341
01342 $this->tpl->setCurrentBlock("objective_row");
01343 if($this->details_id == $objective_ids[$i + $max / 2])
01344 {
01345 $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value_details');
01346 $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center_details');
01347 }
01348 else
01349 {
01350 $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value');
01351 $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center');
01352 }
01353 $this->tpl->setVariable("OBJ_NR_2_OBJECTIVES",($i + $max / 2 + 1).'.');
01354 $this->ctrl->setParameter($this->cci_client_obj,'details',$objective_ids[$i + $max / 2]);
01355 $this->tpl->setVariable("OBJ_LINK_2_OBJECTIVES",$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
01356 $this->tpl->setVariable("OBJ_TITLE_2_OBJECTIVES",$tmp_objective->getTitle());
01357
01358
01359 $objective_id = $objective_ids[$i + $max / 2];
01360 $img = !$this->suggested[$objective_id] ?
01361 ilUtil::getImagePath('crs_accomplished.gif') :
01362 ilUtil::getImagePath('crs_not_accomplished.gif');
01363
01364 $txt = !$this->suggested[$objective_id] ?
01365 $this->lng->txt('crs_objective_accomplished') :
01366 $this->lng->txt('crs_objective_not_accomplished');
01367
01368 $this->tpl->setVariable("OBJ_STATUS_IMG_2_OBJECTIVES",$img);
01369 $this->tpl->setVariable("OBJ_STATUS_ALT_2_OBJECTIVES",$txt);
01370 }
01371
01372 $this->tpl->parseCurrentBlock();
01373 unset($tmp_objective);
01374 }
01375 $this->ctrl->setParameter($this->cci_client_obj,'details','');
01376 }
01377
01378 function __readAccomplished()
01379 {
01380 global $ilUser;
01381
01382 if(isset($_SESSION['accomplished'][$this->cci_course_obj->getId()]))
01383 {
01384 return $this->accomplished = $_SESSION['accomplished'][$this->cci_course_obj->getId()];
01385 }
01386
01387
01388 include_once './course/classes/class.ilCourseObjectiveResult.php';
01389 include_once './course/classes/class.ilCourseObjective.php';
01390
01391 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01392
01393 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
01394 {
01395 return $this->accomplished = array();
01396 }
01397 $this->accomplished = array();
01398 foreach($objective_ids as $objective_id)
01399 {
01400 if($tmp_obj_res->hasAccomplishedObjective($objective_id))
01401 {
01402 $this->accomplished["$objective_id"] = true;
01403 }
01404 else
01405 {
01406 $this->accomplished["$objective_id"] = false;
01407 }
01408 }
01409 $_SESSION['accomplished'][$this->cci_course_obj->getId()] = $this->accomplished;
01410 }
01411 function __readSuggested()
01412 {
01413 global $ilUser;
01414
01415 if(isset($_SESSION['objectives_suggested'][$this->cci_course_obj->getId()]))
01416 {
01417 return $this->suggested = $_SESSION['objectives_suggested'][$this->cci_course_obj->getId()];
01418 }
01419
01420 include_once './course/classes/class.ilCourseObjectiveResult.php';
01421
01422 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01423
01424 $this->suggested = array();
01425 foreach($this->accomplished as $objective_id => $ok)
01426 {
01427 if($ok)
01428 {
01429 $this->suggested["$objective_id"] = false;
01430 }
01431 else
01432 {
01433 $this->suggested["$objective_id"] = $tmp_obj_res->isSuggested($objective_id);
01434 }
01435 }
01436
01437 return $_SESSION['objectives_suggested'][$this->cci_course_obj->getId()] = $this->suggested;
01438
01439 }
01440
01441 function __readStatus()
01442 {
01443 global $ilUser;
01444
01445 if(isset($_SESSION['objectives_status'][$this->cci_course_obj->getId()]))
01446 {
01447 return $this->objective_status = $_SESSION['objectives_status'][$this->cci_course_obj->getId()];
01448 }
01449 $all_success = true;
01450
01451 foreach($this->accomplished as $id => $success)
01452 {
01453 if(!$success)
01454 {
01455 $all_success = false;
01456 }
01457 }
01458 if($all_success)
01459 {
01460
01461 include_once 'course/classes/class.ilCourseMembers.php';
01462
01463 ilCourseMembers::_setPassed($this->cci_course_obj->getId(),$ilUser->getId());
01464
01465 $this->objective_status = 'finished';
01466 $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01467
01468 return true;
01469 }
01470 include_once './course/classes/class.ilCourseObjectiveResult.php';
01471 include_once './course/classes/class.ilCourseObjective.php';
01472
01473 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01474
01475 $this->objective_status = $tmp_obj_res->getStatus($this->cci_course_obj->getId());
01476
01477 if($this->objective_status == 'pretest')
01478 {
01479 $none_suggested = true;
01480 foreach($this->suggested as $value)
01481 {
01482 if($value)
01483 {
01484 $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01485 return true;
01486 }
01487 }
01488 $this->objective_status = 'pretest_non_suggest';
01489 }
01490 $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01491
01492 return true;
01493 }
01494
01495 function __showButton($a_cmd,$a_text,$a_target = '')
01496 {
01497 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01498
01499
01500 $this->tpl->setCurrentBlock("btn_cell");
01501 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this->cci_client_obj,$a_cmd));
01502 $this->tpl->setVariable("BTN_TXT",$a_text);
01503
01504 if($a_target)
01505 {
01506 $this->tpl->setVariable("BTN_TARGET",$a_target);
01507 }
01508
01509 $this->tpl->parseCurrentBlock();
01510 }
01511
01512
01513
01514 function cci_read()
01515 {
01516 global $tree;
01517
01518 if(!$this->cci_course_id = $tree->checkForParentType($this->cci_ref_id,'crs'))
01519 {
01520 echo "ilCourseContentInterface: Cannot find course object";
01521 exit;
01522 }
01523 return true;
01524 }
01525
01526 function cciToUnix($a_time_arr)
01527 {
01528 return mktime($a_time_arr["hour"],
01529 $a_time_arr["minute"],
01530 $a_time_arr["second"],
01531 $a_time_arr["month"],
01532 $a_time_arr["day"],
01533 $a_time_arr["year"]);
01534 }
01535 function cciGetDateSelect($a_type,$a_varname,$a_selected)
01536 {
01537 switch($a_type)
01538 {
01539 case "minute":
01540 for($i=0;$i<=60;$i++)
01541 {
01542 $days[$i] = $i < 10 ? "0".$i : $i;
01543 }
01544 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01545
01546 case "hour":
01547 for($i=0;$i<24;$i++)
01548 {
01549 $days[$i] = $i < 10 ? "0".$i : $i;
01550 }
01551 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01552
01553 case "day":
01554 for($i=1;$i<32;$i++)
01555 {
01556 $days[$i] = $i < 10 ? "0".$i : $i;
01557 }
01558 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01559
01560 case "month":
01561 for($i=1;$i<13;$i++)
01562 {
01563 $month[$i] = $i < 10 ? "0".$i : $i;
01564 }
01565 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
01566
01567 case "year":
01568 for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
01569 {
01570 $year[$i] = $i;
01571 }
01572 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
01573 }
01574 }
01575 }
01576 ?>