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

course/classes/class.ilCourseObjectivesGUI.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 
00035 class ilCourseObjectivesGUI
00036 {
00037         var $ctrl;
00038         var $ilias;
00039         var $ilErr;
00040         var $lng;
00041         var $tpl;
00042 
00043         var $course_obj;
00044         var $course_id;
00045         
00046         function ilCourseObjectivesGUI($a_course_id)
00047         {
00048                 include_once './course/classes/class.ilCourseObjective.php';
00049 
00050                 global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree,$ilTabs;
00051 
00052                 $this->ctrl =& $ilCtrl;
00053                 $this->ctrl->saveParameter($this,array("ref_id"));
00054 
00055                 $this->ilErr =& $ilErr;
00056                 $this->lng =& $lng;
00057                 $this->tpl =& $tpl;
00058                 $this->tree =& $tree;
00059                 $this->tabs_gui =& $ilTabs;
00060 
00061                 $this->course_id = $a_course_id;
00062                 $this->__initCourseObject();
00063         }
00064 
00068         function &executeCommand()
00069         {
00070                 global $ilTabs;
00071 
00072                 $ilTabs->setTabActive('crs_objectives');
00073                 
00074                 $cmd = $this->ctrl->getCmd();
00075 
00076 
00077                 if (!$cmd = $this->ctrl->getCmd())
00078                 {
00079                         $cmd = "list";
00080                 }
00081                 
00082                 $this->setSubTabs();
00083                 $this->$cmd();
00084         }
00085 
00086         function listAssignedLM()
00087         {
00088                 global $rbacsystem;
00089 
00090                 // MINIMUM ACCESS LEVEL = 'write'
00091                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00092                 {
00093                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00094                 }
00095                 if(!isset($_GET['objective_id']))
00096                 {
00097                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00098                         $this->listObjectives();
00099 
00100                         return false;
00101                 }
00102 
00103                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00104                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_list_lm.html","course");
00105 
00106                 if(!count($this->__getAllLMs()))
00107                 {
00108                         $this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00109                         sendInfo($this->lng->txt('crs_no_lms_inside_course'));
00110                         
00111                         return true;
00112                 }
00113 
00114                 $this->__initLMObject((int) $_GET['objective_id']);
00115                 if(!count($lms = $this->objectives_lm_obj->getLMs()))
00116                 {
00117                         sendInfo($this->lng->txt('crs_no_lms_assigned'));
00118                         #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00119                         $this->__showButton('assignLMSelect',$this->lng->txt('crs_objective_assign_lm'));
00120 
00121                         return true;
00122                 }
00123 
00124                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00125                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_lm_list_row.html","course");
00126 
00127                 #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00128 
00129                 $counter = 0;
00130                 foreach($lms as $item)
00131                 {
00132                         ++$counter;
00133 
00134                         $tmp_lm =& ilObjectFactory::getInstanceByRefId($item['ref_id']);
00135 
00136                         $title = $tmp_lm->getTitle();
00137                         if($item['type'] == 'st')
00138                         {
00139                                 include_once './content/classes/class.ilLMObjectFactory.php';
00140 
00141                                 $st_obj = ilLMObjectFactory::getInstance($tmp_lm,$item['obj_id']);
00142                                 $title .= (" -> ".$st_obj->getTitle());
00143                         }
00144                                 
00145                         $tpl->setCurrentBlock("tbl_content");
00146                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00147                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'lm[]',$item['lm_ass_id']));
00148 
00149                         $tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('icon_'.$tmp_lm->getType().'.gif'));
00150                         $tpl->setVariable("IMG_ALT",$this->lng->txt('obj_'.$tmp_lm->getType()));
00151                         $tpl->setVariable("TITLE",$title);
00152                         $tpl->setVariable("DESCRIPTION",$tmp_lm->getDescription());
00153                         $tpl->parseCurrentBlock();
00154 
00155                         unset($tmp_lm);
00156                 }
00157 
00158                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00159 
00160                 // Show action row
00161                 $tpl->setCurrentBlock("tbl_action_btn");
00162                 $tpl->setVariable("BTN_NAME",'askDeleteLM');
00163                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_delete_lm_assignment'));
00164                 $tpl->parseCurrentBlock();
00165 
00166                 // Show add button
00167                 $tpl->setCurrentBlock("plain_button");
00168                 $tpl->setVariable("PBTN_NAME",'assignLMSelect');
00169                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('crs_objective_assign_lm'));
00170                 $tpl->parseCurrentBlock();
00171 
00172 
00173                 $tpl->setCurrentBlock("tbl_action_row");
00174                 $tpl->setVariable("COLUMN_COUNTS",3);
00175                 $tpl->setVariable("WIDTH","width=\"50%\"");
00176                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00177                 $tpl->parseCurrentBlock();
00178 
00179 
00180                 // create table
00181                 $tbl = new ilTableGUI();
00182                 $tbl->setStyle('table','std');
00183 
00184                 // title & header columns
00185                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00186 
00187                 $header_title = $this->lng->txt("crs_objectives_assigned_lms")." (".$objective_obj->getTitle().")";
00188 
00189                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
00190 
00191                 $tbl->setHeaderNames(array('',$this->lng->txt('type'),$this->lng->txt("title")));
00192                 $tbl->setHeaderVars(array("","type","title"), 
00193                                                         array("ref_id" => $this->course_obj->getRefId(),
00194                                                                   "objective_id" => (int) $_GET['objective_id'],
00195                                                                   "cmdClass" => "ilcourseobjectivesgui",
00196                                                                   "cmdNode" => $_GET["cmdNode"]));
00197                 $tbl->setColumnWidth(array("1%","1%",'98%'));
00198 
00199                 $tbl->setLimit($_GET["limit"]);
00200                 $tbl->setOffset($_GET["offset"]);
00201                 $tbl->setMaxCount(count($objectives));
00202 
00203                 // footer
00204                 $tbl->disable("footer");
00205                 $tbl->disable('sort');
00206 
00207                 // render table
00208                 $tbl->setTemplate($tpl);
00209                 $tbl->render();
00210 
00211                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00212 
00213                 return true;
00214 
00215 
00216         }
00217 
00218         function askDeleteLM()
00219         {
00220                 global $rbacsystem;
00221 
00222                 // MINIMUM ACCESS LEVEL = 'write'
00223                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00224                 {
00225                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00226                 }
00227                 if(!count($_POST['lm']))
00228                 {
00229                         sendInfo($this->lng->txt('crs_lm_no_assignments_selected'));
00230                         $this->listAssignedLM();
00231 
00232                         return false;
00233                 }
00234                 if(!isset($_GET['objective_id']))
00235                 {
00236                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00237                         $this->listObjectives();
00238 
00239                         return false;
00240                 }
00241 
00242                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_delete_lm.html","course");
00243                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00244 
00245                 sendInfo($this->lng->txt('crs_deassign_lm_sure'));
00246 
00247                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00248                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_lm_row.html","course");
00249 
00250                 $this->__initLMObject((int) $_GET['objective_id']);
00251 
00252                 $counter = 0;
00253                 foreach($_POST['lm'] as $lm_ass_id)
00254                 {
00255                         $lm_ass_data = $this->objectives_lm_obj->getLM($lm_ass_id);
00256 
00257                         $tmp_lm =& ilObjectFactory::getInstanceByRefId($lm_ass_data['ref_id']);
00258                         $title = $tmp_lm->getTitle();
00259                         if($lm_ass_data['type'] == 'st')
00260                         {
00261                                 include_once './content/classes/class.ilLMObjectFactory.php';
00262 
00263                                 $st_obj = ilLMObjectFactory::getInstance($tmp_lm,$lm_ass_data['obj_id']);
00264                                 $title .= (" -> ".$st_obj->getTitle());
00265                         }
00266 
00267                         $tpl->setCurrentBlock("tbl_content");
00268                         $tpl->setVariable("ROWCOL",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
00269                         $tpl->setVariable("TITLE",$title);
00270                         $tpl->setVariable("DESCRIPTION",$tmp_lm->getDescription());
00271                         $tpl->parseCurrentBlock();
00272                 }
00273 
00274                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00275 
00276                 // Show action row
00277                 $tpl->setCurrentBlock("tbl_action_btn");
00278                 $tpl->setVariable("BTN_NAME",'listAssignedLM');
00279                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('cancel'));
00280                 $tpl->parseCurrentBlock();
00281 
00282                 $tpl->setCurrentBlock("tbl_action_btn");
00283                 $tpl->setVariable("BTN_NAME",'deleteLM');
00284                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_lm_deassign'));
00285                 $tpl->parseCurrentBlock();
00286 
00287                 $tpl->setCurrentBlock("tbl_action_row");
00288                 $tpl->setVariable("COLUMN_COUNTS",1);
00289                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00290                 $tpl->parseCurrentBlock();
00291 
00292                 $tpl->setVariable("WIDTH","width=\"50%\"");
00293 
00294                 // create table
00295                 $tbl = new ilTableGUI();
00296                 $tbl->setStyle('table','std');
00297                 
00298                         
00299                 // title & header columns
00300                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00301                 $header_title = $this->lng->txt("crs_objective")." (".$objective_obj->getTitle().')';
00302 
00303                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
00304 
00305                 $tbl->setHeaderNames(array($this->lng->txt("title")));
00306                 $tbl->setHeaderVars(array("title"), 
00307                                                         array("ref_id" => $this->course_obj->getRefId(),
00308                                                                   "cmdClass" => "ilcourseobjectivesgui",
00309                                                                   "cmdNode" => $_GET["cmdNode"]));
00310                 $tbl->setColumnWidth(array("100%"));
00311 
00312                 $tbl->setLimit($_GET["limit"]);
00313                 $tbl->setOffset($_GET["offset"]);
00314                 $tbl->setMaxCount(count($objectives));
00315 
00316 
00317                 // footer
00318                 $tbl->disable("footer");
00319                 $tbl->disable('sort');
00320 
00321                 // render table
00322                 $tbl->setTemplate($tpl);
00323                 $tbl->render();
00324 
00325                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00326 
00327                 // Save marked objectives
00328                 $_SESSION['crs_delete_lm'] = $_POST['lm'];
00329 
00330                 return true;
00331 
00332 
00333         }
00334 
00335         function deleteLM()
00336         {
00337                 global $rbacsystem;
00338 
00339                 // MINIMUM ACCESS LEVEL = 'write'
00340                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00341                 {
00342                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00343                 }
00344                 if(!isset($_GET['objective_id']))
00345                 {
00346                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00347                         $this->listObjectives();
00348 
00349                         return false;
00350                 }
00351                 if(!count($_SESSION['crs_delete_lm']))
00352                 {
00353                         sendInfo('No lm selected');
00354                         $this->listAssignedLM();
00355 
00356                         return false;
00357                 }
00358 
00359                 $this->__initLMObject((int) $_GET['objective_id']);
00360 
00361                 foreach($_SESSION['crs_delete_lm'] as $lm_ass_id)
00362                 {
00363                         $this->objectives_lm_obj->delete($lm_ass_id);
00364                 }
00365                 sendInfo($this->lng->txt('crs_lm_assignment_deleted'));
00366                 $this->listAssignedLM();
00367 
00368                 return true;
00369         }
00370 
00371 
00372 
00373         function assignLMSelect()
00374         {
00375                 global $rbacsystem;
00376 
00377                 // MINIMUM ACCESS LEVEL = 'write'
00378                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00379                 {
00380                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00381                 }
00382                 if(!isset($_GET['objective_id']))
00383                 {
00384                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00385                         $this->listObjectives();
00386 
00387                         return false;
00388                 }
00389                 if(!count($all_lms = $this->__getAllLMs()))
00390                 {
00391                         sendInfo($this->lng->txt('crs_no_objective_lms_found'));
00392                         $this->listAssignedLM();
00393 
00394                         return false;
00395                 }
00396                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00397                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_lm_select.html","course");
00398                 $this->__showButton('listAssignedLM',$this->lng->txt('back'));
00399 
00400 
00401                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00402                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_lm_select_row.html","course");
00403 
00404                 $counter = 0;
00405                 foreach($all_lms as $item)
00406                 {
00407                         ++$counter;
00408 
00409                         $tmp_lm =& ilObjectFactory::getInstanceByRefId($item);
00410 
00411                         $tpl->setCurrentBlock("tbl_content");
00412                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00413                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'lm[]',$item));
00414 
00415                         $tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('icon_'.$tmp_lm->getType().'.gif'));
00416                         $tpl->setVariable("IMG_ALT",$this->lng->txt('obj_'.$tmp_lm->getType()));
00417                         $tpl->setVariable("TITLE",$tmp_lm->getTitle());
00418                         $tpl->setVariable("DESCRIPTION",$tmp_lm->getDescription());
00419                         $tpl->parseCurrentBlock();
00420 
00421                         unset($tmp_lm);
00422                 }
00423 
00424                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00425 
00426                 // Show action row
00427                 $tpl->setCurrentBlock("tbl_action_btn");
00428                 $tpl->setVariable("BTN_NAME",'assignLM');
00429                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_assign_lm'));
00430                 $tpl->parseCurrentBlock();
00431 
00432                 $tpl->setCurrentBlock("tbl_action_btn");
00433                 $tpl->setVariable("BTN_NAME",'assignChapterSelect');
00434                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_assign_chapter'));
00435                 $tpl->parseCurrentBlock();
00436 
00437                 $tpl->setCurrentBlock("tbl_action_row");
00438                 $tpl->setVariable("COLUMN_COUNTS",3);
00439                 $tpl->setVariable("WIDTH","width=\"50%\"");
00440                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00441                 $tpl->parseCurrentBlock();
00442 
00443 
00444                 // create table
00445                 $tbl = new ilTableGUI();
00446                 $tbl->setStyle('table','std');
00447 
00448                 // title & header columns
00449                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00450                 $header_title = $this->lng->txt("crs_objectives_lm_assignment").' ('.$objectives_obj->getTitle().')';
00451 
00452                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
00453 
00454                 $tbl->setHeaderNames(array('',$this->lng->txt('type'),$this->lng->txt("title")));
00455                 $tbl->setHeaderVars(array("","type","title"), 
00456                                                         array("ref_id" => $this->course_obj->getRefId(),
00457                                                                   "objective_id" => (int) $_GET['objective_id'],
00458                                                                   "cmdClass" => "ilcourseobjectivesgui",
00459                                                                   "cmdNode" => $_GET["cmdNode"]));
00460                 $tbl->setColumnWidth(array("1%","1%",'98%'));
00461 
00462                 $tbl->setLimit($_GET["limit"]);
00463                 $tbl->setOffset($_GET["offset"]);
00464                 $tbl->setMaxCount(count($objectives));
00465 
00466                 // footer
00467                 $tbl->disable("footer");
00468                 $tbl->disable('sort');
00469 
00470                 // render table
00471                 $tbl->setTemplate($tpl);
00472                 $tbl->render();
00473 
00474                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00475 
00476                 return true;
00477         }
00478 
00479         function assignChapterSelect()
00480         {
00481                 global $rbacsystem;
00482 
00483                 // MINIMUM ACCESS LEVEL = 'write'
00484                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00485                 {
00486                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00487                 }
00488                 if(count($_POST['lm']) !== 1)
00489                 {
00490                         sendInfo($this->lng->txt('crs_select_exactly_one_lm'));
00491                         $this->assignLMSelect();
00492 
00493                         return false;
00494                 }
00495                 foreach($_POST['lm'] as $lm_id)
00496                 {
00497                         $tmp_lm =& ilObjectFactory::getInstanceByRefId($lm_id);
00498                         if($tmp_lm->getType() != 'lm')
00499                         {
00500                                 sendInfo($this->lng->txt('crs_select_native_lm'));
00501                                 $this->assignLMSelect();
00502                                 
00503                                 return false;
00504                         }
00505                 }
00506                 $lm_id = (int) $_POST['lm'][0];
00507 
00508                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_chapter_select.html","course");
00509                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00510                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_chapter_select_row.html","course");
00511 
00512                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00513                 $this->ctrl->setParameter($this,'lm_id',(int) $lm_id);
00514                 $this->__showButton('assignLMSelect',$this->lng->txt('back'));
00515                 
00516                 $lm_obj =& ilObjectFactory::getInstanceByRefId($lm_id);
00517 
00518                 $counter = 0;
00519                 foreach($this->__getAllChapters($lm_id) as $chapter)
00520                 {
00521                         ++$counter;
00522                         include_once './content/classes/class.ilLMObjectFactory.php';
00523 
00524                         $st_obj = ilLMObjectFactory::getInstance($lm_obj,$chapter);
00525                         
00526                         $tpl->setCurrentBlock("tbl_content");
00527                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00528                         $tpl->setVariable("TITLE",$st_obj->getTitle());
00529                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'chapter[]',$st_obj->getId()));
00530                         $tpl->parseCurrentBlock();
00531                 }
00532 
00533 
00534                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00535 
00536                 // Show action row
00537                 $tpl->setCurrentBlock("tbl_action_btn");
00538                 $tpl->setVariable("BTN_NAME",'assignLMChapter');
00539                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objectives_assign_chapter'));
00540                 $tpl->parseCurrentBlock();
00541 
00542                 $tpl->setCurrentBlock("tbl_action_row");
00543                 $tpl->setVariable("WIDTH","width=\"50%\"");
00544                 $tpl->setVariable("COLUMN_COUNTS",2);
00545                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00546                 $tpl->parseCurrentBlock();
00547 
00548 
00549                 // create table
00550                 $tbl = new ilTableGUI();
00551                 $tbl->setStyle('table','std');
00552                 
00553 
00554                 // title & header columns
00555                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00556                 $header_title = $this->lng->txt("crs_objectives_chapter_assignment").' ('.$objectives_obj->getTitle().')';
00557 
00558                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
00559 
00560                 $tbl->setHeaderNames(array('',$this->lng->txt("title")));
00561                 $tbl->setHeaderVars(array("type","title"), 
00562                                                         array("ref_id" => $this->course_obj->getRefId(),
00563                                                                   "cmdClass" => "ilcourseobjectivesgui",
00564                                                                   "cmdNode" => $_GET["cmdNode"]));
00565                 $tbl->setColumnWidth(array("1%","99%"));
00566 
00567                 $tbl->setLimit($_GET["limit"]);
00568                 $tbl->setOffset($_GET["offset"]);
00569                 $tbl->setMaxCount(count($objectives));
00570 
00571                 // footer
00572                 $tbl->disable("footer");
00573                 $tbl->disable('sort');
00574 
00575                 // render table
00576                 $tbl->setTemplate($tpl);
00577                 $tbl->render();
00578 
00579                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00580                 
00581                 return true;
00582         }
00583 
00584         function assignLMChapter()
00585         {
00586                 global $rbacsystem;
00587 
00588                 // MINIMUM ACCESS LEVEL = 'write'
00589                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00590                 {
00591                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00592                 }
00593                 if(!isset($_GET['objective_id']))
00594                 {
00595                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00596                         $this->listObjectives();
00597 
00598                         return false;
00599                 }
00600                 if(!count($_POST['chapter']))
00601                 {
00602                         $_POST['lm'] = array((int) $_GET['lm_id']);
00603                         sendInfo($this->lng->txt('crs_no_chapter_selected'));
00604                         $this->assignChapterSelect();
00605 
00606                         return false;
00607                 }
00608 
00609                 $this->__initLMObject((int) $_GET['objective_id']);
00610 
00611                 $counter = 0;
00612                 foreach($_POST['chapter'] as $chapter_id)
00613                 {
00614                         $tmp_lm =& ilObjectFactory::getInstanceByRefId((int) $_GET['lm_id']);
00615 
00616                         $this->objectives_lm_obj->setType('st');
00617                         $this->objectives_lm_obj->setLMRefId($tmp_lm->getRefId());
00618                         $this->objectives_lm_obj->setLMObjId($chapter_id);
00619                         
00620                         if($this->objectives_lm_obj->checkExists())
00621                         {
00622                                 continue;
00623                         }
00624                         
00625                         $this->objectives_lm_obj->add();
00626                         ++$counter;
00627                 }
00628 
00629                 if($counter)
00630                 {
00631                         sendInfo($this->lng->txt('crs_objectives_assigned_lm'));
00632                         $this->listAssignedLM();
00633                 }
00634                 else
00635                 {
00636                         sendInfo($this->lng->txt('crs_chapter_already_assigned'));
00637                         $this->assignLMSelect();
00638                 }
00639 
00640                 return true;
00641         }
00642 
00643         function assignLM()
00644         {
00645                 global $rbacsystem;
00646 
00647                 // MINIMUM ACCESS LEVEL = 'write'
00648                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00649                 {
00650                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00651                 }
00652                 if(!isset($_GET['objective_id']))
00653                 {
00654                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00655                         $this->listObjectives();
00656 
00657                         return false;
00658                 }
00659                 if(!count($_POST['lm']))
00660                 {
00661                         sendInfo($this->lng->txt('crs_no_lm_selected'));
00662                         $this->assignLMSelect();
00663 
00664                         return false;
00665                 }
00666 
00667                 $this->__initLMObject((int) $_GET['objective_id']);
00668 
00669                 $counter = 0;
00670                 foreach($_POST['lm'] as $lm_id)
00671                 {
00672                         $tmp_lm =& ilObjectFactory::getInstanceByRefId($lm_id);
00673 
00674                         $this->objectives_lm_obj->setType($tmp_lm->getType());
00675                         $this->objectives_lm_obj->setLMRefId($tmp_lm->getRefId());
00676                         $this->objectives_lm_obj->setLMObjId($tmp_lm->getId());
00677                         
00678                         if($this->objectives_lm_obj->checkExists())
00679                         {
00680                                 continue;
00681                         }
00682                         
00683                         $this->objectives_lm_obj->add();
00684                         ++$counter;
00685                 }
00686 
00687                 if($counter)
00688                 {
00689                         sendInfo($this->lng->txt('crs_objectives_assigned_lm'));
00690                         $this->listAssignedLM();
00691                 }
00692                 else
00693                 {
00694                         sendInfo($this->lng->txt('crs_lms_already_assigned'));
00695                         $this->assignLMSelect();
00696                 }
00697 
00698                 return true;
00699         }
00700 
00701         function listObjectives()
00702         {
00703                 global $rbacsystem;
00704 
00705                 // MINIMUM ACCESS LEVEL = 'write'
00706                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00707                 {
00708                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00709                 }
00710 
00711                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html","course");
00712                 if(!count($objectives = ilCourseObjective::_getObjectiveIds($this->course_obj->getId())))
00713                 {
00714                         $this->__showButton('addObjective',$this->lng->txt('crs_add_objective'));
00715                         sendInfo($this->lng->txt('crs_no_objectives_created'));
00716                         
00717                         return true;
00718                 }
00719                 #else
00720                 #{
00721                 #       $this->__showButton('editQuestionAssignment',$this->lng->txt('crs_objective_overview_question_assignment'));
00722                 #}
00723 
00724                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00725                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_row.html","course");
00726 
00727                 $counter = 0;
00728                 foreach($objectives as $objective)
00729                 {
00730                         ++$counter;
00731                         $objective_obj =& $this->__initObjectivesObject($objective);
00732 
00733                         // Up down links
00734                         if(count($objectives) > 1)
00735                         {
00736                                 if($counter == 1)
00737                                 {
00738                                         $tpl->setVariable("NO_IMG_PRE_TYPE",ilUtil::getImagePath('empty.gif'));
00739                                 }                                       
00740                                 if($counter > 1) 
00741                                 {
00742                                         $tpl->setCurrentBlock("img");
00743                                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00744                                         $tpl->setVariable("IMG_LINK",$this->ctrl->getLinkTarget($this,'moveObjectiveUp'));
00745                                         $tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('a_up.gif'));
00746                                         $tpl->setVariable("IMG_ALT",$this->lng->txt('crs_move_up'));
00747                                         $tpl->parseCurrentBlock();
00748                                 }
00749                                 if($counter < count($objectives))
00750                                 {
00751                                         $tpl->setCurrentBlock("img");
00752                                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00753                                         $tpl->setVariable("IMG_LINK",$this->ctrl->getLinkTarget($this,'moveObjectiveDown'));
00754                                         $tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('a_down.gif'));
00755                                         $tpl->setVariable("IMG_ALT",$this->lng->txt('crs_move_down'));
00756                                         $tpl->parseCurrentBlock();
00757                                 }
00758                                 if($counter == count($objectives))
00759                                 {
00760                                         $tpl->setCurrentBlock("no_img_post");
00761                                         $tpl->setVariable("NO_IMG_POST_TYPE",ilUtil::getImagePath('empty.gif'));
00762                                         $tpl->parseCurrentBlock();
00763                                 }                                       
00764 
00765                         }
00766                         // Edit link
00767                         $tpl->setCurrentBlock("edit_img");
00768                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00769                         $tpl->setVariable("EDIT_IMG_LINK",$this->ctrl->getLinkTarget($this,'editObjective'));
00770                         $tpl->setVariable("EDIT_IMG_TYPE",ilUtil::getImagePath('edit.gif'));
00771                         $tpl->setVariable("EDIT_IMG_ALT",$this->lng->txt('edit'));
00772                         $tpl->parseCurrentBlock();
00773                         
00774                         // Assign lm
00775                         $tpl->setCurrentBlock("edit_img");
00776                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00777                         $tpl->setVariable("EDIT_IMG_LINK",$this->ctrl->getLinkTarget($this,'listAssignedLM'));
00778                         $tpl->setVariable("EDIT_IMG_TYPE",ilUtil::getImagePath('icon_lm.gif'));
00779                         $tpl->setVariable("EDIT_IMG_ALT",$this->lng->txt('crs_lm_assignment'));
00780                         $tpl->parseCurrentBlock();
00781 
00782                         // Assign questions
00783                         $tpl->setCurrentBlock("edit_img");
00784                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00785                         $tpl->setVariable("EDIT_IMG_LINK",$this->ctrl->getLinkTarget($this,'listAssignedQuestions'));
00786                         $tpl->setVariable("EDIT_IMG_TYPE",ilUtil::getImagePath('icon_tst.gif'));
00787                         $tpl->setVariable("EDIT_IMG_ALT",$this->lng->txt('crs_question_assignment'));
00788                         $tpl->parseCurrentBlock();
00789 
00790                         $tpl->setCurrentBlock("options");
00791                         $tpl->setVariable("OPT_ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00792 
00793 
00794                         $tpl->setCurrentBlock("tbl_content");
00795                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00796                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'objective[]',$objective_obj->getObjectiveId()));
00797                         $tpl->setVariable("TITLE",$objective_obj->getTitle());
00798                         $tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
00799                         $tpl->parseCurrentBlock();
00800                 }
00801 
00802                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00803 
00804                 // Show action row
00805                 $tpl->setCurrentBlock("tbl_action_btn");
00806                 $tpl->setVariable("BTN_NAME",'askDeleteObjective');
00807                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
00808                 $tpl->parseCurrentBlock();
00809 
00810                 $tpl->setCurrentBlock("plain_button");
00811                 $tpl->setVariable("PBTN_NAME",'addObjective');
00812                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('crs_add_objective'));
00813                 $tpl->parseCurrentBlock();
00814 
00815                 $tpl->setCurrentBlock("tbl_action_row");
00816                 $tpl->setVariable("COLUMN_COUNTS",3);
00817                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00818                 $tpl->parseCurrentBlock();
00819 
00820 
00821                 // create table
00822                 $tbl = new ilTableGUI();
00823                 $tbl->setStyle('table','std');
00824 
00825                 // title & header columns
00826                 $tbl->setTitle($this->lng->txt("crs_objectives"),"icon_crs.gif",$this->lng->txt("crs_objectives"));
00827 
00828                 $tbl->setHeaderNames(array('',$this->lng->txt("title"),$this->lng->txt('options')));
00829                 $tbl->setHeaderVars(array("type","title",'options'), 
00830                                                         array("ref_id" => $this->course_obj->getRefId(),
00831                                                                   "cmdClass" => "ilcourseobjectivesgui",
00832                                                                   "cmdNode" => $_GET["cmdNode"]));
00833                 $tbl->setColumnWidth(array("1%","80%",'20%'));
00834 
00835                 $tbl->setLimit($_GET["limit"]);
00836                 $tbl->setOffset($_GET["offset"]);
00837                 $tbl->setMaxCount(count($objectives));
00838 
00839                 // footer
00840                 $tbl->disable("footer");
00841                 $tbl->disable('sort');
00842 
00843                 // render table
00844                 $tbl->setTemplate($tpl);
00845                 $tbl->render();
00846 
00847                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00848                 
00849 
00850                 return true;
00851         }
00852         function moveObjectiveUp()
00853         {
00854                 global $rbacsystem;
00855 
00856                 // MINIMUM ACCESS LEVEL = 'write'
00857                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00858                 {
00859                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00860                 }
00861                 if(!$_GET['objective_id'])
00862                 {
00863                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00864                         $this->listObjectives();
00865                         
00866                         return true;
00867                 }
00868                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00869 
00870                 $objective_obj->moveUp((int) $_GET['objective_id']);
00871                 sendInfo($this->lng->txt('crs_moved_objective'));
00872 
00873                 $this->listObjectives();
00874 
00875                 return true;
00876         }
00877         function moveObjectiveDown()
00878         {
00879                 global $rbacsystem;
00880 
00881                 // MINIMUM ACCESS LEVEL = 'write'
00882                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00883                 {
00884                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00885                 }
00886                 if(!$_GET['objective_id'])
00887                 {
00888                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00889                         $this->listObjectives();
00890                         
00891                         return true;
00892                 }
00893                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00894 
00895                 $objective_obj->moveDown((int) $_GET['objective_id']);
00896                 sendInfo($this->lng->txt('crs_moved_objective'));
00897 
00898                 $this->listObjectives();
00899 
00900                 return true;
00901         }
00902 
00903 
00904         function addObjective()
00905         {
00906                 global $rbacsystem;
00907 
00908                 // MINIMUM ACCESS LEVEL = 'write'
00909                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00910                 {
00911                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00912                 }
00913                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.crs_add_objective.html","course");
00914 
00915                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00916                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('crs_add_objective'));
00917                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00918                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt('description'));
00919                 $this->tpl->setVariable("TXT_REQUIRED_FLD",$this->lng->txt('required'));
00920                 $this->tpl->setVariable("CMD_SUBMIT",'saveObjective');
00921                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('add'));
00922                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00923 
00924                 return true;
00925         }
00926 
00927         function editObjective()
00928         {
00929                 global $rbacsystem;
00930 
00931                 // MINIMUM ACCESS LEVEL = 'write'
00932                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00933                 {
00934                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00935                 }
00936                 if(!isset($_GET['objective_id']))
00937                 {
00938                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00939                         $this->listObjectives();
00940 
00941                         return false;
00942                 }
00943 
00944                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.crs_add_objective.html","course");
00945 
00946                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00947                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00948                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('crs_update_objective'));
00949                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00950                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt('description'));
00951                 $this->tpl->setVariable("TXT_REQUIRED_FLD",$this->lng->txt('required'));
00952                 $this->tpl->setVariable("CMD_SUBMIT",'updateObjective');
00953                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('save'));
00954                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00955 
00956                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00957 
00958                 $this->tpl->setVariable("TITLE",$objective_obj->getTitle());
00959                 $this->tpl->setVariable("DESC",$objective_obj->getDescription());
00960 
00961                 return true;
00962         }
00963 
00964         function updateObjective()
00965         {
00966                 global $rbacsystem;
00967 
00968                 // MINIMUM ACCESS LEVEL = 'write'
00969                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00970                 {
00971                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00972                 }
00973                 if(!isset($_GET['objective_id']))
00974                 {               
00975                         sendInfo($this->lng->txt('crs_no_objective_selected'));
00976                         $this->listObjectives();
00977 
00978                         return false;
00979                 }
00980                 if(!$_POST['objective']['title'])
00981                 {               
00982                         sendInfo($this->lng->txt('crs_objective_no_title_given'));
00983                         $this->editObjective();
00984                         
00985                         return false;
00986                 }
00987 
00988 
00989                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00990 
00991                 $objective_obj->setObjectiveId((int) $_GET['objective_id']);
00992                 $objective_obj->setTitle(ilUtil::stripSlashes($_POST['objective']['title']));
00993                 $objective_obj->setDescription(ilUtil::stripSlashes($_POST['objective']['description']));
00994 
00995                 $objective_obj->update();
00996                 
00997                 sendInfo($this->lng->txt('crs_objective_modified'));
00998                 $this->listObjectives();
00999 
01000                 return true;
01001         }
01002 
01003 
01004         function askDeleteObjective()
01005         {
01006                 global $rbacsystem;
01007 
01008                 // MINIMUM ACCESS LEVEL = 'write'
01009                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01010                 {
01011                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01012                 }
01013                 if(!count($_POST['objective']))
01014                 {
01015                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01016                         $this->listObjectives();
01017                         
01018                         return true;
01019                 }
01020 
01021                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html","course");
01022 
01023                 sendInfo($this->lng->txt('crs_delete_objectve_sure'));
01024 
01025                 $tpl =& new ilTemplate("tpl.table.html", true, true);
01026                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html","course");
01027 
01028                 $counter = 0;
01029                 foreach($_POST['objective'] as $objective_id)
01030                 {
01031                         $objective_obj =& $this->__initObjectivesObject($objective_id);
01032 
01033                         $tpl->setCurrentBlock("tbl_content");
01034                         $tpl->setVariable("ROWCOL",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
01035                         $tpl->setVariable("TITLE",$objective_obj->getTitle());
01036                         $tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
01037                         $tpl->parseCurrentBlock();
01038                 }
01039 
01040                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01041 
01042                 // Show action row
01043                 $tpl->setCurrentBlock("tbl_action_btn");
01044                 $tpl->setVariable("BTN_NAME",'listObjectives');
01045                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('cancel'));
01046                 $tpl->parseCurrentBlock();
01047 
01048                 $tpl->setCurrentBlock("tbl_action_btn");
01049                 $tpl->setVariable("BTN_NAME",'deleteObjectives');
01050                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
01051                 $tpl->parseCurrentBlock();
01052 
01053                 $tpl->setCurrentBlock("tbl_action_row");
01054                 $tpl->setVariable("COLUMN_COUNTS",1);
01055                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
01056                 $tpl->parseCurrentBlock();
01057 
01058 
01059                 // create table
01060                 $tbl = new ilTableGUI();
01061                 $tbl->setStyle('table','std');
01062 
01063                 // title & header columns
01064                 $tbl->setTitle($this->lng->txt("crs_objectives"),"icon_crs.gif",$this->lng->txt("crs_objectives"));
01065 
01066                 $tbl->setHeaderNames(array($this->lng->txt("title")));
01067                 $tbl->setHeaderVars(array("title"), 
01068                                                         array("ref_id" => $this->course_obj->getRefId(),
01069                                                                   "cmdClass" => "ilcourseobjectivesgui",
01070                                                                   "cmdNode" => $_GET["cmdNode"]));
01071                 $tbl->setColumnWidth(array("50%"));
01072 
01073                 $tbl->setLimit($_GET["limit"]);
01074                 $tbl->setOffset($_GET["offset"]);
01075                 $tbl->setMaxCount(count($objectives));
01076 
01077                 // footer
01078                 $tbl->disable("footer");
01079                 $tbl->disable('sort');
01080 
01081                 // render table
01082                 $tbl->setTemplate($tpl);
01083                 $tbl->render();
01084 
01085                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
01086                 
01087 
01088                 // Save marked objectives
01089                 $_SESSION['crs_delete_objectives'] = $_POST['objective'];
01090 
01091                 return true;
01092         }
01093 
01094         function deleteObjectives()
01095         {
01096                 global $rbacsystem;
01097 
01098                 // MINIMUM ACCESS LEVEL = 'write'
01099                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01100                 {
01101                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01102                 }
01103                 if(!count($_SESSION['crs_delete_objectives']))
01104                 {
01105                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01106                         $this->listObjectives();
01107                         
01108                         return true;
01109                 }
01110 
01111                 foreach($_SESSION['crs_delete_objectives'] as $objective_id)
01112                 {
01113                         $objective_obj =& $this->__initObjectivesObject($objective_id);
01114                         $objective_obj->delete();
01115                 }
01116 
01117                 sendInfo($this->lng->txt('crs_objectives_deleted'));
01118                 $this->listObjectives();
01119 
01120                 return true;
01121         }
01122 
01123 
01124         function saveObjective()
01125         {
01126                 global $rbacsystem;
01127 
01128                 // MINIMUM ACCESS LEVEL = 'write'
01129                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01130                 {
01131                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01132                 }
01133                 if(!$_POST['objective']['title'])
01134                 {
01135                         sendInfo('crs_no_title_given',true);
01136 
01137                         $this->addObjective();
01138                         return false;
01139                 }
01140 
01141                 $objective_obj =& $this->__initObjectivesObject();
01142 
01143                 $objective_obj->setTitle(ilUtil::stripSlashes($_POST['objective']['title']));
01144                 $objective_obj->setDescription(ilUtil::stripSlashes($_POST['objective']['description']));
01145                 $objective_obj->add();
01146                 
01147                 sendInfo($this->lng->txt('crs_added_objective'));
01148                 $this->listObjectives();
01149 
01150                 return true;
01151         }
01152 
01153         // Question assignment
01154         function listAssignedQuestions()
01155         {
01156                 global $rbacsystem;
01157 
01158                 // MINIMUM ACCESS LEVEL = 'write'
01159                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01160                 {
01161                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01162                 }
01163                 if(!isset($_GET['objective_id']))
01164                 {
01165                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01166                         $this->listObjectives();
01167 
01168                         return false;
01169                 }
01170 
01171                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
01172                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_list_qst.html","course");
01173 
01174                 if(!count($this->__getAllTests()))
01175                 {
01176                         #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
01177                         sendInfo($this->lng->txt('crs_no_tests_inside_crs'));
01178                         
01179                         return true;
01180                 }
01181 
01182                 $this->__initQuestionObject((int) $_GET['objective_id']);
01183                 if(!count($questions = $this->objectives_qst_obj->getQuestions()))
01184                 {
01185                         sendInfo($this->lng->txt('crs_no_questions_assigned'));
01186                         #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
01187                         $this->__showButton('assignTestSelect',$this->lng->txt('crs_objective_assign_question'));
01188 
01189                         return true;
01190                 }
01191 
01192                 $tpl =& new ilTemplate("tpl.table.html", true, true);
01193                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_list_qst_row.html","course");
01194 
01195                 #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
01196 
01197                 $counter = 0;
01198                 foreach($this->__sortQuestions($questions) as $question)
01199                 {
01200                         ++$counter;
01201 
01202                         include_once './assessment/classes/class.ilObjTest.php';
01203 
01204                         $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
01205 
01206                         $tpl->setCurrentBlock("tbl_content");
01207                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
01208                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'question[]',$question['qst_ass_id']));
01209                         $tpl->setVariable("TITLE",$tmp_question->getTitle());
01210                         $tpl->setVariable("DESCRIPTION",$tmp_question->getComment());
01211                         $tpl->parseCurrentBlock();
01212 
01213                         unset($tmp_question);
01214                 }
01215 
01216                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01217                 // Show action row
01218 
01219                 $tpl->setCurrentBlock("tbl_action_btn");
01220                 $tpl->setVariable("BTN_NAME",'askDeassignQuestion');
01221                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_deassign_question'));
01222                 $tpl->parseCurrentBlock();
01223 
01224                 // Show add button
01225                 $tpl->setCurrentBlock("plain_button");
01226                 $tpl->setVariable("PBTN_NAME",'assignTestSelect');
01227                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('crs_objective_assign_question'));
01228                 $tpl->parseCurrentBlock();
01229 
01230 
01231                 $tpl->setCurrentBlock("tbl_action_row");
01232                 $tpl->setVariable("COLUMN_COUNTS",2);
01233                 $tpl->setVariable("WIDTH","width=\"50%\"");
01234                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
01235                 $tpl->parseCurrentBlock();
01236 
01237                 // create table
01238                 $tbl = new ilTableGUI();
01239                 $tbl->setStyle('table','std');
01240 
01241                 // title & header columns
01242                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
01243                 $header_title = $this->lng->txt("crs_objectives_assigned_questions").' ('.$objectives_obj->getTitle().')';
01244 
01245                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
01246 
01247                 $tbl->setHeaderNames(array('',$this->lng->txt("title")));
01248                 $tbl->setHeaderVars(array("","title"), 
01249                                                         array("ref_id" => $this->course_obj->getRefId(),
01250                                                                   "objective_id" => (int) $_GET['objective_id'],
01251                                                                   "cmdClass" => "ilcourseobjectivesgui",
01252                                                                   "cmdNode" => $_GET["cmdNode"]));
01253                 $tbl->setColumnWidth(array("1%","99%"));
01254 
01255                 $tbl->setLimit($_GET["limit"]);
01256                 $tbl->setOffset($_GET["offset"]);
01257                 $tbl->setMaxCount(count($objectives));
01258 
01259                 // footer
01260                 $tbl->disable("footer");
01261                 $tbl->disable('sort');
01262 
01263                 // render table
01264                 $tbl->setTemplate($tpl);
01265                 $tbl->render();
01266 
01267                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
01268 
01269                 return true;
01270         }
01271 
01272         function askDeassignQuestion()
01273         {
01274                 global $rbacsystem;
01275 
01276                 // MINIMUM ACCESS LEVEL = 'write'
01277                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01278                 {
01279                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01280                 }
01281                 if(!isset($_GET['objective_id']))
01282                 {
01283                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01284                         $this->listObjectives();
01285 
01286                         return false;
01287                 }
01288                 if(!count($_POST['question']))
01289                 {
01290                         sendInfo($this->lng->txt('crs_objectives_no_question_selected'));
01291                         $this->listAssignedQuestions();
01292 
01293                         return false;
01294                 }
01295 
01296                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
01297                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_deassign_qst.html","course");
01298 
01299 
01300                 $this->__initQuestionObject((int) $_GET['objective_id']);
01301 
01302                 $tpl =& new ilTemplate("tpl.table.html", true, true);
01303                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_deassign_qst_row.html","course");
01304 
01305                 // Send info
01306                 sendInfo($this->lng->txt('crs_objectives_deassign_question_sure'));
01307 
01308                 $counter = 0;
01309                 foreach($_POST['question'] as $qid)
01310                 {
01311                         ++$counter;
01312 
01313                         include_once './assessment/classes/class.ilObjTest.php';
01314 
01315                         $question = $this->objectives_qst_obj->getQuestion($qid);
01316                         $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
01317 
01318                         $tpl->setCurrentBlock("tbl_content");
01319                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
01320                         $tpl->setVariable("TITLE",$tmp_question->getTitle());
01321                         $tpl->setVariable("DESCRIPTION",$tmp_question->getComment());
01322                         $tpl->parseCurrentBlock();
01323 
01324                         unset($tmp_question);
01325                 }
01326 
01327                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01328 
01329                 // Show add button
01330                 $tpl->setCurrentBlock("plain_button");
01331                 $tpl->setVariable("PBTN_NAME",'listAssignedQuestions');
01332                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('cancel'));
01333                 $tpl->parseCurrentBlock();
01334 
01335                 // Show add button
01336                 $tpl->setCurrentBlock("plain_button");
01337                 $tpl->setVariable("PBTN_NAME",'deassignQuestion');
01338                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('crs_objective_deassign_question'));
01339                 $tpl->parseCurrentBlock();
01340 
01341                 $tpl->setCurrentBlock("tbl_action_row");
01342                 $tpl->setVariable("COLUMN_COUNTS",1);
01343                 $tpl->setVariable("WIDTH","width=\"50%\"");
01344                 $tpl->parseCurrentBlock();
01345 
01346                 // create table
01347                 $tbl = new ilTableGUI();
01348                 $tbl->setStyle('table','std');
01349 
01350                 // title & header columns
01351                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
01352                 $header_title = $this->lng->txt("crs_objectives_assigned_questions").' ('.$objectives_obj->getTitle().')';
01353 
01354                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
01355 
01356                 $tbl->setHeaderNames(array($this->lng->txt("title")));
01357                 $tbl->setHeaderVars(array("title"), 
01358                                                         array("ref_id" => $this->course_obj->getRefId(),
01359                                                                   "objective_id" => (int) $_GET['objective_id'],
01360                                                                   "cmdClass" => "ilcourseobjectivesgui",
01361                                                                   "cmdNode" => $_GET["cmdNode"]));
01362                 $tbl->setColumnWidth(array("100%"));
01363 
01364                 $tbl->setLimit($_GET["limit"]);
01365                 $tbl->setOffset($_GET["offset"]);
01366                 $tbl->setMaxCount(count($objectives));
01367 
01368                 // footer
01369                 $tbl->disable("footer");
01370                 $tbl->disable('sort');
01371 
01372                 // render table
01373                 $tbl->setTemplate($tpl);
01374                 $tbl->render();
01375 
01376                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
01377 
01378                 $_SESSION['crs_objectives_qst'] = $_POST['question'];
01379 
01380                 return true;
01381         }
01382 
01383         function deassignQuestion()
01384         {
01385                 global $rbacsystem;
01386 
01387                 // MINIMUM ACCESS LEVEL = 'write'
01388                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01389                 {
01390                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01391                 }
01392                 if(!isset($_GET['objective_id']))
01393                 {
01394                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01395                         $this->listObjectives();
01396 
01397                         return false;
01398                 }
01399                 if(!count($_SESSION['crs_objectives_qst']))
01400                 {
01401                         sendInfo($this->lng->txt('crs_objectives_no_question_selected'));
01402                         $this->listAssignedQuestions();
01403 
01404                         return false;
01405                 }
01406                 
01407                 $this->__initQuestionObject((int) $_GET['objective_id']);
01408 
01409                 foreach($_SESSION['crs_objectives_qst'] as $qid)
01410                 {
01411                         $this->objectives_qst_obj->delete($qid);
01412                 }
01413                 unset($_SESSION['crs_objectives_qst']);
01414 
01415                 sendInfo($this->lng->txt('crs_objectives_qst_deassigned'));
01416                 $this->listAssignedQuestions();
01417 
01418                 return true;
01419         }
01420                 
01421 
01422 
01423         function assignTestSelect()
01424         {
01425                 global $rbacsystem;
01426 
01427                 // MINIMUM ACCESS LEVEL = 'write'
01428                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01429                 {
01430                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01431                 }
01432                 if(!isset($_GET['objective_id']))
01433                 {
01434                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01435                         $this->listObjectives();
01436 
01437                         return false;
01438                 }
01439                 if(!count($all_tests = $this->__getAllTests()))
01440                 {
01441                         sendInfo($this->lng->txt('crs_no_objective_tests_found'));
01442                         $this->listAssignedQuestions();
01443 
01444                         return false;
01445                 }
01446                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
01447                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_tst_select.html","course");
01448                 $this->__showButton('listAssignedQuestions',$this->lng->txt('back'));
01449 
01450 
01451                 $tpl =& new ilTemplate("tpl.table.html", true, true);
01452                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_tst_select_row.html","course");
01453 
01454                 $counter = 0;
01455                 foreach($all_tests as $item)
01456                 {
01457                         ++$counter;
01458 
01459                         $tmp_tst =& ilObjectFactory::getInstanceByRefId($item);
01460 
01461                         $tpl->setCurrentBlock("tbl_content");
01462                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
01463 
01464                         $tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('icon_'.$tmp_tst->getType().'.gif'));
01465                         $tpl->setVariable("IMG_ALT",$this->lng->txt('obj_'.$tmp_tst->getType()));
01466                         $tpl->setVariable("TITLE",$tmp_tst->getTitle());
01467                         $tpl->setVariable("DESCRIPTION",$tmp_tst->getDescription());
01468 
01469                         // Get status info
01470                         if($tmp_tst->isRandomTest())
01471                         {
01472                                 $tpl->setVariable("STATUS",$this->lng->txt('crs_test_status_random'));
01473                                 $tpl->setVariable("CHECK_OBJECTIVE",'&nbsp;');
01474                         }
01475                         elseif(!$tmp_tst->isComplete())
01476                         {
01477                                 $tpl->setVariable("STATUS",$this->lng->txt('crs_test_status_not_complete'));
01478                                 $tpl->setVariable("CHECK_OBJECTIVE",'&nbsp;');
01479                         }
01480                         else
01481                         {
01482                                 $tpl->setVariable("STATUS",$this->lng->txt('crs_test_status_complete'));
01483                                 $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formRadioButton(0,'test_id',$item));
01484                         }
01485 
01486                         $tpl->setVariable("COUNT_QUESTIONS",count($tmp_tst->getExistingQuestions()));
01487                         $tpl->parseCurrentBlock();
01488 
01489                         unset($tmp_tst);
01490                 }
01491 
01492                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01493 
01494                 // Show action row
01495                 $tpl->setCurrentBlock("tbl_action_btn");
01496                 $tpl->setVariable("BTN_NAME",'assignQuestionSelect');
01497                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_assign_question'));
01498                 $tpl->parseCurrentBlock();
01499 
01500                 $tpl->setCurrentBlock("tbl_action_row");
01501                 $tpl->setVariable("COLUMN_COUNTS",4);
01502                 $tpl->setVariable("WIDTH","width=\"75%\"");
01503                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
01504                 $tpl->parseCurrentBlock();
01505 
01506 
01507                 // create table
01508                 $tbl = new ilTableGUI();
01509                 $tbl->setStyle('table','std');
01510 
01511                 // title & header columns
01512                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
01513                 $header_title = $this->lng->txt("crs_objective_question_assignment").' ('.$objectives_obj->getTitle().')';
01514 
01515                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
01516 
01517                 $tbl->setHeaderNames(array('',$this->lng->txt("title"),$this->lng->txt('status'),$this->lng->txt('crs_count_questions')));
01518                 $tbl->setHeaderVars(array("","title",'status','nr_questions'), 
01519                                                         array("ref_id" => $this->course_obj->getRefId(),
01520                                                                   "objective_id" => (int) $_GET['objective_id'],
01521                                                                   "cmdClass" => "ilcourseobjectivesgui",
01522                                                                   "cmdNode" => $_GET["cmdNode"]));
01523                 $tbl->setColumnWidth(array("1%","50%",'30%','20%'));
01524 
01525                 $tbl->setLimit($_GET["limit"]);
01526                 $tbl->setOffset($_GET["offset"]);
01527                 $tbl->setMaxCount(count($objectives));
01528 
01529                 // footer
01530                 $tbl->disable("footer");
01531                 $tbl->disable('sort');
01532 
01533                 // render table
01534                 $tbl->setTemplate($tpl);
01535                 $tbl->render();
01536 
01537                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
01538 
01539                 return true;
01540         }
01541 
01542         function assignQuestionSelect()
01543         {
01544                 global $rbacsystem;
01545 
01546                 // MINIMUM ACCESS LEVEL = 'write'
01547                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01548                 {
01549                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01550                 }
01551                 if(!isset($_GET['objective_id']))
01552                 {
01553                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01554                         $this->listObjectives();
01555 
01556                         return false;
01557                 }
01558                 if(!$_POST['test_id'])
01559                 {
01560                         sendInfo($this->lng->txt('crs_select_exactly_one_tst'));
01561                         $this->assignTestSelect();
01562 
01563                         return false;
01564                 }
01565 
01566                 
01567                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
01568                 $this->ctrl->setParameter($this,'test_id',(int) $_POST['test_id']);
01569                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_question_select.html","course");
01570                 $this->__showButton('assignTestSelect',$this->lng->txt('back'));
01571 
01572 
01573                 $tpl =& new ilTemplate("tpl.table.html", true, true);
01574                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_question_select_row.html","course");
01575 
01576                 if(!$tmp_tst =& ilObjectFactory::getInstanceByRefId((int) $_POST['test_id'],false))
01577                 {
01578                         sendInfo('Error: Test does not exist');
01579                         $this->assignTestSelect();
01580 
01581                         return false;
01582                 }               
01583 
01584                 $this->__initQuestionObject((int) $_GET['objective_id']);
01585 
01586                 $counter = 0;
01587                 $assignable = false;
01588                 
01589                 foreach($this->__sortQuestions($tmp_tst->getAllQuestions()) as $question_data)
01590                 {
01591                         ++$counter;
01592 
01593                         $tmp_question =& ilObjTest::_instanciateQuestion($question_data['question_id']);
01594 
01595                         $tpl->setCurrentBlock("tbl_content");
01596                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
01597                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'question[]',$question_data['question_id']));
01598                         $tpl->setVariable("TITLE",$tmp_question->getTitle());
01599                         $tpl->setVariable("DESCRIPTION",$tmp_question->getComment());
01600 
01601                         if(!$objective_id = ilCourseObjectiveQuestion::_isAssigned((int) $_GET['objective_id'],
01602                                                                                                                                            $tmp_tst->getRefId(),$question_data['question_id']))
01603                         {
01604                                 $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'question[]',$question_data['question_id']));
01605                                 $tpl->setVariable("ASSIGNED",$this->lng->txt('no'));
01606                                 
01607                                 $assignable = true;
01608                         }
01609                         else
01610                         {
01611                                 $tmp_objective_obj =& $this->__initObjectivesObject($objective_id);
01612                                 
01613                                 #$assigned = $this->lng->txt('yes').' ('.$tmp_objective_obj->getTitle().')';
01614                                 $assigned = $this->lng->txt('yes');
01615                                 $tpl->setVariable("ASSIGNED",$assigned);
01616                                 $tpl->setVariable("CHECK_OBJECTIVE",'&nbsp;');
01617                         }
01618                         $tpl->parseCurrentBlock();
01619 
01620                         unset($tmp_question);
01621                 }
01622 
01623                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01624                 $tpl->setVariable("WIDTH","width=\"50%\"");
01625 
01626                 // Show action row
01627 
01628                 if($assignable)
01629                 {
01630                         $tpl->setCurrentBlock("tbl_action_btn");
01631                         $tpl->setVariable("BTN_NAME",'assignQuestion');
01632                         $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_assign_question'));
01633                         $tpl->parseCurrentBlock();
01634 
01635                         $tpl->setCurrentBlock("tbl_action_row");
01636                         $tpl->setVariable("COLUMN_COUNTS",3);
01637                         $tpl->setVariable("WIDTH","width=\"50%\"");
01638                         $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
01639                         $tpl->parseCurrentBlock();
01640                 }
01641 
01642                 // create table
01643                 $tbl = new ilTableGUI();
01644                 $tbl->setStyle('table','std');
01645 
01646                 // title & header columns
01647                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
01648                 $header_title = $this->lng->txt("crs_objective_question_assignment").' ('.$objectives_obj->getTitle().')';
01649 
01650                 $tbl->setTitle($header_title,"icon_crs.gif",$this->lng->txt("crs_objectives"));
01651 
01652                 $tbl->setHeaderNames(array('',$this->lng->txt("title"),$this->lng->txt('assigned')));
01653                 $tbl->setHeaderVars(array("","title",'assigned'), 
01654                                                         array("ref_id" => $this->course_obj->getRefId(),
01655                                                                   "objective_id" => (int) $_GET['objective_id'],
01656                                                                   "cmdClass" => "ilcourseobjectivesgui",
01657                                                                   "cmdNode" => $_GET["cmdNode"]));
01658                 $tbl->setColumnWidth(array("1%","60%",'50%'));
01659 
01660                 $tbl->setLimit($_GET["limit"]);
01661                 $tbl->setOffset($_GET["offset"]);
01662                 $tbl->setMaxCount(count($objectives));
01663 
01664                 // footer
01665                 $tbl->disable("footer");
01666                 $tbl->disable('sort');
01667 
01668                 // render table
01669                 $tbl->setTemplate($tpl);
01670                 $tbl->render();
01671 
01672                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
01673 
01674                 return true;
01675 
01676         }
01677 
01678         function __sortQuestions($a_qst_ids)
01679         {
01680                 return ilUtil::sortArray($a_qst_ids,'title','asc');
01681         }
01682 
01683         function assignQuestion()
01684         {
01685                 global $rbacsystem;
01686 
01687                 // MINIMUM ACCESS LEVEL = 'write'
01688                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01689                 {
01690                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01691                 }
01692                 if(!isset($_GET['objective_id']))
01693                 {
01694                         sendInfo($this->lng->txt('crs_no_objective_selected'));
01695                         $this->listObjectives();
01696 
01697                         return false;
01698                 }
01699                 if(!$_GET['test_id'])
01700                 {
01701                         sendInfo($this->lng->txt('crs_no_test_selected'));
01702                         $this->assignTestSelect();
01703 
01704                         return false;
01705                 }
01706                 if(!count($_POST['question']))
01707                 {
01708                         $_POST['test_id'] = $_GET['test_id'];
01709                         sendInfo($this->lng->txt('crs_no_question_selected'));
01710                         $this->assignQuestionSelect();
01711 
01712                         return false;
01713                 }
01714 
01715                 $this->__initQuestionObject((int) $_GET['objective_id']);
01716 
01717                 $tmp_test =& ilObjectFactory::getInstanceByRefId((int) $_GET['test_id'],false);
01718 
01719                 $this->objectives_qst_obj->setTestRefId($tmp_test->getRefId());
01720                 $this->objectives_qst_obj->setTestObjId($tmp_test->getId());
01721 
01722                 $added = 0;
01723                 foreach($_POST['question'] as $qid)
01724                 {
01725                         if((int) $_GET['objective_id'] == ilCourseObjectiveQuestion::_isAssigned((int) $_GET['objective_id'],
01726                                                                                                                                                                          $tmp_test->getRefId(),
01727                                                                                                                                                                          $qid))
01728                         {
01729                                 continue;
01730                         }
01731                         $this->objectives_qst_obj->setQuestionId($qid);
01732                         $this->objectives_qst_obj->add();
01733 
01734                         ++$added;
01735                 }
01736 
01737                 if($added)
01738                 {
01739                         sendInfo($this->lng->txt('crs_objectives_assigned_new_questions'));
01740                         $this->listAssignedQuestions();
01741 
01742                         return true;
01743                 }
01744                 else
01745                 {
01746                         sendInfo($this->lng->txt('crs_objectives_questions_already_assigned'));
01747                         $this->assignQuestionSelect();
01748 
01749                         return false;
01750                 }
01751                 return false;
01752         }
01753 
01754         function editQuestionAssignment()
01755         {
01756                 global $rbacsystem;
01757 
01758                 $this->tabs_gui->setSubTabActive('crs_objective_overview_question_assignment');
01759 
01760                 // MINIMUM ACCESS LEVEL = 'write'
01761                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01762                 {
01763                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01764                 }
01765 
01766                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_objectives_edit_question_assignments.html','course');
01767 
01768                 #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
01769 
01770                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
01771                 $this->tpl->setVariable("CSS_TABLE",'fullwidth');
01772                 $this->tpl->setVariable("WIDTH",'80%');
01773                 $this->tpl->setVariable("COLUMN_COUNT",5);
01774                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_crs.gif'));
01775                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('obj_crs'));
01776                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('crs_objectives_edit_question_assignments'));
01777                 
01778                 $head_titles = array(array($this->lng->txt('title'),"35%"),
01779                                                          array($this->lng->txt('crs_objectives_nr_questions'),"10%"),
01780                                                          array($this->lng->txt('crs_objectives_max_points'),"10%"),
01781                                                          array($this->lng->txt('options'),"35%"));
01782 
01783                 $counter = 0;
01784                 foreach($head_titles as $title)
01785                 {
01786                         $this->tpl->setCurrentBlock("tbl_header_no_link");
01787 
01788                         if(!$counter)
01789                         {
01790                                 $this->tpl->setVariable("TBL_HEADER_COLSPAN",' colspan="2"');
01791                                 ++$counter;
01792                         }
01793                         $this->tpl->setVariable("TBL_HEADER_CELL_NO_LINK",$title[0]);
01794                         $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK",$title[1]);
01795                         $this->tpl->parseCurrentBlock();
01796                 }
01797 
01798                 foreach(ilCourseObjective::_getObjectiveIds($this->course_obj->getId()) as $objective_id)
01799                 {
01800                         $tmp_objective_obj =& $this->__initObjectivesObject($objective_id);
01801                         
01802                         $this->__initQuestionObject($objective_id);
01803 
01804                         $counter = 1;
01805                         foreach($this->objectives_qst_obj->getTests() as $test_data)
01806                         {
01807                                 $show_buttons = true;
01808 
01809                                 $tmp_test =& ilObjectFactory::getInstanceByRefId($test_data['ref_id']);
01810 
01811                                 $this->tpl->setCurrentBlock("test_row");
01812                                 $this->tpl->setVariable("TEST_TITLE",$tmp_test->getTitle());
01813                                 $this->tpl->setVariable("TEST_QST",$this->objectives_qst_obj->getNumberOfQuestionsByTest($test_data['ref_id']));
01814                                 $this->tpl->setVariable("TEST_POINTS",$this->objectives_qst_obj->getMaxPointsByTest($test_data['ref_id']));
01815 
01816                                 // Options
01817                                 $this->tpl->setVariable("TXT_CHANGE_STATUS",$this->lng->txt('crs_change_status'));
01818                                 $this->tpl->setVariable("CHECK_CHANGE_STATUS",ilUtil::formCheckbox((int) $test_data['tst_status'],
01819                                                                                                                                                                    'test['.$test_data['test_objective_id'].'][status]'
01820                                                                                                                                                                    ,1));
01821                                 $this->tpl->setVariable("TXT_SUGGEST",$this->lng->txt('crs_suggest_lm'));
01822                                 $this->tpl->setVariable("SUGGEST_NAME",'test['.$test_data['test_objective_id'].'][limit]');
01823                                 $this->tpl->setVariable("SUGGEST_VALUE",(int) $test_data['tst_limit']);
01824 
01825                                 $this->tpl->parseCurrentBlock();
01826 
01827 
01828 
01829                                 ++$counter;
01830                         }
01831                         $this->tpl->setCurrentBlock("objective_row");
01832                         $this->tpl->setVariable("OBJ_TITLE",$tmp_objective_obj->getTitle());
01833                         $this->tpl->setVariable("OBJ_DESCRIPTION",$tmp_objective_obj->getDescription());
01834                         $this->tpl->setVariable("OBJ_QST",count($this->objectives_qst_obj->getQuestions()));
01835                         $this->tpl->setVariable("OBJ_POINTS",$this->objectives_qst_obj->getMaxPointsByObjective());
01836                         $this->tpl->setVariable("ROWSPAN",$counter);
01837                         $this->tpl->parseCurrentBlock();
01838                         
01839                         // Options
01840                         unset($tmp_objective_obj);
01841                 }
01842                 // Buttons
01843                 if($show_buttons)
01844                 {
01845                         $this->tpl->setCurrentBlock("edit_footer");
01846                         $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
01847                         $this->tpl->setVariable("TXT_UPDATE",$this->lng->txt('save'));
01848                         $this->tpl->setVariable("CMD_UPDATE",'updateQuestionAssignment');
01849                         $this->tpl->parseCurrentBlock();
01850                 }
01851         }
01852 
01853         function updateQuestionAssignment()
01854         {
01855                 global $rbacsystem;
01856 
01857                 $this->tabs_gui->setSubTabActive('crs_objective_overview_question_assignment');
01858 
01859 
01860                 // MINIMUM ACCESS LEVEL = 'write'
01861                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01862                 {
01863                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01864                 }
01865                 if(!is_array($_POST['test']))
01866                 {
01867                         sendInfo('Internal error: CRSM learning objectives');
01868                         $this->editQuestionAssignment();
01869 
01870                         return false;
01871                 }
01872                 // Validate
01873                 foreach($_POST['test'] as $test_obj_id => $data)
01874                 {
01875                         if(!preg_match('/1?[0-9][0-9]?/',$data['limit']) or 
01876                            $data['limit'] < 0 or 
01877                            $data['limit'] > 100)
01878                         {
01879                                 sendInfo($this->lng->txt('crs_objective_insert_percent'));
01880                                 $this->editQuestionAssignment();
01881 
01882                                 return false;
01883                         }
01884                 }
01885                 
01886                 foreach($_POST['test'] as $test_obj_id => $data)
01887                 {
01888                         include_once './course/classes/class.ilCourseObjectiveQuestion.php';
01889 
01890                         $test_data = ilCourseObjectiveQuestion::_getTest($test_obj_id);
01891 
01892                         $this->__initQuestionObject($test_data['objective_id']);
01893                         $this->objectives_qst_obj->setTestStatus($data['status'] ? 1 : 0);
01894                         $this->objectives_qst_obj->setTestSuggestedLimit($data['limit']);
01895                         $this->objectives_qst_obj->updateTest($test_obj_id);
01896                 }
01897                 sendInfo($this->lng->txt('crs_objective_updated_test'));
01898                 $this->editQuestionAssignment();
01899 
01900                 return true;
01901         }
01902                 
01903 
01904         // PRIVATE
01905         function __initCourseObject()
01906         {
01907                 if(!$this->course_obj =& ilObjectFactory::getInstanceByRefId($this->course_id,false))
01908                 {
01909                         $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object",$this->ilErr->MESSAGE);
01910                         exit;
01911                 }
01912                 // do i need members?
01913                 $this->course_obj->initCourseMemberObject();
01914 
01915                 return true;
01916         }
01917 
01918         function &__initObjectivesObject($a_id = 0)
01919         {
01920                 return new ilCourseObjective($this->course_obj,$a_id);
01921         }
01922 
01923         function __initLMObject($a_objective_id = 0)
01924         {
01925                 include_once './course/classes/class.ilCourseObjectiveLM.php';
01926 
01927                 $this->objectives_lm_obj =& new ilCourseObjectiveLM($a_objective_id);
01928 
01929                 return true;
01930         }
01931 
01932         function __initQuestionObject($a_objective_id = 0)
01933         {
01934                 include_once './course/classes/class.ilCourseObjectiveQuestion.php';
01935 
01936                 $this->objectives_qst_obj =& new ilCourseObjectiveQuestion($a_objective_id);
01937 
01938                 return true;
01939         }
01940 
01941         function __showButton($a_cmd,$a_text,$a_target = '')
01942         {
01943                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01944                 
01945                 // display button
01946                 $this->tpl->setCurrentBlock("btn_cell");
01947                 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
01948                 $this->tpl->setVariable("BTN_TXT",$a_text);
01949 
01950                 if($a_target)
01951                 {
01952                         $this->tpl->setVariable("BTN_TARGET",$a_target);
01953                 }
01954 
01955                 $this->tpl->parseCurrentBlock();
01956         }
01957 
01958         function __getAllLMs()
01959         {
01960                 global $tree;
01961                 
01962                 #foreach($tree->getSubTree($tree->getNodeData($this->course_obj->getRefId())) as $node)
01963                 foreach($tree->getChilds($this->course_obj->getRefId()) as $node)
01964                 {
01965                         switch($node['type'])
01966                         {
01967                                 case 'lm':
01968                                 case 'htlm':
01969                                 case 'sahs':
01970                                         $all_lms[] = $node['ref_id'];
01971                                         break;
01972                         }
01973                 }
01974                 return $all_lms ? $all_lms : array();
01975         }
01976 
01977         function __getAllTests()
01978         {
01979                 global $tree;
01980                 
01981                 #foreach($tree->getSubTree($tree->getNodeData($this->course_obj->getRefId())) as $node)
01982                 foreach($tree->getChilds($this->course_obj->getRefId()) as $node)
01983                 {
01984                         switch($node['type'])
01985                         {
01986                                 case 'tst':
01987                                         $all_tst[] = $node['ref_id'];
01988                                         break;
01989                         }
01990                 }
01991                 return $all_tst ? $all_tst : array();
01992         }
01993 
01994         function __getAllChapters($a_ref_id)
01995         {
01996                 $tmp_lm =& ilObjectFactory::getInstanceByRefId($a_ref_id);
01997 
01998                 $tree = new ilTree($tmp_lm->getId());
01999                 $tree->setTableNames('lm_tree','lm_data');
02000                 $tree->setTreeTablePK("lm_id");
02001 
02002                 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node)
02003                 {
02004                         if($node['type'] == 'st')
02005                         {
02006                                 $chapter[] = $node['child'];
02007                         }
02008                 }
02009 
02010                 return $chapter ? $chapter : array();
02011         }
02012 
02016         function setSubTabs()
02017         {
02018                 global $ilTabs;
02019 
02020                 $ilTabs->addSubTabTarget("crs_objective_overview_objectives",
02021                                                                  $this->ctrl->getLinkTarget($this, "listObjectives"),
02022                                                                  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
02023                                                                  array(),
02024                                                                  '',
02025                                                                  true);
02026                         
02027                 $ilTabs->addSubTabTarget("crs_objective_overview_question_assignment",
02028                                                                  $this->ctrl->getLinkTarget($this, "editQuestionAssignment"),
02029                                                                  "editQuestionAssignment",
02030                                                                  array(),
02031                                                                  '',
02032                                                                  false);
02033 
02034         }
02035 }
02036 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1