1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4 5require_once 'Services/Table/classes/class.ilTable2GUI.php'; 6 7/** 8 * 9 * @author Björn Heyser <bheyser@databay.de> 10 * @version $Id$ 11 * 12 * @package Modules/Test 13 * 14 * @ilCtrl_Calls ilTestDynamicQuestionSetStatisticTableGUI: ilFormPropertyDispatchGUI 15 */ 16class ilTestDynamicQuestionSetStatisticTableGUI extends ilTable2GUI 17{ 18 const COMPLETE_TABLE_ID = 'tstDynQuestCompleteStat'; 19 const FILTERED_TABLE_ID = 'tstDynQuestFilteredStat'; 20 21 /** 22 * @var array 23 */ 24 protected $taxIds = array(); 25 26 private $taxonomyFilterEnabled = false; 27 28 private $answerStatusFilterEnabled = false; 29 30 /** 31 * @var ilTestDynamicQuestionSetFilterSelection 32 */ 33 protected $filterSelection = null; 34 35 /** 36 * Constructor 37 * 38 * @global ilObjUser $ilUser 39 */ 40 public function __construct(ilCtrl $ctrl, ilLanguage $lng, $a_parent_obj, $a_parent_cmd, $tableId) 41 { 42 $this->setId($tableId); 43 $this->setPrefix($tableId); 44 45 parent::__construct($a_parent_obj, $a_parent_cmd); 46 47 global $DIC; 48 $lng = $DIC['lng']; 49 $ilCtrl = $DIC['ilCtrl']; 50 51 $this->ctrl = $ilCtrl; 52 $this->lng = $lng; 53 54 $this->setFormName('filteredquestions'); 55 $this->setStyle('table', 'fullwidth'); 56 57 $this->setRowTemplate("tpl.il_as_tst_dynamic_question_set_selection_row.html", "Modules/Test"); 58 59 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd)); 60 61 $this->enable('header'); 62 $this->disable('sort'); 63 $this->disable('select_all'); 64 $this->disable('numinfo'); 65 66 $this->setDisableFilterHiding(true); 67 } 68 69 /** 70 * @return ilTestDynamicQuestionSetFilterSelection 71 */ 72 public function getFilterSelection() 73 { 74 return $this->filterSelection; 75 } 76 77 /** 78 * @param ilTestDynamicQuestionSetFilterSelection $filterSelection 79 */ 80 public function setFilterSelection($filterSelection) 81 { 82 $this->filterSelection = $filterSelection; 83 } 84 85 public function initTitle($titleLangVar) 86 { 87 $this->setTitle($this->lng->txt($titleLangVar)); 88 } 89 90 public function initColumns($totalQuestionsColumnHeaderLangVar) 91 { 92 $this->addColumn($this->lng->txt($totalQuestionsColumnHeaderLangVar), 'num_total_questions', '250'); 93 94 $this->addColumn($this->lng->txt("tst_num_correct_answered_questions"), 'num_correct_answered_questions', ''); 95 $this->addColumn($this->lng->txt("tst_num_wrong_answered_questions"), 'num_wrong_answered_questions', ''); 96 $this->addColumn($this->lng->txt("tst_num_non_answered_questions_skipped"), 'num_non_answered_questions_skipped', ''); 97 $this->addColumn($this->lng->txt("tst_num_non_answered_questions_notseen"), 'num_non_answered_questions_notseen', ''); 98 } 99 100 /** 101 * Init filter 102 */ 103 public function initFilter() 104 { 105 if ($this->isTaxonomyFilterEnabled()) { 106 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php'; 107 108 foreach ($this->taxIds as $taxId) { 109 $postvar = "tax_$taxId"; 110 111 $inp = new ilTaxSelectInputGUI($taxId, $postvar, true); 112 $this->addFilterItem($inp); 113 #$inp->readFromSession(); 114 115 if ($this->getFilterSelection()->hasSelectedTaxonomy($taxId)) { 116 $inp->setValue($this->getFilterSelection()->getSelectedTaxonomy($taxId)); 117 } 118 119 $this->filter[$postvar] = $inp->getValue(); 120 } 121 } 122 123 if ($this->isAnswerStatusFilterEnabled()) { 124 require_once 'Services/Form/classes/class.ilSelectInputGUI.php'; 125 require_once 'Services/Form/classes/class.ilRadioOption.php'; 126 127 $inp = new ilSelectInputGUI($this->lng->txt('tst_question_answer_status'), 'question_answer_status'); 128 $inp->setOptions(array( 129 ilAssQuestionList::ANSWER_STATUS_FILTER_ALL_NON_CORRECT => $this->lng->txt('tst_question_answer_status_all_non_correct'), 130 ilAssQuestionList::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY => $this->lng->txt('tst_question_answer_status_non_answered'), 131 ilAssQuestionList::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY => $this->lng->txt('tst_question_answer_status_wrong_answered') 132 )); 133 $this->addFilterItem($inp); 134 $inp->readFromSession(); 135 136 if ($this->getFilterSelection()->hasAnswerStatusSelection()) { 137 $inp->setValue($this->getFilterSelection()->getAnswerStatusSelection()); 138 } 139 140 $this->filter['question_answer_status'] = $inp->getValue(); 141 } 142 } 143 144 /** 145 * fill row 146 * 147 * @access public 148 * @param 149 * @return 150 */ 151 public function fillRow($data) 152 { 153 $this->tpl->setVariable('NUM_ALL_QUESTIONS', $data['total_all']); 154 $this->tpl->setVariable('NUM_CORRECT_ANSWERED_QUESTIONS', $data['correct_answered']); 155 $this->tpl->setVariable('NUM_WRONG_ANSWERED_QUESTIONS', $data['wrong_answered']); 156 $this->tpl->setVariable('NUM_NON_ANSWERED_QUESTIONS_SKIPPED', $data['non_answered_skipped']); 157 $this->tpl->setVariable('NUM_NON_ANSWERED_QUESTIONS_NOTSEEN', $data['non_answered_notseen']); 158 } 159 160 /** 161 * @param array $taxIds 162 */ 163 public function setTaxIds($taxIds) 164 { 165 $this->taxIds = $taxIds; 166 } 167 168 /** 169 * @return array 170 */ 171 public function getTaxIds() 172 { 173 return $this->taxIds; 174 } 175 176 /** 177 * @return boolean 178 */ 179 public function isAnswerStatusFilterEnabled() 180 { 181 return $this->answerStatusFilterEnabled; 182 } 183 184 /** 185 * @param boolean $answerStatusFilterEnabled 186 */ 187 public function setAnswerStatusFilterEnabled($answerStatusFilterEnabled) 188 { 189 $this->answerStatusFilterEnabled = $answerStatusFilterEnabled; 190 } 191 192 /** 193 * @return boolean 194 */ 195 public function isTaxonomyFilterEnabled() 196 { 197 return $this->taxonomyFilterEnabled; 198 } 199 200 /** 201 * @param boolean $taxonomyFilterEnabled 202 */ 203 public function setTaxonomyFilterEnabled($taxonomyFilterEnabled) 204 { 205 $this->taxonomyFilterEnabled = $taxonomyFilterEnabled; 206 } 207} 208