1<?php 2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4 5include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; 6include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php'; 7 8/** 9* Class ilLOEditorGUI 10* 11* @author Stefan Meyer <smeyer.ilias@gmx.de> 12* $Id$ 13* 14* @ilCtrl_isCalledBy ilLOEditorGUI: ilObjCourseGUI 15* @ilCtrl_Calls ilLOEditorGUI: ilCourseObjectivesGUI, ilContainerStartObjectsGUI, ilConditionHandlerGUI 16* @ilCtrl_Calls ilLOEditorGUI: ilLOPageGUI 17* 18*/ 19class ilLOEditorGUI 20{ 21 const TEST_TYPE_IT = 1; 22 const TEST_TYPE_QT = 2; 23 24 const TEST_NEW = 1; 25 const TEST_ASSIGN = 2; 26 27 const SETTINGS_TEMPLATE_IT = 'il_astpl_loc_initial'; 28 const SETTINGS_TEMPLATE_QT = 'il_astpl_loc_qualified'; 29 30 31 /** 32 * @var \ilLogger 33 */ 34 private $logger = null; 35 36 37 private $parent_obj; 38 private $settings = null; 39 private $lng = null; 40 private $ctrl = null; 41 42 private $test_type = 0; 43 44 45 /** 46 * Constructor 47 * @param type $a_parent_obj 48 */ 49 public function __construct($a_parent_obj) 50 { 51 $this->parent_obj = $a_parent_obj; 52 $this->settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 53 54 $this->lng = $GLOBALS['DIC']['lng']; 55 $this->ctrl = $GLOBALS['DIC']['ilCtrl']; 56 $this->logger = $GLOBALS['DIC']->logger()->crs(); 57 } 58 59 /** 60 * Execute command 61 * @return <type> 62 */ 63 public function executeCommand() 64 { 65 global $DIC; 66 67 $ilCtrl = $DIC['ilCtrl']; 68 69 $next_class = $ilCtrl->getNextClass($this); 70 $cmd = $ilCtrl->getCmd(); 71 72 $this->setTabs(); 73 switch ($next_class) { 74 case 'ilcourseobjectivesgui': 75 76 $this->ctrl->setReturn($this, 'returnFromObjectives'); 77 $GLOBALS['DIC']['ilTabs']->clearTargets(); 78 $GLOBALS['DIC']['ilTabs']->setBackTarget( 79 $this->lng->txt('back'), 80 $this->ctrl->getLinkTarget($this, 'listObjectives') 81 ); 82 83 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php'; 84 $reg_gui = new ilCourseObjectivesGUI($this->getParentObject()->getRefId()); 85 $this->ctrl->forwardCommand($reg_gui); 86 break; 87 88 case 'ilcontainerstartobjectsgui': 89 90 include_once './Services/Container/classes/class.ilContainerStartObjectsGUI.php'; 91 $stgui = new ilContainerStartObjectsGUI($this->getParentObject()); 92 $ret = $this->ctrl->forwardCommand($stgui); 93 94 $GLOBALS['DIC']['ilTabs']->activateSubTab('start'); 95 $GLOBALS['DIC']['ilTabs']->removeSubTab('manage'); 96 97 #$GLOBALS['DIC']['tpl']->setContent($this->ctrl->getHTML($stgui)); 98 break; 99 100 case 'ilconditionhandlergui': 101 102 $this->ctrl->saveParameterByClass('ilconditionhandlergui', 'objective_id'); 103 104 $GLOBALS['DIC']['ilTabs']->clearTargets(); 105 $GLOBALS['DIC']['ilTabs']->setBackTarget( 106 $this->lng->txt('back'), 107 $this->ctrl->getLinkTarget($this, 'listObjectives') 108 ); 109 110 include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php'; 111 $cond = new ilConditionHandlerGUI($this); 112 $cond->setBackButtons(array()); 113 $cond->setAutomaticValidation(false); 114 $cond->setTargetType("lobj"); 115 $cond->setTargetRefId($this->getParentObject()->getRefId()); 116 117 $cond->setTargetId((int) $_REQUEST['objective_id']); 118 119 // objecitve 120 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 121 $obj = new ilCourseObjective($this->getParentObject(), (int) $_REQUEST['objective_id']); 122 $cond->setTargetTitle($obj->getTitle()); 123 $this->ctrl->forwardCommand($cond); 124 break; 125 126 case 'illopagegui': 127 $this->ctrl->saveParameterByClass('illopagegui', 'objective_id'); 128 129 $GLOBALS['DIC']['ilTabs']->clearTargets(); 130 $GLOBALS['DIC']['ilTabs']->setBackTarget( 131 $this->lng->txt('back'), 132 $this->ctrl->getLinkTarget($this, 'listObjectives') 133 ); 134 135 $objtv_id = (int) $_REQUEST['objective_id']; 136 137 include_once 'Modules/Course/classes/Objectives/class.ilLOPage.php'; 138 if (!ilLOPage::_exists('lobj', $objtv_id)) { 139 // doesn't exist -> create new one 140 $new_page_object = new ilLOPage(); 141 $new_page_object->setParentId($objtv_id); 142 $new_page_object->setId($objtv_id); 143 $new_page_object->createFromXML(); 144 unset($new_page_object); 145 } 146 147 $this->ctrl->setReturn($this, 'listObjectives'); 148 include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php'; 149 $pgui = new ilLOPageGUI($objtv_id); 150 $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id)); 151 152 include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php'); 153 $pgui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId( 154 $this->parent_obj->getStyleSheetId(), 155 $this->parent_obj->getType() 156 )); 157 158 // #14895 159 $GLOBALS['DIC']['tpl']->setCurrentBlock("ContentStyle"); 160 $GLOBALS['DIC']['tpl']->setVariable( 161 "LOCATION_CONTENT_STYLESHEET", 162 ilObjStyleSheet::getContentStylePath(ilObjStyleSheet::getEffectiveContentStyleId( 163 $this->parent_obj->getStyleSheetId(), 164 $this->parent_obj->getType() 165 )) 166 ); 167 $GLOBALS['DIC']['tpl']->parseCurrentBlock(); 168 169 $ret = $this->ctrl->forwardCommand($pgui); 170 if ($ret) { 171 $GLOBALS['DIC']['tpl']->setContent($ret); 172 } 173 break; 174 175 default: 176 if (!$cmd) { 177 // get first unaccomplished step 178 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php'; 179 $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep(); 180 } 181 $this->$cmd(); 182 183 break; 184 } 185 return true; 186 } 187 188 /** 189 * Return from objectives 190 * @return type 191 */ 192 protected function returnFromObjectives() 193 { 194 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php'; 195 $_SESSION['objective_mode'] = ilCourseObjectivesGUI::MODE_UNDEFINED; 196 return $this->listObjectives(); 197 } 198 199 /** 200 * @return ilObject 201 */ 202 public function getParentObject() 203 { 204 return $this->parent_obj; 205 } 206 207 /** 208 * Settings 209 * @return ilLOSettings 210 */ 211 public function getSettings() 212 { 213 return $this->settings; 214 } 215 216 public function setTestType($a_type) 217 { 218 $this->test_type = $a_type; 219 } 220 221 public function getTestType() 222 { 223 return $this->test_type; 224 } 225 226 227 /** 228 * Objective Settings 229 */ 230 protected function settings(ilPropertyFormGUI $form = null) 231 { 232 if (!$form instanceof ilPropertyFormGUI) { 233 $form = $this->initSettingsForm(); 234 } 235 236 $GLOBALS['DIC']['ilTabs']->activateSubTab('settings'); 237 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 238 239 $this->showStatus(ilLOEditorStatus::SECTION_SETTINGS); 240 } 241 242 /** 243 * Delete assignments 244 * @param type $a_type 245 */ 246 protected function deleteAssignments($a_type) 247 { 248 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; 249 $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId()); 250 foreach ($assignments->getAssignmentsByType($a_type) as $assignment) { 251 $assignment->delete(); 252 } 253 return; 254 } 255 256 /** 257 * Update Test assignments 258 * @param ilLOSettings $settings 259 */ 260 protected function updateTestAssignments(ilLOSettings $settings) 261 { 262 switch ($settings->getInitialTestType()) { 263 case ilLOSettings::TYPE_INITIAL_NONE: 264 $settings->setInitialTest(0); 265 $this->deleteAssignments(ilLOSettings::TYPE_TEST_INITIAL); 266 267 // no break 268 case ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL: 269 case ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL: 270 $this->deleteAssignments(ilLOSettings::TYPE_TEST_INITIAL); 271 272 break; 273 274 case ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED: 275 case ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED: 276 $settings->setInitialTest(0); 277 break; 278 } 279 280 switch ($settings->getQualifyingTestType()) { 281 case ilLOSettings::TYPE_QUALIFYING_ALL: 282 $this->deleteAssignments(ilLOSettings::TYPE_TEST_QUALIFIED); 283 break; 284 285 case ilLOSettings::TYPE_QUALIFYING_SELECTED: 286 $settings->setQualifiedTest(0); 287 break; 288 } 289 $settings->update(); 290 } 291 292 293 /** 294 * 295 */ 296 protected function saveSettings() 297 { 298 $form = $this->initSettingsForm(); 299 if ($form->checkInput()) { 300 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 301 $settings->setInitialTestType($form->getInput('ittype')); 302 switch ($settings->getInitialTestType()) { 303 case ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL: 304 $settings->setInitialTestAsStart($form->getInput('start_ip')); 305 break; 306 307 case ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED: 308 $settings->setInitialTestAsStart(false); 309 break; 310 311 case ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL: 312 $settings->setInitialTestAsStart($form->getInput('start_iq')); 313 break; 314 315 case ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED: 316 $settings->setInitialTestAsStart(false); 317 break; 318 319 case ilLOSettings::TYPE_INITIAL_NONE: 320 $settings->setInitialTestAsStart(false); 321 break; 322 } 323 324 $settings->setQualifyingTestType($form->getInput('qttype')); 325 switch ($settings->getQualifyingTestType()) { 326 case ilLOSettings::TYPE_QUALIFYING_ALL: 327 $settings->setQualifyingTestAsStart($form->getInput('start_q')); 328 break; 329 330 case ilLOSettings::TYPE_QUALIFYING_SELECTED: 331 $settings->setQualifyingTestAsStart(false); 332 break; 333 } 334 335 336 $settings->resetResults($form->getInput('reset')); 337 $settings->setPassedObjectiveMode($form->getInput('passed_mode')); 338 339 if ( 340 ($settings->getInitialTestType() != ilLOSettings::TYPE_INITIAL_NONE) && 341 ($settings->isQualifyingTestStart()) 342 ) { 343 $settings->setQualifyingTestAsStart(false); 344 ilUtil::sendInfo($this->lng->txt('crs_loc_settings_err_qstart'), true); 345 } 346 347 $settings->update(); 348 $this->updateStartObjects(); 349 $this->updateTestAssignments($settings); 350 351 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; 352 ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId()); 353 354 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 355 $this->ctrl->redirect($this, 'settings'); 356 } 357 358 // Error 359 ilUtil::sendFailure($this->lng->txt('err_check_input')); 360 $form->setValuesByPost(); 361 $this->settings($form); 362 } 363 364 /** 365 * Init settings form 366 */ 367 protected function initSettingsForm() 368 { 369 include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; 370 $form = new ilPropertyFormGUI(); 371 $form->setFormAction($this->ctrl->getFormAction($this)); 372 $form->setTitle($this->lng->txt('crs_loc_settings_tbl')); 373 374 // initial test 375 $type_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_it_type'), 'ittype'); 376 $type_selector->setRequired(true); 377 $type_selector->setValue($this->getSettings()->getInitialTestType()); 378 379 $type_ipa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_all'), ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL); 380 $type_ipa->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_all_info')); 381 $type_selector->addOption($type_ipa); 382 383 $start_ip = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_ip'); 384 $start_ip->setValue(1); 385 $start_ip->setChecked($this->getSettings()->isInitialTestStart()); 386 $type_ipa->addSubItem($start_ip); 387 388 $type_ips = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_sel'), ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED); 389 $type_ips->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_sel_info')); 390 $type_selector->addOption($type_ips); 391 392 $type_iqa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_all'), ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL); 393 $type_iqa->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_all_info')); 394 $type_selector->addOption($type_iqa); 395 396 $start_iq = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_iq'); 397 $start_iq->setValue(1); 398 $start_iq->setChecked($this->getSettings()->isInitialTestStart()); 399 $type_iqa->addSubItem($start_iq); 400 401 $type_iqs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_sel'), ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED); 402 $type_iqs->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_sel_info')); 403 $type_selector->addOption($type_iqs); 404 405 $type_ino = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_none'), ilLOSettings::TYPE_INITIAL_NONE); 406 $type_ino->setInfo($this->lng->txt('crs_loc_settings_type_it_none_info')); 407 $type_selector->addOption($type_ino); 408 409 $form->addItem($type_selector); 410 411 // qualifying test 412 $qt_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_qt_all'), 'qttype'); 413 $qt_selector->setRequired(true); 414 $qt_selector->setValue($this->getSettings()->getQualifyingTestType()); 415 416 $type_qa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_all'), ilLOSettings::TYPE_QUALIFYING_ALL); 417 $type_qa->setInfo($this->lng->txt('crs_loc_settings_type_q_all_info')); 418 $qt_selector->addOption($type_qa); 419 420 $start_q = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_qt_start_object'), 'start_q'); 421 $start_q->setValue(1); 422 $start_q->setChecked($this->getSettings()->isQualifyingTestStart()); 423 $type_qa->addSubItem($start_q); 424 425 $passed_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_passed_mode'), 'passed_mode'); 426 $passed_mode->setValue($this->getSettings()->getPassedObjectiveMode()); 427 428 $passed_mode->addOption( 429 new ilRadioOption( 430 $this->lng->txt('crs_loc_settings_passed_mode_hide'), 431 ilLOSettings::HIDE_PASSED_OBJECTIVE_QST 432 ) 433 ); 434 $passed_mode->addOption( 435 new ilRadioOption( 436 $this->lng->txt('crs_loc_settings_passed_mode_mark'), 437 ilLOSettings::MARK_PASSED_OBJECTIVE_QST 438 ) 439 ); 440 $type_qa->addSubItem($passed_mode); 441 442 $type_qs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_selected'), ilLOSettings::TYPE_QUALIFYING_SELECTED); 443 $type_qs->setInfo($this->lng->txt('crs_loc_settings_type_q_selected_info')); 444 $qt_selector->addOption($type_qs); 445 446 $form->addItem($qt_selector); 447 448 // reset results 449 $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'), 'reset'); 450 $reset->setValue(1); 451 $reset->setChecked($this->getSettings()->isResetResultsEnabled()); 452 $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable')); 453 $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info')); 454 $form->addItem($reset); 455 456 $form->addCommandButton('saveSettings', $this->lng->txt('save')); 457 458 459 return $form; 460 } 461 462 protected function materials() 463 { 464 $GLOBALS['DIC']['ilTabs']->activateSubTab('materials'); 465 466 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php"; 467 $gui = new ilObjectAddNewItemGUI($this->getParentObject()->getRefId()); 468 $gui->setDisabledObjectTypes(array("itgr")); 469 #$gui->setAfterCreationCallback($this->getParentObject()->getRefId()); 470 $gui->render(); 471 472 include_once './Services/Object/classes/class.ilObjectTableGUI.php'; 473 $obj_table = new ilObjectTableGUI( 474 $this, 475 'materials', 476 $this->getParentObject()->getRefId() 477 ); 478 $obj_table->init(); 479 $obj_table->setObjects($GLOBALS['DIC']['tree']->getChildIds($this->getParentObject()->getRefId())); 480 $obj_table->parse(); 481 $GLOBALS['DIC']['tpl']->setContent($obj_table->getHTML()); 482 483 $this->showStatus(ilLOEditorStatus::SECTION_MATERIALS); 484 } 485 486 /** 487 * View test assignments () 488 */ 489 protected function testsOverview() 490 { 491 $this->setTestType((int) $_REQUEST['tt']); 492 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 493 494 $GLOBALS['DIC']['ilToolbar']->setFormAction($this->ctrl->getFormAction($this)); 495 $GLOBALS['DIC']['ilToolbar']->addButton( 496 $this->lng->txt('crs_loc_btn_new_assignment'), 497 $this->ctrl->getLinkTarget($this, 'testAssignment') 498 ); 499 500 501 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 502 switch ($this->getTestType()) { 503 case ilLOSettings::TYPE_TEST_INITIAL: 504 $GLOBALS['DIC']['ilTabs']->activateSubTab('itests'); 505 break; 506 507 case ilLOSettings::TYPE_TEST_QUALIFIED: 508 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtests'); 509 break; 510 } 511 512 try { 513 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php'; 514 $table = new ilLOTestAssignmentTableGUI( 515 $this, 516 'testsOverview', 517 $this->getParentObject()->getId(), 518 $this->getTestType(), 519 ilLOTestAssignmentTableGUI::TYPE_MULTIPLE_ASSIGNMENTS 520 ); 521 $table->init(); 522 $table->parseMultipleAssignments(); 523 $GLOBALS['DIC']['tpl']->setContent($table->getHTML()); 524 525 $this->showStatus( 526 ($this->getTestType() == ilLOEditorGUI::TEST_TYPE_IT) ? 527 ilLOEditorStatus::SECTION_ITES : 528 ilLOEditorStatus::SECTION_QTEST 529 ); 530 } catch (ilLOInvalidConfigurationException $ex) { 531 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Show new assignment screen because of : ' . $ex->getMessage()); 532 $this->testSettings(); 533 } 534 } 535 536 537 /** 538 * Show test overview 539 */ 540 protected function testOverview() 541 { 542 $this->setTestType((int) $_REQUEST['tt']); 543 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 544 545 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 546 switch ($this->getTestType()) { 547 case ilLOSettings::TYPE_TEST_INITIAL: 548 $GLOBALS['DIC']['ilTabs']->activateSubTab('itest'); 549 break; 550 551 case ilLOSettings::TYPE_TEST_QUALIFIED: 552 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtest'); 553 break; 554 } 555 556 557 // Check if test is assigned 558 if (!$settings->getTestByType($this->getTestType())) { 559 return $this->testSettings(); 560 } 561 562 try { 563 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php'; 564 $table = new ilLOTestAssignmentTableGUI( 565 $this, 566 'testOverview', 567 $this->getParentObject()->getId(), 568 $this->getTestType() 569 ); 570 $table->init(); 571 $table->parse(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType())); 572 $GLOBALS['DIC']['tpl']->setContent($table->getHTML()); 573 574 $this->showStatus( 575 ($this->getTestType() == ilLOEditorGUI::TEST_TYPE_IT) ? 576 ilLOEditorStatus::SECTION_ITES : 577 ilLOEditorStatus::SECTION_QTEST 578 ); 579 } catch (ilLOInvalidConfigurationException $ex) { 580 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Show new assignment screen because of : ' . $ex->getMessage()); 581 $this->testSettings(); 582 } 583 } 584 585 /** 586 * Show delete test confirmation 587 */ 588 protected function confirmDeleteTests() 589 { 590 $this->setTestType((int) $_REQUEST['tt']); 591 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 592 593 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 594 switch ($this->getTestType()) { 595 case ilLOSettings::TYPE_TEST_INITIAL: 596 $GLOBALS['DIC']['ilTabs']->activateSubTab('itests'); 597 break; 598 599 case ilLOSettings::TYPE_TEST_QUALIFIED: 600 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtests'); 601 break; 602 } 603 604 if (!(int) $_REQUEST['tst']) { 605 ilUtil::sendFailure($this->lng->txt('select_one'), true); 606 $this->ctrl->redirect($this, 'testsOverview'); 607 } 608 609 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; 610 $confirm = new ilConfirmationGUI(); 611 $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst')); 612 $confirm->setFormAction($this->ctrl->getFormAction($this)); 613 $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTests'); 614 $confirm->setCancel($this->lng->txt('cancel'), 'testsOverview'); 615 616 foreach ((array) $_REQUEST['tst'] as $assign_id) { 617 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; 618 $assignment = new ilLOTestAssignment($assign_id); 619 620 621 $obj_id = ilObject::_lookupObjId($assignment->getTestRefId()); 622 $confirm->addItem('tst[]', $assign_id, ilObject::_lookupTitle($obj_id)); 623 } 624 625 $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML()); 626 627 $this->showStatus( 628 ($this->getTestType() == ilLOSettings::TYPE_TEST_INITIAL) ? 629 ilLOEditorStatus::SECTION_ITES : 630 ilLOEditorStatus::SECTION_QTEST 631 ); 632 } 633 634 /** 635 * Show delete confirmation screen 636 */ 637 protected function confirmDeleteTest() 638 { 639 $this->setTestType((int) $_REQUEST['tt']); 640 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 641 642 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 643 switch ($this->getTestType()) { 644 case ilLOSettings::TYPE_TEST_INITIAL: 645 $GLOBALS['DIC']['ilTabs']->activateSubTab('itest'); 646 break; 647 648 case ilLOSettings::TYPE_TEST_QUALIFIED: 649 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtest'); 650 break; 651 } 652 653 if (!(int) $_REQUEST['tst']) { 654 ilUtil::sendFailure($this->lng->txt('select_one'), true); 655 $this->ctrl->redirect($this, 'testOverview'); 656 } 657 658 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; 659 $confirm = new ilConfirmationGUI(); 660 $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst')); 661 $confirm->setFormAction($this->ctrl->getFormAction($this)); 662 $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTest'); 663 $confirm->setCancel($this->lng->txt('cancel'), 'testOverview'); 664 665 foreach ((array) $_REQUEST['tst'] as $tst_id) { 666 $obj_id = ilObject::_lookupObjId($tst_id); 667 $confirm->addItem('tst[]', $tst_id, ilObject::_lookupTitle($obj_id)); 668 } 669 670 $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML()); 671 672 $this->showStatus( 673 ($this->getTestType() == ilLOEditorGUI::TEST_TYPE_IT) ? 674 ilLOEditorStatus::SECTION_ITES : 675 ilLOEditorStatus::SECTION_QTEST 676 ); 677 } 678 679 /** 680 * Delete test assignments 681 */ 682 protected function deleteTests() 683 { 684 $this->setTestType((int) $_REQUEST['tt']); 685 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 686 687 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 688 switch ($this->getTestType()) { 689 case ilLOSettings::TYPE_TEST_INITIAL: 690 $GLOBALS['DIC']['ilTabs']->activateSubTab('itests'); 691 break; 692 693 case ilLOSettings::TYPE_TEST_QUALIFIED: 694 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtests'); 695 break; 696 } 697 698 foreach ((array) $_REQUEST['tst'] as $assign_id) { 699 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; 700 $assignment = new ilLOTestAssignment($assign_id); 701 $assignment->delete(); 702 703 // finally delete start object assignment 704 include_once './Services/Container/classes/class.ilContainerStartObjects.php'; 705 $start = new ilContainerStartObjects( 706 $this->getParentObject()->getRefId(), 707 $this->getParentObject()->getId() 708 ); 709 $start->deleteItem($assignment->getTestRefId()); 710 711 // ... and assigned questions 712 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; 713 ilCourseObjectiveQuestion::deleteTest($assignment->getTestRefId()); 714 } 715 716 717 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 718 $this->ctrl->redirect($this, 'testsOverview'); 719 } 720 721 /** 722 * Delete test assignment 723 */ 724 protected function deleteTest() 725 { 726 $this->setTestType((int) $_REQUEST['tt']); 727 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 728 729 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 730 switch ($this->getTestType()) { 731 case ilLOSettings::TYPE_TEST_INITIAL: 732 $GLOBALS['DIC']['ilTabs']->activateSubTab('itest'); 733 break; 734 735 case ilLOSettings::TYPE_TEST_QUALIFIED: 736 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtest'); 737 break; 738 } 739 740 foreach ((array) $_REQUEST['tst'] as $tst_id) { 741 switch ($this->getTestType()) { 742 case ilLOSettings::TYPE_TEST_INITIAL: 743 $settings->setInitialTest(0); 744 break; 745 746 case ilLOSettings::TYPE_TEST_QUALIFIED: 747 $settings->setQualifiedTest(0); 748 break; 749 } 750 $settings->update(); 751 752 // finally delete start object assignment 753 include_once './Services/Container/classes/class.ilContainerStartObjects.php'; 754 $start = new ilContainerStartObjects( 755 $this->getParentObject()->getRefId(), 756 $this->getParentObject()->getId() 757 ); 758 $start->deleteItem($tst_id); 759 760 // ... and assigned questions 761 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; 762 ilCourseObjectiveQuestion::deleteTest($tst_id); 763 } 764 765 766 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 767 $this->ctrl->redirect($this, 'testOverview'); 768 } 769 770 /** 771 * new test assignment 772 */ 773 protected function testAssignment(ilPropertyFormGUI $form = null) 774 { 775 $this->setTestType((int) $_REQUEST['tt']); 776 $this->ctrl->setParameter($this, 'tt', $this->getTestType()); 777 778 switch ($this->getTestType()) { 779 case ilLOSettings::TYPE_TEST_INITIAL: 780 $GLOBALS['DIC']['ilTabs']->activateSubTab('itests'); 781 break; 782 783 case ilLOSettings::TYPE_TEST_QUALIFIED: 784 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtests'); 785 break; 786 } 787 if (!$form instanceof ilPropertyFormGUI) { 788 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php'; 789 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType()); 790 $form = $form_helper->initForm(true); 791 } 792 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 793 794 $this->showStatus( 795 ($this->getTestType() == self::TEST_TYPE_IT) ? 796 ilLOEditorStatus::SECTION_ITES : 797 ilLOEditorStatus::SECTION_QTEST 798 ); 799 } 800 801 /** 802 * Show test settings 803 * @param ilPropertyFormGUI $form 804 */ 805 protected function testSettings(ilPropertyFormGUI $form = null) 806 { 807 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']); 808 switch ($this->getTestType()) { 809 case ilLOSettings::TYPE_TEST_INITIAL: 810 $GLOBALS['DIC']['ilTabs']->activateSubTab('itest'); 811 break; 812 813 case ilLOSettings::TYPE_TEST_QUALIFIED: 814 $GLOBALS['DIC']['ilTabs']->activateSubTab('qtest'); 815 break; 816 } 817 818 if (!$form instanceof ilPropertyFormGUI) { 819 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php'; 820 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType()); 821 $form = $form_helper->initForm(false); 822 } 823 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 824 825 $this->showStatus( 826 ($this->getTestType() == self::TEST_TYPE_IT) ? 827 ilLOEditorStatus::SECTION_ITES : 828 ilLOEditorStatus::SECTION_QTEST 829 ); 830 } 831 832 /** 833 * Apply auto generated setttings template 834 * @param ilObjTest $tst 835 */ 836 protected function applySettingsTemplate(ilObjTest $tst) 837 { 838 include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; 839 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php'; 840 841 $tpl_id = 0; 842 foreach (ilSettingsTemplate::getAllSettingsTemplates('tst', true) as $nr => $template) { 843 switch ($this->getTestType()) { 844 case self::TEST_TYPE_IT: 845 if ($template['title'] == self::SETTINGS_TEMPLATE_IT) { 846 $tpl_id = $template['id']; 847 } 848 break; 849 case self::TEST_TYPE_QT: 850 if ($template['title'] == self::SETTINGS_TEMPLATE_QT) { 851 $tpl_id = $template['id']; 852 } 853 break; 854 } 855 if ($tpl_id) { 856 break; 857 } 858 } 859 860 if (!$tpl_id) { 861 return false; 862 } 863 864 include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; 865 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php'; 866 $template = new ilSettingsTemplate($tpl_id, ilObjAssessmentFolderGUI::getSettingsTemplateConfig()); 867 $template_settings = $template->getSettings(); 868 if ($template_settings) { 869 include_once './Modules/Test/classes/class.ilObjTestGUI.php'; 870 $tst_gui = new ilObjTestGUI(); 871 $tst_gui->applyTemplate($template_settings, $tst); 872 } 873 $tst->setTemplate($tpl_id); 874 return true; 875 } 876 877 /** 878 * Add Test as start object 879 * @param ilObjTest $tst 880 */ 881 protected function updateStartObjects() 882 { 883 include_once './Services/Container/classes/class.ilContainerStartObjects.php'; 884 $start = new ilContainerStartObjects(0, $this->getParentObject()->getId()); 885 $this->getSettings()->updateStartObjects($start); 886 return true; 887 } 888 889 protected function saveMultiTestAssignment() 890 { 891 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']); 892 $this->setTestType((int) $_REQUEST['tt']); 893 894 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 895 896 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php'; 897 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType()); 898 $form = $form_helper->initForm(true); 899 900 if ($form->checkInput()) { 901 $mode = $form->getInput('mode'); 902 903 if ($mode == self::TEST_NEW) { 904 $tst = new ilObjTest(); 905 $tst->setType('tst'); 906 $tst->setTitle($form->getInput('title')); 907 $tst->setDescription($form->getInput('desc')); 908 $tst->create(); 909 $tst->createReference(); 910 $tst->putInTree($this->getParentObject()->getRefId()); 911 $tst->setPermissions($this->getParentObject()->getRefId()); 912 913 // apply settings template 914 $this->applySettingsTemplate($tst); 915 916 $tst->setQuestionSetType($form->getInput('qtype')); 917 918 $tst->saveToDb(); 919 920 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; 921 $assignment = new ilLOTestAssignment(); 922 $assignment->setContainerId($this->getParentObject()->getId()); 923 $assignment->setAssignmentType($this->getTestType()); 924 $assignment->setObjectiveId($form->getInput('objective')); 925 $assignment->setTestRefId($tst->getRefId()); 926 $assignment->save(); 927 } else { 928 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; 929 $assignment = new ilLOTestAssignment(); 930 $assignment->setContainerId($this->getParentObject()->getId()); 931 $assignment->setAssignmentType($this->getTestType()); 932 $assignment->setObjectiveId($form->getInput('objective')); 933 $assignment->setTestRefId($form->getInput('tst')); 934 $assignment->save(); 935 936 $tst = new ilObjTest($form->getInput('tst'), true); 937 $this->applySettingsTemplate($tst); 938 $tst->saveToDb(); 939 } 940 941 // deassign as objective material 942 if ($tst instanceof ilObjTest) { 943 $this->updateMaterialAssignments($tst); 944 } 945 $this->updateStartObjects(); 946 947 ilUtil::sendSuccess($this->lng->txt('settings_saved')); 948 $this->ctrl->redirect($this, 'testsOverview'); 949 } 950 951 // Error 952 ilUtil::sendFailure($this->lng->txt('err_check_input')); 953 $form->setValuesByPost(); 954 $this->testAssignment($form); 955 } 956 957 /** 958 * @param \ilObjTest $test 959 */ 960 protected function updateMaterialAssignments(ilObjTest $test) 961 { 962 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 963 foreach (ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId()) as $objective_id) { 964 include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php'; 965 $materials = new ilCourseObjectiveMaterials($objective_id); 966 foreach ($materials->getMaterials() as $key => $material) { 967 if ($material['ref_id'] == $test->getRefId()) { 968 $materials->delete($material['lm_ass_id']); 969 } 970 } 971 } 972 } 973 974 /** 975 * Save Test 976 */ 977 protected function saveTest() 978 { 979 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']); 980 $this->setTestType((int) $_REQUEST['tt']); 981 982 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 983 984 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php'; 985 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType()); 986 $form = $form_helper->initForm(false); 987 988 if ($form->checkInput()) { 989 $mode = $form->getInput('mode'); 990 991 if ($mode == self::TEST_NEW) { 992 $tst = new ilObjTest(); 993 $tst->setType('tst'); 994 $tst->setTitle($form->getInput('title')); 995 $tst->setDescription($form->getInput('desc')); 996 $tst->create(); 997 $tst->createReference(); 998 $tst->putInTree($this->getParentObject()->getRefId()); 999 $tst->setPermissions($this->getParentObject()->getRefId()); 1000 1001 // apply settings template 1002 $this->applySettingsTemplate($tst); 1003 1004 $tst->setQuestionSetType($form->getInput('qtype')); 1005 1006 $tst->saveToDb(); 1007 1008 if ($this->getTestType() == self::TEST_TYPE_IT) { 1009 $this->getSettings()->setInitialTest($tst->getRefId()); 1010 } else { 1011 $this->getSettings()->setQualifiedTest($tst->getRefId()); 1012 } 1013 $this->getSettings()->update(); 1014 } else { 1015 if ($this->getTestType() == self::TEST_TYPE_IT) { 1016 $this->getSettings()->setInitialTest($form->getInput('tst')); 1017 } else { 1018 $this->getSettings()->setQualifiedTest($form->getInput('tst')); 1019 } 1020 1021 $this->getSettings()->update(); 1022 $tst = new ilObjTest($settings->getTestByType($this->getTestType()), true); 1023 $this->applySettingsTemplate($tst); 1024 $tst->saveToDb(); 1025 } 1026 1027 // deassign as objective material 1028 if ($tst instanceof ilObjTest) { 1029 $this->updateMaterialAssignments($tst); 1030 } 1031 $this->updateStartObjects(); 1032 1033 ilUtil::sendSuccess($this->lng->txt('settings_saved')); 1034 $this->ctrl->redirect($this, 'testOverview'); 1035 } 1036 1037 // Error 1038 ilUtil::sendFailure($this->lng->txt('err_check_input')); 1039 $form->setValuesByPost(); 1040 $this->testSettings($form); 1041 } 1042 1043 /** 1044 * List all abvailable objectives 1045 */ 1046 protected function listObjectives() 1047 { 1048 global $DIC; 1049 1050 $ilToolbar = $DIC['ilToolbar']; 1051 1052 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php'; 1053 $_SESSION['objective_mode'] = ilCourseObjectivesGUI::MODE_UNDEFINED; 1054 1055 1056 $GLOBALS['DIC']['ilTabs']->activateSubTab('objectives'); 1057 1058 $objectives = ilCourseObjective::_getObjectiveIds( 1059 $this->getParentObject()->getId(), 1060 false 1061 ); 1062 1063 if (!count($objectives)) { 1064 return $this->showObjectiveCreation(); 1065 } 1066 1067 $ilToolbar->addButton( 1068 $this->lng->txt('crs_add_objective'), 1069 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create") 1070 ); 1071 1072 include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php'); 1073 $table = new ilCourseObjectivesTableGUI($this, $this->getParentObject()); 1074 $table->setTitle($this->lng->txt('crs_objectives'), '', $this->lng->txt('crs_objectives')); 1075 $table->parse($objectives); 1076 $GLOBALS['DIC']['tpl']->setContent($table->getHTML()); 1077 1078 $this->showStatus(ilLOEditorStatus::SECTION_OBJECTIVES); 1079 } 1080 1081 /** 1082 * Show objective creation form 1083 * @param ilPropertyFormGUI $form 1084 */ 1085 protected function showObjectiveCreation(ilPropertyFormGUI $form = null) 1086 { 1087 $GLOBALS['DIC']['ilTabs']->activateSubTab('objectives'); 1088 1089 if (!$form instanceof ilPropertyFormGUI) { 1090 $form = $this->initSimpleObjectiveForm(); 1091 } 1092 1093 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 1094 1095 $this->showStatus(ilLOEditorStatus::SECTION_OBJECTIVES_NEW); 1096 } 1097 1098 /** 1099 * Show objective creation form 1100 */ 1101 protected function initSimpleObjectiveForm() 1102 { 1103 include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; 1104 $form = new ilPropertyFormGUI(); 1105 $form->setTitle($this->lng->txt('crs_loc_form_create_objectives')); 1106 $form->setFormAction($this->ctrl->getFormAction($this)); 1107 1108 $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives'); 1109 $txt->setValues(array(0 => '')); 1110 $txt->setRequired(true); 1111 $form->addItem($txt); 1112 1113 $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save')); 1114 1115 return $form; 1116 } 1117 1118 protected function saveObjectiveCreation() 1119 { 1120 $form = $this->initSimpleObjectiveForm(); 1121 if ($form->checkInput()) { 1122 foreach ((array) $form->getInput('objectives') as $idx => $title) { 1123 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1124 $obj = new ilCourseObjective($this->getParentObject()); 1125 $obj->setActive(true); 1126 $obj->setTitle($title); 1127 $obj->add(); 1128 } 1129 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 1130 $this->ctrl->redirect($this, ''); 1131 } 1132 1133 $form->setValuesByPost(); 1134 $GLOBALS['DIC']['ilTabs']->activateSubTab('objectives'); 1135 $this->showStatus(ilLOEditorStatus::SECTION_OBJECTIVES); 1136 $this->showObjectiveCreation($form); 1137 } 1138 1139 /** 1140 * save position 1141 * 1142 * @access protected 1143 * @return 1144 */ 1145 protected function saveSorting() 1146 { 1147 global $DIC; 1148 1149 $ilAccess = $DIC['ilAccess']; 1150 $ilErr = $DIC['ilErr']; 1151 $ilObjDataCache = $DIC['ilObjDataCache']; 1152 1153 asort($_POST['position'], SORT_NUMERIC); 1154 1155 $counter = 1; 1156 foreach ($_POST['position'] as $objective_id => $position) { 1157 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1158 $objective = new ilCourseObjective($this->getParentObject(), $objective_id); 1159 $objective->writePosition($counter++); 1160 } 1161 ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting')); 1162 $this->listObjectives(); 1163 } 1164 1165 /** 1166 * Confirm delete objectives 1167 */ 1168 protected function askDeleteObjectives() 1169 { 1170 $GLOBALS['DIC']['ilTabs']->activateSubTab('objectives'); 1171 1172 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; 1173 $confirm = new ilConfirmationGUI(); 1174 $confirm->setFormAction($this->ctrl->getFormAction($this)); 1175 $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure')); 1176 $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives'); 1177 $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives'); 1178 1179 foreach ($_POST['objective'] as $objective_id) { 1180 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1181 $obj = new ilCourseObjective($this->getParentObject(), $objective_id); 1182 $name = $obj->getTitle(); 1183 1184 $confirm->addItem( 1185 'objective_ids[]', 1186 $objective_id, 1187 $name 1188 ); 1189 } 1190 $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML()); 1191 $this->showStatus(ilLOEditorStatus::SECTION_OBJECTIVES); 1192 } 1193 1194 /** 1195 * activate chosen objectives 1196 */ 1197 protected function activateObjectives() 1198 { 1199 $enabled = (array) $_REQUEST['objective']; 1200 1201 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1202 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), false); 1203 foreach ((array) $objectives as $objective_id) { 1204 $objective = new ilCourseObjective($this->getParentObject(), $objective_id); 1205 if (in_array($objective_id, $enabled)) { 1206 $objective->setActive(true); 1207 $objective->update(); 1208 } 1209 } 1210 1211 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; 1212 ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId()); 1213 1214 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 1215 $this->ctrl->redirect($this, 'listObjectives'); 1216 } 1217 1218 /** 1219 * activate chosen objectives 1220 */ 1221 protected function deactivateObjectives() 1222 { 1223 $disabled = (array) $_REQUEST['objective']; 1224 1225 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1226 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), false); 1227 foreach ((array) $objectives as $objective_id) { 1228 $objective = new ilCourseObjective($this->getParentObject(), $objective_id); 1229 if (in_array($objective_id, $disabled)) { 1230 $objective->setActive(false); 1231 $objective->update(); 1232 } 1233 } 1234 1235 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; 1236 ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId()); 1237 1238 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 1239 $this->ctrl->redirect($this, 'listObjectives'); 1240 } 1241 1242 /** 1243 * Delete objectives 1244 * @global type $rbacsystem 1245 * @return boolean 1246 */ 1247 protected function deleteObjectives() 1248 { 1249 global $DIC; 1250 1251 $rbacsystem = $DIC['rbacsystem']; 1252 1253 foreach ($_POST['objective_ids'] as $objective_id) { 1254 include_once './Modules/Course/classes/class.ilCourseObjective.php'; 1255 $objective_obj = new ilCourseObjective($this->getParentObject(), $objective_id); 1256 $objective_obj->delete(); 1257 } 1258 1259 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; 1260 ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId()); 1261 1262 ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'), true); 1263 $this->ctrl->redirect($this, 'listObjectives'); 1264 1265 return true; 1266 } 1267 1268 /** 1269 * Show status panel 1270 */ 1271 protected function showStatus($a_section) 1272 { 1273 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php'; 1274 $status = new ilLOEditorStatus($this->getParentObject()); 1275 $status->setSection($a_section); 1276 $status->setCmdClass($this); 1277 $GLOBALS['DIC']['tpl']->setRightContent($status->getHTML()); 1278 } 1279 1280 1281 1282 /** 1283 * Set tabs 1284 * @param type $a_section 1285 */ 1286 protected function setTabs($a_section = '') 1287 { 1288 // objective settings 1289 $GLOBALS['DIC']['ilTabs']->addSubTab( 1290 'settings', 1291 $this->lng->txt('settings'), 1292 $this->ctrl->getLinkTarget($this, 'settings') 1293 ); 1294 // learning objectives 1295 $GLOBALS['DIC']['ilTabs']->addSubTab( 1296 'objectives', 1297 $this->lng->txt('crs_loc_tab_objectives'), 1298 $this->ctrl->getLinkTarget($this, 'listObjectives') 1299 ); 1300 // materials 1301 /* 1302 $GLOBALS['DIC']['ilTabs']->addTab( 1303 'materials', 1304 $this->lng->txt('crs_loc_tab_materials'), 1305 $this->ctrl->getLinkTarget($this,'materials') 1306 ); 1307 */ 1308 // tests 1309 $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); 1310 if ($settings->worksWithInitialTest()) { 1311 if ( 1312 $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL || 1313 $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL 1314 ) { 1315 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL); 1316 $GLOBALS['DIC']['ilTabs']->addSubTab( 1317 'itest', 1318 $this->lng->txt('crs_loc_tab_itest'), 1319 $this->ctrl->getLinkTarget($this, 'testOverview') 1320 ); 1321 } else { 1322 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL); 1323 $GLOBALS['DIC']['ilTabs']->addSubTab( 1324 'itests', 1325 $this->lng->txt('crs_loc_tab_itests'), 1326 $this->ctrl->getLinkTarget($this, 'testsOverview') 1327 ); 1328 } 1329 } 1330 1331 if ($settings->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_ALL) { 1332 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED); 1333 $GLOBALS['DIC']['ilTabs']->addSubTab( 1334 'qtest', 1335 $this->lng->txt('crs_loc_tab_qtest'), 1336 $this->ctrl->getLinkTarget($this, 'testOverview') 1337 ); 1338 } else { 1339 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED); 1340 $GLOBALS['DIC']['ilTabs']->addSubTab( 1341 'qtests', 1342 $this->lng->txt('crs_loc_tab_qtests'), 1343 $this->ctrl->getLinkTarget($this, 'testsOverview') 1344 ); 1345 } 1346 1347 if ($settings->worksWithStartObjects()) { 1348 $GLOBALS['DIC']['ilTabs']->addSubTab( 1349 'start', 1350 $this->lng->txt('crs_loc_tab_start'), 1351 $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui', '') 1352 ); 1353 } 1354 1355 // Member view 1356 #include_once './Services/Container/classes/class.ilMemberViewGUI.php'; 1357 #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId()); 1358 } 1359} 1360