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

Modules/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 
00034 class ilCourseObjectivesGUI
00035 {
00036         var $ctrl;
00037         var $ilias;
00038         var $ilErr;
00039         var $lng;
00040         var $tpl;
00041 
00042         var $course_obj;
00043         var $course_id;
00044         
00045         function ilCourseObjectivesGUI($a_course_id)
00046         {
00047                 include_once './Modules/Course/classes/class.ilCourseObjective.php';
00048 
00049                 global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree,$ilTabs;
00050 
00051                 $this->ctrl =& $ilCtrl;
00052                 $this->ctrl->saveParameter($this,array("ref_id"));
00053 
00054                 $this->ilErr =& $ilErr;
00055                 $this->lng =& $lng;
00056                 $this->tpl =& $tpl;
00057                 $this->tree =& $tree;
00058                 $this->tabs_gui =& $ilTabs;
00059 
00060                 $this->course_id = $a_course_id;
00061                 $this->__initCourseObject();
00062         }
00063 
00067         function &executeCommand()
00068         {
00069                 global $ilTabs;
00070 
00071                 $ilTabs->setTabActive('crs_objectives');
00072                 
00073                 $cmd = $this->ctrl->getCmd();
00074 
00075 
00076                 if (!$cmd = $this->ctrl->getCmd())
00077                 {
00078                         $cmd = "list";
00079                 }
00080                 
00081                 $this->setSubTabs();
00082                 $this->$cmd();
00083         }
00084         
00091         public function listQuestionAssignment()
00092         {
00093                 global $ilAccess;
00094                 
00095                 if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
00096                 {
00097                         $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write',$this->ilErr->MESSAGE));
00098                 }
00099                 if(!isset($_GET['objective_id']))
00100                 {
00101                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00102                         $this->listObjectives();
00103                         return false;
00104                 }
00105                 include_once('Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
00106                 if(!$assignable = ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()))
00107                 {
00108                         ilUtil::sendInfo($this->lng->txt('crs_no_tests_inside_crs'));
00109                         $this->listObjectives();
00110                         return false;
00111                 }
00112                 
00113                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_objective_list_questions.html','Modules/Course');
00114                 $this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('crs_objectives'));
00115                 $this->tpl->setVariable('TBL_TITLE_IMG',ilUtil::getImagePath('icon_lobj.gif'));
00116                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00117                 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
00118                 
00119                 // Back button
00120                 $this->__showButton('listObjectives',$this->lng->txt('back'));
00121                 
00122                 // Title
00123                 $this->__initObjectivesObject((int) $_GET['objective_id']);
00124                 $this->__initQuestionObject((int) $_GET['objective_id']);
00125                 $this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('crs_objectives_lm_assignment'));
00126                 $this->tpl->setVariable('OBJECTIVE_TITLE',$this->objectives_obj->getTitle());
00127                 
00128                 // Footer
00129                 $this->tpl->setVariable('DOWNRIGHT',ilUtil::getImagePath('arrow_downright.gif'));
00130                 $this->tpl->setVariable('BTN_ASSIGN',$this->lng->txt('crs_objective_assign_lm'));
00131                 $this->tpl->setVariable('BTN_CANCEL',$this->lng->txt('cancel'));
00132                 
00133                 $counter = 0;
00134                 foreach($assignable as $node)
00135                 {
00136                         if(!$tmp_tst =& ilObjectFactory::getInstanceByRefId((int) $node['ref_id'],false))
00137                         {
00138                                 continue;
00139                         }               
00140 
00141                         $assignable = false;
00142                         foreach($qst = $this->__sortQuestions($tmp_tst->getAllQuestions()) as $question_data)
00143                         {
00144                                 $tmp_question =& ilObjTest::_instanciateQuestion($question_data['question_id']);
00145 
00146                                 $this->tpl->setCurrentBlock('chapter');
00147                                 $this->tpl->setVariable('CHAPTER_TITLE',$tmp_question->getTitle());
00148                                 $id = ilCourseObjectiveQuestion::_isAssigned((int) $_GET['objective_id'],
00149                                         $tmp_tst->getRefId(),
00150                                         $question_data['question_id']);
00151                                 $this->tpl->setVariable('CHECK_CHAPTER',ilUtil::formCheckbox(
00152                                                 $id ? 1 : 0,
00153                                                 'questions[]',$node['ref_id'].'_'.$question_data['question_id']));
00154                                 $this->tpl->parseCurrentBlock();
00155         
00156                         }
00157                         if(count($qst))
00158                         {
00159                                 $this->tpl->setCurrentBlock('chapters');
00160                                 $this->tpl->setVariable('TXT_CHAPTER',$this->lng->txt('objs_qst'));
00161                                 $this->tpl->parseCurrentBlock();
00162                         }                       
00163                         
00164                         
00165                         if(strlen($node['description']))
00166                         {
00167                                 $this->tpl->setCurrentBlock('row_desc');
00168                                 $this->tpl->setVariable('DESCRIPTION',$node['description']);
00169                                 $this->tpl->parseCurrentBlock();
00170                         }
00171 
00172                         $this->tpl->setCurrentBlock('table_content');
00173                         $this->tpl->setVariable('ROWCOL',ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
00174                         $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'.gif'));
00175                         $this->tpl->setVariable('TYPE_ALT',$this->lng->txt('obj_'.$node['type']));
00176                         $this->tpl->setVariable('MAT_TITLE',$node['title']);
00177                         $this->tpl->parseCurrentBlock();
00178                 }
00179         }
00180         
00186         public function assignQuestions()
00187         {
00188                 global $ilAccess,$ilObjDataCache;
00189 
00190                 // MINIMUM ACCESS LEVEL = 'write'
00191                 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
00192                 {
00193                         $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00194                 }
00195                 if(!isset($_GET['objective_id']))
00196                 {
00197                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00198                         $this->listObjectives();
00199                         return false;
00200                 }
00201 
00202                 $this->__initQuestionObject((int) $_GET['objective_id']);
00203                 
00204                 if(!is_array($_POST['questions']))
00205                 {
00206                         $this->objectives_qst_obj->deleteAll();
00207                 }
00208                 else
00209                 {
00210                         // Delete unchecked
00211                         foreach($this->objectives_qst_obj->getQuestions() as $question)
00212                         {
00213                                 $id = $question['ref_id'].'_'.$question['question_id'];
00214                                 if(!in_array($id,$_POST['questions']))
00215                                 {
00216                                         $this->objectives_qst_obj->delete($question['qst_ass_id']);
00217                                 }
00218                         }
00219                         // Add checked
00220                         foreach($_POST['questions'] as $question_id)
00221                         {
00222                                 list($test_ref_id,$qst_id) = explode('_',$question_id);
00223                                 $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
00224 
00225                                 if(ilCourseObjectiveQuestion::_isAssigned((int) $_GET['objective_id'],$test_ref_id,$qst_id))
00226                                 {
00227                                         continue;
00228                                 }
00229                                 
00230                                 $this->objectives_qst_obj->setTestRefId($test_ref_id);
00231                                 $this->objectives_qst_obj->setTestObjId($test_obj_id);
00232                                 $this->objectives_qst_obj->setQuestionId($qst_id);
00233                                 $this->objectives_qst_obj->add();
00234                         }
00235                 }
00236                 
00237                 ilUtil::sendInfo($this->lng->txt('crs_objectives_assigned_lm'));
00238                 $this->listObjectives();
00239         }
00240         
00241 
00248         public function listMaterialAssignment()
00249         {
00250                 global $ilAccess, $objDefinition;
00251                 
00252                 if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
00253                 {
00254                         $this->ilErr->raiseError($this->lng->txt('msg_no_perm_write',$this->ilErr->MESSAGE));
00255                 }
00256                 if(!isset($_GET['objective_id']))
00257                 {
00258                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00259                         $this->listObjectives();
00260                         return false;
00261                 }
00262                 include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
00263                 if(!$assignable = ilCourseObjectiveMaterials::_getAssignableMaterials($this->course_obj->getRefId()))
00264                 {
00265                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_lms_found'));
00266                         $this->listObjectives();
00267                         return false;
00268                 }
00269                 
00270                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_objective_list_materials.html','Modules/Course');
00271                 $this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('crs_objectives'));
00272                 $this->tpl->setVariable('TBL_TITLE_IMG',ilUtil::getImagePath('icon_lobj.gif'));
00273                 
00274                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00275                 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
00276                 
00277                 // Back button
00278                 $this->__showButton('listObjectives',$this->lng->txt('back'));
00279                 
00280                 // Title
00281                 $this->__initObjectivesObject((int) $_GET['objective_id']);
00282                 $this->__initLMObject((int) $_GET['objective_id']);
00283                 $this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('crs_objectives_lm_assignment'));
00284                 $this->tpl->setVariable('OBJECTIVE_TITLE',$this->objectives_obj->getTitle());
00285                 
00286                 // Footer
00287                 $this->tpl->setVariable('DOWNRIGHT',ilUtil::getImagePath('arrow_downright.gif'));
00288                 $this->tpl->setVariable('BTN_ASSIGN',$this->lng->txt('crs_objective_assign_lm'));
00289                 $this->tpl->setVariable('BTN_CANCEL',$this->lng->txt('cancel'));
00290                 
00291                 $counter = 0;
00292                 foreach($assignable as $node)
00293                 {
00294                         // no side blocks here
00295                         if($objDefinition->isSideBlock($node['type']))
00296                         {
00297                                 continue;
00298                         }
00299                         
00300                         if($node['type'] == 'lm')
00301                         {
00302                                 include_once('Modules/LearningModule/classes/class.ilLMObject.php');
00303                                 foreach($chapters = $this->__getAllChapters($node['child']) as $chapter => $depth)
00304                                 {
00305                                         for($i = $depth;$i > 1;$i--)
00306                                         {
00307                                                 $this->tpl->touchBlock('begin_depth');
00308                                                 $this->tpl->touchBlock('end_depth');
00309                                         }
00310                                 
00311                                         $this->tpl->setCurrentBlock('chapter');
00312                                         $this->tpl->setVariable('CHAPTER_TITLE',ilLMObject::_lookupTitle($chapter));
00313                                         $this->tpl->setVariable('CHECK_CHAPTER',ilUtil::formCheckbox(
00314                                                 $this->objectives_lm_obj->isChapterAssigned($node['ref_id'],$chapter) ? 1 : 0,
00315                                                 'chapters[]',$node['child'].'_'.$chapter));
00316                                         $this->tpl->parseCurrentBlock();
00317                                 }
00318                                 if(count($chapters))
00319                                 {
00320                                         $this->tpl->setCurrentBlock('chapters');
00321                                         $this->tpl->setVariable('TXT_CHAPTER',$this->lng->txt('objs_st'));
00322                                         $this->tpl->parseCurrentBlock();
00323                                 }                       
00324                         }
00325                         if(strlen($node['description']))
00326                         {
00327                                 $this->tpl->setCurrentBlock('row_desc');
00328                                 $this->tpl->setVariable('DESCRIPTION',$node['description']);
00329                                 $this->tpl->parseCurrentBlock();
00330                         }
00331                         
00332                         $this->tpl->setCurrentBlock('table_content');
00333                         $this->tpl->setVariable('ROWCOL',ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
00334                         $this->tpl->setVariable('CHECK_MAT',ilUtil::formCheckbox($this->objectives_lm_obj->isAssigned($node['child']) ? 1 : 0,
00335                                 'materials[]',$node['child']));
00336                         $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'.gif'));
00337                         $this->tpl->setVariable('TYPE_ALT',$this->lng->txt('obj_'.$node['type']));
00338                         $this->tpl->setVariable('MAT_TITLE',$node['title']);
00339                         $this->tpl->parseCurrentBlock();
00340                 }
00341                 
00342 
00343                 
00344         }
00345         
00351         public function assignMaterials()
00352         {
00353                 global $ilAccess,$ilObjDataCache;
00354 
00355                 // MINIMUM ACCESS LEVEL = 'write'
00356                 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
00357                 {
00358                         $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00359                 }
00360                 if(!isset($_GET['objective_id']))
00361                 {
00362                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00363                         $this->listObjectives();
00364                         return false;
00365                 }
00366 
00367                 $this->__initLMObject((int) $_GET['objective_id']);
00368                 $this->objectives_lm_obj->deleteAll();
00369                 
00370                 if(is_array($_POST['materials']))
00371                 {
00372                         foreach($_POST['materials'] as $node_id)
00373                         {
00374                                 $obj_id = $ilObjDataCache->lookupObjId($node_id);
00375                                 $type = $ilObjDataCache->lookupType($obj_id);
00376                                 
00377                                 $this->objectives_lm_obj->setLMRefId($node_id);
00378                                 $this->objectives_lm_obj->setLMObjId($obj_id);
00379                                 $this->objectives_lm_obj->setType($type);
00380                                 $this->objectives_lm_obj->add();
00381                         }
00382                 }
00383                 if(is_array($_POST['chapters']))
00384                 {
00385                         foreach($_POST['chapters'] as $chapter)
00386                         {
00387                                 list($ref_id,$chapter_id) = explode('_',$chapter);
00388                                 
00389                                 $this->objectives_lm_obj->setLMRefId($ref_id);
00390                                 $this->objectives_lm_obj->setLMObjId($chapter_id);
00391                                 $this->objectives_lm_obj->setType('st');
00392                                 $this->objectives_lm_obj->add();
00393                         }
00394                 }
00395                 ilUtil::sendInfo($this->lng->txt('crs_objectives_assigned_lm'));
00396                 $this->listObjectives();
00397         }
00398 
00399         
00406         public function listObjectives()
00407         {
00408                 global $ilAccess,$ilErr,$ilObjDataCache;
00409                 
00410                 if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
00411                 {
00412                         $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00413                 }
00414                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_show_objectives.html','Modules/Course');
00415                 $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
00416                 $this->tpl->setVariable('TABLE_TITLE',$this->lng->txt('crs_objectives'));
00417                 $this->tpl->setVariable('TBL_TITLE_IMG',ilUtil::getImagePath('icon_lobj.gif'));
00418                 $this->tpl->setVariable('TBL_TITLE_IMG_ALT',$this->lng->txt('crs_objectives'));
00419                 $this->tpl->setVariable('HEAD_TITLE',$this->lng->txt('title'));
00420                 $this->tpl->setVariable('HEAD_MATERIALS',$this->lng->txt('crs_objective_assigned_materials'));
00421                 $this->tpl->setVariable('HEAD_QUESTIONS',$this->lng->txt('crs_objective_assigned_qst'));
00422                 $this->tpl->setVariable('DOWNRIGHT',ilUtil::getImagePath('arrow_downright.gif'));
00423                 $this->tpl->setVariable('BTN_DELETE',$this->lng->txt('delete'));
00424                 $this->tpl->setVariable('BTN_ADD',$this->lng->txt('crs_add_objective'));
00425                 
00426                 if(!count($objectives = ilCourseObjective::_getObjectiveIds($this->course_obj->getId())))
00427                 {
00428                         $this->tpl->setCurrentBlock('table_empty');
00429                         $this->tpl->setVariable('EMPTY_TXT',$this->lng->txt('crs_no_objectives_created'));
00430                         $this->tpl->parseCurrentBlock();
00431                         return true;
00432                 }
00433                 
00434                 $counter = 0;
00435                 foreach($objectives as $objective)
00436                 {
00437                         $objective_obj = $this->__initObjectivesObject($objective);
00438         
00439                         // Up down links
00440                         ++$counter;
00441                         if(count($objectives) > 1)
00442                         {
00443                                 if($counter == 1)
00444                                 {
00445                                         $this->tpl->setVariable("NO_IMG_PRE_TYPE",ilUtil::getImagePath('empty.gif'));
00446                                 }                                       
00447                                 if($counter > 1) 
00448                                 {
00449                                         $this->tpl->setCurrentBlock("img");
00450                                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00451                                         $this->tpl->setVariable("IMG_LINK",$this->ctrl->getLinkTarget($this,'moveObjectiveUp'));
00452                                         $this->tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('a_up.gif'));
00453                                         $this->tpl->setVariable("IMG_ALT",$this->lng->txt('crs_move_up'));
00454                                         $this->tpl->parseCurrentBlock();
00455                                 }
00456                                 if($counter < count($objectives))
00457                                 {
00458                                         $this->tpl->setCurrentBlock("img");
00459                                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00460                                         $this->tpl->setVariable("IMG_LINK",$this->ctrl->getLinkTarget($this,'moveObjectiveDown'));
00461                                         $this->tpl->setVariable("IMG_TYPE",ilUtil::getImagePath('a_down.gif'));
00462                                         $this->tpl->setVariable("IMG_ALT",$this->lng->txt('crs_move_down'));
00463                                         $this->tpl->parseCurrentBlock();
00464                                 }
00465                                 if($counter == count($objectives))
00466                                 {
00467                                         $this->tpl->setCurrentBlock("no_img_post");
00468                                         $this->tpl->setVariable("NO_IMG_POST_TYPE",ilUtil::getImagePath('empty.gif'));
00469                                         $this->tpl->parseCurrentBlock();
00470                                 }                                       
00471                         }
00472                         
00473                         // Assigned Tests
00474                         $this->__initQuestionObject($objective_obj->getObjectiveId());
00475                         foreach($this->objectives_qst_obj->getTests() as $tst)
00476                         {
00477                                 foreach($this->objectives_qst_obj->getQuestionsOfTest($tst['obj_id']) as $qst)
00478                                 {
00479                                         $this->tpl->setCurrentBlock('qst_row');
00480                                         $this->tpl->setVariable('QST_TITLE',$qst['title']);
00481                                         $this->tpl->parseCurrentBlock();
00482                                 }
00483                                 $this->tpl->setCurrentBlock('test_row');
00484                                 $this->tpl->setVariable('TST_IMG',ilUtil::getImagePath('icon_tst_s.gif'));
00485                                 $this->tpl->setVariable('TST_ALT',$this->lng->txt('obj_tst'));
00486                                 $this->tpl->setVariable('TST_TITLE',$tst['title']);
00487                                 $this->tpl->parseCurrentBlock();
00488                         }
00489 
00490                         // Assigned Materials
00491                         $this->__initLMObject($objective_obj->getObjectiveId());
00492                         foreach($this->objectives_lm_obj->getMaterials() as $material)
00493                         {
00494                                 $this->tpl->setCurrentBlock('material_row');
00495                 
00496                                 $container_obj_id = $ilObjDataCache->lookupObjId($material['ref_id']);
00497                                 $title = $ilObjDataCache->lookupTitle($container_obj_id);
00498                                 switch($material['type'])
00499                                 {
00500                                         case 'st':
00501                                                 include_once('Modules/LearningModule/classes/class.ilLMObject.php');
00502                                                 $img = ilUtil::getImagePath('icon_lm_s.gif');
00503                                                 $alt = $this->lng->txt('obj_'.$material['type']);
00504                                                 $chapter_title = 
00505                                                 $title .= (' -> '.ilLMObject::_lookupTitle($material['obj_id'])); 
00506                                                 break;
00507                                         default: 
00508                                                 $img = ilUtil::getImagePath('icon_'.$material['type'].'_s.gif');
00509                                                 $alt = $this->lng->txt('obj_'.$material['type']);
00510                                                 break;
00511                                 }
00512                                 $this->tpl->setVariable('MAT_IMG',$img);
00513                                 $this->tpl->setVariable('MAT_ALT',$alt);
00514                                 $this->tpl->setVariable('MAT_TITLE',$title);
00515                                 $this->tpl->parseCurrentBlock();
00516                         }
00517                         $this->tpl->setCurrentBlock("table_content");
00518                         $this->tpl->setVariable('LABEL_ID',$objective_obj->getObjectiveId());
00519                         $this->tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00520                         $this->tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'objective[]',$objective_obj->getObjectiveId()));
00521                         $this->tpl->setVariable("TITLE",$objective_obj->getTitle());
00522                         $this->tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
00523                         
00524                         $this->ctrl->setParameter($this,'objective_id',$objective_obj->getObjectiveId());
00525                         $this->tpl->setVariable('LINK_MAT',$this->ctrl->getLinkTarget($this,'listMaterialAssignment'));
00526                         $this->tpl->setVariable('ADD_MAT',$this->lng->txt('crs_objective_add_mat'));
00527                         $this->tpl->setVariable('LINK_QST',$this->ctrl->getLinkTarget($this,'listQuestionAssignment'));
00528                         $this->tpl->setVariable('ADD_QST',$this->lng->txt('crs_objective_add_qst'));
00529                         $this->tpl->setVariable('LINK_EDIT',$this->ctrl->getLinkTarget($this,'editObjective'));
00530                         $this->tpl->setVariable('EDIT',$this->lng->txt('edit'));
00531                         $this->tpl->parseCurrentBlock();
00532                 }
00533                 
00534         }
00535 
00536         function moveObjectiveUp()
00537         {
00538                 global $rbacsystem;
00539 
00540                 // MINIMUM ACCESS LEVEL = 'write'
00541                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00542                 {
00543                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00544                 }
00545                 if(!$_GET['objective_id'])
00546                 {
00547                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00548                         $this->listObjectives();
00549                         
00550                         return true;
00551                 }
00552                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00553 
00554                 $objective_obj->moveUp((int) $_GET['objective_id']);
00555                 ilUtil::sendInfo($this->lng->txt('crs_moved_objective'));
00556 
00557                 $this->listObjectives();
00558 
00559                 return true;
00560         }
00561         function moveObjectiveDown()
00562         {
00563                 global $rbacsystem;
00564 
00565                 // MINIMUM ACCESS LEVEL = 'write'
00566                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00567                 {
00568                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00569                 }
00570                 if(!$_GET['objective_id'])
00571                 {
00572                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00573                         $this->listObjectives();
00574                         
00575                         return true;
00576                 }
00577                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00578 
00579                 $objective_obj->moveDown((int) $_GET['objective_id']);
00580                 ilUtil::sendInfo($this->lng->txt('crs_moved_objective'));
00581 
00582                 $this->listObjectives();
00583 
00584                 return true;
00585         }
00586 
00587 
00588         function addObjective()
00589         {
00590                 global $rbacsystem;
00591 
00592                 // MINIMUM ACCESS LEVEL = 'write'
00593                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00594                 {
00595                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00596                 }
00597                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.crs_add_objective.html",'Modules/Course');
00598                 
00599                 $this->tpl->setVariable('TBL_TITLE_IMG',ilUtil::getImagePath('icon_lobj.gif'));
00600                 $this->tpl->setVariable('TBL_TITLE_IMG_ALT',$this->lng->txt('crs_objectives'));
00601 
00602                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00603                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('crs_add_objective'));
00604                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00605                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt('description'));
00606                 $this->tpl->setVariable("TXT_REQUIRED_FLD",$this->lng->txt('required_field'));
00607                 $this->tpl->setVariable("CMD_SUBMIT",'saveObjective');
00608                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('add'));
00609                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00610 
00611                 return true;
00612         }
00613 
00614         function editObjective()
00615         {
00616                 global $rbacsystem;
00617 
00618                 // MINIMUM ACCESS LEVEL = 'write'
00619                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00620                 {
00621                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00622                 }
00623                 if(!isset($_GET['objective_id']))
00624                 {
00625                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00626                         $this->listObjectives();
00627 
00628                         return false;
00629                 }
00630 
00631                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.crs_add_objective.html",'Modules/Course');
00632 
00633                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00634                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00635                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt('crs_update_objective'));
00636                 $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('title'));
00637                 $this->tpl->setVariable('TBL_TITLE_IMG',ilUtil::getImagePath('icon_lobj.gif'));
00638                 $this->tpl->setVariable('TBL_TITLE_IMG_ALT',$this->lng->txt('crs_objectives'));
00639                 $this->tpl->setVariable("TXT_DESC",$this->lng->txt('description'));
00640                 $this->tpl->setVariable("TXT_REQUIRED_FLD",$this->lng->txt('required_field'));
00641                 $this->tpl->setVariable("CMD_SUBMIT",'updateObjective');
00642                 $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('save'));
00643                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00644 
00645                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00646 
00647                 $this->tpl->setVariable("TITLE",$objective_obj->getTitle());
00648                 $this->tpl->setVariable("DESC",$objective_obj->getDescription());
00649 
00650                 return true;
00651         }
00652 
00653         function updateObjective()
00654         {
00655                 global $rbacsystem;
00656 
00657                 // MINIMUM ACCESS LEVEL = 'write'
00658                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00659                 {
00660                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00661                 }
00662                 if(!isset($_GET['objective_id']))
00663                 {               
00664                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00665                         $this->listObjectives();
00666 
00667                         return false;
00668                 }
00669                 if(!$_POST['objective']['title'])
00670                 {               
00671                         ilUtil::sendInfo($this->lng->txt('crs_objective_no_title_given'));
00672                         $this->editObjective();
00673                         
00674                         return false;
00675                 }
00676 
00677 
00678                 $objective_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00679 
00680                 $objective_obj->setObjectiveId((int) $_GET['objective_id']);
00681                 $objective_obj->setTitle(ilUtil::stripSlashes($_POST['objective']['title']));
00682                 $objective_obj->setDescription(ilUtil::stripSlashes($_POST['objective']['description']));
00683 
00684                 $objective_obj->update();
00685                 
00686                 ilUtil::sendInfo($this->lng->txt('crs_objective_modified'));
00687                 $this->listObjectives();
00688 
00689                 return true;
00690         }
00691 
00692 
00693         function askDeleteObjective()
00694         {
00695                 global $rbacsystem;
00696 
00697                 // MINIMUM ACCESS LEVEL = 'write'
00698                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00699                 {
00700                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00701                 }
00702                 if(!count($_POST['objective']))
00703                 {
00704                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00705                         $this->listObjectives();
00706                         
00707                         return true;
00708                 }
00709 
00710                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html",'Modules/Course');
00711 
00712                 ilUtil::sendInfo($this->lng->txt('crs_delete_objectve_sure'));
00713 
00714                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00715                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html",'Modules/Course');
00716 
00717                 $counter = 0;
00718                 foreach($_POST['objective'] as $objective_id)
00719                 {
00720                         $objective_obj =& $this->__initObjectivesObject($objective_id);
00721 
00722                         $tpl->setCurrentBlock("tbl_content");
00723                         $tpl->setVariable("ROWCOL",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
00724                         $tpl->setVariable("TITLE",$objective_obj->getTitle());
00725                         $tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
00726                         $tpl->parseCurrentBlock();
00727                 }
00728 
00729                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00730 
00731                 // Show action row
00732                 $tpl->setCurrentBlock("tbl_action_btn");
00733                 $tpl->setVariable("BTN_NAME",'deleteObjectives');
00734                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
00735                 $tpl->parseCurrentBlock();
00736 
00737                 $tpl->setCurrentBlock("tbl_action_btn");
00738                 $tpl->setVariable("BTN_NAME",'listObjectives');
00739                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('cancel'));
00740                 $tpl->parseCurrentBlock();
00741 
00742                 $tpl->setCurrentBlock("tbl_action_row");
00743                 $tpl->setVariable("COLUMN_COUNTS",1);
00744                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00745                 $tpl->parseCurrentBlock();
00746 
00747 
00748                 // create table
00749                 $tbl = new ilTableGUI();
00750                 $tbl->setStyle('table','std');
00751 
00752                 // title & header columns
00753                 $tbl->setTitle($this->lng->txt("crs_objectives"),"icon_lobj.gif",$this->lng->txt("crs_objectives"));
00754 
00755                 $tbl->setHeaderNames(array($this->lng->txt("title")));
00756                 $tbl->setHeaderVars(array("title"), 
00757                                                         array("ref_id" => $this->course_obj->getRefId(),
00758                                                                   "cmdClass" => "ilcourseobjectivesgui",
00759                                                                   "cmdNode" => $_GET["cmdNode"]));
00760                 $tbl->setColumnWidth(array("50%"));
00761 
00762                 $tbl->setLimit($_GET["limit"]);
00763                 $tbl->setOffset($_GET["offset"]);
00764                 $tbl->setMaxCount(count($_POST['objective']));
00765 
00766                 // footer
00767                 $tbl->disable("footer");
00768                 $tbl->disable('sort');
00769 
00770                 // render table
00771                 $tbl->setTemplate($tpl);
00772                 $tbl->render();
00773 
00774                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00775                 
00776 
00777                 // Save marked objectives
00778                 $_SESSION['crs_delete_objectives'] = $_POST['objective'];
00779 
00780                 return true;
00781         }
00782 
00783         function deleteObjectives()
00784         {
00785                 global $rbacsystem;
00786 
00787                 // MINIMUM ACCESS LEVEL = 'write'
00788                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00789                 {
00790                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00791                 }
00792                 if(!count($_SESSION['crs_delete_objectives']))
00793                 {
00794                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00795                         $this->listObjectives();
00796                         
00797                         return true;
00798                 }
00799 
00800                 foreach($_SESSION['crs_delete_objectives'] as $objective_id)
00801                 {
00802                         $objective_obj =& $this->__initObjectivesObject($objective_id);
00803                         $objective_obj->delete();
00804                 }
00805 
00806                 ilUtil::sendInfo($this->lng->txt('crs_objectives_deleted'));
00807                 $this->listObjectives();
00808 
00809                 return true;
00810         }
00811 
00812 
00813         function saveObjective()
00814         {
00815                 global $rbacsystem;
00816 
00817                 // MINIMUM ACCESS LEVEL = 'write'
00818                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00819                 {
00820                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00821                 }
00822                 if(!$_POST['objective']['title'])
00823                 {
00824                         ilUtil::sendInfo('crs_no_title_given',true);
00825 
00826                         $this->addObjective();
00827                         return false;
00828                 }
00829 
00830                 $objective_obj =& $this->__initObjectivesObject();
00831 
00832                 $objective_obj->setTitle(ilUtil::stripSlashes($_POST['objective']['title']));
00833                 $objective_obj->setDescription(ilUtil::stripSlashes($_POST['objective']['description']));
00834                 $objective_obj->add();
00835                 
00836                 ilUtil::sendInfo($this->lng->txt('crs_added_objective'));
00837                 $this->listObjectives();
00838 
00839                 return true;
00840         }
00841 
00842         // Question assignment
00843         function listAssignedQuestions()
00844         {
00845                 global $rbacsystem;
00846 
00847                 // MINIMUM ACCESS LEVEL = 'write'
00848                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00849                 {
00850                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00851                 }
00852                 if(!isset($_GET['objective_id']))
00853                 {
00854                         ilUtil::sendInfo($this->lng->txt('crs_no_objective_selected'));
00855                         $this->listObjectives();
00856 
00857                         return false;
00858                 }
00859 
00860                 $this->ctrl->setParameter($this,'objective_id',(int) $_GET['objective_id']);
00861                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_list_qst.html",'Modules/Course');
00862 
00863                 if(!count($this->__getAllTests()))
00864                 {
00865                         #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00866                         ilUtil::sendInfo($this->lng->txt('crs_no_tests_inside_crs'));
00867                         
00868                         return true;
00869                 }
00870 
00871                 $this->__initQuestionObject((int) $_GET['objective_id']);
00872                 if(!count($questions = $this->objectives_qst_obj->getQuestions()))
00873                 {
00874                         ilUtil::sendInfo($this->lng->txt('crs_no_questions_assigned'));
00875                         #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00876                         $this->__showButton('assignTestSelect',$this->lng->txt('crs_objective_assign_question'));
00877 
00878                         return true;
00879                 }
00880 
00881                 $tpl =& new ilTemplate("tpl.table.html", true, true);
00882                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_list_qst_row.html",'Modules/Course');
00883 
00884                 #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00885 
00886                 $counter = 0;
00887                 foreach($this->__sortQuestions($questions) as $question)
00888                 {
00889                         ++$counter;
00890 
00891                         include_once './Modules/Test/classes/class.ilObjTest.php';
00892 
00893                         $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
00894 
00895                         $tpl->setCurrentBlock("tbl_content");
00896                         $tpl->setVariable("ROWCOL",ilUtil::switchColor($counter,"tblrow2","tblrow1"));
00897                         $tpl->setVariable("CHECK_OBJECTIVE",ilUtil::formCheckbox(0,'question[]',$question['qst_ass_id']));
00898                         $tpl->setVariable("TITLE",$tmp_question->getTitle());
00899                         $tpl->setVariable("DESCRIPTION",$tmp_question->getComment());
00900                         $tpl->parseCurrentBlock();
00901 
00902                         unset($tmp_question);
00903                 }
00904 
00905                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00906                 // Show action row
00907 
00908                 $tpl->setCurrentBlock("tbl_action_btn");
00909                 $tpl->setVariable("BTN_NAME",'askDeassignQuestion');
00910                 $tpl->setVariable("BTN_VALUE",$this->lng->txt('crs_objective_deassign_question'));
00911                 $tpl->parseCurrentBlock();
00912 
00913                 // Show add button
00914                 $tpl->setCurrentBlock("plain_button");
00915                 $tpl->setVariable("PBTN_NAME",'assignTestSelect');
00916                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt('crs_objective_assign_question'));
00917                 $tpl->parseCurrentBlock();
00918 
00919 
00920                 $tpl->setCurrentBlock("tbl_action_row");
00921                 $tpl->setVariable("COLUMN_COUNTS",2);
00922                 $tpl->setVariable("WIDTH","width=\"50%\"");
00923                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
00924                 $tpl->parseCurrentBlock();
00925 
00926                 // create table
00927                 $tbl = new ilTableGUI();
00928                 $tbl->setStyle('table','std');
00929 
00930                 // title & header columns
00931                 $objectives_obj =& $this->__initObjectivesObject((int) $_GET['objective_id']);
00932                 $header_title = $this->lng->txt("crs_objectives_assigned_questions").' ('.$objectives_obj->getTitle().')';
00933 
00934                 $tbl->setTitle($header_title,"icon_lobj.gif",$this->lng->txt("crs_objectives"));
00935 
00936                 $tbl->setHeaderNames(array('',$this->lng->txt("title")));
00937                 $tbl->setHeaderVars(array("","title"), 
00938                                                         array("ref_id" => $this->course_obj->getRefId(),
00939                                                                   "objective_id" => (int) $_GET['objective_id'],
00940                                                                   "cmdClass" => "ilcourseobjectivesgui",
00941                                                                   "cmdNode" => $_GET["cmdNode"]));
00942                 $tbl->setColumnWidth(array("1%","99%"));
00943 
00944                 $tbl->setLimit($_GET["limit"]);
00945                 $tbl->setOffset($_GET["offset"]);
00946                 $tbl->setMaxCount(0);
00947 
00948                 // footer
00949                 $tbl->disable("footer");
00950                 $tbl->disable('sort');
00951 
00952                 // render table
00953                 $tbl->setTemplate($tpl);
00954                 $tbl->render();
00955 
00956                 $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
00957 
00958                 return true;
00959         }
00960 
00961 
00962         function __sortQuestions($a_qst_ids)
00963         {
00964                 return ilUtil::sortArray($a_qst_ids,'title','asc');
00965         }
00966 
00967 
00968         function editQuestionAssignment()
00969         {
00970                 global $rbacsystem;
00971 
00972                 $this->tabs_gui->setSubTabActive('crs_objective_overview_question_assignment');
00973 
00974                 // MINIMUM ACCESS LEVEL = 'write'
00975                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
00976                 {
00977                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
00978                 }
00979 
00980                 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_objectives_edit_question_assignments.html','Modules/Course');
00981 
00982                 #$this->__showButton('listObjectives',$this->lng->txt('crs_objective_overview_objectives'));
00983 
00984                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00985                 $this->tpl->setVariable("CSS_TABLE",'fullwidth');
00986                 $this->tpl->setVariable("WIDTH",'80%');
00987                 $this->tpl->setVariable("COLUMN_COUNT",5);
00988                 $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath('icon_lobj.gif'));
00989                 $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->lng->txt('crs_objectives'));
00990                 $this->tpl->setVariable("TBL_TITLE",$this->lng->txt('crs_objectives_edit_question_assignments'));
00991                 
00992                 $head_titles = array(array($this->lng->txt('title'),"35%"),
00993                                                          array($this->lng->txt('crs_objectives_nr_questions'),"10%"),
00994                                                          array($this->lng->txt('crs_objectives_max_points'),"10%"),
00995                                                          array($this->lng->txt('options'),"35%"));
00996 
00997                 $counter = 0;
00998                 foreach($head_titles as $title)
00999                 {
01000                         $this->tpl->setCurrentBlock("tbl_header_no_link");
01001 
01002                         if(!$counter)
01003                         {
01004                                 $this->tpl->setVariable("TBL_HEADER_COLSPAN",' colspan="2"');
01005                                 ++$counter;
01006                         }
01007                         $this->tpl->setVariable("TBL_HEADER_CELL_NO_LINK",$title[0]);
01008                         $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK",$title[1]);
01009                         $this->tpl->parseCurrentBlock();
01010                 }
01011 
01012                 foreach(ilCourseObjective::_getObjectiveIds($this->course_obj->getId()) as $objective_id)
01013                 {
01014                         $tmp_objective_obj =& $this->__initObjectivesObject($objective_id);
01015                         
01016                         $this->__initQuestionObject($objective_id);
01017 
01018                         $counter = 1;
01019                         foreach($this->objectives_qst_obj->getTests() as $test_data)
01020                         {
01021                                 $show_buttons = true;
01022 
01023                                 $tmp_test =& ilObjectFactory::getInstanceByRefId($test_data['ref_id']);
01024 
01025                                 $this->tpl->setCurrentBlock("test_row");
01026                                 $this->tpl->setVariable("TEST_TITLE",$tmp_test->getTitle());
01027                                 $this->tpl->setVariable("TEST_QST",$this->objectives_qst_obj->getNumberOfQuestionsByTest($test_data['ref_id']));
01028                                 $this->tpl->setVariable("TEST_POINTS",$this->objectives_qst_obj->getMaxPointsByTest($test_data['ref_id']));
01029 
01030                                 // Options
01031                                 $this->tpl->setVariable("TXT_CHANGE_STATUS",$this->lng->txt('crs_change_status'));
01032                                 $this->tpl->setVariable("CHECK_CHANGE_STATUS",ilUtil::formCheckbox((int) $test_data['tst_status'],
01033                                                                                                                                                                    'test['.$test_data['test_objective_id'].'][status]'
01034                                                                                                                                                                    ,1));
01035                                 $this->tpl->setVariable("TXT_SUGGEST",$this->lng->txt('crs_suggest_lm'));
01036                                 $this->tpl->setVariable("SUGGEST_NAME",'test['.$test_data['test_objective_id'].'][limit]');
01037                                 $this->tpl->setVariable("SUGGEST_VALUE",(int) $test_data['tst_limit']);
01038 
01039                                 $this->tpl->parseCurrentBlock();
01040 
01041 
01042 
01043                                 ++$counter;
01044                         }
01045                         $this->tpl->setCurrentBlock("objective_row");
01046                         $this->tpl->setVariable("OBJ_TITLE",$tmp_objective_obj->getTitle());
01047                         $this->tpl->setVariable("OBJ_DESCRIPTION",$tmp_objective_obj->getDescription());
01048                         $this->tpl->setVariable("OBJ_QST",count($this->objectives_qst_obj->getQuestions()));
01049                         $this->tpl->setVariable("OBJ_POINTS",$this->objectives_qst_obj->getMaxPointsByObjective());
01050                         $this->tpl->setVariable("ROWSPAN",$counter);
01051                         $this->tpl->parseCurrentBlock();
01052                         
01053                         // Options
01054                         unset($tmp_objective_obj);
01055                 }
01056                 // Buttons
01057                 if($show_buttons)
01058                 {
01059                         $this->tpl->setCurrentBlock("edit_footer");
01060                         $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
01061                         $this->tpl->setVariable("TXT_UPDATE",$this->lng->txt('save'));
01062                         $this->tpl->setVariable("CMD_UPDATE",'updateQuestionAssignment');
01063                         $this->tpl->parseCurrentBlock();
01064                 }
01065         }
01066 
01067         function updateQuestionAssignment()
01068         {
01069                 global $rbacsystem;
01070 
01071                 $this->tabs_gui->setSubTabActive('crs_objective_overview_question_assignment');
01072 
01073 
01074                 // MINIMUM ACCESS LEVEL = 'write'
01075                 if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
01076                 {
01077                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
01078                 }
01079                 if(!is_array($_POST['test']))
01080                 {
01081                         ilUtil::sendInfo('Internal error: CRSM learning objectives');
01082                         $this->editQuestionAssignment();
01083 
01084                         return false;
01085                 }
01086                 // Validate
01087                 foreach($_POST['test'] as $test_obj_id => $data)
01088                 {
01089                         if(!preg_match('/1?[0-9][0-9]?/',$data['limit']) or 
01090                            $data['limit'] < 0 or 
01091                            $data['limit'] > 100)
01092                         {
01093                                 ilUtil::sendInfo($this->lng->txt('crs_objective_insert_percent'));
01094                                 $this->editQuestionAssignment();
01095 
01096                                 return false;
01097                         }
01098                 }
01099                 
01100                 foreach($_POST['test'] as $test_obj_id => $data)
01101                 {
01102                         include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
01103 
01104                         $test_data = ilCourseObjectiveQuestion::_getTest($test_obj_id);
01105 
01106                         $this->__initQuestionObject($test_data['objective_id']);
01107                         $this->objectives_qst_obj->setTestStatus($data['status'] ? 1 : 0);
01108                         $this->objectives_qst_obj->setTestSuggestedLimit($data['limit']);
01109                         $this->objectives_qst_obj->updateTest($test_obj_id);
01110                 }
01111                 ilUtil::sendInfo($this->lng->txt('crs_objective_updated_test'));
01112                 $this->editQuestionAssignment();
01113 
01114                 return true;
01115         }
01116                 
01117 
01118         // PRIVATE
01119         function __initCourseObject()
01120         {
01121                 if(!$this->course_obj =& ilObjectFactory::getInstanceByRefId($this->course_id,false))
01122                 {
01123                         $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object",$this->ilErr->MESSAGE);
01124                         exit;
01125                 }
01126                 // do i need members?
01127                 $this->course_obj->initCourseMemberObject();
01128 
01129                 return true;
01130         }
01131 
01132         function &__initObjectivesObject($a_id = 0)
01133         {
01134                 return $this->objectives_obj = new ilCourseObjective($this->course_obj,$a_id);
01135         }
01136 
01137         function __initLMObject($a_objective_id = 0)
01138         {
01139                 include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
01140                 $this->objectives_lm_obj =& new ilCourseObjectiveMaterials($a_objective_id);
01141 
01142                 return true;
01143         }
01144 
01145         function __initQuestionObject($a_objective_id = 0)
01146         {
01147                 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
01148                 $this->objectives_qst_obj =& new ilCourseObjectiveQuestion($a_objective_id);
01149 
01150                 return true;
01151         }
01152 
01153         function __showButton($a_cmd,$a_text,$a_target = '')
01154         {
01155                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
01156                 
01157                 // display button
01158                 $this->tpl->setCurrentBlock("btn_cell");
01159                 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
01160                 $this->tpl->setVariable("BTN_TXT",$a_text);
01161 
01162                 if($a_target)
01163                 {
01164                         $this->tpl->setVariable("BTN_TARGET",$a_target);
01165                 }
01166 
01167                 $this->tpl->parseCurrentBlock();
01168         }
01169 
01170 
01171 
01172         function __getAllChapters($a_ref_id)
01173         {
01174                 $tmp_lm =& ilObjectFactory::getInstanceByRefId($a_ref_id);
01175 
01176                 $tree = new ilTree($tmp_lm->getId());
01177                 $tree->setTableNames('lm_tree','lm_data');
01178                 $tree->setTreeTablePK("lm_id");
01179 
01180                 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node)
01181                 {
01182                 
01183                         if($node['type'] == 'st')
01184                         {
01185                                 $depth = $node['depth'] - 1;
01186                                 $child = $node['child'];
01187                                 $chapter[$child] = $depth;
01188                         }
01189                 }
01190 
01191                 return $chapter ? $chapter : array();
01192         }
01193 
01197         function setSubTabs()
01198         {
01199                 global $ilTabs;
01200 
01201                 $ilTabs->addSubTabTarget("crs_objective_overview_objectives",
01202                                                                  $this->ctrl->getLinkTarget($this, "listObjectives"),
01203                                                                  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
01204                                                                  array(),
01205                                                                  '',
01206                                                                  true);
01207                         
01208                 $ilTabs->addSubTabTarget("crs_objective_overview_question_assignment",
01209                                                                  $this->ctrl->getLinkTarget($this, "editQuestionAssignment"),
01210                                                                  "editQuestionAssignment",
01211                                                                  array(),
01212                                                                  '',
01213                                                                  false);
01214 
01215         }
01216 }
01217 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1