1<?php 2 3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5include_once("./Services/Table/classes/class.ilTable2GUI.php"); 6 7/** 8 * TableGUI class for competence thresholds 9 * 10 * @author Alex Killing <alex.killing@gmx.de> 11 * @version $Id$ 12 * 13 * @ingroup Services 14 */ 15class ilSurveySkillThresholdsTableGUI extends ilTable2GUI 16{ 17 /** 18 * Constructor 19 */ 20 public function __construct( 21 $a_parent_obj, 22 $a_parent_cmd, 23 $a_survey, 24 $a_base_skill_id, 25 $a_tref_id 26 ) { 27 global $DIC; 28 29 $this->ctrl = $DIC->ctrl(); 30 $this->lng = $DIC->language(); 31 $ilCtrl = $DIC->ctrl(); 32 $lng = $DIC->language(); 33 34 $this->object = $a_survey; 35 $this->base_skill_id = $a_base_skill_id; 36 $this->tref_id = $a_tref_id; 37 38 39 $this->determineMaxScalesAndQuestions(); 40 41 ilUtil::sendInfo( 42 $lng->txt("survey_skill_nr_q") . ": " . count($this->question_ids) . 43 ", " . $lng->txt("survey_skill_max_scale_points") . ": " . $this->scale_sum 44 ); 45 46 include_once("./Modules/Survey/classes/class.ilSurveySkillThresholds.php"); 47 $this->skill_thres = new ilSurveySkillThresholds($this->object); 48 $this->thresholds = $this->skill_thres->getThresholds(); 49 50 parent::__construct($a_parent_obj, $a_parent_cmd); 51 52 include_once("./Modules/Survey/classes/class.ilSurveySkill.php"); 53 $this->skill_survey = new ilSurveySkill($a_survey); 54 $this->setData($this->getLevels()); 55 $this->setTitle(ilBasicSkill::_lookupTitle($this->base_skill_id, $this->tref_id)); 56 57 $this->addColumn($this->lng->txt("survey_skill_level")); 58 $this->addColumn($this->lng->txt("survey_up_to_x_points")); 59 60 $this->setRowTemplate("tpl.svy_skill_threshold_row.html", "Modules/Survey"); 61 62 // $this->addMultiCommand("saveThresholds", $lng->txt("save")); 63 $this->addCommandButton("saveThresholds", $lng->txt("save")); 64 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj)); 65 } 66 67 /** 68 * Determine max scales and questions 69 * 70 * @param 71 * @return 72 */ 73 public function determineMaxScalesAndQuestions() 74 { 75 include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"); 76 include_once("./Modules/Survey/classes/class.ilSurveySkill.php"); 77 $ssk = new ilSurveySkill($this->object); 78 $this->question_ids = $ssk->getQuestionsForSkill( 79 $this->base_skill_id, 80 $this->tref_id 81 ); 82 $this->scale_sum = $ssk->determineMaxScale( 83 $this->base_skill_id, 84 $this->tref_id 85 ); 86 } 87 88 89 /** 90 * Get levels 91 * 92 * @param 93 * @return 94 */ 95 public function getLevels() 96 { 97 include_once("./Services/Skill/classes/class.ilBasicSkill.php"); 98 $bs = new ilBasicSkill($this->base_skill_id); 99 return $bs->getLevelData(); 100 } 101 102 103 /** 104 * Fill table row 105 */ 106 protected function fillRow($a_set) 107 { 108 $lng = $this->lng; 109 $ilCtrl = $this->ctrl; 110 111 $this->tpl->setVariable("LEVEL", $a_set["title"]); 112 $this->tpl->setVariable("LEVEL_ID", $a_set["id"]); 113 114 $tr = $this->thresholds[$a_set["id"]][$this->tref_id]; 115 if ((int) $tr != 0) { 116 $this->tpl->setVariable("THRESHOLD", (int) $tr); 117 } else { 118 $this->tpl->setVariable("THRESHOLD", ""); 119 } 120 } 121} 122