• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

course/classes/class.ilCourseContentInterface.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                                 //$new_gui->setBackButtons(array('edit' => $this->ctrl->getLinkTarget($this,'cciEdit'),
00089                                 //                                                         'preconditions' => $this->ctrl->getLinkTargetByClass('ilconditionhandlerinterface',
00090                                 //                                                                                                                                                                      'listConditions')));
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          * set container (gui) object (e.g. instance of ilObjCourseGUI, ilObjGroupGUI, ...)
00135          *
00136          * @param       object          container gui object
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                 // Jump to start objects if there is one
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                 // Jump to objective view if selected or user is only member
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($this->cci_client_obj->object->getType()=='crs'){
00184                         include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
00185                         $feedbackGUI = new ilFeedbackGUI();
00186                         $feedbackHTML = $feedbackGUI->getCRSFeedbackListHTML();
00187                         $this->tpl->setVariable("FEEDBACK",$feedbackHTML);
00188                 }
00189 
00190                 if($write_perm and $enabled_objectives)
00191                 {
00192                         $this->tabs_gui->setTabActive('edit_content');
00193                         $items = $this->cci_course_obj->items_obj->getAllItems();
00194                 }
00195                 elseif($write_perm)
00196                 {
00197                         // (do not set tab, if we are in folder/group)
00198                         if (strtolower(get_class($this->container)) == "ilobjcoursegui")
00199                         {
00200                                 $this->tabs_gui->setTabActive('content');
00201                         }
00202                         $items = $this->cci_course_obj->items_obj->getAllItems();
00203                 }
00204                 else
00205                 {
00206                         // (do not set tab, if we are in folder/group)
00207                         if (strtolower(get_class($this->container)) == "ilobjcoursegui")
00208                         {
00209                                 $this->tabs_gui->setTabActive('content');
00210                         }
00211                         $items = $this->cci_course_obj->items_obj->getAllItems();
00212                 }
00213                 // NO ITEMS FOUND
00214                 if(!count($items))
00215                 {
00216                         sendInfo($this->lng->txt("crs_no_items_found"));
00217                         $this->tpl->addBlockFile("CONTENT_TABLE", "content_tab", "tpl.container_page.html");
00218                         $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this->container));
00219                         $this->tpl->setVariable("CONTAINER_PAGE_CONTENT", "");
00220                         $this->container->showAdministrationPanel($this->tpl);
00221                         return true;
00222                 }
00223 
00224                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00225 
00226                 $maxcount = count($items);
00227 
00228                 #$cont_arr = array_slice($items, $_GET["offset"], $_GET["limit"]);
00229                 // no limit
00230                 $cont_arr = $items;
00231 
00232                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_content_row.html","course");
00233                 $cont_num = count($cont_arr);
00234                 
00235                 $this->container->clearAdminCommandsDetermination();
00236 
00237                 // render table content data
00238                 if ($cont_num > 0)
00239                 {
00240                         // counter for rowcolor change
00241                         $num = 0;
00242                         foreach ($cont_arr as $cont_data)
00243                         {
00244                                 $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($cont_data['obj_id']);
00245 
00246                                 #if ($rbacsystem->checkAccess('read',$cont_data["ref_id"]) and 
00247                                 #       ($conditions_ok or $rbacsystem->checkAccess('write',$cont_data['ref_id'])))
00248 
00249                                 $tpl->setCurrentBlock("tbl_content");
00250 
00251                                 //}
00252                                 //$tpl->setVariable("DESCRIPTION", $cont_data["description"]);
00253 
00254                                 // ACTIVATION
00255                                 $buyable = ilPaymentObject::_isBuyable($this->cci_ref_id);
00256                                 if (($rbacsystem->checkAccess('write',$this->cci_ref_id) ||
00257                                          $buyable == false) &&
00258                                         $cont_data["timing_type"] != IL_CRS_TIMINGS_ACTIVATION)
00259                                 {
00260                                         //$activation = $this->lng->txt("crs_unlimited");
00261                                         $activation = "";
00262                                 }
00263                                 else if ($buyable)
00264                                 {
00265                                         if (is_array($activation = ilPaymentObject::_getActivation($this->cci_ref_id)))
00266                                         {
00267                                                 $activation = $this->lng->txt("crs_from")." ".
00268 
00269                                                 $activation = $this->lng->txt("crs_from")." ".strftime("%Y-%m-%d %R",$activation["activation_start"]).
00270                                                         " ".$this->lng->txt("crs_to")." ".strftime("%Y-%m-%d %R",$activation["activation_end"]);
00271                                         }
00272                                         else
00273                                         {
00274                                                 $activation = "N/A";
00275                                         }
00276                                 }
00277                                 elseif($cont_data['timing_type'] == IL_CRS_TIMINGS_ACTIVATION)
00278                                 {
00279                                         $activation = $this->lng->txt("crs_from").' '.ilFormat::formatUnixTime($cont_data['timing_start'],true).' '.
00280                                                 $this->lng->txt("crs_to").' '.ilFormat::formatUnixTime($cont_data['timing_end'],true);
00281                                 }
00282                                 //$tpl->setVariable("ACTIVATION_END",$activation);
00283                                 
00284                                 // get item list gui object
00285                                 if (!is_object ($this->list_gui[$cont_data["type"]]))
00286                                 {
00287                                         $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($cont_data["type"]);
00288                                         $item_list_gui->setContainerObject($this->container);
00289                                         
00290                                         // Enable/disable subscription depending on course settings
00291                                         $item_list_gui->enableSubscribe($this->cci_course_obj->getAboStatus());
00292 
00293                                         $this->list_gui[$cont_data["type"]] =& $item_list_gui;
00294                                 }
00295                                 else
00296                                 {
00297                                         $item_list_gui =& $this->list_gui[$cont_data["type"]];
00298                                 }
00299                                 
00300                                 // show administration command buttons (or not)
00301                                 if (!$this->container->isActiveAdministrationPanel())
00302                                 {
00303                                         $item_list_gui->enableDelete(false);
00304                                         $item_list_gui->enableLink(false);
00305                                         $item_list_gui->enableCut(false);
00306                                 }
00307                                 
00308                                 // add activation custom property
00309                                 if ($activation != "")
00310                                 {
00311                                         $item_list_gui->addCustomProperty($this->lng->txt("activation"), $activation,
00312                                                 false, true);
00313                                 }
00314                                 
00315                                 if($write_perm)
00316                                 {
00317                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"ref_id",
00318                                                                                                          $this->cci_client_obj->object->getRefId());
00319                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"item_id",
00320                                                                                                          $cont_data['child']);
00321 
00322                                         $item_list_gui->addCustomCommand($this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI',
00323                                                                                                                                                                            'edit'),
00324                                                                                                          'activation');
00325                                 }
00326                                 
00327                                 $html = $item_list_gui->getListItemHTML($cont_data['ref_id'],
00328                                         $cont_data['obj_id'], $cont_data['title'], $cont_data['description']);
00329                                         
00330                                 $this->container->determineAdminCommands($cont_data['ref_id'],
00331                                         $item_list_gui->adminCommandsIncluded());
00332 
00333                                 if(strlen($html))
00334                                 {
00335                                         $tpl->setVariable("ITEM_HTML", $html);
00336                                 }
00337 
00338                                 // OPTIONS
00339                                 if($write_perm)
00340                                 {
00341                                         $images = array();
00342                                         if($this->cci_course_obj->getOrderType() == $this->cci_course_obj->SORT_MANUAL)
00343                                         {
00344                                                 if($num != 0)
00345                                                 {
00346                                                         $tmp_array["gif"] = ilUtil::getImagePath("a_up.gif");
00347                                                         $tmp_array["lng"] = $this->lng->txt("crs_move_up");
00348 
00349                                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"ref_id",
00350                                                                                                                          $this->cci_client_obj->object->getRefId());
00351                                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"item_id",
00352                                                                                                                          $cont_data['child']);
00353                                                         $tmp_array['lnk'] = $this->ctrl->getLinkTargetByClass('ilcourseitemadministrationgui','moveUp');
00354                                                         $tmp_array["tar"] = "";
00355 
00356                                                         $images[] = $tmp_array;
00357                                                 }
00358                                                 if($num != count($cont_arr) - 1)
00359                                                 {
00360                                                         $tmp_array["gif"] = ilUtil::getImagePath("a_down.gif");
00361                                                         $tmp_array["lng"] = $this->lng->txt("crs_move_down");
00362                                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"ref_id",
00363                                                                                                                          $this->cci_client_obj->object->getRefId());
00364                                                         $this->ctrl->setParameterByClass('ilcourseitemadministrationgui',"item_id",
00365                                                                                                                          $cont_data['child']);
00366                                                         $tmp_array['lnk'] = $this->ctrl->getLinkTargetByClass('ilcourseitemadministrationgui','moveDown');
00367                                                         
00368                                                         $images[] = $tmp_array;
00369                                                 }
00370                                         }
00371                                                                                 
00372                                         foreach($images as $key => $image)
00373                                         {
00374                                                 $tpl->setCurrentBlock("img");
00375                                                 $tpl->setVariable("IMG_TYPE",$image["gif"]);
00376                                                 $tpl->setVariable("IMG_ALT",$image["lng"]);
00377                                                 $tpl->setVariable("IMG_LINK",$image["lnk"]);
00378                                                 $tpl->setVariable("IMG_TARGET",$image["tar"]);
00379                                                 $tpl->parseCurrentBlock();
00380                                         }
00381                                         unset($images);
00382                                         
00383                                         $tpl->setCurrentBlock("options");
00384                                         $tpl->setVariable("OPT_ROWCOL", ilUtil::switchColor($num,"tblrow1","tblrow2"));
00385                                         $tpl->parseCurrentBlock();
00386                                 } // END write perm
00387 
00388                                 if(strlen($html))
00389                                 {
00390                                         if ($this->container->isActiveAdministrationPanel())
00391                                         {
00392                                                 $tpl->setCurrentBlock("block_row_check");
00393                                                 $tpl->setVariable("ITEM_ID", $cont_data['ref_id']);
00394                                                 $tpl->parseCurrentBlock();
00395                                                 //$nbsp = false;
00396                                         }
00397 
00398                                         // change row color
00399                                         $tpl->setVariable("ROWCOL", ilUtil::switchColor($num,"tblrow1","tblrow2"));
00400                                         $tpl->setVariable("TYPE_IMG", ilUtil::getImagePath("icon_".$cont_data["type"].".gif"));
00401                                         $tpl->setVariable("ALT_IMG", $this->lng->txt("obj_".$cont_data["type"]));
00402                                         $tpl->setCurrentBlock("tbl_content");
00403                                         $tpl->parseCurrentBlock();
00404                                         $num++;
00405                                 }
00406                         }
00407                 }
00408 
00409                 // create table
00410                 include_once './classes/class.ilTableGUI.php';
00411                 $tbl = new ilTableGUI();
00412 
00413                 // title & header columns
00414                 $tbl->setTitle($this->lng->txt("crs_content"),"icon_crs.gif",$this->lng->txt("courses"));
00415                 $tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00416 
00417                 if($write_perm)
00418                 {
00419                         $tbl->setHeaderNames(array($this->lng->txt("type"),$this->lng->txt("title"),
00420                                                                            ""));
00421                         $tbl->setHeaderVars(array("type","title","options"), 
00422                                                                 array("ref_id" => $this->cci_course_obj->getRefId(),
00423                                                                           "cmdClass" => "ilobjcoursegui",
00424                                                                           "cmdNode" => $_GET["cmdNode"]));
00425                         $tbl->setColumnWidth(array("1px","100%","24px"));
00426                         $tbl->disable("header");
00427                 }
00428                 else
00429                 {
00430                         $tbl->setHeaderNames(array($this->lng->txt("type"),$this->lng->txt("title")));
00431                         $tbl->setHeaderVars(array("type","title"), 
00432                                                                 array("ref_id" => $this->cci_course_obj->getRefId(),
00433                                                                           "cmdClass" => "ilobjcoursegui",
00434                                                                           "cmdNode" => $_GET["cmdNode"]));
00435                         $tbl->setColumnWidth(array("1px",""));
00436                         $tbl->disable("header");
00437                 }
00438 
00439                 $tbl->setLimit($_GET["limit"]);
00440                 $tbl->setOffset($_GET["offset"]);
00441                 $tbl->setMaxCount($maxcount);
00442 
00443                 // footer
00444                 $tbl->disable("footer");
00445                 $tbl->disable('sort');
00446                 $tbl->disable("form");
00447 
00448                 // render table
00449                 $tbl->setTemplate($tpl);
00450                 $tbl->render();
00451 
00452                 $this->tpl->addBlockFile("CONTENT_TABLE", "content_tab", "tpl.container_page.html");
00453                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this->container));
00454                 $this->tpl->setVariable("CONTAINER_PAGE_CONTENT", $tpl->get());
00455 
00456                 $this->container->showAdministrationPanel($this->tpl);
00457                 
00458                 return true;
00459         }
00460         
00461         function cci_start_objects()
00462         {
00463                 include_once './course/classes/class.ilCourseLMHistory.php';
00464                 include_once './classes/class.ilRepositoryExplorer.php';
00465 
00466                 global $rbacsystem,$ilias,$ilUser;
00467 
00468                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html","course");
00469                 #$this->__showButton('view',$this->lng->txt('refresh'));
00470                 
00471                 $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_info_start'));
00472                 $this->tpl->setVariable("TBL_TITLE_START",$this->lng->txt('crs_table_start_objects'));
00473                 $this->tpl->setVariable("HEADER_NR",$this->lng->txt('crs_nr'));
00474                 $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
00475                 $this->tpl->setVariable("HEADER_EDITED",$this->lng->txt('crs_objective_accomplished'));
00476 
00477 
00478                 $lm_continue =& new ilCourseLMHistory($this->cci_ref_id,$ilUser->getId());
00479                 $continue_data = $lm_continue->getLMHistory();
00480 
00481                 $counter = 0;
00482                 foreach($this->starter as $start)
00483                 {
00484                         $tmp_obj =& ilObjectFactory::getInstanceByRefId($start['item_ref_id']);
00485 
00486                         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($tmp_obj->getId());
00487 
00488                         $obj_link = ilRepositoryExplorer::buildLinkTarget($tmp_obj->getRefId(),$tmp_obj->getType());
00489                         $obj_frame = ilRepositoryExplorer::buildFrameTarget($tmp_obj->getType(),$tmp_obj->getRefId(),$tmp_obj->getId());
00490                         $obj_frame = $obj_frame ? $obj_frame : '';
00491 
00492                         // Tmp fix for tests
00493                         $obj_frame = $tmp_obj->getType() == 'tst' ? '' : $obj_frame;
00494 
00495                         $contentObj = false;
00496 
00497                         if(ilRepositoryExplorer::isClickable($tmp_obj->getType(),$tmp_obj->getRefId(),$tmp_obj->getId()))
00498                         {
00499                                 $this->tpl->setCurrentBlock("start_read");
00500                                 $this->tpl->setVariable("READ_TITLE_START",$tmp_obj->getTitle());
00501                                 $this->tpl->setVariable("READ_TARGET_START",$obj_frame);
00502                                 $this->tpl->setVariable("READ_LINK_START", $obj_link.'&crs_show_result='.$this->cci_ref_id);
00503                                 $this->tpl->parseCurrentBlock();
00504                         }
00505                         else
00506                         {
00507                                 $this->tpl->setCurrentBlock("start_visible");
00508                                 $this->tpl->setVariable("VISIBLE_LINK_START",$tmp_obj->getTitle());
00509                                 $this->tpl->parseCurrentBlock();
00510                         }
00511                         // add to desktop link
00512                         if(!$ilias->account->isDesktopItem($tmp_obj->getRefId(),$tmp_obj->getType()) and 
00513                            ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
00514                         {
00515                                 if ($rbacsystem->checkAccess('read',$tmp_obj->getRefId()))
00516                                 {
00517                                         $this->tpl->setCurrentBlock("start_desklink");
00518                                         #$this->tpl->setVariable("DESK_LINK_START", "repository.php?cmd=addToDeskCourse&ref_id=".$this->cci_ref_id.
00519                                         #                                               "&item_ref_id=".$tmp_obj->getRefId()."&type=".$tmp_obj->getType());
00520 
00521                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$tmp_obj->getRefId());
00522                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$tmp_obj->getRefId());
00523                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$tmp_obj->getType());
00524                                         
00525                                         $this->tpl->setVariable("DESK_LINK_START",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
00526 
00527                                         $this->tpl->setVariable("TXT_DESK_START", $this->lng->txt("to_desktop"));
00528                                         $this->tpl->parseCurrentBlock();
00529                                 }
00530                         }
00531 
00532                         // CONTINUE LINK
00533                         if(isset($continue_data[$tmp_obj->getRefId()]))
00534                         {
00535                                 $this->tpl->setCurrentBlock("start_continuelink");
00536                                 $this->tpl->setVariable("CONTINUE_LINK_START",'./content/lm_presentation.php?ref_id='.$tmp_obj->getRefId().'&obj_id='.
00537                                                                                 $continue_data[$tmp_obj->getRefId()]['lm_page_id']);
00538 
00539                                 //$target = $ilias->ini->readVariable("layout","view_target") == "frame" ? 
00540                                 //      '' :
00541                                 //      'ilContObj'.$cont_data[$obj_id]['obj_page_id'];
00542                                 $target = '';
00543                                         
00544                                 $this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
00545                                 $this->tpl->setVariable("TXT_CONTINUE_START",$this->lng->txt('continue_work'));
00546                                 $this->tpl->parseCurrentBlock();
00547                         }
00548 
00549                         // Description
00550                         if(strlen($tmp_obj->getDescription()))
00551                         {
00552                                 $this->tpl->setCurrentBlock("start_description");
00553                                 $this->tpl->setVariable("DESCRIPTION_START",$tmp_obj->getDescription());
00554                                 $this->tpl->parseCurrentBlock();
00555                         }
00556 
00557                         switch($tmp_obj->getType())
00558                         {
00559                                 case 'tst':
00560                                         include_once './assessment/classes/class.ilObjTestAccess.php';
00561                                         $accomplished = ilObjTestAccess::_checkCondition($tmp_obj->getId(),'finished','') ? 'accomplished' : 'not_accomplished';
00562                                         break;
00563 
00564                                 case 'sahs':
00565                                         include_once './Services/Tracking/classes/class.ilLPStatusSCORM.php';
00566                                         $completed = ilLPStatusSCORM::_getCompleted($tmp_obj->getId());
00567                                         $accomplished = in_array($ilUser->getId(),$completed) ? 'accomplished' : 'not_accomplished';
00568                                         break;
00569 
00570                                 default:
00571                                         $accomplished = isset($continue_data[$tmp_obj->getRefId()]) ? 'accomplished' : 'not_accomplished';
00572                                         break;
00573                         }
00574                         $this->tpl->setCurrentBlock("start_row");
00575                         $this->tpl->setVariable("EDITED_IMG",ilUtil::getImagePath('crs_'.$accomplished.'.gif'));
00576                         $this->tpl->setVariable("EDITED_ALT",$this->lng->txt('crs_objective_'.$accomplished));
00577                         $this->tpl->setVariable("ROW_CLASS",'option_value');
00578                         $this->tpl->setVariable("ROW_CLASS_CENTER",'option_value_center');
00579                         $this->tpl->setVariable("OBJ_NR_START",++$counter.'.');
00580                         $this->tpl->parseCurrentBlock();
00581                 }                       
00582                 return true;
00583         }
00584 
00585         function cci_objectives()
00586         {
00587                 include_once "./course/classes/class.ilCourseStart.php";
00588 
00589                 global $rbacsystem,$ilUser,$ilBench;
00590 
00591                 $ilBench->start('Objectives','Objectives_view');
00592 
00593                 // Jump to start objects if there is one
00594 
00595                 $ilBench->start('Objectives','Objectives_start_objects');
00596                 if(!$_SESSION['objectives_fullfilled'][$this->cci_course_obj->getId()])
00597                 {
00598                         $start_obj =& new ilCourseStart($this->cci_course_obj->getRefId(),$this->cci_course_obj->getId());
00599                         if(count($this->starter = $start_obj->getStartObjects()) and !$start_obj->isFullfilled($ilUser->getId()))
00600                         {
00601                                 $this->cci_start_objects();
00602                                 
00603                                 return true;
00604                         }
00605                         $_SESSION['objectives_fullfilled'][$this->cci_course_obj->getId()] = true;
00606                 }
00607                 $ilBench->stop('Objectives','Objectives_start_objects');
00608 
00609                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objective_view.html","course");
00610                 $this->__showButton('cciObjectivesAskReset',$this->lng->txt('crs_reset_results'));
00611 
00612                 $ilBench->start('Objectives','Objectives_read');
00613 
00614                 $ilBench->start('Objectives','Objectives_read_accomplished');
00615                 $this->__readAccomplished();
00616                 $ilBench->stop('Objectives','Objectives_read_accomplished');
00617 
00618                 $ilBench->start('Objectives','Objectives_read_suggested');
00619                 $this->__readSuggested();
00620                 $ilBench->stop('Objectives','Objectives_read_suggested');
00621 
00622                 $ilBench->start('Objectives','Objectives_read_status');
00623                 $this->__readStatus();
00624                 $ilBench->stop('Objectives','Objectives_read_status');
00625 
00626                 $ilBench->stop('Objectives','Objectives_read');
00627 
00628                 // (1) show infos
00629                 $this->__showInfo();
00630 
00631                 // (2) show objectives
00632                 $ilBench->start('Objectives','Objectives_objectives');
00633                 $this->__showObjectives();
00634                 $ilBench->stop('Objectives','Objectives_objectives');
00635 
00636                 // (3) show lm's
00637                 $ilBench->start('Objectives','Objectives_lms');
00638                 $this->__showLearningMaterials();
00639                 $ilBench->stop('Objectives','Objectives_lms');
00640 
00641                 // (4) show tests
00642                 $ilBench->start('Objectives','Objectives_tests');
00643                 $this->__showTests();
00644                 $ilBench->stop('Objectives','Objectives_tests');
00645 
00646                 // (5) show other resources
00647                 $ilBench->start('Objectives','Objectives_or');
00648                 $this->__showOtherResources();
00649                 $ilBench->stop('Objectives','Objectives_or');
00650 
00651                 $ilBench->stop('Objectives','Objectives_view');
00652 
00653                 $ilBench->save();
00654 
00655                 return true;
00656         }
00657 
00658         // PRIVATE
00659         function __showHideLinks($a_part)
00660         {
00661                 if($_GET['show_hide_'.$a_part] == 1)
00662                 {
00663                         unset($_SESSION['crs_hide_'.$a_part]);
00664                 }
00665                 if($_GET['show_hide_'.$a_part] == 2)
00666                 {
00667                         $_SESSION['crs_hide_'.$a_part] = true;
00668                 }
00669 
00670                 $this->ctrl->setParameter($this->cci_client_obj,'show_hide_'.$a_part,$_SESSION['crs_hide_'.$a_part] ? 1 : 2);
00671                 $this->tpl->setVariable("LINK_HIDE_SHOW_".strtoupper($a_part),$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
00672                 $this->tpl->setVariable("TXT_HIDE_SHOW_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ? 
00673                                                                 $this->lng->txt('crs_show_link_'.$a_part) :
00674                                                                 $this->lng->txt('crs_hide_link_'.$a_part));
00675 
00676                 $this->ctrl->setParameter($this->cci_client_obj,'show_hide_'.$a_part,'');
00677 
00678                 $this->tpl->setVariable("HIDE_SHOW_IMG_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ? 
00679                                                                 ilUtil::getImagePath('a_down.gif') :
00680                                                                 ilUtil::getImagePath('a_up.gif'));
00681 
00682                 return true;
00683         }
00684         
00685         function __getAllLearningMaterials()
00686         {
00687                 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00688                 {
00689                         switch($node['type'])
00690                         {
00691                                 case 'lm':
00692                                 case 'htlm':
00693                                 case 'alm':
00694                                 case 'sahs':
00695                                         $all_lms[] = $node['ref_id'];
00696                                         break;
00697                         }
00698                 }
00699                 return $all_lms ? $all_lms : array();
00700         }
00701 
00702         function __getAllTests()
00703         {
00704                 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00705                 {
00706                         switch($node['type'])
00707                         {
00708                                 case 'tst':
00709                                         $tests[] = $node['ref_id'];
00710                                         break;
00711                         }
00712                 }
00713                 return $tests ? $tests : array();
00714         }
00715 
00716         function __getOtherResources()
00717         {
00718                 foreach($items = $this->cci_course_obj->items_obj->getItems() as $node)
00719                 {
00720                         switch($node['type'])
00721                         {
00722                                 case 'lm':
00723                                 case 'htlm':
00724                                 case 'sahs':
00725                                 case 'tst':
00726                                         continue;
00727 
00728                                 default:
00729                                         $all_lms[] = $node['ref_id'];
00730                                         break;
00731                         }
00732                 }
00733                 return $all_lms ? $all_lms : array();
00734         }
00735 
00736         function __showInfo()
00737         {
00738                 include_once './course/classes/class.ilCourseObjective.php';
00739 
00740                 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
00741                 {
00742                         return true;
00743                 }
00744 
00745                 $this->tpl->addBlockfile('INFO_BLOCK','info_block','tpl.crs_objectives_view_info_table.html','course');
00746                 $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_info_'.$this->objective_status));
00747                 
00748                 return true;
00749         }
00750                 
00751 
00752         function __showOtherResources()
00753         {
00754                 global $ilias,$rbacsystem,$ilObjDataCache;
00755 
00756                 if(!count($ors = $this->__getOtherResources()))
00757                 {
00758                         return false;
00759                 }
00760 
00761                 $this->tpl->addBlockfile('RESOURCES_BLOCK','resources_block','tpl.crs_objectives_view_or_table.html','course');
00762                 $this->tpl->setVariable("TBL_TITLE_OR",$this->lng->txt('crs_other_resources'));
00763 
00764 
00765                 $this->__showHideLinks('or');
00766 
00767                 if(isset($_SESSION['crs_hide_or']))
00768                 {
00769                         return true;
00770                 }
00771 
00772                 $this->tpl->setCurrentBlock("tbl_header_columns_or");
00773                 $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","5%");
00774                 $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('type'));
00775                 $this->tpl->parseCurrentBlock();
00776 
00777                 $this->tpl->setCurrentBlock("tbl_header_columns_or");
00778                 $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","75%");
00779                 $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('description'));
00780                 $this->tpl->parseCurrentBlock();
00781 
00782                 $this->tpl->setCurrentBlock("tbl_header_columns_or");
00783                 $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","20%");
00784                 $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('actions'));
00785                 $this->tpl->parseCurrentBlock();
00786 
00787                 $counter = 1;
00788                 foreach($ors as $or_id)
00789                 {
00790                         $obj_id = $ilObjDataCache->lookupObjId($or_id);
00791                         $obj_type = $ilObjDataCache->lookupType($obj_id);
00792 
00793                         
00794                         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
00795                                 
00796                         $obj_link = ilRepositoryExplorer::buildLinkTarget($or_id,$obj_type);
00797                         $obj_frame = ilRepositoryExplorer::buildFrameTarget($obj_type,$or_id,$obj_id);
00798                         $obj_frame = $obj_frame ? $obj_frame : '';
00799 
00800                         if(ilRepositoryExplorer::isClickable($obj_type,$or_id,$obj_id))
00801                         {
00802                                 $this->tpl->setCurrentBlock("or_read");
00803                                 $this->tpl->setVariable("READ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
00804                                 $this->tpl->setVariable("READ_TARGET_OR",$obj_frame);
00805                                 $this->tpl->setVariable("READ_LINK_OR", $obj_link);
00806                                 $this->tpl->parseCurrentBlock();
00807                         }
00808                         else
00809                         {
00810                                 $this->tpl->setCurrentBlock("or_visible");
00811                                 $this->tpl->setVariable("VISIBLE_LINK_OR",$ilObjDataCache->lookupTitle($obj_id));
00812                                 $this->tpl->parseCurrentBlock();
00813                         }
00814                                 // add to desktop link
00815                         if(!$ilias->account->isDesktopItem($or_id,$obj_type) and 
00816                            ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
00817                         {
00818                                 if ($rbacsystem->checkAccess('read',$or_id))
00819                                 {
00820                                         $this->tpl->setCurrentBlock("or_desklink");
00821                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$or_id);
00822                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$or_id);
00823                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
00824                                         
00825                                         $this->tpl->setVariable("DESK_LINK_OR",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
00826 
00827                                         $this->tpl->setVariable("TXT_DESK_OR", $this->lng->txt("to_desktop"));
00828                                         $this->tpl->parseCurrentBlock();
00829                                 }
00830                         }
00831                         
00832                         $this->tpl->setCurrentBlock("or_row");
00833                         $this->tpl->setVariable("OBJ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
00834                         $this->tpl->setVariable("IMG_TYPE_OR",ilUtil::getImagePath('icon_'.$obj_type.'.gif'));
00835                         $this->tpl->setVariable("TXT_IMG_OR",$this->lng->txt('obj_'.$obj_type));
00836                         $this->tpl->setVariable("OBJ_CLASS_CENTER_OR",'option_value_center');
00837                         $this->tpl->setVariable("OBJ_CLASS_OR",'option_value');
00838                         $this->tpl->parseCurrentBlock();
00839 
00840                         unset($tmp_or);
00841                         ++$counter;
00842                 }
00843         }
00844 
00845 
00846         function __showLearningMaterials()
00847         {
00848                 global $rbacsystem,$ilias,$ilUser,$ilObjDataCache;
00849 
00850                 include_once './course/classes/class.ilCourseObjectiveLM.php';
00851                 include_once './classes/class.ilRepositoryExplorer.php';
00852                 include_once './course/classes/class.ilCourseLMHistory.php';
00853 
00854                 if(!count($lms = $this->__getAllLearningMaterials()))
00855                 {
00856                         return false;
00857                 }
00858                 if($this->details_id)
00859                 {
00860                         $objectives_lm_obj =& new ilCourseObjectiveLM($this->details_id);
00861                 }
00862 
00863                 $lm_continue =& new ilCourseLMHistory($this->cci_ref_id,$ilUser->getId());
00864                 $continue_data = $lm_continue->getLMHistory();
00865 
00866                 $this->tpl->addBlockfile('LM_BLOCK','lm_block','tpl.crs_objectives_view_lm_table.html','course');
00867                 $this->tpl->setVariable("TBL_TITLE_LMS",$this->lng->txt('crs_learning_materials'));
00868 
00869 
00870                 $this->__showHideLinks('lms');
00871 
00872                 if(isset($_SESSION['crs_hide_lms']))
00873                 {
00874                         return true;
00875                 }
00876 
00877                 $this->tpl->setCurrentBlock("tbl_header_columns_lms");
00878                 $this->tpl->setVariable("TBL_HEADER_WIDTH_LMS","5%");
00879                 $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('crs_nr'));
00880                 $this->tpl->parseCurrentBlock();
00881 
00882                 $this->tpl->setCurrentBlock("tbl_header_columns_lms");
00883                 $this->tpl->setVariable("TBL_HEADER_WIDTH_LMS","75%");
00884                 $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('description'));
00885                 $this->tpl->parseCurrentBlock();
00886 
00887                 $this->tpl->setCurrentBlock("tbl_header_columns_lms");
00888                 $this->tpl->setVariable("TBL_HEADER_WIDTH_LMS","20%");
00889                 $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('actions'));
00890                 $this->tpl->parseCurrentBlock();
00891 
00892                 $counter = 1;
00893                 foreach($lms as $lm_id)
00894                 {
00895                         $obj_id = $ilObjDataCache->lookupObjId($lm_id);
00896                         $obj_type = $ilObjDataCache->lookupType($obj_id);
00897 
00898                         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
00899                                 
00900                         $obj_link = ilRepositoryExplorer::buildLinkTarget($lm_id,$ilObjDataCache->lookupType($obj_id));
00901                         $obj_frame = ilRepositoryExplorer::buildFrameTarget($ilObjDataCache->lookupType($obj_id),$lm_id,$obj_id);
00902                         $obj_frame = $obj_frame ? $obj_frame : '';
00903                         $contentObj = false;
00904 
00905                         if(ilRepositoryExplorer::isClickable($obj_type,$lm_id,$obj_id))
00906                         {
00907                                 $this->tpl->setCurrentBlock("lm_read");
00908                                 $this->tpl->setVariable("READ_TITLE_LMS",$ilObjDataCache->lookupTitle($obj_id));
00909                                 $this->tpl->setVariable("READ_TARGET_LMS",$obj_frame);
00910                                 $this->tpl->setVariable("READ_LINK_LMS", $obj_link);
00911                                 $this->tpl->parseCurrentBlock();
00912                         }
00913                         else
00914                         {
00915                                 $this->tpl->setCurrentBlock("lm_visible");
00916                                 $this->tpl->setVariable("VISIBLE_LINK_LMS",$ilObjDataCache->lookupTitle($obj_id));
00917                                 $this->tpl->parseCurrentBlock();
00918                         }
00919                         // add to desktop link
00920                         if(!$ilias->account->isDesktopItem($lm_id,$obj_type) and 
00921                            ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
00922                         {
00923                                 if ($rbacsystem->checkAccess('read',$lm_id))
00924                                 {
00925                                         $this->tpl->setCurrentBlock("lm_desklink");
00926                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$lm_id);
00927                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$lm_id);
00928                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
00929                                         
00930                                         $this->tpl->setVariable("DESK_LINK_LMS",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
00931 
00932                                         $this->tpl->setVariable("TXT_DESK_LMS", $this->lng->txt("to_desktop"));
00933                                         $this->tpl->parseCurrentBlock();
00934                                 }
00935                         }
00936 
00937                         // CONTINUE LINK
00938                         if(isset($continue_data[$lm_id]))
00939                         {
00940                                 $this->tpl->setCurrentBlock("lm_continuelink");
00941                                 $this->tpl->setVariable("CONTINUE_LINK_LMS",'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$lm_id.'&obj_id='.
00942                                                                                 $continue_data[$lm_id]['lm_page_id']);
00943 
00944                                 $target = '';
00945                                 $this->tpl->setVariable("CONTINUE_LINK_TARGET",$obj_frame);
00946                                 $this->tpl->setVariable("TXT_CONTINUE_LMS",$this->lng->txt('continue_work'));
00947                                 $this->tpl->parseCurrentBlock();
00948                         }
00949 
00950                         // Description
00951                         if(strlen($ilObjDataCache->lookupDescription($obj_id)))
00952                         {
00953                                 $this->tpl->setCurrentBlock("lms_description");
00954                                 $this->tpl->setVariable("DESCRIPTION_LMS",$ilObjDataCache->lookupDescription($obj_id));
00955                                 $this->tpl->parseCurrentBlock();
00956                         }
00957                         // LAST ACCESS
00958                         if(isset($continue_data["$lm_id"]))
00959                         {
00960                                 $this->tpl->setVariable("TEXT_INFO_LMS",$this->lng->txt('last_access'));
00961                                 $this->tpl->setVariable("INFO_LMS",date('Y-m-d H:i:s',$continue_data["$lm_id"]['last_access']));
00962                         }
00963                         else
00964                         {
00965                                 $this->tpl->setVariable("INFO_LMS",$this->lng->txt('not_accessed'));
00966                         }
00967                         
00968                         if($this->details_id)
00969                         {
00970                                 $objectives_lm_obj->setLMRefId($lm_id);
00971                                 if($objectives_lm_obj->checkExists())
00972                                 {
00973                                         $objectives_lm_obj =& new ilCourseObjectiveLM($this->details_id);
00974                                         
00975                                         if($conditions_ok)
00976                                         {
00977                                                 foreach($objectives_lm_obj->getChapters() as $lm_obj_data)
00978                                                 {
00979                                                         if($lm_obj_data['ref_id'] != $lm_id)
00980                                                         {
00981                                                                 continue;
00982                                                         }
00983 
00984                                                         include_once './content/classes/class.ilLMObject.php';
00985                                                         
00986                                                 
00987                                                         $this->tpl->setCurrentBlock("chapters");
00988                                                         $this->tpl->setVariable("TXT_CHAPTER",$this->lng->txt('chapter'));
00989                                                         $this->tpl->setVariable("CHAPTER_LINK_LMS","ilias.php?baseClass=ilLMPresentationGUI&ref_id=".
00990                                                                                                         $lm_obj_data['ref_id'].
00991                                                                                                         '&obj_id='.$lm_obj_data['obj_id']);
00992                                                         $this->tpl->setVariable("CHAPTER_LINK_TARGET_LMS",$obj_frame);
00993                                                         $this->tpl->setVariable("CHAPTER_TITLE",ilLMObject::_lookupTitle($lm_obj_data['obj_id']));
00994                                                         $this->tpl->parseCurrentBlock();
00995                                                 }
00996                                         }
00997                                         $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center_details');
00998                                         $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value_details');
00999                                 }
01000                                 else
01001                                 {
01002                                         $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
01003                                         $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
01004                                 }
01005                         }
01006                         else
01007                         {
01008                                 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
01009                                 $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
01010                         }
01011                         $this->tpl->setCurrentBlock("lm_row");
01012                         $this->tpl->setVariable("OBJ_NR_LMS",$counter.'.');
01013                         $this->tpl->parseCurrentBlock();
01014 
01015                         ++$counter;
01016                 }
01017         }
01018 
01019         function __showTests()
01020         {
01021                 global $ilias,$rbacsystem,$ilObjDataCache;
01022 
01023                 include_once './course/classes/class.ilCourseObjectiveLM.php';
01024 
01025                 if(!count($tests = $this->__getAllTests()))
01026                 {
01027                         return false;
01028                 }
01029 
01030                 $this->tpl->addBlockfile('TEST_BLOCK','test_block','tpl.crs_objectives_view_tst_table.html','course');
01031                 $this->tpl->setVariable("TBL_TITLE_TST",$this->lng->txt('tests'));
01032 
01033 
01034                 $this->__showHideLinks('tst');
01035 
01036                 if(isset($_SESSION['crs_hide_tst']))
01037                 {
01038                         return true;
01039                 }
01040 
01041                 $this->tpl->setCurrentBlock("tbl_header_columns_tst");
01042                 $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","5%");
01043                 $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('crs_nr'));
01044                 $this->tpl->parseCurrentBlock();
01045 
01046                 $this->tpl->setCurrentBlock("tbl_header_columns_tst");
01047                 $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","75%");
01048                 $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('description'));
01049                 $this->tpl->parseCurrentBlock();
01050 
01051                 $this->tpl->setCurrentBlock("tbl_header_columns_tst");
01052                 $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","20%");
01053                 $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('actions'));
01054                 $this->tpl->parseCurrentBlock();
01055 
01056                 $counter = 1;
01057                 foreach($tests as $tst_id)
01058                 {
01059                         $obj_id = $ilObjDataCache->lookupObjId($tst_id);
01060                         $obj_type = $ilObjDataCache->lookupType($obj_id);
01061 
01062                         #$tmp_tst = ilObjectFactory::getInstanceByRefId($tst_id);
01063 
01064                         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($obj_id);
01065                                 
01066                         $obj_link = ilRepositoryExplorer::buildLinkTarget($tst_id,$obj_type);
01067                         $obj_link = "ilias.php?baseClass=ilObjTestGUI&ref_id=".$tst_id."&cmd=infoScreen";
01068 
01069                         #$obj_frame = ilRepositoryExplorer::buildFrameTarget($tmp_tst->getType(),$tmp_tst->getRefId(),$tmp_tst->getId());
01070                         #$obj_frame = $obj_frame ? $obj_frame : 'bottom';
01071                         // Always open in frameset
01072                         $obj_frame = '';
01073 
01074                         if(ilRepositoryExplorer::isClickable($obj_type,$tst_id,$obj_id))
01075                         {
01076                                 $this->tpl->setCurrentBlock("tst_read");
01077                                 $this->tpl->setVariable("READ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
01078                                 $this->tpl->setVariable("READ_TARGET_TST",$obj_frame);
01079                                 $this->tpl->setVariable("READ_LINK_TST", $obj_link.'&crs_show_result='.$this->cci_ref_id);
01080                                 $this->tpl->parseCurrentBlock();
01081                         }
01082                         else
01083                         {
01084                                 $this->tpl->setCurrentBlock("tst_visible");
01085                                 $this->tpl->setVariable("VISIBLE_LINK_TST",$ilObjDataCache->lookupTitle($obj_id));
01086                                 $this->tpl->parseCurrentBlock();
01087                         }
01088                                 // add to desktop link
01089                         if(!$ilias->account->isDesktopItem($tst_id,$obj_type) and 
01090                            ($this->cci_course_obj->getAboStatus() == $this->cci_course_obj->ABO_ENABLED))
01091                         {
01092                                 if ($rbacsystem->checkAccess('read',$tst_id))
01093                                 {
01094                                         $this->tpl->setCurrentBlock("tst_desklink");
01095                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_ref_id',$tst_id);
01096                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'item_id',$tst_id);
01097                                         $this->ctrl->setParameterByClass(get_class($this->cci_client_obj),'type',$obj_type);
01098                                         
01099                                         $this->tpl->setVariable("DESK_LINK_TST",$this->ctrl->getLinkTarget($this->cci_client_obj,'addToDesk'));
01100 
01101 
01102                                         $this->tpl->setVariable("TXT_DESK_TST", $this->lng->txt("to_desktop"));
01103                                         $this->tpl->parseCurrentBlock();
01104                                 }
01105                         }
01106                         
01107                         $this->tpl->setCurrentBlock("tst_row");
01108                         $this->tpl->setVariable("OBJ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
01109                         $this->tpl->setVariable("OBJ_NR_TST",$counter.'.');
01110 
01111                         $this->tpl->setVariable("OBJ_CLASS_CENTER_TST",'option_value_center');
01112                         $this->tpl->setVariable("OBJ_CLASS_TST",'option_value');
01113                         $this->tpl->parseCurrentBlock();
01114 
01115                         unset($tmp_tst);
01116                         ++$counter;
01117                 }
01118         }
01119 
01120         function __showObjectives()
01121         {
01122                 include_once './course/classes/class.ilCourseObjective.php';
01123 
01124                 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
01125                 {
01126                         return false;
01127                 }
01128                 // TODO
01129                 if($_GET['details'])
01130                 {
01131                         $_SESSION['crs_details_id'] = $_GET['details'];
01132                 }
01133                 $this->details_id = $_SESSION['crs_details_id'] ? $_SESSION['crs_details_id'] : $objective_ids[0];
01134 
01135                 // TODO get status for table header
01136                 switch($this->objective_status)
01137                 {
01138                         case 'none':
01139                                 $status = $this->lng->txt('crs_objective_accomplished');
01140                                 break;
01141 
01142                         case 'pretest':
01143                         case 'pretest_non_suggest':
01144                                 $status = $this->lng->txt('crs_objective_pretest');
01145                                 break;
01146 
01147                         default:
01148                                 $status = $this->lng->txt('crs_objective_result');
01149                 }
01150 
01151                 // show table
01152                 $this->tpl->addBlockfile('OBJECTIVE_BLOCK','objective_block','tpl.crs_objectives_view_table.html','course');
01153 
01154                 $this->tpl->setVariable("TBL_TITLE_OBJECTIVES",$this->lng->txt('crs_objectives'));
01155 
01156                 $this->__showHideLinks('objectives');
01157 
01158                 if(isset($_SESSION['crs_hide_objectives']))
01159                 {
01160                         return true;
01161                 }
01162 
01163                 // show table header
01164                 for($i = 0; $i < 1; ++$i)
01165                 {
01166                         $this->tpl->setCurrentBlock("tbl_header_columns");
01167                         $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","5%");
01168                         $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$this->lng->txt('crs_nr'));
01169                         $this->tpl->parseCurrentBlock();
01170 
01171                         $this->tpl->setCurrentBlock("tbl_header_columns");
01172                         $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","35%");
01173                         $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$this->lng->txt('description'));
01174                         $this->tpl->parseCurrentBlock();
01175 
01176                         $this->tpl->setCurrentBlock("tbl_header_columns");
01177                         $this->tpl->setVariable("TBL_HEADER_WIDTH_OBJECTIVES","10%");
01178                         $this->tpl->setVariable("TBL_HEADER_NAME_OBJECTIVES",$status);
01179                         $this->tpl->parseCurrentBlock();
01180                 }
01181 
01182                 //$max = count($objective_ids) % 2 ? count($objective_ids) + 1 : count($objective_ids); 
01183                 $max = count($objective_ids); 
01184                 for($i = 0; $i < $max; ++$i)
01185                 {
01186                         $tmp_objective =& new ilCourseObjective($this->cci_course_obj,$objective_ids[$i]);
01187 
01188                         $this->tpl->setCurrentBlock("objective_row");
01189 
01190                         if($this->details_id == $objective_ids[$i])
01191                         {
01192                                 $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value_details');
01193                                 $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center_details');
01194                         }
01195                         else
01196                         {
01197                                 $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value');
01198                                 $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center');
01199                         }                               
01200                         $this->tpl->setVariable("OBJ_NR_1_OBJECTIVES",($i + 1).'.');
01201 
01202                         $this->ctrl->setParameter($this->cci_client_obj,'details',$objective_ids[$i]);
01203                         $this->tpl->setVariable("OBJ_LINK_1_OBJECTIVES",$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
01204                         $this->tpl->setVariable("OBJ_TITLE_1_OBJECTIVES",$tmp_objective->getTitle());
01205 
01206                         $img = !$this->suggested["$objective_ids[$i]"] ? 
01207                                 ilUtil::getImagePath('icon_ok.gif') :
01208                                 ilUtil::getImagePath('icon_not_ok.gif');
01209 
01210                         $txt = !$this->suggested["$objective_ids[$i]"] ? 
01211                                 $this->lng->txt('crs_objective_accomplished') :
01212                                 $this->lng->txt('crs_objective_not_accomplished');
01213 
01214                         $this->tpl->setVariable("OBJ_STATUS_IMG_1_OBJECTIVES",$img);
01215                         $this->tpl->setVariable("OBJ_STATUS_ALT_1_OBJECTIVES",$txt);
01216 
01217 
01218                         if(isset($objective_ids[$i + $max / 2]))
01219                         {
01220                                 $tmp_objective =& new ilCourseObjective($this->cci_course_obj,$objective_ids[$i + $max / 2]);
01221 
01222                                 $this->tpl->setCurrentBlock("objective_row");
01223                                 if($this->details_id == $objective_ids[$i + $max / 2])
01224                                 {
01225                                         $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value_details');
01226                                         $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center_details');
01227                                 }
01228                                 else
01229                                 {
01230                                         $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value');
01231                                         $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center');
01232                                 }                               
01233                                 $this->tpl->setVariable("OBJ_NR_2_OBJECTIVES",($i + $max / 2 + 1).'.');
01234                                 $this->ctrl->setParameter($this->cci_client_obj,'details',$objective_ids[$i + $max / 2]);
01235                                 $this->tpl->setVariable("OBJ_LINK_2_OBJECTIVES",$this->ctrl->getLinkTarget($this->cci_client_obj,'cciObjectives'));
01236                                 $this->tpl->setVariable("OBJ_TITLE_2_OBJECTIVES",$tmp_objective->getTitle());
01237 
01238 
01239                                 $objective_id = $objective_ids[$i + $max / 2];
01240                                 $img = !$this->suggested[$objective_id] ? 
01241                                         ilUtil::getImagePath('icon_ok.gif') :
01242                                         ilUtil::getImagePath('icon_not_ok.gif');
01243 
01244                                 $txt = !$this->suggested[$objective_id] ? 
01245                                         $this->lng->txt('crs_objective_accomplished') :
01246                                         $this->lng->txt('crs_objective_not_accomplished');
01247 
01248                                 $this->tpl->setVariable("OBJ_STATUS_IMG_2_OBJECTIVES",$img);
01249                                 $this->tpl->setVariable("OBJ_STATUS_ALT_2_OBJECTIVES",$txt);
01250                         }
01251         
01252                         $this->tpl->parseCurrentBlock();
01253                         unset($tmp_objective);
01254                 }
01255                 $this->ctrl->setParameter($this->cci_client_obj,'details','');
01256         }
01257 
01258         function __readAccomplished()
01259         {
01260                 global $ilUser;
01261 
01262                 if(isset($_SESSION['accomplished'][$this->cci_course_obj->getId()]))
01263                 {
01264                         return $this->accomplished = $_SESSION['accomplished'][$this->cci_course_obj->getId()];
01265                 }
01266 
01267 
01268                 include_once './course/classes/class.ilCourseObjectiveResult.php';
01269                 include_once './course/classes/class.ilCourseObjective.php';
01270 
01271                 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01272                 
01273                 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->cci_course_obj->getId())))
01274                 {
01275                         return $this->accomplished = array();
01276                 }
01277                 $this->accomplished = array();
01278                 foreach($objective_ids as $objective_id)
01279                 {
01280                         if($tmp_obj_res->hasAccomplishedObjective($objective_id))
01281                         {
01282                                 $this->accomplished["$objective_id"] = true;
01283                         }
01284                         else
01285                         {
01286                                 $this->accomplished["$objective_id"] = false;
01287                         }
01288                 }
01289                 $_SESSION['accomplished'][$this->cci_course_obj->getId()] = $this->accomplished;
01290         }
01291         function __readSuggested()
01292         {
01293                 global $ilUser;
01294 
01295                 if(isset($_SESSION['objectives_suggested'][$this->cci_course_obj->getId()]))
01296                 {
01297                         return $this->suggested = $_SESSION['objectives_suggested'][$this->cci_course_obj->getId()];
01298                 }
01299 
01300                 include_once './course/classes/class.ilCourseObjectiveResult.php';
01301 
01302                 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01303 
01304                 $this->suggested = array();
01305                 foreach($this->accomplished as $objective_id => $ok)
01306                 {
01307                         if($ok)
01308                         {
01309                                 $this->suggested["$objective_id"] = false;
01310                         }
01311                         else
01312                         {
01313                                 $this->suggested["$objective_id"] = $tmp_obj_res->isSuggested($objective_id);
01314                         }
01315                 }
01316 
01317                 return $_SESSION['objectives_suggested'][$this->cci_course_obj->getId()] = $this->suggested;
01318 
01319         }
01320 
01321         function __readStatus()
01322         {
01323                 global $ilUser;
01324 
01325                 if(isset($_SESSION['objectives_status'][$this->cci_course_obj->getId()]))
01326                 {
01327                         return $this->objective_status = $_SESSION['objectives_status'][$this->cci_course_obj->getId()];
01328                 }
01329                 $all_success = true;
01330 
01331                 foreach($this->accomplished as $id => $success)
01332                 {
01333                         if(!$success)
01334                         {
01335                                 $all_success = false;
01336                         }
01337                 }
01338                 if($all_success)
01339                 {
01340                         // set status passed
01341                         include_once 'course/classes/class.ilCourseMembers.php';
01342 
01343                         ilCourseMembers::_setPassed($this->cci_course_obj->getId(),$ilUser->getId());
01344 
01345                         $this->objective_status = 'finished';
01346                         $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01347 
01348                         return true;
01349                 }
01350                 include_once './course/classes/class.ilCourseObjectiveResult.php';
01351                 include_once './course/classes/class.ilCourseObjective.php';
01352 
01353                 $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
01354 
01355                 $this->objective_status = $tmp_obj_res->getStatus($this->cci_course_obj->getId());
01356 
01357                 if($this->objective_status == 'pretest')
01358                 {
01359                         $none_suggested = true;
01360                         foreach($this->suggested as $value)
01361                         {
01362                                 if($value)
01363                                 {
01364                                         $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01365                                         return true;
01366                                 }
01367                         }
01368                         $this->objective_status = 'pretest_non_suggest';
01369                 }
01370                 $_SESSION['objectives_status'][$this->cci_course_obj->getId()] = $this->objective_status;
01371 
01372                 return true;
01373         }
01374 
01375         function __showButton($a_cmd,$a_text,$a_target = '')
01376         {
01377                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01378                 
01379                 // display button
01380                 $this->tpl->setCurrentBlock("btn_cell");
01381                 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this->cci_client_obj,$a_cmd));
01382                 $this->tpl->setVariable("BTN_TXT",$a_text);
01383 
01384                 if($a_target)
01385                 {
01386                         $this->tpl->setVariable("BTN_TARGET",$a_target);
01387                 }
01388 
01389                 $this->tpl->parseCurrentBlock();
01390         }
01391 
01392 
01393 
01394         function cci_read()
01395         {
01396                 global $tree;
01397 
01398                 if(!$this->cci_course_id = $tree->checkForParentType($this->cci_ref_id,'crs'))
01399                 {
01400                         echo "ilCourseContentInterface: Cannot find course object";
01401                         exit;
01402                 }
01403                 return true;
01404         }
01405 
01406         function cciToUnix($a_time_arr)
01407         {
01408                 return mktime($a_time_arr["hour"],
01409                                           $a_time_arr["minute"],
01410                                           $a_time_arr["second"],
01411                                           $a_time_arr["month"],
01412                                           $a_time_arr["day"],
01413                                           $a_time_arr["year"]);
01414         }
01415         function cciGetDateSelect($a_type,$a_varname,$a_selected)
01416         {
01417                 switch($a_type)
01418                 {
01419                         case "minute":
01420                                 for($i=0;$i<=60;$i++)
01421                                 {
01422                                         $days[$i] = $i < 10 ? "0".$i : $i;
01423                                 }
01424                                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01425 
01426                         case "hour":
01427                                 for($i=0;$i<24;$i++)
01428                                 {
01429                                         $days[$i] = $i < 10 ? "0".$i : $i;
01430                                 }
01431                                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01432 
01433                         case "day":
01434                                 for($i=1;$i<32;$i++)
01435                                 {
01436                                         $days[$i] = $i < 10 ? "0".$i : $i;
01437                                 }
01438                                 return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
01439                         
01440                         case "month":
01441                                 for($i=1;$i<13;$i++)
01442                                 {
01443                                         $month[$i] = $i < 10 ? "0".$i : $i;
01444                                 }
01445                                 return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
01446 
01447                         case "year":
01448                                 for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
01449                                 {
01450                                         $year[$i] = $i;
01451                                 }
01452                                 return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
01453                 }
01454         }
01455 }
01456 ?>

Generated on Fri Dec 13 2013 13:52:10 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1