ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
78  $name = ilObjUser::_lookupName($this->getUserId());
79 
80  if(strlen($name['firstname']) and strlen($name['lastname']))
81  {
82  $name_string = $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']';
83  }
84  elseif(strlen($name['lastname']))
85  {
86  $name_string = $name['lastname'].' ['.$name['login'].']';
87  }
88  else
89  {
90  $name_string = $name['login'];
91  }
92 
93  $this->setTitle($GLOBALS['lng']->txt('crs_loc_test_results_of').' '.$name_string);
94 
95  $this->addColumn($GLOBALS['lng']->txt('crs_objectives'),'title','50%');
96 
97  if($this->getSettings()->worksWithInitialTest())
98  {
99  $this->addColumn($GLOBALS['lng']->txt('crs_loc_itest_info'),'it','25%');
100  $this->addColumn($GLOBALS['lng']->txt('crs_loc_qtest_info'),'qt','25%');
101  }
102  else
103  {
104  $this->addColumn($GLOBALS['lng']->txt('crs_loc_qtest_info'),'qt','25%');
105  }
106 
107  $this->setRowTemplate('tpl.crs_objectives_usr_result_row.html','Modules/Course');
108 
109  $this->disable('sort');
110  $this->disable('num_info');
111  }
112 
113 
118  public function fillRow($set)
119  {
120  $this->tpl->setVariable('VAL_TITLE', $set['title']);
121  if($this->getSettings()->worksWithInitialTest())
122  {
123  if($set['tries_it'] or $set['res_it'])
124  {
125  $this->tpl->setCurrentBlock('it_has_result');
126  $this->tpl->setVariable('IT_LINK',$set['link_it']);
127  $this->tpl->setVariable('IT_VAL',$set['res_it'].'%');
128  $this->tpl->parseCurrentBlock();
129  }
130  else
131  {
132  $this->tpl->setVariable('IT_NO_RES','-');
133  }
134 
135  }
136 
137  if($set['tries_qt'] or $set['res_qt'])
138  {
139  $this->tpl->setCurrentBlock('qt_has_result');
140  $this->tpl->setVariable('QT_LINK',$set['link_qt']);
141  $this->tpl->setVariable('QT_VAL',$set['res_qt'].'%');
142  $this->tpl->parseCurrentBlock();
143  }
144  else
145  {
146  $this->tpl->setVariable('QT_NO_RES','-');
147  }
148 
149  }
150 
155  public function parse()
156  {
157  include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
158 
159  include_once './Modules/Course/classes/class.ilCourseObjective.php';
160  $objective_ids = ilCourseObjective::_getObjectiveIds($this->getParentContainer()->getId(), TRUE);
161 
162  foreach((array) $objective_ids as $objective_id)
163  {
164  $objective = array();
165  $objective['id'] = $objective_id;
166  $objective['title'] = ilCourseObjective::lookupObjectiveTitle($objective_id);
167 
168 
169  if($this->getSettings()->worksWithInitialTest())
170  {
171  $results_it = ilLOUserResults::lookupResult(
172  $this->getParentContainer()->getId(),
173  $this->getUserId(),
174  $objective_id,
176  );
177  $objective['tries_it'] = $results_it['tries'];
178  $objective['res_it'] = $results_it['result_perc'];
179  $objective['link_it'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_INITIAL, $objective_id);
180  }
181  $results_qt = ilLOUserResults::lookupResult(
182  $this->getParentContainer()->getId(),
183  $this->getUserId(),
184  $objective_id,
186  );
187  $objective['tries_qt'] = $results_qt['tries'];
188  $objective['res_qt'] = $results_qt['result_perc'];
189  $objective['link_qt'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_QUALIFIED, $objective_id);
190 
191  $tbl_data[] = $objective;
192  }
193 
194  return $this->setData($tbl_data);
195  }
196 
202  protected function createTestResultLink($a_type, $a_objective_id)
203  {
204  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
205  $assignments = ilLOTestAssignments::getInstance($this->getParentContainer()->getId());
206 
207  $test_ref_id = $assignments->getTestByObjective($a_objective_id, $a_type);
208  if(!$test_ref_id)
209  {
210  return '';
211  }
212  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
213  return ilLOUtils::getTestResultLinkForUser($test_ref_id, $this->getUserId());
214  }
215 }
216 
217 ?>
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:93
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)
createTestResultLink($a_type, $a_objective_id)
Create test result link.
getId()
Get element 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.