ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLOMemberTestResultTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6 
14 {
15  private $settings = null;
16  private $parent_container = null;
17 
18  private $current_user = 0;
19 
20 
27  public function __construct($a_parent_obj_gui, $a_parent_obj, $a_parent_cmd)
28  {
29  $this->parent_container = $a_parent_obj;
30 
31  $this->setId('lomemtstres_' . $a_parent_obj->getId());
32  parent::__construct($a_parent_obj_gui, $a_parent_cmd);
33 
34 
35  $this->settings = ilLOSettings::getInstanceByObjId($a_parent_obj->getId());
36  }
37 
42  public function getParentContainer()
43  {
45  }
46 
50  public function getSettings()
51  {
52  return $this->settings;
53  }
54 
59  public function setUserId($a_id)
60  {
61  $this->current_user = $a_id;
62  }
63 
64 
68  public function getUserId()
69  {
70  return $this->current_user;
71  }
72 
76  public function init()
77  {
79 
80  if (strlen($name['firstname']) and strlen($name['lastname'])) {
81  $name_string = $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']';
82  } elseif (strlen($name['lastname'])) {
83  $name_string = $name['lastname'] . ' [' . $name['login'] . ']';
84  } else {
85  $name_string = $name['login'];
86  }
87 
88  $this->setTitle($GLOBALS['lng']->txt('crs_loc_test_results_of') . ' ' . $name_string);
89 
90  $this->addColumn($GLOBALS['lng']->txt('crs_objectives'), 'title', '50%');
91 
92  if ($this->getSettings()->worksWithInitialTest()) {
93  $this->addColumn($GLOBALS['lng']->txt('crs_loc_itest_info'), 'it', '25%');
94  $this->addColumn($GLOBALS['lng']->txt('crs_loc_qtest_info'), 'qt', '25%');
95  } else {
96  $this->addColumn($GLOBALS['lng']->txt('crs_loc_qtest_info'), 'qt', '25%');
97  }
98 
99  $this->setRowTemplate('tpl.crs_objectives_usr_result_row.html', 'Modules/Course');
100 
101  $this->disable('sort');
102  $this->disable('num_info');
103  }
104 
105 
110  public function fillRow($set)
111  {
112  $this->tpl->setVariable('VAL_TITLE', $set['title']);
113  if ($this->getSettings()->worksWithInitialTest()) {
114  if ($set['has_result_it']) {
115  $this->tpl->setCurrentBlock('it_has_result');
116  $this->tpl->setVariable('IT_LINK', $set['link_it']);
117  $this->tpl->setVariable('IT_VAL', $set['res_it'] . '%');
118  $this->tpl->parseCurrentBlock();
119  } else {
120  $this->tpl->setVariable('IT_NO_RES', '-');
121  }
122  }
123 
124  if ($set['has_result_qt']) {
125  $this->tpl->setCurrentBlock('qt_has_result');
126  $this->tpl->setVariable('QT_LINK', $set['link_qt']);
127  $this->tpl->setVariable('QT_VAL', $set['res_qt'] . '%');
128  $this->tpl->parseCurrentBlock();
129  } else {
130  $this->tpl->setVariable('QT_NO_RES', '-');
131  }
132  }
133 
138  public function parse()
139  {
140  include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
141 
142  include_once './Modules/Course/classes/class.ilCourseObjective.php';
143  $objective_ids = ilCourseObjective::_getObjectiveIds($this->getParentContainer()->getId(), true);
144 
145  foreach ((array) $objective_ids as $objective_id) {
146  $objective = array();
147  $objective['id'] = $objective_id;
148  $objective['title'] = ilCourseObjective::lookupObjectiveTitle($objective_id);
149 
150 
151  if ($this->getSettings()->worksWithInitialTest()) {
152  $results_it = ilLOUserResults::lookupResult(
153  $this->getParentContainer()->getId(),
154  $this->getUserId(),
155  $objective_id,
157  );
158  $objective['tries_it'] = $results_it['tries'];
159  $objective['res_it'] = $results_it['result_perc'];
160  $objective['link_it'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_INITIAL, $objective_id);
161  $objective['has_result_it'] = (bool) $results_it['has_result'];
162  }
163  $results_qt = ilLOUserResults::lookupResult(
164  $this->getParentContainer()->getId(),
165  $this->getUserId(),
166  $objective_id,
168  );
169  $objective['tries_qt'] = $results_qt['tries'];
170  $objective['res_qt'] = $results_qt['result_perc'];
171  $objective['link_qt'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_QUALIFIED, $objective_id);
172  $objective['has_result_qt'] = (bool) $results_qt['has_result'];
173 
174  $tbl_data[] = $objective;
175  }
176 
177  return $this->setData($tbl_data);
178  }
179 
185  protected function createTestResultLink($a_type, $a_objective_id)
186  {
187  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
188  $assignments = ilLOTestAssignments::getInstance($this->getParentContainer()->getId());
189 
190  $test_ref_id = $assignments->getTestByObjective($a_objective_id, $a_type);
191  if (!$test_ref_id) {
192  return '';
193  }
194  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
195  return ilLOUtils::getTestResultLinkForUser($test_ref_id, $this->getUserId());
196  }
197 }
static _lookupName($a_user_id)
lookup user name
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
Class ilLOmemberTestResultTableGUI.
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _getObjectiveIds($course_id, $a_activated_only=false)
setId($a_val)
Set id.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$a_type
Definition: workflow.php:92
if($format !==null) $name
Definition: metadata.php:146
Class ilTable2GUI.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
__construct($a_parent_obj_gui, $a_parent_obj, $a_parent_cmd)
Constructor.
settings()
Definition: settings.php:2
disable($a_module_name)
diesables particular modules of table
static getTestResultLinkForUser($a_test_ref_id, $a_user_id)
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.
createTestResultLink($a_type, $a_objective_id)
Create test result link.
getId()
Get element id.