|
1
|
|
|
<?php |
|
2
|
|
|
/* For licensing terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Class ResultTable |
|
6
|
|
|
* Table to display results for an evaluation |
|
7
|
|
|
* @author Stijn Konings |
|
8
|
|
|
* @author Bert Steppé |
|
9
|
|
|
* @package chamilo.gradebook |
|
10
|
|
|
*/ |
|
11
|
|
|
class ResultTable extends SortableTable |
|
12
|
|
|
{ |
|
13
|
|
|
private $datagen; |
|
14
|
|
|
private $evaluation; |
|
15
|
|
|
private $allresults; |
|
|
|
|
|
|
16
|
|
|
private $iscourse; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Constructor |
|
20
|
|
|
*/ |
|
21
|
|
|
public function ResultTable ($evaluation, $results = array(), $iscourse, $addparams = null,$forprint = false) |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
parent :: __construct ('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1); |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
$this->datagen = new ResultsDataGenerator($evaluation, $results, true); |
|
26
|
|
|
|
|
27
|
|
|
$this->evaluation = $evaluation; |
|
28
|
|
|
$this->iscourse = $iscourse; |
|
29
|
|
|
$this->forprint = $forprint; |
|
30
|
|
|
|
|
31
|
|
|
if (isset ($addparams)) { |
|
32
|
|
|
$this->set_additional_parameters($addparams); |
|
33
|
|
|
} |
|
34
|
|
|
$scoredisplay = ScoreDisplay :: instance(); |
|
35
|
|
|
$column= 0; |
|
36
|
|
|
if ($this->iscourse == '1') { |
|
37
|
|
|
$this->set_header($column++, '', false); |
|
38
|
|
|
$this->set_form_actions(array ( |
|
39
|
|
|
'delete' => get_lang('Delete') |
|
40
|
|
|
)); |
|
41
|
|
|
} |
|
42
|
|
|
if (api_is_western_name_order()) { |
|
43
|
|
|
$this->set_header($column++, get_lang('FirstName')); |
|
44
|
|
|
$this->set_header($column++, get_lang('LastName')); |
|
45
|
|
|
} else { |
|
46
|
|
|
$this->set_header($column++, get_lang('LastName')); |
|
47
|
|
|
$this->set_header($column++, get_lang('FirstName')); |
|
48
|
|
|
} |
|
49
|
|
|
$this->set_header($column++, get_lang('Score')); |
|
50
|
|
|
if ($scoredisplay->is_custom()) { |
|
51
|
|
|
$this->set_header($column++, get_lang('Display')); |
|
52
|
|
|
} |
|
53
|
|
|
if (!$this->forprint) { |
|
54
|
|
|
$this->set_header($column++, get_lang('Modify'),false); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Function used by SortableTable to get total number of items in the table |
|
61
|
|
|
*/ |
|
62
|
|
|
public function get_total_number_of_items () |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->datagen->get_total_results_count(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Function used by SortableTable to generate the data to display |
|
69
|
|
|
*/ |
|
70
|
|
|
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { |
|
71
|
|
|
|
|
72
|
|
|
$is_western_name_order = api_is_western_name_order(); |
|
73
|
|
|
$scoredisplay = ScoreDisplay :: instance(); |
|
74
|
|
|
|
|
75
|
|
|
// determine sorting type |
|
76
|
|
|
$col_adjust = $this->iscourse == '1' ? 1 : 0; |
|
77
|
|
|
|
|
78
|
|
|
switch ($this->column) { |
|
79
|
|
|
// first name or last name |
|
80
|
|
View Code Duplication |
case (0 + $col_adjust): |
|
81
|
|
|
if ($is_western_name_order) { |
|
82
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
83
|
|
|
} else { |
|
84
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
85
|
|
|
} |
|
86
|
|
|
break; |
|
87
|
|
|
// first name or last name |
|
88
|
|
View Code Duplication |
case (1 + $col_adjust): |
|
89
|
|
|
if ($is_western_name_order) { |
|
90
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME; |
|
91
|
|
|
} else { |
|
92
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME; |
|
93
|
|
|
} |
|
94
|
|
|
break; |
|
95
|
|
|
//Score |
|
96
|
|
|
case (2 + $col_adjust): |
|
97
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_SCORE; |
|
98
|
|
|
break; |
|
99
|
|
|
case (3 + $col_adjust): |
|
100
|
|
|
$sorting = ResultsDataGenerator :: RDG_SORT_MASK; |
|
101
|
|
|
break; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if ($this->direction == 'DESC') { |
|
105
|
|
|
$sorting |= ResultsDataGenerator :: RDG_SORT_DESC; |
|
106
|
|
|
} else { |
|
107
|
|
|
$sorting |= ResultsDataGenerator :: RDG_SORT_ASC; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page); |
|
111
|
|
|
|
|
112
|
|
|
// generate the data to display |
|
113
|
|
|
$sortable_data = array(); |
|
114
|
|
|
foreach ($data_array as $item) { |
|
115
|
|
|
$row = array (); |
|
116
|
|
|
if ($this->iscourse == '1') { |
|
117
|
|
|
$row[] = $item['result_id']; |
|
118
|
|
|
} |
|
119
|
|
|
if ($is_western_name_order) { |
|
120
|
|
|
$row[] = $item['firstname']; |
|
121
|
|
|
$row[] = $item['lastname']; |
|
122
|
|
|
} else { |
|
123
|
|
|
$row[] = $item['lastname']; |
|
124
|
|
|
$row[] = $item['firstname']; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
$row[] = Display::bar_progress($item['percentage_score'], false, $item['score']); |
|
128
|
|
|
//$row[] = Display::bar_progress($item['percentage_score'], true); |
|
129
|
|
|
if ($scoredisplay->is_custom()) { |
|
130
|
|
|
$row[] = $item['display']; |
|
131
|
|
|
} |
|
132
|
|
|
if (!$this->forprint) { |
|
133
|
|
|
$row[] = $this->build_edit_column ($item); |
|
134
|
|
|
} |
|
135
|
|
|
$sortable_data[] = $row; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
return $sortable_data; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
private function build_edit_column ($item) |
|
142
|
|
|
{ |
|
143
|
|
|
$status=CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); |
|
144
|
|
|
$locked_status = $this->evaluation->get_locked(); |
|
145
|
|
|
if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { |
|
146
|
|
|
//api_is_course_admin() |
|
147
|
|
|
$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
148
|
|
|
Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>'; |
|
149
|
|
|
$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'. |
|
150
|
|
|
Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>'; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
if ($this->evaluation->get_course_code() == null) { |
|
154
|
|
|
$edit_column .= ' <a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">'; |
|
155
|
|
|
$edit_column .= Display::return_icon('delete.png', get_lang('Delete')); |
|
156
|
|
|
$edit_column .= '</a>'; |
|
157
|
|
|
$edit_column .= ' <a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">'; |
|
158
|
|
|
$edit_column .= Display::return_icon('statistics.gif', get_lang('Statistics')); |
|
159
|
|
|
$edit_column .= '</a>'; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
// Evaluation's origin is a link |
|
163
|
|
|
if ($this->evaluation->get_category_id() < 0) { |
|
164
|
|
|
$link = LinkFactory::get_evaluation_link($this->evaluation->get_id()); |
|
165
|
|
|
$doc_url = $link->get_view_url($item['id']); |
|
166
|
|
|
|
|
167
|
|
|
if ($doc_url != null) { |
|
168
|
|
|
$edit_column .= ' <a href="'. $doc_url . '" target="_blank">'; |
|
169
|
|
|
$edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>'; |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
return $edit_column; |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.