ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
5 require_once 'Services/Table/classes/class.ilTable2GUI.php';
6 
14 {
15  const PARENT_DEFAULT_CMD = 'showManScoringByQuestionParticipantsTable';
16  const PARENT_APPLY_FILTER_CMD = 'applyManScoringByQuestionFilter';
17  const PARENT_RESET_FILTER_CMD = 'resetManScoringByQuestionFilter';
18  const PARENT_SAVE_SCORING_CMD = 'saveManScoringByQuestion';
19 
20  private $manPointsPostData = array();
21 
22  private $curQuestionMaxPoints = null;
23 
27  protected $first_row_rendered = false;
28 
32  protected $first_row = true;
33 
34  public function __construct($parentObj)
35  {
36  $this->setFilterCommand(self::PARENT_APPLY_FILTER_CMD);
37  $this->setResetCommand(self::PARENT_RESET_FILTER_CMD);
38  global $DIC;
39 
40  $ilCtrl = $DIC->ctrl();
41  $tpl = $DIC->ui()->mainTemplate();
42  $tpl->addJavaScript('./node_modules/tinymce/tinymce.js');
43  $this->setId('man_scor_by_qst_' . $parentObj->object->getId());
44 
45  parent::__construct($parentObj, self::PARENT_DEFAULT_CMD);
46 
47  $this->setFormAction($ilCtrl->getFormAction($parentObj, self::PARENT_DEFAULT_CMD));
48  $this->setRowTemplate("tpl.il_as_tst_man_scoring_by_question_tblrow.html", "Modules/Test");
49  $this->setShowRowsSelector(true);
50 
51  $this->initOrdering();
52  $this->initColumns();
53  $this->initFilter();
54  }
55 
56  private function initColumns()
57  {
58  $this->addColumn($this->lng->txt('name'), 'name');
59  $this->addColumn($this->lng->txt('tst_reached_points'), 'reached_points');
60  $this->addColumn($this->lng->txt('tst_maximum_points'), 'maximum_points');
61  $this->addColumn($this->lng->txt('tst_feedback'), 'feedback', '30%');
62  $this->addColumn($this->lng->txt('finalized_evaluation'), 'finalized_evaluation');
63  $this->addColumn($this->lng->txt('finalized_by'), 'finalized_by_uid');
64  $this->addColumn($this->lng->txt('finalized_on'), 'finalized_tstamp');
65  $this->addColumn($this->lng->txt('actions'), '', '1%');
66  }
67 
68  private function initOrdering()
69  {
70  $this->enable('sort');
71 
72  $this->setDefaultOrderField("name");
73  $this->setDefaultOrderDirection("asc");
74  }
75 
76  public function initFilter()
77  {
78  $this->setDisableFilterHiding(true);
79 
80  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
81  $available_questions = new ilSelectInputGUI($this->lng->txt('question'), 'question');
82  $select_questions = array();
83  if (!$this->getParentObject()->object->isRandomTest()) {
84  $questions = $this->getParentObject()->object->getTestQuestions();
85  } else {
86  $questions = $this->getParentObject()->object->getPotentialRandomTestQuestions();
87  }
89  foreach ($questions as $data) {
90  include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
91  $info = assQuestion::_getQuestionInfo($data['question_id']);
92  $type = $info["question_type_fi"];
93  if (in_array($type, $scoring)) {
94  $maxpoints = assQuestion::_getMaximumPoints($data["question_id"]);
95  if ($maxpoints == 1) {
96  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('point') . ')';
97  } else {
98  $maxpoints = ' (' . $maxpoints . ' ' . $this->lng->txt('points') . ')';
99  }
100 
101  $select_questions[$data["question_id"]] = $data['title'] . $maxpoints . ' [' . $this->lng->txt('question_id_short') . ': ' . $data["question_id"] . ']';
102  }
103  }
104  if (!$select_questions) {
105  $select_questions[0] = $this->lng->txt('tst_no_scorable_qst_available');
106  }
107  $available_questions->setOptions(array('' => $this->lng->txt('please_choose')) + $select_questions);
108  $this->addFilterItem($available_questions);
109  $available_questions->readFromSession();
110  $this->filter['question'] = $available_questions->getValue();
111 
112  $pass = new ilSelectInputGUI($this->lng->txt('pass'), 'pass');
113  $passes = array();
114  $max_pass = $this->getParentObject()->object->getMaxPassOfTest();
115  for ($i = 1; $i <= $max_pass; $i++) {
116  $passes[$i] = $i;
117  }
118  $pass->setOptions($passes);
119  $this->addFilterItem($pass);
120  $pass->readFromSession();
121  $this->filter['pass'] = $pass->getValue();
122 
123  $only_answered = new ilCheckboxInputGUI($this->lng->txt('tst_man_scoring_only_answered'), 'only_answered');
124  $this->addFilterItem($only_answered);
125  $only_answered->readFromSession();
126  ;
127  $this->filter['only_answered'] = $only_answered->getChecked();
128 
129  $correction = new ilSelectInputGUI(
130  $this->lng->txt('finalized_evaluation'),
131  'finalize_evaluation'
132  );
133  $evaluated = array(
134  $this->lng->txt('all_users'),
135  $this->lng->txt('evaluated_users'),
136  $this->lng->txt('not_evaluated_users')
137  );
138  $correction->setOptions($evaluated);
139  $this->addFilterItem($correction);
140  $correction->readFromSession();
141  $this->filter['finalize_evaluation'] = $correction->getValue();
142  }
143 
147  public function fillRow($row)
148  {
149  global $DIC;
150  $ilCtrl = $DIC->ctrl();
151  $ilAccess = $DIC->access();
152 
153  if (
154  $this->getParentObject()->object->anonymity == 1 ||
155  (
156  $this->getParentObject()->object->getAnonymity() == 2 &&
157  false == $ilAccess->checkAccess('write', '', $this->getParentObject()->object->getRefId())
158  )
159  ) {
160  $this->tpl->setVariable('VAL_NAME', $this->lng->txt("anonymous"));
161  } else {
162  $this->tpl->setVariable('VAL_NAME', $row['name']);
163  }
164 
165  if (!$this->first_row_rendered) {
166  $this->first_row_rendered = true;
167  $this->tpl->touchBlock('row_js');
168  }
169 
170  $this->tpl->setVariable('VAL_REACHED_POINTS', $row['reached_points']);
171  $this->tpl->setVariable('VAL_MAX_POINTS', $row['maximum_points']);
172  $finalized = (isset($row['finalized_evaluation']) && $row['finalized_evaluation'] == 1);
173  $this->tpl->setVariable(
174  'VAL_EVALUATED',
175  ($finalized) ? $this->lng->txt('yes') : $this->lng->txt('no')
176  );
177  $fin_usr_id = $row['finalized_by_usr_id'];
178 
179  $this->tpl->setVariable('VAL_MODAL_CORRECTION', $row['feedback']);
180  if ($fin_usr_id > 0) {
181  $this->tpl->setVariable('VAL_FINALIZED_BY', ilObjUser::_lookupFullname($fin_usr_id));
182  }
183  $fin_timestamp = $row['finalized_tstamp'];
184  if ($fin_timestamp > 0) {
185  $time = new ilDateTime($fin_timestamp, 3);
186  $this->tpl->setVariable('VAL_FINALIZED_ON', \ilDatePresentation::formatDate($time));
187  }
188 
189  $this->tpl->setVariable('VAL_PASS', $row['pass_id']);
190  $this->tpl->setVariable('VAL_ACTIVE_ID', $row['active_id']);
191  $this->tpl->setVariable('VAL_QUESTION_ID', $row['qst_id']);
192 
193  if ($this->first_row) {
194  $this->tpl->touchBlock('scoring_by_question_refresher');
195  $this->tpl->parseCurrentBlock();
196  $this->first_row = false;
197  }
198 
199  $ilCtrl->setParameter($this->getParentObject(), 'qst_id', $row['qst_id']);
200  $ilCtrl->setParameter($this->getParentObject(), 'active_id', $row['active_id']);
201  $ilCtrl->setParameter($this->getParentObject(), 'pass_id', $row['pass_id']);
202  $this->tpl->setVariable('VAL_LINK_ANSWER', $ilCtrl->getLinkTarget($this->getParentObject(), 'getAnswerDetail', '', true, false));
203  $ilCtrl->setParameter($this->getParentObject(), 'qst_id', '');
204  $ilCtrl->setParameter($this->getParentObject(), 'active_id', '');
205  $ilCtrl->setParameter($this->getParentObject(), 'pass_id', '');
206  $this->tpl->setVariable('VAL_TXT_ANSWER', $this->lng->txt('tst_eval_show_answer'));
207  $this->tpl->setVariable('ANSWER_TITLE', $this->lng->txt('answer_of') . ': ' . $row['name']);
208  }
209 
211  {
212  $this->manPointsPostData = $manPointsPostData;
213  }
214 
215  public function getCurQuestionMaxPoints()
216  {
218  }
219 
221  {
222  $this->curQuestionMaxPoints = $curQuestionMaxPoints;
223  }
224 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
$type
static _lookupFullname($a_user_id)
Lookup Full Name.
This class represents a checkbox property in a property form.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
setId($a_val)
Set id.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static _getQuestionInfo($question_id)
Returns question information from the database.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
global $DIC
Definition: goto.php:24
enable($a_module_name)
enables particular modules of table
setOptions($a_options)
Set Options.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static _getManualScoring()
Retrieve the manual scoring settings.
__construct(Container $dic, ilPlugin $plugin)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
filter()
Definition: filter.php:2
$i
Definition: metadata.php:24
setFilterCommand($a_val, $a_caption=null)
Set filter command.