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