@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | $last_access = ''; |
8 | 8 | // get the last time the user accessed the tool |
9 | 9 | if (isset($_SESSION[$_course['id']]) && $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') { |
10 | - $last_access = get_last_tool_access(TOOL_DROPBOX); |
|
11 | - $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; |
|
10 | + $last_access = get_last_tool_access(TOOL_DROPBOX); |
|
11 | + $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; |
|
12 | 12 | } else { |
13 | - if (isset($_SESSION[$_course['id']])) { |
|
14 | - $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX]; |
|
15 | - } |
|
13 | + if (isset($_SESSION[$_course['id']])) { |
|
14 | + $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX]; |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | $postAction = isset($_POST['action']) ? $_POST['action'] : null; |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | // Display the form for adding a new dropbox item. |
52 | 52 | if ($action == 'add') { |
53 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
54 | - api_not_allowed(); |
|
55 | - } |
|
53 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
54 | + api_not_allowed(); |
|
55 | + } |
|
56 | 56 | display_add_form( |
57 | 57 | $dropbox_unid, |
58 | 58 | $viewReceivedCategory, |
@@ -62,56 +62,56 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | if (isset($_POST['submitWork'])) { |
65 | - $check = Security::check_token(); |
|
66 | - if ($check) { |
|
65 | + $check = Security::check_token(); |
|
66 | + if ($check) { |
|
67 | 67 | store_add_dropbox(); |
68 | - } |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Display the form for adding a category |
72 | 72 | if ($action == 'addreceivedcategory' || $action == 'addsentcategory') { |
73 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
74 | - api_not_allowed(); |
|
75 | - } |
|
76 | - $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : ''; |
|
77 | - display_addcategory_form($categoryName, '', $_GET['action']); |
|
73 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
74 | + api_not_allowed(); |
|
75 | + } |
|
76 | + $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : ''; |
|
77 | + display_addcategory_form($categoryName, '', $_GET['action']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Editing a category: displaying the form |
81 | 81 | if ($action == 'editcategory' && isset($_GET['id'])) { |
82 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
83 | - api_not_allowed(); |
|
84 | - } |
|
85 | - if (!$_POST) { |
|
86 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
87 | - api_not_allowed(); |
|
88 | - } |
|
89 | - display_addcategory_form('', $_GET['id'], 'editcategory'); |
|
90 | - } |
|
82 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
83 | + api_not_allowed(); |
|
84 | + } |
|
85 | + if (!$_POST) { |
|
86 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
87 | + api_not_allowed(); |
|
88 | + } |
|
89 | + display_addcategory_form('', $_GET['id'], 'editcategory'); |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Storing a new or edited category |
94 | 94 | if (isset($_POST['StoreCategory'])) { |
95 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
96 | - api_not_allowed(); |
|
97 | - } |
|
98 | - $return_information = store_addcategory(); |
|
99 | - if ($return_information['type'] == 'confirmation') { |
|
100 | - Display :: display_confirmation_message($return_information['message']); |
|
101 | - } |
|
102 | - if ($return_information['type'] == 'error') { |
|
103 | - Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']); |
|
104 | - display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction); |
|
105 | - } |
|
95 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
96 | + api_not_allowed(); |
|
97 | + } |
|
98 | + $return_information = store_addcategory(); |
|
99 | + if ($return_information['type'] == 'confirmation') { |
|
100 | + Display :: display_confirmation_message($return_information['message']); |
|
101 | + } |
|
102 | + if ($return_information['type'] == 'error') { |
|
103 | + Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']); |
|
104 | + display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | // Move a File |
110 | 110 | if (($action == 'movesent' || $action == 'movereceived') AND isset($_GET['move_id'])) { |
111 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
112 | - api_not_allowed(); |
|
113 | - } |
|
114 | - display_move_form( |
|
111 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
112 | + api_not_allowed(); |
|
113 | + } |
|
114 | + display_move_form( |
|
115 | 115 | str_replace('move', '', $action), |
116 | 116 | $_GET['move_id'], |
117 | 117 | get_dropbox_categories(str_replace('move', '', $action)), |
@@ -122,33 +122,33 @@ discard block |
||
122 | 122 | ); |
123 | 123 | } |
124 | 124 | if (isset($_POST['do_move'])) { |
125 | - Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); |
|
125 | + Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Delete a file |
129 | 129 | if (($action == 'deletereceivedfile' || $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { |
130 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
131 | - api_not_allowed(); |
|
132 | - } |
|
133 | - $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
134 | - if ($action == 'deletereceivedfile') { |
|
135 | - $dropboxfile->deleteReceivedWork($_GET['id']); |
|
136 | - $message = get_lang('ReceivedFileDeleted'); |
|
137 | - } |
|
138 | - if ($action == 'deletesentfile') { |
|
139 | - $dropboxfile->deleteSentWork($_GET['id']); |
|
140 | - $message = get_lang('SentFileDeleted'); |
|
141 | - } |
|
142 | - Display :: display_confirmation_message($message); |
|
130 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
131 | + api_not_allowed(); |
|
132 | + } |
|
133 | + $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
134 | + if ($action == 'deletereceivedfile') { |
|
135 | + $dropboxfile->deleteReceivedWork($_GET['id']); |
|
136 | + $message = get_lang('ReceivedFileDeleted'); |
|
137 | + } |
|
138 | + if ($action == 'deletesentfile') { |
|
139 | + $dropboxfile->deleteSentWork($_GET['id']); |
|
140 | + $message = get_lang('SentFileDeleted'); |
|
141 | + } |
|
142 | + Display :: display_confirmation_message($message); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Delete a category |
146 | 146 | if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { |
147 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
148 | - api_not_allowed(); |
|
149 | - } |
|
150 | - $message = delete_category($action, $_GET['id']); |
|
151 | - Display :: display_confirmation_message($message); |
|
147 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
148 | + api_not_allowed(); |
|
149 | + } |
|
150 | + $message = delete_category($action, $_GET['id']); |
|
151 | + Display :: display_confirmation_message($message); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Do an action on multiple files |
@@ -163,27 +163,27 @@ discard block |
||
163 | 163 | $postAction == 'delete_sent' || |
164 | 164 | $postAction == 'download_sent') |
165 | 165 | ) { |
166 | - $display_message = handle_multiple_actions(); |
|
167 | - Display :: display_normal_message($display_message); |
|
166 | + $display_message = handle_multiple_actions(); |
|
167 | + Display :: display_normal_message($display_message); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Store Feedback |
171 | 171 | |
172 | 172 | if (isset($_POST['feedback'])) { |
173 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
174 | - api_not_allowed(); |
|
175 | - } |
|
176 | - $check = Security::check_token(); |
|
177 | - if ($check) { |
|
178 | - $display_message = store_feedback(); |
|
179 | - Display :: display_normal_message($display_message); |
|
180 | - Security::check_token(); |
|
181 | - } |
|
173 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
174 | + api_not_allowed(); |
|
175 | + } |
|
176 | + $check = Security::check_token(); |
|
177 | + if ($check) { |
|
178 | + $display_message = store_feedback(); |
|
179 | + Display :: display_normal_message($display_message); |
|
180 | + Security::check_token(); |
|
181 | + } |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | // Error Message |
185 | 185 | if (isset($_GET['error']) AND !empty($_GET['error'])) { |
186 | - Display :: display_normal_message(get_lang($_GET['error'])); |
|
186 | + Display :: display_normal_message(get_lang($_GET['error'])); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $dropbox_data_sent = array(); |
@@ -191,96 +191,96 @@ discard block |
||
191 | 191 | $dropbox_data_recieved = array(); |
192 | 192 | |
193 | 193 | if ($action != 'add') { |
194 | - // Getting all the categories in the dropbox for the given user |
|
195 | - $dropbox_categories = get_dropbox_categories(); |
|
196 | - // Greating the arrays with the categories for the received files and for the sent files |
|
197 | - foreach ($dropbox_categories as $category) { |
|
198 | - if ($category['received'] == '1') { |
|
199 | - $dropbox_received_category[] = $category; |
|
200 | - } |
|
201 | - if ($category['sent'] == '1') { |
|
202 | - $dropbox_sent_category[] = $category; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - // ACTIONS |
|
207 | - if ($view == 'received' || !$showSentReceivedTabs) { |
|
208 | - //echo '<h3>'.get_lang('ReceivedFiles').'</h3>'; |
|
209 | - |
|
210 | - // This is for the categories |
|
211 | - if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
212 | - $view_dropbox_category_received = $viewReceivedCategory; |
|
213 | - } else { |
|
214 | - $view_dropbox_category_received = 0; |
|
215 | - } |
|
216 | - |
|
217 | - /* Menu Received */ |
|
218 | - |
|
219 | - if (api_get_session_id() == 0) { |
|
220 | - echo '<div class="actions">'; |
|
221 | - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
222 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
223 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
224 | - $movelist[0] = 'Root'; // move_received selectbox content |
|
225 | - } else { |
|
226 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
227 | - } |
|
228 | - echo '</div>'; |
|
229 | - } else { |
|
230 | - if (api_is_allowed_to_session_edit(false, true)) { |
|
231 | - echo '<div class="actions">'; |
|
232 | - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
233 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
234 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
235 | - $movelist[0] = 'Root'; // move_received selectbox content |
|
236 | - } else { |
|
237 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
238 | - } |
|
239 | - echo '</div>'; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
245 | - // This is for the categories |
|
246 | - if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
247 | - $view_dropbox_category_sent = $viewSentCategory; |
|
248 | - } else { |
|
249 | - $view_dropbox_category_sent = 0; |
|
250 | - } |
|
251 | - |
|
252 | - /* Menu Sent */ |
|
253 | - |
|
254 | - if (api_get_session_id() == 0) { |
|
255 | - echo '<div class="actions">'; |
|
256 | - if ($view_dropbox_category_sent != 0) { |
|
257 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
258 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
259 | - } else { |
|
260 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
261 | - } |
|
262 | - if (empty($viewSentCategory)) { |
|
263 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
264 | - } |
|
265 | - echo '</div>'; |
|
266 | - } else { |
|
267 | - if (api_is_allowed_to_session_edit(false, true)) { |
|
268 | - echo '<div class="actions">'; |
|
269 | - if ($view_dropbox_category_sent != 0) { |
|
270 | - echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
271 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
272 | - } else { |
|
273 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
274 | - } |
|
275 | - if (empty($viewSentCategory)) { |
|
276 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
277 | - } |
|
278 | - echo '</div>'; |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - /* THE MENU TABS */ |
|
283 | - if ($showSentReceivedTabs) { |
|
194 | + // Getting all the categories in the dropbox for the given user |
|
195 | + $dropbox_categories = get_dropbox_categories(); |
|
196 | + // Greating the arrays with the categories for the received files and for the sent files |
|
197 | + foreach ($dropbox_categories as $category) { |
|
198 | + if ($category['received'] == '1') { |
|
199 | + $dropbox_received_category[] = $category; |
|
200 | + } |
|
201 | + if ($category['sent'] == '1') { |
|
202 | + $dropbox_sent_category[] = $category; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + // ACTIONS |
|
207 | + if ($view == 'received' || !$showSentReceivedTabs) { |
|
208 | + //echo '<h3>'.get_lang('ReceivedFiles').'</h3>'; |
|
209 | + |
|
210 | + // This is for the categories |
|
211 | + if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
212 | + $view_dropbox_category_received = $viewReceivedCategory; |
|
213 | + } else { |
|
214 | + $view_dropbox_category_received = 0; |
|
215 | + } |
|
216 | + |
|
217 | + /* Menu Received */ |
|
218 | + |
|
219 | + if (api_get_session_id() == 0) { |
|
220 | + echo '<div class="actions">'; |
|
221 | + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
222 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
223 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
224 | + $movelist[0] = 'Root'; // move_received selectbox content |
|
225 | + } else { |
|
226 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
227 | + } |
|
228 | + echo '</div>'; |
|
229 | + } else { |
|
230 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
231 | + echo '<div class="actions">'; |
|
232 | + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
233 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
234 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
235 | + $movelist[0] = 'Root'; // move_received selectbox content |
|
236 | + } else { |
|
237 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
238 | + } |
|
239 | + echo '</div>'; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
245 | + // This is for the categories |
|
246 | + if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
247 | + $view_dropbox_category_sent = $viewSentCategory; |
|
248 | + } else { |
|
249 | + $view_dropbox_category_sent = 0; |
|
250 | + } |
|
251 | + |
|
252 | + /* Menu Sent */ |
|
253 | + |
|
254 | + if (api_get_session_id() == 0) { |
|
255 | + echo '<div class="actions">'; |
|
256 | + if ($view_dropbox_category_sent != 0) { |
|
257 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
258 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
259 | + } else { |
|
260 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
261 | + } |
|
262 | + if (empty($viewSentCategory)) { |
|
263 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
264 | + } |
|
265 | + echo '</div>'; |
|
266 | + } else { |
|
267 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
268 | + echo '<div class="actions">'; |
|
269 | + if ($view_dropbox_category_sent != 0) { |
|
270 | + echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
271 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
272 | + } else { |
|
273 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
274 | + } |
|
275 | + if (empty($viewSentCategory)) { |
|
276 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
277 | + } |
|
278 | + echo '</div>'; |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + /* THE MENU TABS */ |
|
283 | + if ($showSentReceivedTabs) { |
|
284 | 284 | ?> |
285 | 285 | <ul class="nav nav-tabs"> |
286 | 286 | <li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> > |
@@ -294,80 +294,80 @@ discard block |
||
294 | 294 | </li> |
295 | 295 | </ul> |
296 | 296 | <?php |
297 | - } |
|
297 | + } |
|
298 | 298 | /* RECEIVED FILES */ |
299 | - if ($view == 'received' || !$showSentReceivedTabs) { |
|
300 | - // This is for the categories |
|
301 | - if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
302 | - $view_dropbox_category_received = $viewReceivedCategory; |
|
303 | - } else { |
|
304 | - $view_dropbox_category_received = 0; |
|
305 | - } |
|
306 | - |
|
307 | - // Object initialisation |
|
308 | - $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
309 | - // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? |
|
310 | - |
|
311 | - // Constructing the array that contains the total number of feedback messages per document. |
|
312 | - $number_feedback = get_total_number_feedback(); |
|
313 | - |
|
314 | - // Sorting and paging options |
|
315 | - $sorting_options = array(); |
|
316 | - $paging_options = array(); |
|
317 | - |
|
318 | - // The headers of the sortable tables |
|
319 | - $column_header = array(); |
|
320 | - $column_header[] = array('', false, ''); |
|
321 | - $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
322 | - $column_header[] = array(get_lang('ReceivedTitle'), true, ''); |
|
323 | - $column_header[] = array(get_lang('Size'), true, ''); |
|
324 | - $column_header[] = array(get_lang('Authors'), true, ''); |
|
325 | - $column_header[] = array(get_lang('LastResent'), true); |
|
326 | - |
|
327 | - if (api_get_session_id() == 0) { |
|
328 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
329 | - } elseif (api_is_allowed_to_session_edit(false,true)) { |
|
330 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
331 | - } |
|
332 | - |
|
333 | - $column_header[] = array('RealDate', true); |
|
334 | - $column_header[] = array('RealSize', true); |
|
335 | - |
|
336 | - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
337 | - $column_show[] = 1; |
|
338 | - $column_show[] = 1; |
|
339 | - $column_show[] = 1; |
|
340 | - $column_show[] = 1; |
|
341 | - $column_show[] = 1; |
|
342 | - $column_show[] = 1; |
|
343 | - |
|
344 | - if (api_get_session_id() == 0) { |
|
345 | - $column_show[] = 1; |
|
346 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
347 | - $column_show[] = 1; |
|
348 | - } |
|
349 | - $column_show[] = 0; |
|
350 | - |
|
351 | - // Here we change the way how the columns are going to be sort |
|
352 | - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
353 | - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
354 | - |
|
355 | - $column_order[3] = 8; |
|
356 | - $column_order[5] = 7; |
|
357 | - |
|
358 | - // The content of the sortable table = the received files |
|
359 | - foreach ($dropbox_person -> receivedWork as $dropbox_file) { |
|
360 | - $dropbox_file_data = array(); |
|
361 | - if ($view_dropbox_category_received == $dropbox_file->category) { |
|
299 | + if ($view == 'received' || !$showSentReceivedTabs) { |
|
300 | + // This is for the categories |
|
301 | + if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
302 | + $view_dropbox_category_received = $viewReceivedCategory; |
|
303 | + } else { |
|
304 | + $view_dropbox_category_received = 0; |
|
305 | + } |
|
306 | + |
|
307 | + // Object initialisation |
|
308 | + $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
309 | + // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? |
|
310 | + |
|
311 | + // Constructing the array that contains the total number of feedback messages per document. |
|
312 | + $number_feedback = get_total_number_feedback(); |
|
313 | + |
|
314 | + // Sorting and paging options |
|
315 | + $sorting_options = array(); |
|
316 | + $paging_options = array(); |
|
317 | + |
|
318 | + // The headers of the sortable tables |
|
319 | + $column_header = array(); |
|
320 | + $column_header[] = array('', false, ''); |
|
321 | + $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
322 | + $column_header[] = array(get_lang('ReceivedTitle'), true, ''); |
|
323 | + $column_header[] = array(get_lang('Size'), true, ''); |
|
324 | + $column_header[] = array(get_lang('Authors'), true, ''); |
|
325 | + $column_header[] = array(get_lang('LastResent'), true); |
|
326 | + |
|
327 | + if (api_get_session_id() == 0) { |
|
328 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
329 | + } elseif (api_is_allowed_to_session_edit(false,true)) { |
|
330 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
331 | + } |
|
332 | + |
|
333 | + $column_header[] = array('RealDate', true); |
|
334 | + $column_header[] = array('RealSize', true); |
|
335 | + |
|
336 | + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
337 | + $column_show[] = 1; |
|
338 | + $column_show[] = 1; |
|
339 | + $column_show[] = 1; |
|
340 | + $column_show[] = 1; |
|
341 | + $column_show[] = 1; |
|
342 | + $column_show[] = 1; |
|
343 | + |
|
344 | + if (api_get_session_id() == 0) { |
|
345 | + $column_show[] = 1; |
|
346 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
347 | + $column_show[] = 1; |
|
348 | + } |
|
349 | + $column_show[] = 0; |
|
350 | + |
|
351 | + // Here we change the way how the columns are going to be sort |
|
352 | + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
353 | + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
354 | + |
|
355 | + $column_order[3] = 8; |
|
356 | + $column_order[5] = 7; |
|
357 | + |
|
358 | + // The content of the sortable table = the received files |
|
359 | + foreach ($dropbox_person -> receivedWork as $dropbox_file) { |
|
360 | + $dropbox_file_data = array(); |
|
361 | + if ($view_dropbox_category_received == $dropbox_file->category) { |
|
362 | 362 | // we only display the files that are in the category that we are in. |
363 | - $dropbox_file_data[] = $dropbox_file->id; |
|
363 | + $dropbox_file_data[] = $dropbox_file->id; |
|
364 | 364 | |
365 | - if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { |
|
366 | - $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); |
|
367 | - } |
|
365 | + if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { |
|
366 | + $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); |
|
367 | + } |
|
368 | 368 | |
369 | - // New icon |
|
370 | - $new_icon = ''; |
|
369 | + // New icon |
|
370 | + $new_icon = ''; |
|
371 | 371 | if (isset($_SESSION['_seen'])) { |
372 | 372 | if ($dropbox_file->last_upload_date > $last_access && |
373 | 373 | !in_array( |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
388 | - $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
389 | - $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
387 | + $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
388 | + $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
389 | + $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
390 | 390 | Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description; |
391 | - $file_size = $dropbox_file->filesize; |
|
392 | - $dropbox_file_data[] = format_file_size($file_size); |
|
391 | + $file_size = $dropbox_file->filesize; |
|
392 | + $dropbox_file_data[] = format_file_size($file_size); |
|
393 | 393 | |
394 | 394 | $authorInfo = api_get_user_info($dropbox_file->uploader_id); |
395 | 395 | if ($authorInfo) { |
@@ -398,62 +398,62 @@ discard block |
||
398 | 398 | $dropbox_file_data[] = ''; |
399 | 399 | } |
400 | 400 | |
401 | - $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
402 | - $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
401 | + $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
402 | + $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
403 | 403 | api_format_date($last_upload_date).'</span>'; |
404 | 404 | |
405 | - $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
405 | + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
406 | 406 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a> |
407 | 407 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movereceived&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a> |
408 | 408 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'. |
409 | 409 | Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
410 | 410 | |
411 | - // This is a hack to have an additional row in a sortable table |
|
412 | - |
|
413 | - if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) { |
|
414 | - $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table |
|
415 | - $action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
416 | - } |
|
417 | - if (api_get_session_id() == 0) { |
|
418 | - $dropbox_file_data[] = $action_icons; |
|
419 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
420 | - $dropbox_file_data[] = $action_icons; |
|
421 | - } |
|
422 | - $action_icons = ''; |
|
423 | - $dropbox_file_data[] = $last_upload_date; |
|
424 | - $dropbox_file_data[] = $file_size; |
|
425 | - $dropbox_data_recieved[] = $dropbox_file_data; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - // The content of the sortable table = the categories (if we are not in the root) |
|
430 | - if ($view_dropbox_category_received == 0) { |
|
431 | - foreach ($dropbox_categories as $category) { |
|
432 | - /* Note: This can probably be shortened since the categories |
|
411 | + // This is a hack to have an additional row in a sortable table |
|
412 | + |
|
413 | + if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) { |
|
414 | + $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table |
|
415 | + $action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
416 | + } |
|
417 | + if (api_get_session_id() == 0) { |
|
418 | + $dropbox_file_data[] = $action_icons; |
|
419 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
420 | + $dropbox_file_data[] = $action_icons; |
|
421 | + } |
|
422 | + $action_icons = ''; |
|
423 | + $dropbox_file_data[] = $last_upload_date; |
|
424 | + $dropbox_file_data[] = $file_size; |
|
425 | + $dropbox_data_recieved[] = $dropbox_file_data; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + // The content of the sortable table = the categories (if we are not in the root) |
|
430 | + if ($view_dropbox_category_received == 0) { |
|
431 | + foreach ($dropbox_categories as $category) { |
|
432 | + /* Note: This can probably be shortened since the categories |
|
433 | 433 | for the received files are already in the |
434 | 434 | $dropbox_received_category array;*/ |
435 | - $dropbox_category_data = array(); |
|
436 | - if ($category['received'] == '1') { |
|
437 | - $movelist[$category['cat_id']] = $category['cat_name']; |
|
435 | + $dropbox_category_data = array(); |
|
436 | + if ($category['received'] == '1') { |
|
437 | + $movelist[$category['cat_id']] = $category['cat_name']; |
|
438 | 438 | // This is where the checkbox icon for the files appear |
439 | - $dropbox_category_data[] = $category['cat_id']; |
|
440 | - // The icon of the category |
|
441 | - $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">'; |
|
442 | - $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>'; |
|
443 | - $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>'; |
|
444 | - $dropbox_category_data[] = ''; |
|
445 | - $dropbox_category_data[] = ''; |
|
446 | - $dropbox_category_data[] = ''; |
|
447 | - $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
|
439 | + $dropbox_category_data[] = $category['cat_id']; |
|
440 | + // The icon of the category |
|
441 | + $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">'; |
|
442 | + $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>'; |
|
443 | + $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>'; |
|
444 | + $dropbox_category_data[] = ''; |
|
445 | + $dropbox_category_data[] = ''; |
|
446 | + $dropbox_category_data[] = ''; |
|
447 | + $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
|
448 | 448 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
449 | - } |
|
450 | - if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
451 | - $dropbox_data_recieved[] = $dropbox_category_data; |
|
452 | - } |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - // Displaying the table |
|
449 | + } |
|
450 | + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
451 | + $dropbox_data_recieved[] = $dropbox_category_data; |
|
452 | + } |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + // Displaying the table |
|
457 | 457 | $additional_get_parameters = array( |
458 | 458 | 'view' => $view, |
459 | 459 | 'view_received_category' => $viewReceivedCategory, |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | 'download_received' => get_lang('Download') |
465 | 465 | ); |
466 | 466 | |
467 | - if (is_array($movelist)) { |
|
468 | - foreach ($movelist as $catid => $catname){ |
|
469 | - $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname); |
|
470 | - } |
|
471 | - } |
|
467 | + if (is_array($movelist)) { |
|
468 | + foreach ($movelist as $catid => $catname){ |
|
469 | + $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname); |
|
470 | + } |
|
471 | + } |
|
472 | 472 | |
473 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
474 | - $selectlist = array(); |
|
475 | - } |
|
473 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
474 | + $selectlist = array(); |
|
475 | + } |
|
476 | 476 | echo '<div class="files-table">'; |
477 | 477 | Display::display_sortable_config_table( |
478 | 478 | 'dropbox', |
@@ -486,154 +486,154 @@ discard block |
||
486 | 486 | $selectlist |
487 | 487 | ); |
488 | 488 | echo '</div>'; |
489 | - } |
|
490 | - |
|
491 | - /* SENT FILES */ |
|
492 | - |
|
493 | - if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
494 | - // This is for the categories |
|
495 | - if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
496 | - $view_dropbox_category_sent = $viewSentCategory; |
|
497 | - } else { |
|
498 | - $view_dropbox_category_sent = 0; |
|
499 | - } |
|
500 | - |
|
501 | - // Object initialisation |
|
502 | - $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
503 | - |
|
504 | - // Constructing the array that contains the total number of feedback messages per document. |
|
505 | - $number_feedback = get_total_number_feedback(); |
|
506 | - |
|
507 | - // Sorting and paging options |
|
508 | - $sorting_options = array(); |
|
509 | - $paging_options = array(); |
|
510 | - |
|
511 | - // The headers of the sortable tables |
|
512 | - $column_header = array(); |
|
513 | - |
|
514 | - $column_header[] = array('', false, ''); |
|
515 | - $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
516 | - $column_header[] = array(get_lang('SentTitle'), true, ''); |
|
517 | - $column_header[] = array(get_lang('Size'), true, ''); |
|
518 | - $column_header[] = array(get_lang('SentTo'), true, ''); |
|
519 | - $column_header[] = array(get_lang('LastResent'), true, ''); |
|
520 | - |
|
521 | - if (api_get_session_id() == 0) { |
|
522 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
523 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
524 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
525 | - } |
|
526 | - |
|
527 | - $column_header[] = array('RealDate', true); |
|
528 | - $column_header[] = array('RealSize', true); |
|
529 | - |
|
530 | - $column_show = array(); |
|
531 | - $column_order = array(); |
|
532 | - |
|
533 | - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
534 | - $column_show[] = 1; |
|
535 | - $column_show[] = 1; |
|
536 | - $column_show[] = 1; |
|
537 | - $column_show[] = 1; |
|
538 | - $column_show[] = 1; |
|
539 | - $column_show[] = 1; |
|
540 | - if (api_get_session_id() == 0) { |
|
541 | - $column_show[] = 1; |
|
542 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
543 | - $column_show[] = 1; |
|
544 | - } |
|
545 | - $column_show[] = 0; |
|
546 | - |
|
547 | - // Here we change the way how the colums are going to be sort |
|
548 | - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
549 | - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
550 | - |
|
551 | - $column_order[3] = 8; |
|
552 | - $column_order[5] = 7; |
|
553 | - |
|
554 | - // The content of the sortable table = the received files |
|
555 | - foreach ($dropbox_person->sentWork as $dropbox_file) { |
|
556 | - $dropbox_file_data = array(); |
|
557 | - |
|
558 | - if ($view_dropbox_category_sent == $dropbox_file->category) { |
|
559 | - $dropbox_file_data[] = $dropbox_file->id; |
|
560 | - $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
561 | - $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
562 | - $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
489 | + } |
|
490 | + |
|
491 | + /* SENT FILES */ |
|
492 | + |
|
493 | + if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
494 | + // This is for the categories |
|
495 | + if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
496 | + $view_dropbox_category_sent = $viewSentCategory; |
|
497 | + } else { |
|
498 | + $view_dropbox_category_sent = 0; |
|
499 | + } |
|
500 | + |
|
501 | + // Object initialisation |
|
502 | + $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
503 | + |
|
504 | + // Constructing the array that contains the total number of feedback messages per document. |
|
505 | + $number_feedback = get_total_number_feedback(); |
|
506 | + |
|
507 | + // Sorting and paging options |
|
508 | + $sorting_options = array(); |
|
509 | + $paging_options = array(); |
|
510 | + |
|
511 | + // The headers of the sortable tables |
|
512 | + $column_header = array(); |
|
513 | + |
|
514 | + $column_header[] = array('', false, ''); |
|
515 | + $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
516 | + $column_header[] = array(get_lang('SentTitle'), true, ''); |
|
517 | + $column_header[] = array(get_lang('Size'), true, ''); |
|
518 | + $column_header[] = array(get_lang('SentTo'), true, ''); |
|
519 | + $column_header[] = array(get_lang('LastResent'), true, ''); |
|
520 | + |
|
521 | + if (api_get_session_id() == 0) { |
|
522 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
523 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
524 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
525 | + } |
|
526 | + |
|
527 | + $column_header[] = array('RealDate', true); |
|
528 | + $column_header[] = array('RealSize', true); |
|
529 | + |
|
530 | + $column_show = array(); |
|
531 | + $column_order = array(); |
|
532 | + |
|
533 | + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
534 | + $column_show[] = 1; |
|
535 | + $column_show[] = 1; |
|
536 | + $column_show[] = 1; |
|
537 | + $column_show[] = 1; |
|
538 | + $column_show[] = 1; |
|
539 | + $column_show[] = 1; |
|
540 | + if (api_get_session_id() == 0) { |
|
541 | + $column_show[] = 1; |
|
542 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
543 | + $column_show[] = 1; |
|
544 | + } |
|
545 | + $column_show[] = 0; |
|
546 | + |
|
547 | + // Here we change the way how the colums are going to be sort |
|
548 | + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
549 | + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
550 | + |
|
551 | + $column_order[3] = 8; |
|
552 | + $column_order[5] = 7; |
|
553 | + |
|
554 | + // The content of the sortable table = the received files |
|
555 | + foreach ($dropbox_person->sentWork as $dropbox_file) { |
|
556 | + $dropbox_file_data = array(); |
|
557 | + |
|
558 | + if ($view_dropbox_category_sent == $dropbox_file->category) { |
|
559 | + $dropbox_file_data[] = $dropbox_file->id; |
|
560 | + $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
561 | + $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
562 | + $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
563 | 563 | Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description; |
564 | - $file_size = $dropbox_file->filesize; |
|
565 | - $dropbox_file_data[] = format_file_size($file_size); |
|
564 | + $file_size = $dropbox_file->filesize; |
|
565 | + $dropbox_file_data[] = format_file_size($file_size); |
|
566 | 566 | $receivers_celldata = null; |
567 | - foreach ($dropbox_file->recipients as $recipient) { |
|
568 | - $userInfo = api_get_user_info($recipient['user_id']); |
|
569 | - $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata; |
|
570 | - } |
|
571 | - $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. |
|
572 | - $dropbox_file_data[] = $receivers_celldata; |
|
573 | - $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
574 | - $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
575 | - api_format_date($last_upload_date).'</span>'; |
|
576 | - |
|
577 | - //$dropbox_file_data[] = $dropbox_file->author; |
|
578 | - $receivers_celldata = ''; |
|
579 | - |
|
580 | - $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
567 | + foreach ($dropbox_file->recipients as $recipient) { |
|
568 | + $userInfo = api_get_user_info($recipient['user_id']); |
|
569 | + $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata; |
|
570 | + } |
|
571 | + $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. |
|
572 | + $dropbox_file_data[] = $receivers_celldata; |
|
573 | + $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
574 | + $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
575 | + api_format_date($last_upload_date).'</span>'; |
|
576 | + |
|
577 | + //$dropbox_file_data[] = $dropbox_file->author; |
|
578 | + $receivers_celldata = ''; |
|
579 | + |
|
580 | + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
581 | 581 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a> |
582 | 582 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movesent&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a> |
583 | 583 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
584 | - // This is a hack to have an additional row in a sortable table |
|
585 | - if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) { |
|
586 | - $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table |
|
587 | - $action_icons .= "<tr><td colspan=\"2\">"; |
|
588 | - $action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>"; |
|
589 | - $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
590 | - } |
|
591 | - $dropbox_file_data[] = $action_icons; |
|
592 | - $dropbox_file_data[] = $last_upload_date; |
|
593 | - $dropbox_file_data[] = $file_size; |
|
594 | - $action_icons = ''; |
|
595 | - $dropbox_data_sent[] = $dropbox_file_data; |
|
596 | - } |
|
597 | - } |
|
584 | + // This is a hack to have an additional row in a sortable table |
|
585 | + if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) { |
|
586 | + $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table |
|
587 | + $action_icons .= "<tr><td colspan=\"2\">"; |
|
588 | + $action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>"; |
|
589 | + $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
590 | + } |
|
591 | + $dropbox_file_data[] = $action_icons; |
|
592 | + $dropbox_file_data[] = $last_upload_date; |
|
593 | + $dropbox_file_data[] = $file_size; |
|
594 | + $action_icons = ''; |
|
595 | + $dropbox_data_sent[] = $dropbox_file_data; |
|
596 | + } |
|
597 | + } |
|
598 | 598 | |
599 | 599 | $moveList = array(); |
600 | - // The content of the sortable table = the categories (if we are not in the root) |
|
601 | - if ($view_dropbox_category_sent == 0) { |
|
602 | - foreach ($dropbox_categories as $category) { |
|
603 | - $dropbox_category_data = array(); |
|
600 | + // The content of the sortable table = the categories (if we are not in the root) |
|
601 | + if ($view_dropbox_category_sent == 0) { |
|
602 | + foreach ($dropbox_categories as $category) { |
|
603 | + $dropbox_category_data = array(); |
|
604 | 604 | |
605 | - if ($category['sent'] == '1') { |
|
605 | + if ($category['sent'] == '1') { |
|
606 | 606 | |
607 | 607 | $moveList[$category['cat_id']] = $category['cat_name']; |
608 | - $dropbox_category_data[] = $category['cat_id']; |
|
609 | - // This is where the checkbox icon for the files appear. |
|
610 | - $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">'; |
|
611 | - $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>'; |
|
612 | - $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>'; |
|
613 | - //$dropbox_category_data[] = ''; |
|
614 | - $dropbox_category_data[] = ''; |
|
615 | - //$dropbox_category_data[] = ''; |
|
616 | - $dropbox_category_data[] = ''; |
|
617 | - $dropbox_category_data[] = ''; |
|
618 | - $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'. |
|
608 | + $dropbox_category_data[] = $category['cat_id']; |
|
609 | + // This is where the checkbox icon for the files appear. |
|
610 | + $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">'; |
|
611 | + $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>'; |
|
612 | + $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>'; |
|
613 | + //$dropbox_category_data[] = ''; |
|
614 | + $dropbox_category_data[] = ''; |
|
615 | + //$dropbox_category_data[] = ''; |
|
616 | + $dropbox_category_data[] = ''; |
|
617 | + $dropbox_category_data[] = ''; |
|
618 | + $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'. |
|
619 | 619 | Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
620 | 620 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'. |
621 | 621 | Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
622 | - } |
|
623 | - if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
624 | - $dropbox_data_sent[] = $dropbox_category_data; |
|
625 | - } |
|
626 | - } |
|
627 | - } |
|
628 | - |
|
629 | - // Displaying the table |
|
630 | - $additional_get_parameters = array( |
|
622 | + } |
|
623 | + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
624 | + $dropbox_data_sent[] = $dropbox_category_data; |
|
625 | + } |
|
626 | + } |
|
627 | + } |
|
628 | + |
|
629 | + // Displaying the table |
|
630 | + $additional_get_parameters = array( |
|
631 | 631 | 'view' => $view, |
632 | 632 | 'view_received_category' => $viewReceivedCategory, |
633 | 633 | 'view_sent_category' => $viewSentCategory |
634 | 634 | ); |
635 | 635 | |
636 | - $selectlist = array( |
|
636 | + $selectlist = array( |
|
637 | 637 | 'delete_received' => get_lang('Delete'), |
638 | 638 | 'download_received' => get_lang('Download') |
639 | 639 | ); |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
648 | - $selectlist = array('download_received' => get_lang('Download')); |
|
649 | - } |
|
647 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
648 | + $selectlist = array('download_received' => get_lang('Download')); |
|
649 | + } |
|
650 | 650 | |
651 | 651 | echo '<div class="files-table">'; |
652 | - Display::display_sortable_config_table( |
|
652 | + Display::display_sortable_config_table( |
|
653 | 653 | 'dropbox', |
654 | 654 | $column_header, |
655 | 655 | $dropbox_data_sent, |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $selectlist |
662 | 662 | ); |
663 | 663 | echo '</div>'; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | Display::display_footer(); |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * private function creating a new work object |
|
81 | - * |
|
82 | - * @param int $uploader_id |
|
83 | - * @param string $title |
|
84 | - * @param string $description |
|
85 | - * @param string $author |
|
86 | - * @param string $filename |
|
87 | - * @param int $filesize |
|
88 | - * |
|
89 | - * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
90 | - * As a consequence this parameter can be removed |
|
91 | - */ |
|
92 | - public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
79 | + /** |
|
80 | + * private function creating a new work object |
|
81 | + * |
|
82 | + * @param int $uploader_id |
|
83 | + * @param string $title |
|
84 | + * @param string $description |
|
85 | + * @param string $author |
|
86 | + * @param string $filename |
|
87 | + * @param int $filesize |
|
88 | + * |
|
89 | + * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
90 | + * As a consequence this parameter can be removed |
|
91 | + */ |
|
92 | + public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
93 | 93 | { |
94 | 94 | // Fill in the properties |
95 | 95 | $this->uploader_id = intval($uploader_id); |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | // Check if object exists already. If it does, the old object is used |
105 | 105 | // with updated information (authors, description, upload_date) |
106 | 106 | $this->isOldWork = false; |
107 | - $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
107 | + $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
108 | 108 | WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'"; |
109 | 109 | $result = Database::query($sql); |
110 | - $res = Database::fetch_array($result); |
|
111 | - if ($res) { |
|
112 | - $this->isOldWork = true; |
|
113 | - } |
|
114 | - // Insert or update the dropbox_file table and set the id property |
|
115 | - if ($this->isOldWork) { |
|
116 | - $this->id = $res['id']; |
|
117 | - $this->upload_date = $res['upload_date']; |
|
110 | + $res = Database::fetch_array($result); |
|
111 | + if ($res) { |
|
112 | + $this->isOldWork = true; |
|
113 | + } |
|
114 | + // Insert or update the dropbox_file table and set the id property |
|
115 | + if ($this->isOldWork) { |
|
116 | + $this->id = $res['id']; |
|
117 | + $this->upload_date = $res['upload_date']; |
|
118 | 118 | |
119 | 119 | $params = [ |
120 | 120 | 'filesize' => $this->filesize, |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | $params, |
131 | 131 | ['c_id = ? AND id = ?' => [$course_id, $this->id]] |
132 | 132 | ); |
133 | - } else { |
|
134 | - $this->upload_date = $this->last_upload_date; |
|
135 | - $params = [ |
|
133 | + } else { |
|
134 | + $this->upload_date = $this->last_upload_date; |
|
135 | + $params = [ |
|
136 | 136 | 'c_id' => $course_id, |
137 | 137 | 'uploader_id' => $this->uploader_id, |
138 | 138 | 'filename' => $this->filename, |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | 'last_upload_date' => $this->last_upload_date, |
145 | 145 | 'session_id' => api_get_session_id(), |
146 | 146 | 'cat_id' => 0 |
147 | - ]; |
|
147 | + ]; |
|
148 | 148 | |
149 | - $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params); |
|
150 | - if ($this->id) { |
|
151 | - $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}"; |
|
152 | - Database::query($sql); |
|
153 | - } |
|
154 | - } |
|
149 | + $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params); |
|
150 | + if ($this->id) { |
|
151 | + $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}"; |
|
152 | + Database::query($sql); |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | 156 | $sql = "SELECT count(file_id) as count |
157 | 157 | FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")"; |
166 | 166 | Database::query($sql); |
167 | 167 | } |
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * private function creating existing object by retreiving info from db |
|
172 | - * |
|
173 | - * @param int $id |
|
174 | - */ |
|
175 | - public function _createExistingWork($id) |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * private function creating existing object by retreiving info from db |
|
172 | + * |
|
173 | + * @param int $id |
|
174 | + */ |
|
175 | + public function _createExistingWork($id) |
|
176 | 176 | { |
177 | - $course_id = api_get_course_int_id(); |
|
177 | + $course_id = api_get_course_int_id(); |
|
178 | 178 | |
179 | 179 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
180 | 180 | |
@@ -222,52 +222,52 @@ discard block |
||
222 | 222 | } |
223 | 223 | $this->feedback2= $feedback2; |
224 | 224 | } |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | class Dropbox_SentWork extends Dropbox_Work |
229 | 229 | { |
230 | - public $recipients; //array of ['id']['name'] arrays |
|
231 | - |
|
232 | - /** |
|
233 | - * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
234 | - * depending on the number of parameters |
|
235 | - * |
|
236 | - * @param unknown_type $arg1 |
|
237 | - * @param unknown_type $arg2 |
|
238 | - * @param unknown_type $arg3 |
|
239 | - * @param unknown_type $arg4 |
|
240 | - * @param unknown_type $arg5 |
|
241 | - * @param unknown_type $arg6 |
|
242 | - * @param unknown_type $arg7 |
|
243 | - * @return Dropbox_SentWork |
|
244 | - */ |
|
245 | - public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
230 | + public $recipients; //array of ['id']['name'] arrays |
|
231 | + |
|
232 | + /** |
|
233 | + * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
234 | + * depending on the number of parameters |
|
235 | + * |
|
236 | + * @param unknown_type $arg1 |
|
237 | + * @param unknown_type $arg2 |
|
238 | + * @param unknown_type $arg3 |
|
239 | + * @param unknown_type $arg4 |
|
240 | + * @param unknown_type $arg5 |
|
241 | + * @param unknown_type $arg6 |
|
242 | + * @param unknown_type $arg7 |
|
243 | + * @return Dropbox_SentWork |
|
244 | + */ |
|
245 | + public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
246 | 246 | { |
247 | - if (func_num_args() > 1) { |
|
248 | - $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
249 | - } else { |
|
250 | - $this->_createExistingSentWork($arg1); |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * private function creating a new SentWork object |
|
256 | - * |
|
257 | - * @param int $uploader_id |
|
258 | - * @param string $title |
|
259 | - * @param string $description |
|
260 | - * @param string $author |
|
261 | - * @param string $filename |
|
262 | - * @param int $filesize |
|
263 | - * @param array $recipient_ids |
|
264 | - */ |
|
265 | - public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
247 | + if (func_num_args() > 1) { |
|
248 | + $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
249 | + } else { |
|
250 | + $this->_createExistingSentWork($arg1); |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * private function creating a new SentWork object |
|
256 | + * |
|
257 | + * @param int $uploader_id |
|
258 | + * @param string $title |
|
259 | + * @param string $description |
|
260 | + * @param string $author |
|
261 | + * @param string $filename |
|
262 | + * @param int $filesize |
|
263 | + * @param array $recipient_ids |
|
264 | + */ |
|
265 | + public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
266 | 266 | { |
267 | 267 | $dropbox_cnf = getDropboxConf(); |
268 | 268 | $_course = api_get_course_info(); |
269 | 269 | |
270 | - // Call constructor of Dropbox_Work object |
|
270 | + // Call constructor of Dropbox_Work object |
|
271 | 271 | parent::__construct( |
272 | 272 | $uploader_id, |
273 | 273 | $title, |
@@ -277,33 +277,33 @@ discard block |
||
277 | 277 | $filesize |
278 | 278 | ); |
279 | 279 | |
280 | - $course_id = api_get_course_int_id(); |
|
281 | - |
|
282 | - // Do sanity checks on recipient_ids array & property fillin |
|
283 | - // The sanity check for ex-coursemembers is already done in base constructor |
|
284 | - $uploader_id = (int) $uploader_id; |
|
280 | + $course_id = api_get_course_int_id(); |
|
285 | 281 | |
286 | - $justSubmit = false; |
|
287 | - if (is_int($recipient_ids)) { |
|
288 | - $justSubmit = true; |
|
289 | - $recipient_ids = array($recipient_ids + $this->id); |
|
290 | - } elseif (count($recipient_ids) == 0) { |
|
291 | - $justSubmit = true; |
|
292 | - $recipient_ids = array($uploader_id); |
|
293 | - } |
|
282 | + // Do sanity checks on recipient_ids array & property fillin |
|
283 | + // The sanity check for ex-coursemembers is already done in base constructor |
|
284 | + $uploader_id = (int) $uploader_id; |
|
285 | + |
|
286 | + $justSubmit = false; |
|
287 | + if (is_int($recipient_ids)) { |
|
288 | + $justSubmit = true; |
|
289 | + $recipient_ids = array($recipient_ids + $this->id); |
|
290 | + } elseif (count($recipient_ids) == 0) { |
|
291 | + $justSubmit = true; |
|
292 | + $recipient_ids = array($uploader_id); |
|
293 | + } |
|
294 | 294 | |
295 | - if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
296 | - die(get_lang('GeneralError').' (code 209)'); |
|
297 | - } |
|
295 | + if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
296 | + die(get_lang('GeneralError').' (code 209)'); |
|
297 | + } |
|
298 | 298 | |
299 | - foreach ($recipient_ids as $rec) { |
|
300 | - if (empty($rec)) { |
|
301 | - continue; |
|
299 | + foreach ($recipient_ids as $rec) { |
|
300 | + if (empty($rec)) { |
|
301 | + continue; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | //this check is done when validating submitted data |
305 | - $this->recipients[] = array('id' => $rec); |
|
306 | - } |
|
305 | + $this->recipients[] = array('id' => $rec); |
|
306 | + } |
|
307 | 307 | |
308 | 308 | $table_post = Database::get_course_table(TABLE_DROPBOX_POST); |
309 | 309 | $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON); |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | $mailId = get_mail_id_base(); |
314 | 314 | |
315 | 315 | // Insert data in dropbox_post and dropbox_person table for each recipient |
316 | - foreach ($this->recipients as $rec) { |
|
316 | + foreach ($this->recipients as $rec) { |
|
317 | 317 | $file_id = (int)$this->id; |
318 | 318 | $user_id = (int)$rec['id']; |
319 | - $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
319 | + $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
320 | 320 | VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)"; |
321 | - Database::query($sql); |
|
321 | + Database::query($sql); |
|
322 | 322 | // If work already exists no error is generated |
323 | 323 | |
324 | 324 | /** |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - // Update item_property table for each recipient |
|
339 | - if (($ownerid = $this->uploader_id) > $mailId) { |
|
340 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
341 | - } |
|
342 | - if (($recipid = $rec["id"]) > $mailId) { |
|
343 | - $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
344 | - } |
|
338 | + // Update item_property table for each recipient |
|
339 | + if (($ownerid = $this->uploader_id) > $mailId) { |
|
340 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
341 | + } |
|
342 | + if (($recipid = $rec["id"]) > $mailId) { |
|
343 | + $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
344 | + } |
|
345 | 345 | api_item_property_update( |
346 | 346 | $_course, |
347 | 347 | TOOL_DROPBOX, |
@@ -351,90 +351,90 @@ discard block |
||
351 | 351 | null, |
352 | 352 | $recipid |
353 | 353 | ); |
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * private function creating existing object by retreiving info from db |
|
359 | - * |
|
360 | - * @param unknown_type $id |
|
361 | - */ |
|
362 | - public function _createExistingSentWork($id) |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * private function creating existing object by retreiving info from db |
|
359 | + * |
|
360 | + * @param unknown_type $id |
|
361 | + */ |
|
362 | + public function _createExistingSentWork($id) |
|
363 | 363 | { |
364 | 364 | $id = intval($id); |
365 | 365 | |
366 | - $course_id = api_get_course_int_id(); |
|
366 | + $course_id = api_get_course_int_id(); |
|
367 | 367 | |
368 | - // Call constructor of Dropbox_Work object |
|
369 | - parent::__construct($id); |
|
368 | + // Call constructor of Dropbox_Work object |
|
369 | + parent::__construct($id); |
|
370 | 370 | |
371 | - // Fill in recipients array |
|
372 | - $this->recipients = array(); |
|
373 | - $sql = "SELECT dest_user_id, feedback_date, feedback |
|
371 | + // Fill in recipients array |
|
372 | + $this->recipients = array(); |
|
373 | + $sql = "SELECT dest_user_id, feedback_date, feedback |
|
374 | 374 | FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
375 | 375 | WHERE c_id = $course_id AND file_id = ".intval($id).""; |
376 | 376 | $result = Database::query($sql); |
377 | - while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
378 | - // Check for deleted users |
|
379 | - $dest_user_id = $res['dest_user_id']; |
|
380 | - $user_info = api_get_user_info($dest_user_id); |
|
381 | - //$this->category = $res['cat_id']; |
|
382 | - if (!$user_info) { |
|
383 | - $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
384 | - } else { |
|
385 | - $this->recipients[] = array( |
|
377 | + while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
378 | + // Check for deleted users |
|
379 | + $dest_user_id = $res['dest_user_id']; |
|
380 | + $user_info = api_get_user_info($dest_user_id); |
|
381 | + //$this->category = $res['cat_id']; |
|
382 | + if (!$user_info) { |
|
383 | + $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
384 | + } else { |
|
385 | + $this->recipients[] = array( |
|
386 | 386 | 'id' => $dest_user_id, |
387 | 387 | 'name' => $user_info['complete_name'], |
388 | 388 | 'user_id' => $dest_user_id, |
389 | - 'feedback_date' => $res['feedback_date'], |
|
389 | + 'feedback_date' => $res['feedback_date'], |
|
390 | 390 | 'feedback' => $res['feedback'] |
391 | 391 | ); |
392 | - } |
|
393 | - } |
|
394 | - } |
|
392 | + } |
|
393 | + } |
|
394 | + } |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | class Dropbox_Person |
398 | 398 | { |
399 | - // The receivedWork and the sentWork arrays are sorted. |
|
400 | - public $receivedWork; // an array of Dropbox_Work objects |
|
401 | - public $sentWork; // an array of Dropbox_SentWork objects |
|
402 | - |
|
403 | - public $userId = 0; |
|
404 | - public $isCourseAdmin = false; |
|
405 | - public $isCourseTutor = false; |
|
406 | - public $_orderBy = ''; // private property that determines by which field |
|
407 | - |
|
408 | - /** |
|
409 | - * Constructor for recreating the Dropbox_Person object |
|
410 | - * |
|
411 | - * @param int $userId |
|
412 | - * @param bool $isCourseAdmin |
|
413 | - * @param bool $isCourseTutor |
|
414 | - * @return Dropbox_Person |
|
415 | - */ |
|
416 | - public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
399 | + // The receivedWork and the sentWork arrays are sorted. |
|
400 | + public $receivedWork; // an array of Dropbox_Work objects |
|
401 | + public $sentWork; // an array of Dropbox_SentWork objects |
|
402 | + |
|
403 | + public $userId = 0; |
|
404 | + public $isCourseAdmin = false; |
|
405 | + public $isCourseTutor = false; |
|
406 | + public $_orderBy = ''; // private property that determines by which field |
|
407 | + |
|
408 | + /** |
|
409 | + * Constructor for recreating the Dropbox_Person object |
|
410 | + * |
|
411 | + * @param int $userId |
|
412 | + * @param bool $isCourseAdmin |
|
413 | + * @param bool $isCourseTutor |
|
414 | + * @return Dropbox_Person |
|
415 | + */ |
|
416 | + public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
417 | 417 | { |
418 | - $course_id = api_get_course_int_id(); |
|
418 | + $course_id = api_get_course_int_id(); |
|
419 | 419 | |
420 | - // Fill in properties |
|
420 | + // Fill in properties |
|
421 | 421 | $this->userId = $userId; |
422 | 422 | $this->isCourseAdmin = $isCourseAdmin; |
423 | 423 | $this->isCourseTutor = $isCourseTutor; |
424 | 424 | $this->receivedWork = array(); |
425 | 425 | $this->sentWork = array(); |
426 | 426 | |
427 | - // Note: perhaps include an ex coursemember check to delete old files |
|
427 | + // Note: perhaps include an ex coursemember check to delete old files |
|
428 | 428 | |
429 | - $session_id = api_get_session_id(); |
|
430 | - $condition_session = api_get_session_condition($session_id); |
|
429 | + $session_id = api_get_session_id(); |
|
430 | + $condition_session = api_get_session_condition($session_id); |
|
431 | 431 | |
432 | - $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
433 | - $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
434 | - $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
432 | + $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
433 | + $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
434 | + $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
435 | 435 | |
436 | 436 | // Find all entries where this person is the recipient |
437 | - $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
437 | + $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
438 | 438 | FROM $post_tbl r |
439 | 439 | INNER JOIN $person_tbl p |
440 | 440 | ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id ) |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | r.dest_user_id = ".intval($this->userId)." $condition_session "; |
444 | 444 | |
445 | 445 | $result = Database::query($sql); |
446 | - while ($res = Database::fetch_array($result)) { |
|
447 | - $temp = new Dropbox_Work($res['file_id']); |
|
448 | - $temp->category = $res['cat_id']; |
|
449 | - $this->receivedWork[] = $temp; |
|
450 | - } |
|
451 | - // Find all entries where this person is the sender/uploader |
|
446 | + while ($res = Database::fetch_array($result)) { |
|
447 | + $temp = new Dropbox_Work($res['file_id']); |
|
448 | + $temp->category = $res['cat_id']; |
|
449 | + $this->receivedWork[] = $temp; |
|
450 | + } |
|
451 | + // Find all entries where this person is the sender/uploader |
|
452 | 452 | $sql = "SELECT DISTINCT f.id |
453 | 453 | FROM $file_tbl f |
454 | 454 | INNER JOIN $person_tbl p |
@@ -459,160 +459,160 @@ discard block |
||
459 | 459 | $condition_session |
460 | 460 | "; |
461 | 461 | $result = Database::query($sql); |
462 | - while ($res = Database::fetch_array($result)) { |
|
463 | - $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
464 | - } |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * Deletes all the received work of this person |
|
469 | - */ |
|
470 | - public function deleteAllReceivedWork() |
|
462 | + while ($res = Database::fetch_array($result)) { |
|
463 | + $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
464 | + } |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * Deletes all the received work of this person |
|
469 | + */ |
|
470 | + public function deleteAllReceivedWork() |
|
471 | 471 | { |
472 | - $course_id = api_get_course_int_id(); |
|
473 | - // Delete entries in person table concerning received works |
|
474 | - foreach ($this->receivedWork as $w) { |
|
472 | + $course_id = api_get_course_int_id(); |
|
473 | + // Delete entries in person table concerning received works |
|
474 | + foreach ($this->receivedWork as $w) { |
|
475 | 475 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
476 | 476 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
477 | - Database::query($sql); |
|
478 | - } |
|
477 | + Database::query($sql); |
|
478 | + } |
|
479 | 479 | // Check for unused files |
480 | - removeUnusedFiles(); |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Deletes all the received categories and work of this person |
|
485 | - * @param integer $id |
|
486 | - */ |
|
487 | - public function deleteReceivedWorkFolder($id) |
|
480 | + removeUnusedFiles(); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Deletes all the received categories and work of this person |
|
485 | + * @param integer $id |
|
486 | + */ |
|
487 | + public function deleteReceivedWorkFolder($id) |
|
488 | 488 | { |
489 | 489 | $course_id = api_get_course_int_id(); |
490 | 490 | |
491 | - $id = intval($id); |
|
492 | - $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
491 | + $id = intval($id); |
|
492 | + $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
493 | 493 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
494 | - if (!Database::query($sql)) return false; |
|
495 | - $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ." |
|
494 | + if (!Database::query($sql)) return false; |
|
495 | + $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ." |
|
496 | 496 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
497 | - if (!Database::query($sql)) return false; |
|
498 | - $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
|
497 | + if (!Database::query($sql)) return false; |
|
498 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
|
499 | 499 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
500 | - if (!Database::query($sql)) return false; |
|
501 | - return true; |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
505 | - * Deletes a received dropbox file of this person with id=$id |
|
506 | - * |
|
507 | - * @param integer $id |
|
508 | - */ |
|
509 | - public function deleteReceivedWork($id) |
|
500 | + if (!Database::query($sql)) return false; |
|
501 | + return true; |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * Deletes a received dropbox file of this person with id=$id |
|
506 | + * |
|
507 | + * @param integer $id |
|
508 | + */ |
|
509 | + public function deleteReceivedWork($id) |
|
510 | 510 | { |
511 | - $course_id = api_get_course_int_id(); |
|
512 | - $id = intval($id); |
|
513 | - |
|
514 | - // index check |
|
515 | - $found = false; |
|
516 | - foreach ($this->receivedWork as $w) { |
|
517 | - if ($w->id == $id) { |
|
518 | - $found = true; |
|
519 | - break; |
|
520 | - } |
|
521 | - } |
|
522 | - |
|
523 | - if (!$found) { |
|
524 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
525 | - die(get_lang('GeneralError').' (code 216)'); |
|
526 | - } |
|
527 | - } |
|
528 | - // Delete entries in person table concerning received works |
|
511 | + $course_id = api_get_course_int_id(); |
|
512 | + $id = intval($id); |
|
513 | + |
|
514 | + // index check |
|
515 | + $found = false; |
|
516 | + foreach ($this->receivedWork as $w) { |
|
517 | + if ($w->id == $id) { |
|
518 | + $found = true; |
|
519 | + break; |
|
520 | + } |
|
521 | + } |
|
522 | + |
|
523 | + if (!$found) { |
|
524 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
525 | + die(get_lang('GeneralError').' (code 216)'); |
|
526 | + } |
|
527 | + } |
|
528 | + // Delete entries in person table concerning received works |
|
529 | 529 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
530 | 530 | WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'"; |
531 | - Database::query($sql); |
|
532 | - removeUnusedFiles(); // Check for unused files |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * Deletes all the sent dropbox files of this person |
|
537 | - */ |
|
538 | - public function deleteAllSentWork() |
|
531 | + Database::query($sql); |
|
532 | + removeUnusedFiles(); // Check for unused files |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * Deletes all the sent dropbox files of this person |
|
537 | + */ |
|
538 | + public function deleteAllSentWork() |
|
539 | 539 | { |
540 | - $course_id = api_get_course_int_id(); |
|
541 | - //delete entries in person table concerning sent works |
|
542 | - foreach ($this->sentWork as $w) { |
|
540 | + $course_id = api_get_course_int_id(); |
|
541 | + //delete entries in person table concerning sent works |
|
542 | + foreach ($this->sentWork as $w) { |
|
543 | 543 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
544 | 544 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
545 | - Database::query($sql); |
|
546 | - removeMoreIfMailing($w->id); |
|
547 | - } |
|
548 | - removeUnusedFiles(); // Check for unused files |
|
549 | - } |
|
550 | - |
|
551 | - /** |
|
552 | - * Deletes a sent dropbox file of this person with id=$id |
|
553 | - * |
|
554 | - * @param unknown_type $id |
|
555 | - */ |
|
556 | - public function deleteSentWork($id) |
|
545 | + Database::query($sql); |
|
546 | + removeMoreIfMailing($w->id); |
|
547 | + } |
|
548 | + removeUnusedFiles(); // Check for unused files |
|
549 | + } |
|
550 | + |
|
551 | + /** |
|
552 | + * Deletes a sent dropbox file of this person with id=$id |
|
553 | + * |
|
554 | + * @param unknown_type $id |
|
555 | + */ |
|
556 | + public function deleteSentWork($id) |
|
557 | 557 | { |
558 | - $course_id = api_get_course_int_id(); |
|
559 | - |
|
560 | - $id = intval($id); |
|
561 | - |
|
562 | - // index check |
|
563 | - $found = false; |
|
564 | - foreach ($this->sentWork as $w) { |
|
565 | - if ($w->id == $id) { |
|
566 | - $found = true; |
|
567 | - break; |
|
568 | - } |
|
569 | - } |
|
570 | - if (!$found) { |
|
571 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
572 | - die(get_lang('GeneralError').' (code 219)'); |
|
573 | - } |
|
574 | - } |
|
575 | - //$file_id = $this->sentWork[$index]->id; |
|
576 | - // Delete entries in person table concerning sent works |
|
558 | + $course_id = api_get_course_int_id(); |
|
559 | + |
|
560 | + $id = intval($id); |
|
561 | + |
|
562 | + // index check |
|
563 | + $found = false; |
|
564 | + foreach ($this->sentWork as $w) { |
|
565 | + if ($w->id == $id) { |
|
566 | + $found = true; |
|
567 | + break; |
|
568 | + } |
|
569 | + } |
|
570 | + if (!$found) { |
|
571 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
572 | + die(get_lang('GeneralError').' (code 219)'); |
|
573 | + } |
|
574 | + } |
|
575 | + //$file_id = $this->sentWork[$index]->id; |
|
576 | + // Delete entries in person table concerning sent works |
|
577 | 577 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
578 | 578 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'"; |
579 | - Database::query($sql); |
|
580 | - removeMoreIfMailing($id); |
|
581 | - removeUnusedFiles(); // Check for unused files |
|
582 | - } |
|
583 | - |
|
584 | - /** |
|
585 | - * Updates feedback for received work of this person with id=$id |
|
586 | - * |
|
587 | - * @param string $id |
|
588 | - * @param string $text |
|
589 | - */ |
|
590 | - public function updateFeedback($id, $text) |
|
579 | + Database::query($sql); |
|
580 | + removeMoreIfMailing($id); |
|
581 | + removeUnusedFiles(); // Check for unused files |
|
582 | + } |
|
583 | + |
|
584 | + /** |
|
585 | + * Updates feedback for received work of this person with id=$id |
|
586 | + * |
|
587 | + * @param string $id |
|
588 | + * @param string $text |
|
589 | + */ |
|
590 | + public function updateFeedback($id, $text) |
|
591 | 591 | { |
592 | - $course_id = api_get_course_int_id(); |
|
592 | + $course_id = api_get_course_int_id(); |
|
593 | 593 | $_course = api_get_course_info(); |
594 | 594 | $dropbox_cnf = getDropboxConf(); |
595 | 595 | |
596 | - $id = intval($id); |
|
596 | + $id = intval($id); |
|
597 | 597 | |
598 | - // index check |
|
599 | - $found = false; |
|
600 | - $wi = -1; |
|
601 | - foreach ($this->receivedWork as $w) { |
|
602 | - $wi++; |
|
603 | - if ($w->id == $id){ |
|
604 | - $found = true; |
|
605 | - break; |
|
606 | - } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
607 | - } |
|
598 | + // index check |
|
599 | + $found = false; |
|
600 | + $wi = -1; |
|
601 | + foreach ($this->receivedWork as $w) { |
|
602 | + $wi++; |
|
603 | + if ($w->id == $id){ |
|
604 | + $found = true; |
|
605 | + break; |
|
606 | + } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
607 | + } |
|
608 | 608 | |
609 | - if (!$found) { |
|
610 | - return false; |
|
611 | - } |
|
609 | + if (!$found) { |
|
610 | + return false; |
|
611 | + } |
|
612 | 612 | |
613 | - $feedback_date = api_get_utc_datetime(); |
|
614 | - $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
615 | - $this->receivedWork[$wi]->feedback = $text; |
|
613 | + $feedback_date = api_get_utc_datetime(); |
|
614 | + $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
615 | + $this->receivedWork[$wi]->feedback = $text; |
|
616 | 616 | |
617 | 617 | $params = [ |
618 | 618 | 'feedback_date' => $feedback_date, |
@@ -630,11 +630,11 @@ discard block |
||
630 | 630 | ] |
631 | 631 | ); |
632 | 632 | |
633 | - // Update item_property table |
|
633 | + // Update item_property table |
|
634 | 634 | $mailId = get_mail_id_base(); |
635 | - if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) { |
|
636 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
637 | - } |
|
635 | + if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) { |
|
636 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
637 | + } |
|
638 | 638 | |
639 | 639 | api_item_property_update( |
640 | 640 | $_course, |
@@ -646,33 +646,33 @@ discard block |
||
646 | 646 | $ownerid |
647 | 647 | ); |
648 | 648 | |
649 | - } |
|
649 | + } |
|
650 | 650 | |
651 | - /** |
|
652 | - * Filter the received work |
|
653 | - * @param string $type |
|
654 | - * @param string $value |
|
655 | - */ |
|
656 | - public function filter_received_work($type, $value) |
|
651 | + /** |
|
652 | + * Filter the received work |
|
653 | + * @param string $type |
|
654 | + * @param string $value |
|
655 | + */ |
|
656 | + public function filter_received_work($type, $value) |
|
657 | 657 | { |
658 | 658 | $dropbox_cnf = getDropboxConf(); |
659 | - $new_received_work = array(); |
|
659 | + $new_received_work = array(); |
|
660 | 660 | $mailId = get_mail_id_base(); |
661 | 661 | foreach ($this->receivedWork as $work) { |
662 | - switch ($type) { |
|
663 | - case 'uploader_id': |
|
664 | - if ($work->uploader_id == $value || |
|
665 | - ($work->uploader_id > $mailId && |
|
662 | + switch ($type) { |
|
663 | + case 'uploader_id': |
|
664 | + if ($work->uploader_id == $value || |
|
665 | + ($work->uploader_id > $mailId && |
|
666 | 666 | getUserOwningThisMailing($work->uploader_id) == $value) |
667 | 667 | ) { |
668 | - $new_received_work[] = $work; |
|
669 | - } |
|
670 | - break; |
|
671 | - default: |
|
672 | - $new_received_work[] = $work; |
|
668 | + $new_received_work[] = $work; |
|
669 | + } |
|
670 | + break; |
|
671 | + default: |
|
672 | + $new_received_work[] = $work; |
|
673 | 673 | break; |
674 | - } |
|
675 | - } |
|
676 | - $this->receivedWork = $new_received_work; |
|
677 | - } |
|
674 | + } |
|
675 | + } |
|
676 | + $this->receivedWork = $new_received_work; |
|
677 | + } |
|
678 | 678 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | //Event::event_download($doc_url); |
24 | 24 | if (isset($_course['path'])) { |
25 | 25 | $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
26 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
26 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
27 | 27 | } else { |
28 | 28 | $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document'; |
29 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
29 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if(!is_file($full_file_name)) { |
33 | - exit; |
|
33 | + exit; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if (!Security::check_abs_path($full_file_name, $course_path.'/')) { |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | $extension=strtolower($extension[sizeof($extension)-1]); |
42 | 42 | |
43 | 43 | switch($extension) { |
44 | - case 'gz': $content_type='application/x-gzip'; break; |
|
45 | - case 'zip': $content_type='application/zip'; break; |
|
46 | - case 'pdf': $content_type='application/pdf'; break; |
|
47 | - case 'png': $content_type='image/png'; break; |
|
48 | - case 'gif': $content_type='image/gif'; break; |
|
49 | - case 'jpg': $content_type='image/jpeg'; break; |
|
50 | - case 'txt': $content_type='text/plain'; break; |
|
51 | - case 'htm': $content_type='text/html'; break; |
|
52 | - case 'html': $content_type='text/html'; break; |
|
53 | - default: $content_type='application/octet-stream'; break; |
|
44 | + case 'gz': $content_type='application/x-gzip'; break; |
|
45 | + case 'zip': $content_type='application/zip'; break; |
|
46 | + case 'pdf': $content_type='application/pdf'; break; |
|
47 | + case 'png': $content_type='image/png'; break; |
|
48 | + case 'gif': $content_type='image/gif'; break; |
|
49 | + case 'jpg': $content_type='image/jpeg'; break; |
|
50 | + case 'txt': $content_type='text/plain'; break; |
|
51 | + case 'htm': $content_type='text/html'; break; |
|
52 | + case 'html': $content_type='text/html'; break; |
|
53 | + default: $content_type='application/octet-stream'; break; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | header('Content-disposition: filename='.$filename); |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | */ |
69 | 69 | |
70 | 70 | if ($content_type == 'text/html') { |
71 | - $directory_name = dirname($full_file_name); |
|
71 | + $directory_name = dirname($full_file_name); |
|
72 | 72 | |
73 | - $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
73 | + $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
74 | 74 | |
75 | - if($dir[strlen($dir)-1] != '/') { |
|
76 | - $dir.='/'; |
|
77 | - } |
|
75 | + if($dir[strlen($dir)-1] != '/') { |
|
76 | + $dir.='/'; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - //Parse whole file at one |
|
81 | - $fp = fopen($full_file_name, "r"); |
|
82 | - $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | - fclose($fp); |
|
80 | + //Parse whole file at one |
|
81 | + $fp = fopen($full_file_name, "r"); |
|
82 | + $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | + fclose($fp); |
|
84 | 84 | $exercisePath = api_get_self(); |
85 | - $exfile = explode('/',$exercisePath); |
|
86 | - $exfile = $exfile[sizeof($exfile)-1]; |
|
87 | - $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
88 | - $exercisePath = $exercisePath; |
|
85 | + $exfile = explode('/',$exercisePath); |
|
86 | + $exfile = $exfile[sizeof($exfile)-1]; |
|
87 | + $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
88 | + $exercisePath = $exercisePath; |
|
89 | 89 | |
90 | - $content = $file_content; |
|
91 | - $mit = "function Finish(){"; |
|
90 | + $content = $file_content; |
|
91 | + $mit = "function Finish(){"; |
|
92 | 92 | |
93 | - $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
94 | - "function mySaveScore() // This function included by Dokeos System\n". |
|
93 | + $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
94 | + "function mySaveScore() // This function included by Dokeos System\n". |
|
95 | 95 | "{\n". |
96 | 96 | " if (SaveScoreVariable==0)\n". |
97 | 97 | " {\n". |
@@ -109,23 +109,23 @@ discard block |
||
109 | 109 | "// Must be included \n". |
110 | 110 | "function Finish(){\n". |
111 | 111 | " mySaveScore();"; |
112 | - $newcontent = str_replace($mit,$js_content,$content); |
|
112 | + $newcontent = str_replace($mit,$js_content,$content); |
|
113 | 113 | |
114 | - $prehref="javascript:void(0);"; |
|
115 | - $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
116 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
114 | + $prehref="javascript:void(0);"; |
|
115 | + $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
116 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
117 | 117 | |
118 | 118 | |
119 | - $prehref="class=\"GridNum\" onclick="; |
|
120 | - $posthref="class=\"GridNum\" onMouseover="; |
|
121 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
119 | + $prehref="class=\"GridNum\" onclick="; |
|
120 | + $posthref="class=\"GridNum\" onMouseover="; |
|
121 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
122 | 122 | |
123 | 123 | |
124 | - header('Content-length: '.strlen($newcontent)); |
|
125 | - // Dipsp. |
|
126 | - echo $newcontent; |
|
124 | + header('Content-length: '.strlen($newcontent)); |
|
125 | + // Dipsp. |
|
126 | + echo $newcontent; |
|
127 | 127 | |
128 | - exit(); |
|
128 | + exit(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | //normal case, all non-html files |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | */ |
83 | 83 | interface WSCMErrorHandler |
84 | 84 | { |
85 | - /** |
|
86 | - * Handle method |
|
87 | - * |
|
88 | - * @param WSError Error |
|
89 | - */ |
|
90 | - public function handle($error); |
|
85 | + /** |
|
86 | + * Handle method |
|
87 | + * |
|
88 | + * @param WSError Error |
|
89 | + */ |
|
90 | + public function handle($error); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,57 +95,57 @@ discard block |
||
95 | 95 | */ |
96 | 96 | class WSCM |
97 | 97 | { |
98 | - /** |
|
99 | - * Chamilo configuration |
|
100 | - * |
|
101 | - * @var array |
|
102 | - */ |
|
103 | - protected $_configuration; |
|
98 | + /** |
|
99 | + * Chamilo configuration |
|
100 | + * |
|
101 | + * @var array |
|
102 | + */ |
|
103 | + protected $_configuration; |
|
104 | 104 | |
105 | - /** |
|
106 | - * Constructor |
|
107 | - */ |
|
108 | - public function __construct() |
|
105 | + /** |
|
106 | + * Constructor |
|
107 | + */ |
|
108 | + public function __construct() |
|
109 | 109 | { |
110 | - $this->_configuration = $GLOBALS['_configuration']; |
|
111 | - } |
|
110 | + $this->_configuration = $GLOBALS['_configuration']; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Verifies the API key |
|
115 | - * |
|
116 | - * @param string Secret key |
|
117 | - * @return mixed WSError in case of failure, null in case of success |
|
118 | - */ |
|
119 | - protected function verifyKey($secret_key) |
|
113 | + /** |
|
114 | + * Verifies the API key |
|
115 | + * |
|
116 | + * @param string Secret key |
|
117 | + * @return mixed WSError in case of failure, null in case of success |
|
118 | + */ |
|
119 | + protected function verifyKey($secret_key) |
|
120 | 120 | { |
121 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
122 | - // if we are behind a reverse proxy, assume it will send the |
|
123 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
124 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
125 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
126 | - $ip = trim($ip1); |
|
127 | - } |
|
128 | - $security_key = $ip.$this->_configuration['security_key']; |
|
121 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
122 | + // if we are behind a reverse proxy, assume it will send the |
|
123 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
124 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
125 | + list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
126 | + $ip = trim($ip1); |
|
127 | + } |
|
128 | + $security_key = $ip.$this->_configuration['security_key']; |
|
129 | 129 | |
130 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
131 | - return new WSCMError(1, "API key is invalid"); |
|
132 | - } else { |
|
133 | - return null; |
|
134 | - } |
|
135 | - } |
|
130 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
131 | + return new WSCMError(1, "API key is invalid"); |
|
132 | + } else { |
|
133 | + return null; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Verifies if the user is valid |
|
139 | - * |
|
140 | - * @param <String> $username of the user in chamilo |
|
141 | - * @param <String> $pass of the same user (in MD5 of SHA) |
|
142 | - * |
|
143 | - * return "valid" if username e password are correct! Else, return a message error |
|
144 | - */ |
|
145 | - public function verifyUserPass($username, $pass) |
|
137 | + /** |
|
138 | + * Verifies if the user is valid |
|
139 | + * |
|
140 | + * @param <String> $username of the user in chamilo |
|
141 | + * @param <String> $pass of the same user (in MD5 of SHA) |
|
142 | + * |
|
143 | + * return "valid" if username e password are correct! Else, return a message error |
|
144 | + */ |
|
145 | + public function verifyUserPass($username, $pass) |
|
146 | 146 | { |
147 | - $login = $username; |
|
148 | - $password = $pass; |
|
147 | + $login = $username; |
|
148 | + $password = $pass; |
|
149 | 149 | |
150 | 150 | $userRepo = UserManager::getRepository(); |
151 | 151 | /** @var User $uData */ |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | return get_lang('InvalidId'); |
181 | - } |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Gets the real user id based on the user id field name and value. |
|
185 | - * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
186 | - * in the system database |
|
187 | - * |
|
188 | - * @param string User id field name |
|
189 | - * @param string User id value |
|
190 | - * @return mixed System user id if the user was found, WSError otherwise |
|
191 | - */ |
|
183 | + /** |
|
184 | + * Gets the real user id based on the user id field name and value. |
|
185 | + * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
186 | + * in the system database |
|
187 | + * |
|
188 | + * @param string User id field name |
|
189 | + * @param string User id value |
|
190 | + * @return mixed System user id if the user was found, WSError otherwise |
|
191 | + */ |
|
192 | 192 | protected function getUserId($user_id_field_name, $user_id_value) |
193 | 193 | { |
194 | 194 | if ($user_id_field_name == "chamilo_user_id") { |
@@ -210,16 +210,16 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - /** |
|
214 | - * Gets the real course id based on the course id field name and value. |
|
215 | - * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
216 | - * in the system database |
|
217 | - * |
|
218 | - * @param string Course id field name |
|
219 | - * @param string Course id value |
|
220 | - * @return mixed System course id if the course was found, WSError otherwise |
|
221 | - */ |
|
222 | - protected function getCourseId($course_id_field_name, $course_id_value) |
|
213 | + /** |
|
214 | + * Gets the real course id based on the course id field name and value. |
|
215 | + * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
216 | + * in the system database |
|
217 | + * |
|
218 | + * @param string Course id field name |
|
219 | + * @param string Course id value |
|
220 | + * @return mixed System course id if the course was found, WSError otherwise |
|
221 | + */ |
|
222 | + protected function getCourseId($course_id_field_name, $course_id_value) |
|
223 | 223 | { |
224 | 224 | if ($course_id_field_name == "chamilo_course_id") { |
225 | 225 | if (CourseManager::get_course_code_from_course_id($course_id_value) != null) { |
@@ -238,78 +238,78 @@ discard block |
||
238 | 238 | return $courseId; |
239 | 239 | } |
240 | 240 | } |
241 | - } |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Gets the real session id based on the session id field name and value. |
|
245 | - * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
246 | - * in the system database |
|
247 | - * |
|
248 | - * @param string Session id field name |
|
249 | - * @param string Session id value |
|
250 | - * @return mixed System session id if the session was found, WSError otherwise |
|
251 | - */ |
|
252 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
253 | - { |
|
254 | - if ($session_id_field_name == "chamilo_session_id") { |
|
255 | - $session = SessionManager::fetch((int)$session_id_value); |
|
256 | - if(!empty($session)) { |
|
257 | - return intval($session_id_value); |
|
258 | - } else { |
|
259 | - return new WSCMError(300, "Session not found"); |
|
260 | - } |
|
261 | - } else { |
|
262 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
263 | - $session_id_value, |
|
264 | - $session_id_field_name |
|
265 | - ); |
|
266 | - if($session_id == 0) { |
|
267 | - return new WSCMError(300, "Session not found"); |
|
268 | - } else { |
|
269 | - return $session_id; |
|
270 | - } |
|
271 | - } |
|
272 | - } |
|
243 | + /** |
|
244 | + * Gets the real session id based on the session id field name and value. |
|
245 | + * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
246 | + * in the system database |
|
247 | + * |
|
248 | + * @param string Session id field name |
|
249 | + * @param string Session id value |
|
250 | + * @return mixed System session id if the session was found, WSError otherwise |
|
251 | + */ |
|
252 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
253 | + { |
|
254 | + if ($session_id_field_name == "chamilo_session_id") { |
|
255 | + $session = SessionManager::fetch((int)$session_id_value); |
|
256 | + if(!empty($session)) { |
|
257 | + return intval($session_id_value); |
|
258 | + } else { |
|
259 | + return new WSCMError(300, "Session not found"); |
|
260 | + } |
|
261 | + } else { |
|
262 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
263 | + $session_id_value, |
|
264 | + $session_id_field_name |
|
265 | + ); |
|
266 | + if($session_id == 0) { |
|
267 | + return new WSCMError(300, "Session not found"); |
|
268 | + } else { |
|
269 | + return $session_id; |
|
270 | + } |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Handles an error by calling the WSError error handler |
|
276 | - * |
|
277 | - * @param WSError Error |
|
278 | - */ |
|
279 | - protected function handleError($error) |
|
280 | - { |
|
281 | - $handler = WSCMError::getErrorHandler(); |
|
282 | - $handler->handle($error); |
|
283 | - } |
|
274 | + /** |
|
275 | + * Handles an error by calling the WSError error handler |
|
276 | + * |
|
277 | + * @param WSError Error |
|
278 | + */ |
|
279 | + protected function handleError($error) |
|
280 | + { |
|
281 | + $handler = WSCMError::getErrorHandler(); |
|
282 | + $handler->handle($error); |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Gets a successful result |
|
287 | - * |
|
288 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
289 | - */ |
|
290 | - protected function getSuccessfulResult() |
|
291 | - { |
|
292 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
293 | - } |
|
285 | + /** |
|
286 | + * Gets a successful result |
|
287 | + * |
|
288 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
289 | + */ |
|
290 | + protected function getSuccessfulResult() |
|
291 | + { |
|
292 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * Test function. Returns the string success |
|
297 | - * |
|
298 | - * @return string Success |
|
299 | - */ |
|
300 | - public function test() |
|
301 | - { |
|
302 | - return "success"; |
|
303 | - } |
|
295 | + /** |
|
296 | + * Test function. Returns the string success |
|
297 | + * |
|
298 | + * @return string Success |
|
299 | + */ |
|
300 | + public function test() |
|
301 | + { |
|
302 | + return "success"; |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
307 | - * @param <type> $string |
|
308 | - * @return <type> $string |
|
309 | - */ |
|
310 | - public function nl2br_revert($string) |
|
305 | + /** |
|
306 | + * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
307 | + * @param <type> $string |
|
308 | + * @return <type> $string |
|
309 | + */ |
|
310 | + public function nl2br_revert($string) |
|
311 | 311 | { |
312 | - return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
313 | - } |
|
312 | + return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
313 | + } |
|
314 | 314 | } |
315 | 315 |
@@ -13,21 +13,21 @@ discard block |
||
13 | 13 | |
14 | 14 | public function find_id_user($username, $password, $name) |
15 | 15 | { |
16 | - if ($this->verifyUserPass($username, $password) == "valid") { |
|
16 | + if ($this->verifyUserPass($username, $password) == "valid") { |
|
17 | 17 | $listResult = "#"; |
18 | 18 | |
19 | 19 | $listArrayResult = Array(); |
20 | 20 | $listArray = Array(); |
21 | 21 | |
22 | 22 | $list = $this->get_user_list_like_start(array('firstname'=>$name), array('firstname')); |
23 | - foreach ($list as $userData) { |
|
24 | - $listArray[] = $userData['user_id']; |
|
25 | - } |
|
23 | + foreach ($list as $userData) { |
|
24 | + $listArray[] = $userData['user_id']; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | $list = $this->get_user_list_like_start(array('lastname'=>$name), array('firstname')); |
28 | - foreach ($list as $userData) { |
|
29 | - $listArray[] = $userData['user_id']; |
|
30 | - } |
|
28 | + foreach ($list as $userData) { |
|
29 | + $listArray[] = $userData['user_id']; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | $list = $this->get_user_list_like_start(array('email'=>$name), array('firstname')); |
33 | 33 | foreach ($list as $userData) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | global $charset; |
91 | 91 | if ($this->verifyUserPass($username, $password) == "valid") { |
92 | - $user_id = UserManager::get_user_id_from_username($username); |
|
92 | + $user_id = UserManager::get_user_id_from_username($username); |
|
93 | 93 | $message_title = get_lang('Invitation'); |
94 | 94 | $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
95 | 95 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | |
130 | 130 | |
131 | 131 | /** |
132 | - * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
133 | - * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
134 | - * @param array $order_by a list of fields on which sort |
|
135 | - * @return array An array with all users of the platform. |
|
136 | - * @todo optional course code parameter, optional sorting parameters... |
|
132 | + * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
133 | + * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
134 | + * @param array $order_by a list of fields on which sort |
|
135 | + * @return array An array with all users of the platform. |
|
136 | + * @todo optional course code parameter, optional sorting parameters... |
|
137 | 137 | *@todo Use the UserManager class |
138 | 138 | * @todo security filter order by |
139 | - */ |
|
139 | + */ |
|
140 | 140 | private static function get_user_list_like_start($conditions = array(), $order_by = array()) |
141 | 141 | { |
142 | 142 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -195,7 +195,7 @@ |
||
195 | 195 | $parentId = !$assignment ? 0 : $assignment->getId(); |
196 | 196 | |
197 | 197 | if (empty($session)) { |
198 | - $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
198 | + $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
199 | 199 | WHERE |
200 | 200 | a.cId = :course AND |
201 | 201 | a.active = :active AND |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | //stores the results |
15 | 15 | private $results = array(); |
16 | 16 | |
17 | - /** |
|
18 | - * Gets the results of all students (or just one student if access is limited) |
|
19 | - * @param string The document path (for HotPotatoes retrieval) |
|
20 | - * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | - * @param string $document_path |
|
22 | - */ |
|
23 | - public function getExercisesReporting($document_path, $hotpotato_name) |
|
17 | + /** |
|
18 | + * Gets the results of all students (or just one student if access is limited) |
|
19 | + * @param string The document path (for HotPotatoes retrieval) |
|
20 | + * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null |
|
21 | + * @param string $document_path |
|
22 | + */ |
|
23 | + public function getExercisesReporting($document_path, $hotpotato_name) |
|
24 | 24 | { |
25 | - $return = array(); |
|
25 | + $return = array(); |
|
26 | 26 | $TBL_USER = Database::get_main_table(TABLE_MAIN_USER); |
27 | 27 | $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); |
28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $hotpotato_name = Database::escape_string($hotpotato_name); |
35 | 35 | |
36 | 36 | if (!empty($exercise_id)) { |
37 | - $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
37 | + $session_id_and .= " AND exe_exo_id = $exercise_id "; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | if (empty($user_id)) { |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | $this->results = $return; |
112 | 112 | |
113 | 113 | return true; |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * Exports the complete report as a CSV file |
|
119 | - * @param string Document path inside the document tool |
|
120 | - * @param integer Optional user ID |
|
121 | - * @param boolean Whether to include user fields or not |
|
122 | - * @return boolean False on error |
|
123 | - */ |
|
124 | - public function exportCompleteReportCSV($document_path = '', $hotpotato_name) |
|
117 | + /** |
|
118 | + * Exports the complete report as a CSV file |
|
119 | + * @param string Document path inside the document tool |
|
120 | + * @param integer Optional user ID |
|
121 | + * @param boolean Whether to include user fields or not |
|
122 | + * @return boolean False on error |
|
123 | + */ |
|
124 | + public function exportCompleteReportCSV($document_path = '', $hotpotato_name) |
|
125 | 125 | { |
126 | - global $charset; |
|
127 | - $this->getExercisesReporting($document_path, $hotpotato_name); |
|
128 | - $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
129 | - if (!empty($user_id)) { |
|
130 | - $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
131 | - } |
|
132 | - $data = ''; |
|
126 | + global $charset; |
|
127 | + $this->getExercisesReporting($document_path, $hotpotato_name); |
|
128 | + $filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
129 | + if (!empty($user_id)) { |
|
130 | + $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; |
|
131 | + } |
|
132 | + $data = ''; |
|
133 | 133 | |
134 | 134 | if (api_is_western_name_order()) { |
135 | 135 | if(!empty($this->results[0]['first_name'])) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | $data .= get_lang('Email').';'; |
150 | 150 | |
151 | - /*if ($export_user_fields) { |
|
151 | + /*if ($export_user_fields) { |
|
152 | 152 | //show user fields section with a big th colspan that spans over all fields |
153 | 153 | $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
154 | 154 | $num = count($extra_user_fields); |
@@ -157,25 +157,25 @@ discard block |
||
157 | 157 | } |
158 | 158 | }*/ |
159 | 159 | |
160 | - $data .= get_lang('Title').';'; |
|
161 | - $data .= get_lang('StartDate').';'; |
|
162 | - $data .= get_lang('Score').';'; |
|
163 | - $data .= get_lang('Total').';'; |
|
164 | - $data .= "\n"; |
|
160 | + $data .= get_lang('Title').';'; |
|
161 | + $data .= get_lang('StartDate').';'; |
|
162 | + $data .= get_lang('Score').';'; |
|
163 | + $data .= get_lang('Total').';'; |
|
164 | + $data .= "\n"; |
|
165 | 165 | |
166 | - //results |
|
167 | - foreach($this->results as $row) { |
|
166 | + //results |
|
167 | + foreach($this->results as $row) { |
|
168 | 168 | if (api_is_western_name_order()) { |
169 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
170 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
169 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
170 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
171 | 171 | } else { |
172 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
173 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
172 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; |
|
173 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';'; |
177 | 177 | |
178 | - /*if ($export_user_fields) { |
|
178 | + /*if ($export_user_fields) { |
|
179 | 179 | //show user fields data, if any, for this user |
180 | 180 | $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
181 | 181 | foreach($user_fields_values as $value) { |
@@ -183,40 +183,40 @@ discard block |
||
183 | 183 | } |
184 | 184 | }*/ |
185 | 185 | |
186 | - $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
187 | - $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
188 | - $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
189 | - $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
190 | - $data .= "\n"; |
|
191 | - } |
|
192 | - |
|
193 | - //output the results |
|
194 | - $len = strlen($data); |
|
195 | - header('Content-type: application/octet-stream'); |
|
196 | - header('Content-Type: application/force-download'); |
|
197 | - header('Content-length: '.$len); |
|
198 | - if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
199 | - header('Content-Disposition: filename= '.$filename); |
|
200 | - } else { |
|
201 | - header('Content-Disposition: attachment; filename= '.$filename); |
|
202 | - } |
|
203 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
204 | - header('Pragma: '); |
|
205 | - header('Cache-Control: '); |
|
206 | - header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
207 | - } |
|
208 | - header('Content-Description: '.$filename); |
|
209 | - header('Content-transfer-encoding: binary'); |
|
210 | - // @todo add this utf-8 header for all csv files |
|
211 | - echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
212 | - echo $data; |
|
213 | - return true; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Exports the complete report as an XLS file |
|
218 | - * @return boolean False on error |
|
219 | - */ |
|
186 | + $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';'; |
|
187 | + $data .= str_replace("\r\n",' ',$row['exe_date']).';'; |
|
188 | + $data .= str_replace("\r\n",' ',$row['result']).';'; |
|
189 | + $data .= str_replace("\r\n",' ',$row['max']).';'; |
|
190 | + $data .= "\n"; |
|
191 | + } |
|
192 | + |
|
193 | + //output the results |
|
194 | + $len = strlen($data); |
|
195 | + header('Content-type: application/octet-stream'); |
|
196 | + header('Content-Type: application/force-download'); |
|
197 | + header('Content-length: '.$len); |
|
198 | + if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) { |
|
199 | + header('Content-Disposition: filename= '.$filename); |
|
200 | + } else { |
|
201 | + header('Content-Disposition: attachment; filename= '.$filename); |
|
202 | + } |
|
203 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { |
|
204 | + header('Pragma: '); |
|
205 | + header('Cache-Control: '); |
|
206 | + header('Cache-Control: public'); // IE cannot download from sessions without a cache |
|
207 | + } |
|
208 | + header('Content-Description: '.$filename); |
|
209 | + header('Content-transfer-encoding: binary'); |
|
210 | + // @todo add this utf-8 header for all csv files |
|
211 | + echo "\xEF\xBB\xBF"; // force utf-8 header of csv file |
|
212 | + echo $data; |
|
213 | + return true; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Exports the complete report as an XLS file |
|
218 | + * @return boolean False on error |
|
219 | + */ |
|
220 | 220 | public function exportCompleteReportXLS( |
221 | 221 | $document_path = '', |
222 | 222 | $user_id = null, |
@@ -225,36 +225,36 @@ discard block |
||
225 | 225 | $exercise_id = 0, |
226 | 226 | $hotpotato_name = null |
227 | 227 | ) { |
228 | - global $charset; |
|
229 | - $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
230 | - $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
231 | - if (!empty($user_id)) { |
|
232 | - $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
233 | - } |
|
228 | + global $charset; |
|
229 | + $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name); |
|
230 | + $filename = 'exercise_results_'.api_get_local_time().'.xls'; |
|
231 | + if (!empty($user_id)) { |
|
232 | + $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls'; |
|
233 | + } |
|
234 | 234 | |
235 | 235 | $spreadsheet = new PHPExcel(); |
236 | 236 | $spreadsheet->setActiveSheetIndex(0); |
237 | 237 | $worksheet = $spreadsheet->getActiveSheet(); |
238 | 238 | |
239 | 239 | |
240 | - $line = 0; |
|
241 | - $column = 0; //skip the first column (row titles) |
|
240 | + $line = 0; |
|
241 | + $column = 0; //skip the first column (row titles) |
|
242 | 242 | |
243 | - // check if exists column 'user' |
|
244 | - $with_column_user = false; |
|
245 | - foreach ($this->results as $result) { |
|
246 | - if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
247 | - $with_column_user = true; |
|
248 | - break; |
|
249 | - } |
|
250 | - } |
|
243 | + // check if exists column 'user' |
|
244 | + $with_column_user = false; |
|
245 | + foreach ($this->results as $result) { |
|
246 | + if (!empty($result['last_name']) && !empty($result['first_name'])) { |
|
247 | + $with_column_user = true; |
|
248 | + break; |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - if ($with_column_user) { |
|
253 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email')); |
|
254 | - $column++; |
|
252 | + if ($with_column_user) { |
|
253 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email')); |
|
254 | + $column++; |
|
255 | 255 | if (api_is_western_name_order()) { |
256 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); |
|
257 | - $column++; |
|
256 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); |
|
257 | + $column++; |
|
258 | 258 | $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName')); |
259 | 259 | $column++; |
260 | 260 | } else { |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName')); |
264 | 264 | $column++; |
265 | 265 | } |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if ($export_user_fields) { |
|
269 | - //show user fields section with a big th colspan that spans over all fields |
|
270 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
268 | + if ($export_user_fields) { |
|
269 | + //show user fields section with a big th colspan that spans over all fields |
|
270 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
271 | 271 | |
272 | - //show the fields names for user fields |
|
273 | - foreach ($extra_user_fields as $field) { |
|
272 | + //show the fields names for user fields |
|
273 | + foreach ($extra_user_fields as $field) { |
|
274 | 274 | $worksheet->setCellValueByColumnAndRow( |
275 | 275 | $column, |
276 | 276 | $line, |
@@ -280,27 +280,27 @@ discard block |
||
280 | 280 | $charset |
281 | 281 | ) |
282 | 282 | ); |
283 | - $column++; |
|
284 | - } |
|
285 | - } |
|
283 | + $column++; |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title')); |
|
288 | - $column++; |
|
289 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate')); |
|
287 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title')); |
|
288 | + $column++; |
|
289 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate')); |
|
290 | 290 | $column++; |
291 | 291 | $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate')); |
292 | 292 | $column++; |
293 | 293 | $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
294 | - $column++; |
|
295 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score')); |
|
296 | - $column++; |
|
297 | - $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total')); |
|
298 | - $column++; |
|
294 | + $column++; |
|
295 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score')); |
|
296 | + $column++; |
|
297 | + $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total')); |
|
298 | + $column++; |
|
299 | 299 | $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status')); |
300 | - $line++; |
|
300 | + $line++; |
|
301 | 301 | |
302 | - foreach ($this->results as $row) { |
|
303 | - $column = 0; |
|
302 | + foreach ($this->results as $row) { |
|
303 | + $column = 0; |
|
304 | 304 | |
305 | 305 | if ($with_column_user) { |
306 | 306 | $worksheet->setCellValueByColumnAndRow( |
@@ -325,38 +325,38 @@ discard block |
||
325 | 325 | $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
326 | 326 | $column++; |
327 | 327 | } |
328 | - } |
|
328 | + } |
|
329 | 329 | |
330 | - if ($export_user_fields) { |
|
331 | - //show user fields data, if any, for this user |
|
332 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
333 | - foreach($user_fields_values as $value) { |
|
334 | - $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
335 | - $column++; |
|
336 | - } |
|
337 | - } |
|
330 | + if ($export_user_fields) { |
|
331 | + //show user fields data, if any, for this user |
|
332 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
333 | + foreach($user_fields_values as $value) { |
|
334 | + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
335 | + $column++; |
|
336 | + } |
|
337 | + } |
|
338 | 338 | |
339 | - $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
340 | - $column++; |
|
341 | - $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']); |
|
339 | + $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
340 | + $column++; |
|
341 | + $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']); |
|
342 | 342 | $column++; |
343 | - $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']); |
|
343 | + $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']); |
|
344 | + $column++; |
|
345 | + $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']); |
|
346 | + $column++; |
|
347 | + $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']); |
|
348 | + $column++; |
|
349 | + $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']); |
|
344 | 350 | $column++; |
345 | - $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']); |
|
346 | - $column++; |
|
347 | - $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']); |
|
348 | - $column++; |
|
349 | - $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']); |
|
350 | - $column++; |
|
351 | 351 | $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']); |
352 | - $line++; |
|
353 | - } |
|
352 | + $line++; |
|
353 | + } |
|
354 | 354 | |
355 | 355 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
356 | 356 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
357 | 357 | $writer->save($file); |
358 | 358 | DocumentManager::file_send_for_download($file, true, $filename); |
359 | 359 | |
360 | - return true; |
|
361 | - } |
|
360 | + return true; |
|
361 | + } |
|
362 | 362 | } |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | $extend_link = ''; |
315 | 315 | if (!empty($inter_num)) { |
316 | 316 | $extend_link = Display::url( |
317 | - Display::return_icon('visible.gif', get_lang('HideAttemptView')), |
|
318 | - api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix |
|
317 | + Display::return_icon('visible.gif', get_lang('HideAttemptView')), |
|
318 | + api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | $title = $row['mytitle']; |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | $newDate = new DateTime('-30 days', new DateTimeZone('UTC')); |
1371 | 1371 | $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'"; |
1372 | 1372 | $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') "; |
1373 | - break; |
|
1373 | + break; |
|
1374 | 1374 | case 'custom': |
1375 | 1375 | if (!empty($start_date) && !empty($end_date)) { |
1376 | 1376 | $start_date = Database::escape_string($start_date); |
@@ -1380,10 +1380,10 @@ discard block |
||
1380 | 1380 | break; |
1381 | 1381 | } |
1382 | 1382 | |
1383 | - $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff |
|
1383 | + $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff |
|
1384 | 1384 | FROM '.$tbl_track_login.' |
1385 | 1385 | WHERE '.$userCondition.$condition_time; |
1386 | - $rs = Database::query($sql); |
|
1386 | + $rs = Database::query($sql); |
|
1387 | 1387 | $row = Database::fetch_array($rs, 'ASSOC'); |
1388 | 1388 | $diff = $row['diff']; |
1389 | 1389 | |
@@ -1405,18 +1405,18 @@ discard block |
||
1405 | 1405 | public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0) |
1406 | 1406 | { |
1407 | 1407 | $courseId = intval($courseId); |
1408 | - $session_id = intval($session_id); |
|
1409 | - |
|
1410 | - $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1411 | - if (is_array($user_id)) { |
|
1412 | - $user_id = array_map('intval', $user_id); |
|
1413 | - $condition_user = " AND user_id IN (".implode(',',$user_id).") "; |
|
1414 | - } else { |
|
1415 | - $user_id = intval($user_id); |
|
1416 | - $condition_user = " AND user_id = $user_id "; |
|
1417 | - } |
|
1418 | - |
|
1419 | - $sql = "SELECT |
|
1408 | + $session_id = intval($session_id); |
|
1409 | + |
|
1410 | + $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1411 | + if (is_array($user_id)) { |
|
1412 | + $user_id = array_map('intval', $user_id); |
|
1413 | + $condition_user = " AND user_id IN (".implode(',',$user_id).") "; |
|
1414 | + } else { |
|
1415 | + $user_id = intval($user_id); |
|
1416 | + $condition_user = " AND user_id = $user_id "; |
|
1417 | + } |
|
1418 | + |
|
1419 | + $sql = "SELECT |
|
1420 | 1420 | SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds |
1421 | 1421 | FROM $tbl_track_course |
1422 | 1422 | WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) "; |
@@ -1431,9 +1431,9 @@ discard block |
||
1431 | 1431 | |
1432 | 1432 | $sql .= $condition_user; |
1433 | 1433 | $rs = Database::query($sql); |
1434 | - $row = Database::fetch_array($rs); |
|
1434 | + $row = Database::fetch_array($rs); |
|
1435 | 1435 | |
1436 | - return $row['nb_seconds']; |
|
1436 | + return $row['nb_seconds']; |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | /** |
@@ -1444,25 +1444,25 @@ discard block |
||
1444 | 1444 | */ |
1445 | 1445 | public static function get_first_connection_date($student_id) |
1446 | 1446 | { |
1447 | - $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1448 | - $sql = 'SELECT login_date |
|
1447 | + $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1448 | + $sql = 'SELECT login_date |
|
1449 | 1449 | FROM ' . $tbl_track_login . ' |
1450 | 1450 | WHERE login_user_id = ' . intval($student_id) . ' |
1451 | 1451 | ORDER BY login_date ASC |
1452 | 1452 | LIMIT 0,1'; |
1453 | 1453 | |
1454 | - $rs = Database::query($sql); |
|
1455 | - if (Database::num_rows($rs)>0) { |
|
1456 | - if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1454 | + $rs = Database::query($sql); |
|
1455 | + if (Database::num_rows($rs)>0) { |
|
1456 | + if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1457 | 1457 | return api_convert_and_format_date( |
1458 | 1458 | $first_login_date, |
1459 | 1459 | DATE_FORMAT_SHORT, |
1460 | 1460 | date_default_timezone_get() |
1461 | 1461 | ); |
1462 | - } |
|
1463 | - } |
|
1462 | + } |
|
1463 | + } |
|
1464 | 1464 | |
1465 | - return false; |
|
1465 | + return false; |
|
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | /** |
@@ -1475,38 +1475,38 @@ discard block |
||
1475 | 1475 | */ |
1476 | 1476 | public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false) |
1477 | 1477 | { |
1478 | - $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1479 | - $sql = 'SELECT login_date |
|
1478 | + $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1479 | + $sql = 'SELECT login_date |
|
1480 | 1480 | FROM ' . $table . ' |
1481 | 1481 | WHERE login_user_id = ' . intval($student_id) . ' |
1482 | 1482 | ORDER BY login_date |
1483 | 1483 | DESC LIMIT 0,1'; |
1484 | 1484 | |
1485 | - $rs = Database::query($sql); |
|
1486 | - if (Database::num_rows($rs) > 0) { |
|
1487 | - if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1488 | - $last_login_date = api_get_local_time($last_login_date); |
|
1489 | - if ($return_timestamp) { |
|
1490 | - return api_strtotime($last_login_date,'UTC'); |
|
1491 | - } else { |
|
1492 | - if (!$warning_message) { |
|
1493 | - return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1494 | - } else { |
|
1495 | - $timestamp = api_strtotime($last_login_date,'UTC'); |
|
1496 | - $currentTimestamp = time(); |
|
1497 | - |
|
1498 | - //If the last connection is > than 7 days, the text is red |
|
1499 | - //345600 = 7 days in seconds |
|
1500 | - if ($currentTimestamp - $timestamp > 604800) { |
|
1501 | - return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>'; |
|
1502 | - } else { |
|
1503 | - return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1504 | - } |
|
1505 | - } |
|
1506 | - } |
|
1507 | - } |
|
1508 | - } |
|
1509 | - return false; |
|
1485 | + $rs = Database::query($sql); |
|
1486 | + if (Database::num_rows($rs) > 0) { |
|
1487 | + if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1488 | + $last_login_date = api_get_local_time($last_login_date); |
|
1489 | + if ($return_timestamp) { |
|
1490 | + return api_strtotime($last_login_date,'UTC'); |
|
1491 | + } else { |
|
1492 | + if (!$warning_message) { |
|
1493 | + return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1494 | + } else { |
|
1495 | + $timestamp = api_strtotime($last_login_date,'UTC'); |
|
1496 | + $currentTimestamp = time(); |
|
1497 | + |
|
1498 | + //If the last connection is > than 7 days, the text is red |
|
1499 | + //345600 = 7 days in seconds |
|
1500 | + if ($currentTimestamp - $timestamp > 604800) { |
|
1501 | + return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>'; |
|
1502 | + } else { |
|
1503 | + return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1504 | + } |
|
1505 | + } |
|
1506 | + } |
|
1507 | + } |
|
1508 | + } |
|
1509 | + return false; |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | 1512 | /** |
@@ -1560,30 +1560,30 @@ discard block |
||
1560 | 1560 | $session_id = 0, |
1561 | 1561 | $convert_date = true |
1562 | 1562 | ) { |
1563 | - $student_id = intval($student_id); |
|
1563 | + $student_id = intval($student_id); |
|
1564 | 1564 | $courseId = intval($courseId); |
1565 | - $session_id = intval($session_id); |
|
1565 | + $session_id = intval($session_id); |
|
1566 | 1566 | |
1567 | - $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1568 | - $sql = 'SELECT login_course_date |
|
1567 | + $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1568 | + $sql = 'SELECT login_course_date |
|
1569 | 1569 | FROM '.$tbl_track_login.' |
1570 | 1570 | WHERE |
1571 | 1571 | user_id = '.$student_id.' AND |
1572 | 1572 | c_id = '.$courseId.' AND |
1573 | 1573 | session_id = '.$session_id.' |
1574 | 1574 | ORDER BY login_course_date ASC LIMIT 0,1'; |
1575 | - $rs = Database::query($sql); |
|
1576 | - if (Database::num_rows($rs) > 0) { |
|
1577 | - if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1578 | - if ($convert_date) { |
|
1579 | - return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT); |
|
1580 | - } else { |
|
1581 | - return $first_login_date; |
|
1582 | - } |
|
1583 | - } |
|
1584 | - } |
|
1585 | - |
|
1586 | - return false; |
|
1575 | + $rs = Database::query($sql); |
|
1576 | + if (Database::num_rows($rs) > 0) { |
|
1577 | + if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1578 | + if ($convert_date) { |
|
1579 | + return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT); |
|
1580 | + } else { |
|
1581 | + return $first_login_date; |
|
1582 | + } |
|
1583 | + } |
|
1584 | + } |
|
1585 | + |
|
1586 | + return false; |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | /** |
@@ -1599,13 +1599,13 @@ discard block |
||
1599 | 1599 | $session_id = 0, |
1600 | 1600 | $convert_date = true |
1601 | 1601 | ) { |
1602 | - // protect data |
|
1603 | - $student_id = intval($student_id); |
|
1602 | + // protect data |
|
1603 | + $student_id = intval($student_id); |
|
1604 | 1604 | $courseId = $courseInfo['real_id']; |
1605 | - $session_id = intval($session_id); |
|
1605 | + $session_id = intval($session_id); |
|
1606 | 1606 | |
1607 | - $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
1608 | - $sql = 'SELECT access_date |
|
1607 | + $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
1608 | + $sql = 'SELECT access_date |
|
1609 | 1609 | FROM '.$tbl_track_e_access.' |
1610 | 1610 | WHERE access_user_id = '.$student_id.' AND |
1611 | 1611 | c_id = "'.$courseId.'" AND |
@@ -1613,39 +1613,39 @@ discard block |
||
1613 | 1613 | ORDER BY access_date DESC |
1614 | 1614 | LIMIT 0,1'; |
1615 | 1615 | |
1616 | - $rs = Database::query($sql); |
|
1617 | - if (Database::num_rows($rs) > 0) { |
|
1618 | - if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1616 | + $rs = Database::query($sql); |
|
1617 | + if (Database::num_rows($rs) > 0) { |
|
1618 | + if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1619 | 1619 | if (empty($last_login_date)) { |
1620 | 1620 | return false; |
1621 | 1621 | } |
1622 | 1622 | //see #5736 |
1623 | 1623 | $last_login_date_timestamp = api_strtotime($last_login_date); |
1624 | - $now = time(); |
|
1625 | - //If the last connection is > than 7 days, the text is red |
|
1626 | - //345600 = 7 days in seconds |
|
1627 | - if ($now - $last_login_date_timestamp > 604800) { |
|
1628 | - if ($convert_date) { |
|
1624 | + $now = time(); |
|
1625 | + //If the last connection is > than 7 days, the text is red |
|
1626 | + //345600 = 7 days in seconds |
|
1627 | + if ($now - $last_login_date_timestamp > 604800) { |
|
1628 | + if ($convert_date) { |
|
1629 | 1629 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
1630 | 1630 | $icon = api_is_allowed_to_edit() ? |
1631 | 1631 | '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'"> |
1632 | 1632 | '.Display::return_icon('messagebox_warning.gif').' |
1633 | 1633 | </a>' |
1634 | 1634 | : null; |
1635 | - return $icon. Display::label($last_login_date, 'warning'); |
|
1636 | - } else { |
|
1637 | - return $last_login_date; |
|
1638 | - } |
|
1639 | - } else { |
|
1640 | - if ($convert_date) { |
|
1641 | - return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1642 | - } else { |
|
1643 | - return $last_login_date; |
|
1644 | - } |
|
1645 | - } |
|
1646 | - } |
|
1647 | - } |
|
1648 | - return false; |
|
1635 | + return $icon. Display::label($last_login_date, 'warning'); |
|
1636 | + } else { |
|
1637 | + return $last_login_date; |
|
1638 | + } |
|
1639 | + } else { |
|
1640 | + if ($convert_date) { |
|
1641 | + return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1642 | + } else { |
|
1643 | + return $last_login_date; |
|
1644 | + } |
|
1645 | + } |
|
1646 | + } |
|
1647 | + } |
|
1648 | + return false; |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | /** |
@@ -1659,11 +1659,11 @@ discard block |
||
1659 | 1659 | public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null) |
1660 | 1660 | { |
1661 | 1661 | if ($start < 0) { |
1662 | - $start = 0; |
|
1663 | - } |
|
1664 | - if (!isset($stop) or ($stop < 0)) { |
|
1665 | - $stop = api_get_utc_datetime(); |
|
1666 | - } |
|
1662 | + $start = 0; |
|
1663 | + } |
|
1664 | + if (!isset($stop) or ($stop < 0)) { |
|
1665 | + $stop = api_get_utc_datetime(); |
|
1666 | + } |
|
1667 | 1667 | |
1668 | 1668 | // Given we're storing in cache, round the start and end times |
1669 | 1669 | // to the lower minute |
@@ -1672,11 +1672,11 @@ discard block |
||
1672 | 1672 | $roundedStart = Database::escape_string($roundedStart); |
1673 | 1673 | $roundedStop = Database::escape_string($roundedStop); |
1674 | 1674 | |
1675 | - $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' "; |
|
1675 | + $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' "; |
|
1676 | 1676 | |
1677 | 1677 | $courseId = intval($courseId); |
1678 | - $session_id = intval($session_id); |
|
1679 | - $count = 0; |
|
1678 | + $session_id = intval($session_id); |
|
1679 | + $count = 0; |
|
1680 | 1680 | $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
1681 | 1681 | $sql = "SELECT count(*) as count_connections |
1682 | 1682 | FROM $tbl_track_e_course_access |
@@ -1715,7 +1715,7 @@ discard block |
||
1715 | 1715 | } |
1716 | 1716 | } |
1717 | 1717 | |
1718 | - return $count; |
|
1718 | + return $count; |
|
1719 | 1719 | } |
1720 | 1720 | |
1721 | 1721 | /** |
@@ -1726,25 +1726,25 @@ discard block |
||
1726 | 1726 | */ |
1727 | 1727 | public static function count_course_per_student($user_id, $include_sessions = true) |
1728 | 1728 | { |
1729 | - $user_id = intval($user_id); |
|
1730 | - $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
1731 | - $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
1729 | + $user_id = intval($user_id); |
|
1730 | + $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
1731 | + $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
1732 | 1732 | |
1733 | - $sql = 'SELECT DISTINCT c_id |
|
1733 | + $sql = 'SELECT DISTINCT c_id |
|
1734 | 1734 | FROM ' . $tbl_course_rel_user . ' |
1735 | 1735 | WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH; |
1736 | - $rs = Database::query($sql); |
|
1737 | - $nb_courses = Database::num_rows($rs); |
|
1736 | + $rs = Database::query($sql); |
|
1737 | + $nb_courses = Database::num_rows($rs); |
|
1738 | 1738 | |
1739 | - if ($include_sessions) { |
|
1740 | - $sql = 'SELECT DISTINCT c_id |
|
1739 | + if ($include_sessions) { |
|
1740 | + $sql = 'SELECT DISTINCT c_id |
|
1741 | 1741 | FROM ' . $tbl_session_course_rel_user . ' |
1742 | 1742 | WHERE user_id = ' . $user_id; |
1743 | - $rs = Database::query($sql); |
|
1744 | - $nb_courses += Database::num_rows($rs); |
|
1745 | - } |
|
1743 | + $rs = Database::query($sql); |
|
1744 | + $nb_courses += Database::num_rows($rs); |
|
1745 | + } |
|
1746 | 1746 | |
1747 | - return $nb_courses; |
|
1747 | + return $nb_courses; |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | /** |
@@ -1775,25 +1775,25 @@ discard block |
||
1775 | 1775 | $into_lp = 0 |
1776 | 1776 | ) { |
1777 | 1777 | $course_code = Database::escape_string($course_code); |
1778 | - $course_info = api_get_course_info($course_code); |
|
1779 | - if (!empty($course_info)) { |
|
1780 | - // table definition |
|
1781 | - $tbl_course_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1782 | - $tbl_stats_exercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1783 | - |
|
1784 | - // Compose a filter based on optional exercise given |
|
1785 | - $condition_quiz = ""; |
|
1786 | - if (!empty($exercise_id)) { |
|
1787 | - $exercise_id = intval($exercise_id); |
|
1788 | - $condition_quiz =" AND id = $exercise_id "; |
|
1789 | - } |
|
1790 | - |
|
1791 | - // Compose a filter based on optional session id given |
|
1792 | - $condition_session = ""; |
|
1793 | - if (isset($session_id)) { |
|
1794 | - $session_id = intval($session_id); |
|
1795 | - $condition_session = " AND session_id = $session_id "; |
|
1796 | - } |
|
1778 | + $course_info = api_get_course_info($course_code); |
|
1779 | + if (!empty($course_info)) { |
|
1780 | + // table definition |
|
1781 | + $tbl_course_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1782 | + $tbl_stats_exercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1783 | + |
|
1784 | + // Compose a filter based on optional exercise given |
|
1785 | + $condition_quiz = ""; |
|
1786 | + if (!empty($exercise_id)) { |
|
1787 | + $exercise_id = intval($exercise_id); |
|
1788 | + $condition_quiz =" AND id = $exercise_id "; |
|
1789 | + } |
|
1790 | + |
|
1791 | + // Compose a filter based on optional session id given |
|
1792 | + $condition_session = ""; |
|
1793 | + if (isset($session_id)) { |
|
1794 | + $session_id = intval($session_id); |
|
1795 | + $condition_session = " AND session_id = $session_id "; |
|
1796 | + } |
|
1797 | 1797 | if ($active_filter == 1) { |
1798 | 1798 | $condition_active = 'AND active <> -1'; |
1799 | 1799 | } elseif ($active_filter == 0) { |
@@ -1809,7 +1809,7 @@ discard block |
||
1809 | 1809 | $select_lp_id = ', orig_lp_id as lp_id '; |
1810 | 1810 | } |
1811 | 1811 | |
1812 | - $sql = "SELECT count(id) FROM $tbl_course_quiz |
|
1812 | + $sql = "SELECT count(id) FROM $tbl_course_quiz |
|
1813 | 1813 | WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz "; |
1814 | 1814 | $count_quiz = 0; |
1815 | 1815 | $countQuizResult = Database::query($sql); |
@@ -1817,21 +1817,21 @@ discard block |
||
1817 | 1817 | $count_quiz = Database::fetch_row($countQuizResult); |
1818 | 1818 | } |
1819 | 1819 | |
1820 | - if (!empty($count_quiz[0]) && !empty($student_id)) { |
|
1821 | - if (is_array($student_id)) { |
|
1820 | + if (!empty($count_quiz[0]) && !empty($student_id)) { |
|
1821 | + if (is_array($student_id)) { |
|
1822 | 1822 | $student_id = array_map('intval', $student_id); |
1823 | - $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") "; |
|
1824 | - } else { |
|
1823 | + $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") "; |
|
1824 | + } else { |
|
1825 | 1825 | $student_id = intval($student_id); |
1826 | - $condition_user = " AND exe_user_id = '$student_id' "; |
|
1827 | - } |
|
1826 | + $condition_user = " AND exe_user_id = '$student_id' "; |
|
1827 | + } |
|
1828 | 1828 | |
1829 | - if (empty($exercise_id)) { |
|
1830 | - $sql = "SELECT id FROM $tbl_course_quiz |
|
1829 | + if (empty($exercise_id)) { |
|
1830 | + $sql = "SELECT id FROM $tbl_course_quiz |
|
1831 | 1831 | WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz"; |
1832 | 1832 | $result = Database::query($sql); |
1833 | 1833 | $exercise_list = array(); |
1834 | - $exercise_id = null; |
|
1834 | + $exercise_id = null; |
|
1835 | 1835 | if (!empty($result) && Database::num_rows($result)) { |
1836 | 1836 | while ($row = Database::fetch_array($result)) { |
1837 | 1837 | $exercise_list[] = $row['id']; |
@@ -1840,11 +1840,11 @@ discard block |
||
1840 | 1840 | if (!empty($exercise_list)) { |
1841 | 1841 | $exercise_id = implode("','",$exercise_list); |
1842 | 1842 | } |
1843 | - } |
|
1843 | + } |
|
1844 | 1844 | |
1845 | - $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1845 | + $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1846 | 1846 | |
1847 | - $sql = "SELECT |
|
1847 | + $sql = "SELECT |
|
1848 | 1848 | SUM(exe_result/exe_weighting*100) as avg_score, |
1849 | 1849 | COUNT(*) as num_attempts |
1850 | 1850 | $select_lp_id |
@@ -1858,20 +1858,20 @@ discard block |
||
1858 | 1858 | $condition_into_lp |
1859 | 1859 | ORDER BY exe_date DESC"; |
1860 | 1860 | |
1861 | - $res = Database::query($sql); |
|
1862 | - $row = Database::fetch_array($res); |
|
1863 | - $quiz_avg_score = null; |
|
1861 | + $res = Database::query($sql); |
|
1862 | + $row = Database::fetch_array($res); |
|
1863 | + $quiz_avg_score = null; |
|
1864 | 1864 | |
1865 | - if (!empty($row['avg_score'])) { |
|
1866 | - $quiz_avg_score = round($row['avg_score'],2); |
|
1867 | - } |
|
1865 | + if (!empty($row['avg_score'])) { |
|
1866 | + $quiz_avg_score = round($row['avg_score'],2); |
|
1867 | + } |
|
1868 | 1868 | |
1869 | - if(!empty($row['num_attempts'])) { |
|
1870 | - $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2); |
|
1871 | - } |
|
1872 | - if (is_array($student_id)) { |
|
1873 | - $quiz_avg_score = round($quiz_avg_score / count($student_id), 2); |
|
1874 | - } |
|
1869 | + if(!empty($row['num_attempts'])) { |
|
1870 | + $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2); |
|
1871 | + } |
|
1872 | + if (is_array($student_id)) { |
|
1873 | + $quiz_avg_score = round($quiz_avg_score / count($student_id), 2); |
|
1874 | + } |
|
1875 | 1875 | if ($into_lp == 0) { |
1876 | 1876 | return $quiz_avg_score; |
1877 | 1877 | } else { |
@@ -1894,9 +1894,9 @@ discard block |
||
1894 | 1894 | return array($quiz_avg_score, null); |
1895 | 1895 | } |
1896 | 1896 | } |
1897 | - } |
|
1898 | - } |
|
1899 | - return null; |
|
1897 | + } |
|
1898 | + } |
|
1899 | + return null; |
|
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | /** |
@@ -1929,15 +1929,15 @@ discard block |
||
1929 | 1929 | $find_all_lp = 0 |
1930 | 1930 | ) { |
1931 | 1931 | $courseId = intval($courseId); |
1932 | - $student_id = intval($student_id); |
|
1933 | - $exercise_id = intval($exercise_id); |
|
1934 | - $session_id = intval($session_id); |
|
1932 | + $student_id = intval($student_id); |
|
1933 | + $exercise_id = intval($exercise_id); |
|
1934 | + $session_id = intval($session_id); |
|
1935 | 1935 | |
1936 | - $lp_id = intval($lp_id); |
|
1936 | + $lp_id = intval($lp_id); |
|
1937 | 1937 | $lp_item_id = intval($lp_item_id); |
1938 | - $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1938 | + $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1939 | 1939 | |
1940 | - $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex |
|
1940 | + $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex |
|
1941 | 1941 | WHERE ex.c_id = $courseId |
1942 | 1942 | AND ex.exe_exo_id = $exercise_id |
1943 | 1943 | AND status = '' |
@@ -1952,11 +1952,11 @@ discard block |
||
1952 | 1952 | AND orig_lp_item_id = $lp_item_id"; |
1953 | 1953 | } |
1954 | 1954 | |
1955 | - $rs = Database::query($sql); |
|
1956 | - $row = Database::fetch_row($rs); |
|
1957 | - $count_attempts = $row[0]; |
|
1955 | + $rs = Database::query($sql); |
|
1956 | + $row = Database::fetch_row($rs); |
|
1957 | + $count_attempts = $row[0]; |
|
1958 | 1958 | |
1959 | - return $count_attempts; |
|
1959 | + return $count_attempts; |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | * @param int $user_id |
1967 | 1967 | * @param int $courseId |
1968 | 1968 | * @param int $session_id |
1969 | - */ |
|
1969 | + */ |
|
1970 | 1970 | public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id) |
1971 | 1971 | { |
1972 | 1972 | $courseId = intval($courseId); |
@@ -3634,8 +3634,8 @@ discard block |
||
3634 | 3634 | |
3635 | 3635 | $condition_session = ''; |
3636 | 3636 | if (isset($session_id)) { |
3637 | - $session_id = intval($session_id); |
|
3638 | - $condition_session = ' AND f.session_id = '. $session_id; |
|
3637 | + $session_id = intval($session_id); |
|
3638 | + $condition_session = ' AND f.session_id = '. $session_id; |
|
3639 | 3639 | } |
3640 | 3640 | |
3641 | 3641 | $groupId = intval($groupId); |
@@ -5564,9 +5564,9 @@ discard block |
||
5564 | 5564 | } |
5565 | 5565 | |
5566 | 5566 | /** |
5567 | - * @param FormValidator $form |
|
5568 | - * @return mixed |
|
5569 | - */ |
|
5567 | + * @param FormValidator $form |
|
5568 | + * @return mixed |
|
5569 | + */ |
|
5570 | 5570 | public static function setUserSearchForm($form) |
5571 | 5571 | { |
5572 | 5572 | global $_configuration; |
@@ -5961,26 +5961,26 @@ discard block |
||
5961 | 5961 | $session_id = api_get_session_id(); |
5962 | 5962 | $course_id = api_get_course_int_id(); |
5963 | 5963 | |
5964 | - $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5965 | - $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5964 | + $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5965 | + $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5966 | 5966 | |
5967 | - $sql = "SELECT count(tool) AS total_number_of_items |
|
5967 | + $sql = "SELECT count(tool) AS total_number_of_items |
|
5968 | 5968 | FROM $table_item_property track_resource, $table_user user |
5969 | 5969 | WHERE |
5970 | 5970 | track_resource.c_id = $course_id AND |
5971 | 5971 | track_resource.insert_user_id = user.user_id AND |
5972 | 5972 | session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id "); |
5973 | 5973 | |
5974 | - if (isset($_GET['keyword'])) { |
|
5975 | - $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5976 | - $sql .= " AND ( |
|
5974 | + if (isset($_GET['keyword'])) { |
|
5975 | + $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5976 | + $sql .= " AND ( |
|
5977 | 5977 | user.username LIKE '%".$keyword."%' OR |
5978 | 5978 | lastedit_type LIKE '%".$keyword."%' OR |
5979 | 5979 | tool LIKE '%".$keyword."%' |
5980 | 5980 | )"; |
5981 | - } |
|
5981 | + } |
|
5982 | 5982 | |
5983 | - $sql .= " AND tool IN ( |
|
5983 | + $sql .= " AND tool IN ( |
|
5984 | 5984 | 'document', |
5985 | 5985 | 'learnpath', |
5986 | 5986 | 'quiz', |
@@ -5992,10 +5992,10 @@ discard block |
||
5992 | 5992 | 'thematic_advance', |
5993 | 5993 | 'thematic_plan' |
5994 | 5994 | )"; |
5995 | - $res = Database::query($sql); |
|
5996 | - $obj = Database::fetch_object($res); |
|
5995 | + $res = Database::query($sql); |
|
5996 | + $obj = Database::fetch_object($res); |
|
5997 | 5997 | |
5998 | - return $obj->total_number_of_items; |
|
5998 | + return $obj->total_number_of_items; |
|
5999 | 5999 | } |
6000 | 6000 | |
6001 | 6001 | /** |
@@ -6010,12 +6010,12 @@ discard block |
||
6010 | 6010 | $session_id = api_get_session_id(); |
6011 | 6011 | $course_id = api_get_course_int_id(); |
6012 | 6012 | |
6013 | - $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
6014 | - $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
6015 | - $table_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
|
6016 | - $session_id = intval($session_id); |
|
6013 | + $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
6014 | + $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
6015 | + $table_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
|
6016 | + $session_id = intval($session_id); |
|
6017 | 6017 | |
6018 | - $sql = "SELECT |
|
6018 | + $sql = "SELECT |
|
6019 | 6019 | tool as col0, |
6020 | 6020 | lastedit_type as col1, |
6021 | 6021 | ref as ref, |
@@ -6029,16 +6029,16 @@ discard block |
||
6029 | 6029 | track_resource.insert_user_id = user.user_id AND |
6030 | 6030 | session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id "); |
6031 | 6031 | |
6032 | - if (isset($_GET['keyword'])) { |
|
6033 | - $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
6034 | - $sql .= " AND ( |
|
6032 | + if (isset($_GET['keyword'])) { |
|
6033 | + $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
6034 | + $sql .= " AND ( |
|
6035 | 6035 | user.username LIKE '%".$keyword."%' OR |
6036 | 6036 | lastedit_type LIKE '%".$keyword."%' OR |
6037 | 6037 | tool LIKE '%".$keyword."%' |
6038 | 6038 | ) "; |
6039 | - } |
|
6039 | + } |
|
6040 | 6040 | |
6041 | - $sql .= " AND tool IN ( |
|
6041 | + $sql .= " AND tool IN ( |
|
6042 | 6042 | 'document', |
6043 | 6043 | 'learnpath', |
6044 | 6044 | 'quiz', |
@@ -6051,41 +6051,41 @@ discard block |
||
6051 | 6051 | 'thematic_plan' |
6052 | 6052 | )"; |
6053 | 6053 | |
6054 | - if ($column == 0) { |
|
6055 | - $column = '0'; |
|
6056 | - } |
|
6057 | - if ($column != '' && $direction != '') { |
|
6058 | - if ($column != 2 && $column != 4) { |
|
6059 | - $sql .= " ORDER BY col$column $direction"; |
|
6060 | - } |
|
6061 | - } else { |
|
6062 | - $sql .= " ORDER BY col5 DESC "; |
|
6063 | - } |
|
6054 | + if ($column == 0) { |
|
6055 | + $column = '0'; |
|
6056 | + } |
|
6057 | + if ($column != '' && $direction != '') { |
|
6058 | + if ($column != 2 && $column != 4) { |
|
6059 | + $sql .= " ORDER BY col$column $direction"; |
|
6060 | + } |
|
6061 | + } else { |
|
6062 | + $sql .= " ORDER BY col5 DESC "; |
|
6063 | + } |
|
6064 | 6064 | |
6065 | 6065 | $from = intval($from); |
6066 | 6066 | $number_of_items = intval($number_of_items); |
6067 | 6067 | |
6068 | - $sql .= " LIMIT $from, $number_of_items "; |
|
6069 | - |
|
6070 | - $res = Database::query($sql); |
|
6071 | - $resources = array(); |
|
6072 | - $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan'); |
|
6073 | - while ($row = Database::fetch_array($res)) { |
|
6074 | - $ref = $row['ref']; |
|
6075 | - $table_name = TrackingCourseLog::get_tool_name_table($row['col0']); |
|
6076 | - $table_tool = Database :: get_course_table($table_name['table_name']); |
|
6068 | + $sql .= " LIMIT $from, $number_of_items "; |
|
6077 | 6069 | |
6078 | - $id = $table_name['id_tool']; |
|
6079 | - $recorset = false; |
|
6080 | - |
|
6081 | - if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { |
|
6082 | - $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
6083 | - $sql = "SELECT thematic_id FROM $table_tool |
|
6070 | + $res = Database::query($sql); |
|
6071 | + $resources = array(); |
|
6072 | + $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan'); |
|
6073 | + while ($row = Database::fetch_array($res)) { |
|
6074 | + $ref = $row['ref']; |
|
6075 | + $table_name = TrackingCourseLog::get_tool_name_table($row['col0']); |
|
6076 | + $table_tool = Database :: get_course_table($table_name['table_name']); |
|
6077 | + |
|
6078 | + $id = $table_name['id_tool']; |
|
6079 | + $recorset = false; |
|
6080 | + |
|
6081 | + if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { |
|
6082 | + $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
6083 | + $sql = "SELECT thematic_id FROM $table_tool |
|
6084 | 6084 | WHERE c_id = $course_id AND id = $ref"; |
6085 | - $rs_thematic = Database::query($sql); |
|
6086 | - if (Database::num_rows($rs_thematic)) { |
|
6087 | - $row_thematic = Database::fetch_array($rs_thematic); |
|
6088 | - $thematic_id = $row_thematic['thematic_id']; |
|
6085 | + $rs_thematic = Database::query($sql); |
|
6086 | + if (Database::num_rows($rs_thematic)) { |
|
6087 | + $row_thematic = Database::fetch_array($rs_thematic); |
|
6088 | + $thematic_id = $row_thematic['thematic_id']; |
|
6089 | 6089 | |
6090 | 6090 | $sql = "SELECT session.id, session.name, user.username |
6091 | 6091 | FROM $tbl_thematic t, $table_session session, $table_user user |
@@ -6094,9 +6094,9 @@ discard block |
||
6094 | 6094 | t.session_id = session.id AND |
6095 | 6095 | session.id_coach = user.user_id AND |
6096 | 6096 | t.id = $thematic_id"; |
6097 | - $recorset = Database::query($sql); |
|
6098 | - } |
|
6099 | - } else { |
|
6097 | + $recorset = Database::query($sql); |
|
6098 | + } |
|
6099 | + } else { |
|
6100 | 6100 | $sql = "SELECT session.id, session.name, user.username |
6101 | 6101 | FROM $table_tool tool, $table_session session, $table_user user |
6102 | 6102 | WHERE |
@@ -6104,134 +6104,134 @@ discard block |
||
6104 | 6104 | tool.session_id = session.id AND |
6105 | 6105 | session.id_coach = user.user_id AND |
6106 | 6106 | tool.$id = $ref"; |
6107 | - $recorset = Database::query($sql); |
|
6108 | - } |
|
6109 | - |
|
6110 | - if (!empty($recorset)) { |
|
6111 | - $obj = Database::fetch_object($recorset); |
|
6112 | - |
|
6113 | - $name_session = ''; |
|
6114 | - $coach_name = ''; |
|
6115 | - if (!empty($obj)) { |
|
6116 | - $name_session = $obj->name; |
|
6117 | - $coach_name = $obj->username; |
|
6118 | - } |
|
6119 | - |
|
6120 | - $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool']; |
|
6121 | - $row[0] = ''; |
|
6122 | - if ($row['col6'] != 2) { |
|
6123 | - if (in_array($row['col0'], $thematic_tools)) { |
|
6124 | - |
|
6125 | - $exp_thematic_tool = explode('_', $row['col0']); |
|
6126 | - $thematic_tool_title = ''; |
|
6127 | - if (is_array($exp_thematic_tool)) { |
|
6128 | - foreach ($exp_thematic_tool as $exp) { |
|
6129 | - $thematic_tool_title .= api_ucfirst($exp); |
|
6130 | - } |
|
6131 | - } else { |
|
6132 | - $thematic_tool_title = api_ucfirst($row['col0']); |
|
6133 | - } |
|
6134 | - |
|
6135 | - $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>'; |
|
6136 | - } else { |
|
6137 | - $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>'; |
|
6138 | - } |
|
6139 | - } else { |
|
6140 | - $row[0] = api_ucfirst($row['col0']); |
|
6141 | - } |
|
6142 | - $row[1] = get_lang($row[1]); |
|
6143 | - $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get()); |
|
6144 | - $row[5] = ''; |
|
6145 | - //@todo Improve this code please |
|
6146 | - switch ($table_name['table_name']) { |
|
6147 | - case 'document': |
|
6148 | - $sql = "SELECT tool.title as title FROM $table_tool tool |
|
6107 | + $recorset = Database::query($sql); |
|
6108 | + } |
|
6109 | + |
|
6110 | + if (!empty($recorset)) { |
|
6111 | + $obj = Database::fetch_object($recorset); |
|
6112 | + |
|
6113 | + $name_session = ''; |
|
6114 | + $coach_name = ''; |
|
6115 | + if (!empty($obj)) { |
|
6116 | + $name_session = $obj->name; |
|
6117 | + $coach_name = $obj->username; |
|
6118 | + } |
|
6119 | + |
|
6120 | + $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool']; |
|
6121 | + $row[0] = ''; |
|
6122 | + if ($row['col6'] != 2) { |
|
6123 | + if (in_array($row['col0'], $thematic_tools)) { |
|
6124 | + |
|
6125 | + $exp_thematic_tool = explode('_', $row['col0']); |
|
6126 | + $thematic_tool_title = ''; |
|
6127 | + if (is_array($exp_thematic_tool)) { |
|
6128 | + foreach ($exp_thematic_tool as $exp) { |
|
6129 | + $thematic_tool_title .= api_ucfirst($exp); |
|
6130 | + } |
|
6131 | + } else { |
|
6132 | + $thematic_tool_title = api_ucfirst($row['col0']); |
|
6133 | + } |
|
6134 | + |
|
6135 | + $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>'; |
|
6136 | + } else { |
|
6137 | + $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>'; |
|
6138 | + } |
|
6139 | + } else { |
|
6140 | + $row[0] = api_ucfirst($row['col0']); |
|
6141 | + } |
|
6142 | + $row[1] = get_lang($row[1]); |
|
6143 | + $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get()); |
|
6144 | + $row[5] = ''; |
|
6145 | + //@todo Improve this code please |
|
6146 | + switch ($table_name['table_name']) { |
|
6147 | + case 'document': |
|
6148 | + $sql = "SELECT tool.title as title FROM $table_tool tool |
|
6149 | 6149 | WHERE c_id = $course_id AND id = $ref"; |
6150 | - $rs_document = Database::query($sql); |
|
6151 | - $obj_document = Database::fetch_object($rs_document); |
|
6150 | + $rs_document = Database::query($sql); |
|
6151 | + $obj_document = Database::fetch_object($rs_document); |
|
6152 | 6152 | if ($obj_document) { |
6153 | 6153 | $row[5] = $obj_document->title; |
6154 | 6154 | } |
6155 | - break; |
|
6156 | - case 'announcement': |
|
6155 | + break; |
|
6156 | + case 'announcement': |
|
6157 | 6157 | $sql = "SELECT title FROM $table_tool |
6158 | 6158 | WHERE c_id = $course_id AND id = $ref"; |
6159 | - $rs_document = Database::query($sql); |
|
6160 | - $obj_document = Database::fetch_object($rs_document); |
|
6159 | + $rs_document = Database::query($sql); |
|
6160 | + $obj_document = Database::fetch_object($rs_document); |
|
6161 | 6161 | if ($obj_document) { |
6162 | 6162 | $row[5] = $obj_document->title; |
6163 | 6163 | } |
6164 | - break; |
|
6165 | - case 'glossary': |
|
6164 | + break; |
|
6165 | + case 'glossary': |
|
6166 | 6166 | $sql = "SELECT name FROM $table_tool |
6167 | 6167 | WHERE c_id = $course_id AND glossary_id = $ref"; |
6168 | - $rs_document = Database::query($sql); |
|
6169 | - $obj_document = Database::fetch_object($rs_document); |
|
6168 | + $rs_document = Database::query($sql); |
|
6169 | + $obj_document = Database::fetch_object($rs_document); |
|
6170 | 6170 | if ($obj_document) { |
6171 | 6171 | $row[5] = $obj_document->name; |
6172 | 6172 | } |
6173 | - break; |
|
6174 | - case 'lp': |
|
6173 | + break; |
|
6174 | + case 'lp': |
|
6175 | 6175 | $sql = "SELECT name |
6176 | 6176 | FROM $table_tool WHERE c_id = $course_id AND id = $ref"; |
6177 | - $rs_document = Database::query($sql); |
|
6178 | - $obj_document = Database::fetch_object($rs_document); |
|
6179 | - $row[5] = $obj_document->name; |
|
6180 | - break; |
|
6181 | - case 'quiz': |
|
6177 | + $rs_document = Database::query($sql); |
|
6178 | + $obj_document = Database::fetch_object($rs_document); |
|
6179 | + $row[5] = $obj_document->name; |
|
6180 | + break; |
|
6181 | + case 'quiz': |
|
6182 | 6182 | $sql = "SELECT title FROM $table_tool |
6183 | 6183 | WHERE c_id = $course_id AND id = $ref"; |
6184 | - $rs_document = Database::query($sql); |
|
6185 | - $obj_document = Database::fetch_object($rs_document); |
|
6184 | + $rs_document = Database::query($sql); |
|
6185 | + $obj_document = Database::fetch_object($rs_document); |
|
6186 | 6186 | if ($obj_document) { |
6187 | 6187 | $row[5] = $obj_document->title; |
6188 | 6188 | } |
6189 | - break; |
|
6190 | - case 'course_description': |
|
6189 | + break; |
|
6190 | + case 'course_description': |
|
6191 | 6191 | $sql = "SELECT title FROM $table_tool |
6192 | 6192 | WHERE c_id = $course_id AND id = $ref"; |
6193 | - $rs_document = Database::query($sql); |
|
6194 | - $obj_document = Database::fetch_object($rs_document); |
|
6193 | + $rs_document = Database::query($sql); |
|
6194 | + $obj_document = Database::fetch_object($rs_document); |
|
6195 | 6195 | if ($obj_document) { |
6196 | 6196 | $row[5] = $obj_document->title; |
6197 | 6197 | } |
6198 | - break; |
|
6199 | - case 'thematic': |
|
6200 | - $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6201 | - if (Database::num_rows($rs) > 0) { |
|
6202 | - $obj = Database::fetch_object($rs); |
|
6198 | + break; |
|
6199 | + case 'thematic': |
|
6200 | + $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6201 | + if (Database::num_rows($rs) > 0) { |
|
6202 | + $obj = Database::fetch_object($rs); |
|
6203 | 6203 | if ($obj) { |
6204 | 6204 | $row[5] = $obj->title; |
6205 | 6205 | } |
6206 | - } |
|
6207 | - break; |
|
6208 | - case 'thematic_advance': |
|
6209 | - $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6210 | - if (Database::num_rows($rs) > 0) { |
|
6211 | - $obj = Database::fetch_object($rs); |
|
6206 | + } |
|
6207 | + break; |
|
6208 | + case 'thematic_advance': |
|
6209 | + $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6210 | + if (Database::num_rows($rs) > 0) { |
|
6211 | + $obj = Database::fetch_object($rs); |
|
6212 | 6212 | if ($obj) { |
6213 | 6213 | $row[5] = $obj->content; |
6214 | 6214 | } |
6215 | - } |
|
6216 | - break; |
|
6217 | - case 'thematic_plan': |
|
6218 | - $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6219 | - if (Database::num_rows($rs) > 0) { |
|
6220 | - $obj = Database::fetch_object($rs); |
|
6215 | + } |
|
6216 | + break; |
|
6217 | + case 'thematic_plan': |
|
6218 | + $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
6219 | + if (Database::num_rows($rs) > 0) { |
|
6220 | + $obj = Database::fetch_object($rs); |
|
6221 | 6221 | if ($obj) { |
6222 | 6222 | $row[5] = $obj->title; |
6223 | 6223 | } |
6224 | - } |
|
6225 | - break; |
|
6226 | - default: |
|
6227 | - break; |
|
6228 | - } |
|
6229 | - |
|
6230 | - $row2 = $name_session; |
|
6231 | - if (!empty($coach_name)) { |
|
6232 | - $row2 .= '<br />'.get_lang('Coach').': '.$coach_name; |
|
6233 | - } |
|
6234 | - $row[2] = $row2; |
|
6224 | + } |
|
6225 | + break; |
|
6226 | + default: |
|
6227 | + break; |
|
6228 | + } |
|
6229 | + |
|
6230 | + $row2 = $name_session; |
|
6231 | + if (!empty($coach_name)) { |
|
6232 | + $row2 .= '<br />'.get_lang('Coach').': '.$coach_name; |
|
6233 | + } |
|
6234 | + $row[2] = $row2; |
|
6235 | 6235 | if (!empty($row['col3'])) { |
6236 | 6236 | $userInfo = api_get_user_info($row['user_id']); |
6237 | 6237 | $row['col3'] = Display::url( |
@@ -6247,11 +6247,11 @@ discard block |
||
6247 | 6247 | $row[4] = $ip; |
6248 | 6248 | } |
6249 | 6249 | |
6250 | - $resources[] = $row; |
|
6251 | - } |
|
6252 | - } |
|
6250 | + $resources[] = $row; |
|
6251 | + } |
|
6252 | + } |
|
6253 | 6253 | |
6254 | - return $resources; |
|
6254 | + return $resources; |
|
6255 | 6255 | } |
6256 | 6256 | |
6257 | 6257 | /** |
@@ -6261,63 +6261,63 @@ discard block |
||
6261 | 6261 | */ |
6262 | 6262 | public static function get_tool_name_table($tool) |
6263 | 6263 | { |
6264 | - switch ($tool) { |
|
6265 | - case 'document': |
|
6266 | - $table_name = TABLE_DOCUMENT; |
|
6267 | - $link_tool = 'document/document.php'; |
|
6268 | - $id_tool = 'id'; |
|
6269 | - break; |
|
6270 | - case 'learnpath': |
|
6271 | - $table_name = TABLE_LP_MAIN; |
|
6272 | - $link_tool = 'lp/lp_controller.php'; |
|
6273 | - $id_tool = 'id'; |
|
6274 | - break; |
|
6275 | - case 'quiz': |
|
6276 | - $table_name = TABLE_QUIZ_TEST; |
|
6277 | - $link_tool = 'exercise/exercise.php'; |
|
6278 | - $id_tool = 'id'; |
|
6279 | - break; |
|
6280 | - case 'glossary': |
|
6281 | - $table_name = TABLE_GLOSSARY; |
|
6282 | - $link_tool = 'glossary/index.php'; |
|
6283 | - $id_tool = 'glossary_id'; |
|
6284 | - break; |
|
6285 | - case 'link': |
|
6286 | - $table_name = TABLE_LINK; |
|
6287 | - $link_tool = 'link/link.php'; |
|
6288 | - $id_tool = 'id'; |
|
6289 | - break; |
|
6290 | - case 'course_description': |
|
6291 | - $table_name = TABLE_COURSE_DESCRIPTION; |
|
6292 | - $link_tool = 'course_description/'; |
|
6293 | - $id_tool = 'id'; |
|
6294 | - break; |
|
6295 | - case 'announcement': |
|
6296 | - $table_name = TABLE_ANNOUNCEMENT; |
|
6297 | - $link_tool = 'announcements/announcements.php'; |
|
6298 | - $id_tool = 'id'; |
|
6299 | - break; |
|
6300 | - case 'thematic': |
|
6301 | - $table_name = TABLE_THEMATIC; |
|
6302 | - $link_tool = 'course_progress/index.php'; |
|
6303 | - $id_tool = 'id'; |
|
6304 | - break; |
|
6305 | - case 'thematic_advance': |
|
6306 | - $table_name = TABLE_THEMATIC_ADVANCE; |
|
6307 | - $link_tool = 'course_progress/index.php'; |
|
6308 | - $id_tool = 'id'; |
|
6309 | - break; |
|
6310 | - case 'thematic_plan': |
|
6311 | - $table_name = TABLE_THEMATIC_PLAN; |
|
6312 | - $link_tool = 'course_progress/index.php'; |
|
6313 | - $id_tool = 'id'; |
|
6314 | - break; |
|
6315 | - default: |
|
6316 | - $table_name = $tool; |
|
6317 | - break; |
|
6318 | - } |
|
6319 | - |
|
6320 | - return array( |
|
6264 | + switch ($tool) { |
|
6265 | + case 'document': |
|
6266 | + $table_name = TABLE_DOCUMENT; |
|
6267 | + $link_tool = 'document/document.php'; |
|
6268 | + $id_tool = 'id'; |
|
6269 | + break; |
|
6270 | + case 'learnpath': |
|
6271 | + $table_name = TABLE_LP_MAIN; |
|
6272 | + $link_tool = 'lp/lp_controller.php'; |
|
6273 | + $id_tool = 'id'; |
|
6274 | + break; |
|
6275 | + case 'quiz': |
|
6276 | + $table_name = TABLE_QUIZ_TEST; |
|
6277 | + $link_tool = 'exercise/exercise.php'; |
|
6278 | + $id_tool = 'id'; |
|
6279 | + break; |
|
6280 | + case 'glossary': |
|
6281 | + $table_name = TABLE_GLOSSARY; |
|
6282 | + $link_tool = 'glossary/index.php'; |
|
6283 | + $id_tool = 'glossary_id'; |
|
6284 | + break; |
|
6285 | + case 'link': |
|
6286 | + $table_name = TABLE_LINK; |
|
6287 | + $link_tool = 'link/link.php'; |
|
6288 | + $id_tool = 'id'; |
|
6289 | + break; |
|
6290 | + case 'course_description': |
|
6291 | + $table_name = TABLE_COURSE_DESCRIPTION; |
|
6292 | + $link_tool = 'course_description/'; |
|
6293 | + $id_tool = 'id'; |
|
6294 | + break; |
|
6295 | + case 'announcement': |
|
6296 | + $table_name = TABLE_ANNOUNCEMENT; |
|
6297 | + $link_tool = 'announcements/announcements.php'; |
|
6298 | + $id_tool = 'id'; |
|
6299 | + break; |
|
6300 | + case 'thematic': |
|
6301 | + $table_name = TABLE_THEMATIC; |
|
6302 | + $link_tool = 'course_progress/index.php'; |
|
6303 | + $id_tool = 'id'; |
|
6304 | + break; |
|
6305 | + case 'thematic_advance': |
|
6306 | + $table_name = TABLE_THEMATIC_ADVANCE; |
|
6307 | + $link_tool = 'course_progress/index.php'; |
|
6308 | + $id_tool = 'id'; |
|
6309 | + break; |
|
6310 | + case 'thematic_plan': |
|
6311 | + $table_name = TABLE_THEMATIC_PLAN; |
|
6312 | + $link_tool = 'course_progress/index.php'; |
|
6313 | + $id_tool = 'id'; |
|
6314 | + break; |
|
6315 | + default: |
|
6316 | + $table_name = $tool; |
|
6317 | + break; |
|
6318 | + } |
|
6319 | + |
|
6320 | + return array( |
|
6321 | 6321 | 'table_name' => $table_name, |
6322 | 6322 | 'link_tool' => $link_tool, |
6323 | 6323 | 'id_tool' => $id_tool |
@@ -6326,45 +6326,45 @@ discard block |
||
6326 | 6326 | |
6327 | 6327 | public static function display_additional_profile_fields() |
6328 | 6328 | { |
6329 | - // getting all the extra profile fields that are defined by the platform administrator |
|
6330 | - $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC'); |
|
6331 | - |
|
6332 | - // creating the form |
|
6333 | - $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">'; |
|
6334 | - |
|
6335 | - // the select field with the additional user profile fields (= this is where we select the field of which we want to see |
|
6336 | - // the information the users have entered or selected. |
|
6337 | - $return .= '<select name="additional_profile_field">'; |
|
6338 | - $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>'; |
|
6339 | - $extra_fields_to_show = 0; |
|
6340 | - foreach ($extra_fields as $key=>$field) { |
|
6341 | - // show only extra fields that are visible + and can be filtered, added by J.Montoya |
|
6342 | - if ($field[6]==1 && $field[8] == 1) { |
|
6343 | - if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) { |
|
6344 | - $selected = 'selected="selected"'; |
|
6345 | - } else { |
|
6346 | - $selected = ''; |
|
6347 | - } |
|
6348 | - $extra_fields_to_show++; |
|
6349 | - $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>'; |
|
6350 | - } |
|
6351 | - } |
|
6352 | - $return .= '</select>'; |
|
6353 | - |
|
6354 | - // the form elements for the $_GET parameters (because the form is passed through GET |
|
6355 | - foreach ($_GET as $key=>$value){ |
|
6356 | - if ($key <> 'additional_profile_field') { |
|
6357 | - $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />'; |
|
6358 | - } |
|
6359 | - } |
|
6360 | - // the submit button |
|
6361 | - $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>'; |
|
6362 | - $return .= '</form>'; |
|
6363 | - if ($extra_fields_to_show > 0) { |
|
6364 | - return $return; |
|
6365 | - } else { |
|
6366 | - return ''; |
|
6367 | - } |
|
6329 | + // getting all the extra profile fields that are defined by the platform administrator |
|
6330 | + $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC'); |
|
6331 | + |
|
6332 | + // creating the form |
|
6333 | + $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">'; |
|
6334 | + |
|
6335 | + // the select field with the additional user profile fields (= this is where we select the field of which we want to see |
|
6336 | + // the information the users have entered or selected. |
|
6337 | + $return .= '<select name="additional_profile_field">'; |
|
6338 | + $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>'; |
|
6339 | + $extra_fields_to_show = 0; |
|
6340 | + foreach ($extra_fields as $key=>$field) { |
|
6341 | + // show only extra fields that are visible + and can be filtered, added by J.Montoya |
|
6342 | + if ($field[6]==1 && $field[8] == 1) { |
|
6343 | + if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) { |
|
6344 | + $selected = 'selected="selected"'; |
|
6345 | + } else { |
|
6346 | + $selected = ''; |
|
6347 | + } |
|
6348 | + $extra_fields_to_show++; |
|
6349 | + $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>'; |
|
6350 | + } |
|
6351 | + } |
|
6352 | + $return .= '</select>'; |
|
6353 | + |
|
6354 | + // the form elements for the $_GET parameters (because the form is passed through GET |
|
6355 | + foreach ($_GET as $key=>$value){ |
|
6356 | + if ($key <> 'additional_profile_field') { |
|
6357 | + $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />'; |
|
6358 | + } |
|
6359 | + } |
|
6360 | + // the submit button |
|
6361 | + $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>'; |
|
6362 | + $return .= '</form>'; |
|
6363 | + if ($extra_fields_to_show > 0) { |
|
6364 | + return $return; |
|
6365 | + } else { |
|
6366 | + return ''; |
|
6367 | + } |
|
6368 | 6368 | } |
6369 | 6369 | |
6370 | 6370 | /** |
@@ -6383,31 +6383,31 @@ discard block |
||
6383 | 6383 | */ |
6384 | 6384 | public static function get_addtional_profile_information_of_field_by_user($field_id, $users) |
6385 | 6385 | { |
6386 | - // Database table definition |
|
6387 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6388 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
6386 | + // Database table definition |
|
6387 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6388 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
6389 | 6389 | $extraField = Database::get_main_table(TABLE_EXTRA_FIELD); |
6390 | - $result_extra_field = UserManager::get_extra_field_information($field_id); |
|
6391 | - |
|
6392 | - if (!empty($users)) { |
|
6393 | - if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) { |
|
6394 | - foreach($users as $user_id) { |
|
6395 | - $user_result = UserManager::get_user_tags($user_id, $field_id); |
|
6396 | - $tag_list = array(); |
|
6397 | - foreach($user_result as $item) { |
|
6398 | - $tag_list[] = $item['tag']; |
|
6399 | - } |
|
6400 | - $return[$user_id][] = implode(', ',$tag_list); |
|
6401 | - } |
|
6402 | - } else { |
|
6403 | - $new_user_array = array(); |
|
6404 | - foreach ($users as $user_id) { |
|
6405 | - $new_user_array[]= "'".$user_id."'"; |
|
6406 | - } |
|
6407 | - $users = implode(',',$new_user_array); |
|
6390 | + $result_extra_field = UserManager::get_extra_field_information($field_id); |
|
6391 | + |
|
6392 | + if (!empty($users)) { |
|
6393 | + if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) { |
|
6394 | + foreach($users as $user_id) { |
|
6395 | + $user_result = UserManager::get_user_tags($user_id, $field_id); |
|
6396 | + $tag_list = array(); |
|
6397 | + foreach($user_result as $item) { |
|
6398 | + $tag_list[] = $item['tag']; |
|
6399 | + } |
|
6400 | + $return[$user_id][] = implode(', ',$tag_list); |
|
6401 | + } |
|
6402 | + } else { |
|
6403 | + $new_user_array = array(); |
|
6404 | + foreach ($users as $user_id) { |
|
6405 | + $new_user_array[]= "'".$user_id."'"; |
|
6406 | + } |
|
6407 | + $users = implode(',',$new_user_array); |
|
6408 | 6408 | $extraFieldType = EntityExtraField::USER_FIELD_TYPE; |
6409 | - // Selecting only the necessary information NOT ALL the user list |
|
6410 | - $sql = "SELECT user.user_id, v.value |
|
6409 | + // Selecting only the necessary information NOT ALL the user list |
|
6410 | + $sql = "SELECT user.user_id, v.value |
|
6411 | 6411 | FROM $table_user user |
6412 | 6412 | INNER JOIN $table_user_field_values v |
6413 | 6413 | ON (user.user_id = v.item_id) |
@@ -6418,27 +6418,27 @@ discard block |
||
6418 | 6418 | v.field_id=".intval($field_id)." AND |
6419 | 6419 | user.user_id IN ($users)"; |
6420 | 6420 | |
6421 | - $result = Database::query($sql); |
|
6422 | - while($row = Database::fetch_array($result)) { |
|
6423 | - // get option value for field type double select by id |
|
6424 | - if (!empty($row['value'])) { |
|
6425 | - if ($result_extra_field['field_type'] == |
|
6421 | + $result = Database::query($sql); |
|
6422 | + while($row = Database::fetch_array($result)) { |
|
6423 | + // get option value for field type double select by id |
|
6424 | + if (!empty($row['value'])) { |
|
6425 | + if ($result_extra_field['field_type'] == |
|
6426 | 6426 | ExtraField::FIELD_TYPE_DOUBLE_SELECT |
6427 | 6427 | ) { |
6428 | - $id_double_select = explode(';', $row['value']); |
|
6429 | - if (is_array($id_double_select)) { |
|
6430 | - $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value']; |
|
6431 | - $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value']; |
|
6432 | - $row['value'] = ($value1.';'.$value2); |
|
6433 | - } |
|
6434 | - } |
|
6435 | - } |
|
6436 | - // get other value from extra field |
|
6437 | - $return[$row['user_id']][] = $row['value']; |
|
6438 | - } |
|
6439 | - } |
|
6440 | - } |
|
6441 | - return $return; |
|
6428 | + $id_double_select = explode(';', $row['value']); |
|
6429 | + if (is_array($id_double_select)) { |
|
6430 | + $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value']; |
|
6431 | + $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value']; |
|
6432 | + $row['value'] = ($value1.';'.$value2); |
|
6433 | + } |
|
6434 | + } |
|
6435 | + } |
|
6436 | + // get other value from extra field |
|
6437 | + $return[$row['user_id']][] = $row['value']; |
|
6438 | + } |
|
6439 | + } |
|
6440 | + } |
|
6441 | + return $return; |
|
6442 | 6442 | } |
6443 | 6443 | |
6444 | 6444 | /** |
@@ -6447,18 +6447,18 @@ discard block |
||
6447 | 6447 | */ |
6448 | 6448 | public function count_student_in_course() |
6449 | 6449 | { |
6450 | - global $nbStudents; |
|
6451 | - return $nbStudents; |
|
6450 | + global $nbStudents; |
|
6451 | + return $nbStudents; |
|
6452 | 6452 | } |
6453 | 6453 | |
6454 | 6454 | public function sort_users($a, $b) |
6455 | 6455 | { |
6456 | - return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']]))); |
|
6456 | + return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']]))); |
|
6457 | 6457 | } |
6458 | 6458 | |
6459 | 6459 | public function sort_users_desc($a, $b) |
6460 | 6460 | { |
6461 | - return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']]))); |
|
6461 | + return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']]))); |
|
6462 | 6462 | } |
6463 | 6463 | |
6464 | 6464 | /** |
@@ -6467,8 +6467,8 @@ discard block |
||
6467 | 6467 | */ |
6468 | 6468 | public static function get_number_of_users() |
6469 | 6469 | { |
6470 | - global $user_ids; |
|
6471 | - return count($user_ids); |
|
6470 | + global $user_ids; |
|
6471 | + return count($user_ids); |
|
6472 | 6472 | } |
6473 | 6473 | |
6474 | 6474 | /** |
@@ -6484,37 +6484,37 @@ discard block |
||
6484 | 6484 | { |
6485 | 6485 | global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id; |
6486 | 6486 | |
6487 | - $course_code = Database::escape_string($course_code); |
|
6488 | - $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6489 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
6487 | + $course_code = Database::escape_string($course_code); |
|
6488 | + $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6489 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
6490 | 6490 | |
6491 | - $access_url_id = api_get_current_access_url_id(); |
|
6491 | + $access_url_id = api_get_current_access_url_id(); |
|
6492 | 6492 | |
6493 | - // get all users data from a course for sortable with limit |
|
6494 | - if (is_array($user_ids)) { |
|
6495 | - $user_ids = array_map('intval', $user_ids); |
|
6496 | - $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") "; |
|
6497 | - } else { |
|
6498 | - $user_ids = intval($user_ids); |
|
6499 | - $condition_user = " WHERE user.user_id = $user_ids "; |
|
6500 | - } |
|
6493 | + // get all users data from a course for sortable with limit |
|
6494 | + if (is_array($user_ids)) { |
|
6495 | + $user_ids = array_map('intval', $user_ids); |
|
6496 | + $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") "; |
|
6497 | + } else { |
|
6498 | + $user_ids = intval($user_ids); |
|
6499 | + $condition_user = " WHERE user.user_id = $user_ids "; |
|
6500 | + } |
|
6501 | 6501 | |
6502 | - if (!empty($_GET['user_keyword'])) { |
|
6503 | - $keyword = trim(Database::escape_string($_GET['user_keyword'])); |
|
6504 | - $condition_user .= " AND ( |
|
6502 | + if (!empty($_GET['user_keyword'])) { |
|
6503 | + $keyword = trim(Database::escape_string($_GET['user_keyword'])); |
|
6504 | + $condition_user .= " AND ( |
|
6505 | 6505 | user.firstname LIKE '%".$keyword."%' OR |
6506 | 6506 | user.lastname LIKE '%".$keyword."%' OR |
6507 | 6507 | user.username LIKE '%".$keyword."%' OR |
6508 | 6508 | user.email LIKE '%".$keyword."%' |
6509 | 6509 | ) "; |
6510 | - } |
|
6510 | + } |
|
6511 | 6511 | |
6512 | 6512 | $url_table = null; |
6513 | 6513 | $url_condition = null; |
6514 | - if (api_is_multiple_url_enabled()) { |
|
6515 | - $url_table = ", ".$tbl_url_rel_user." as url_users"; |
|
6516 | - $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'"; |
|
6517 | - } |
|
6514 | + if (api_is_multiple_url_enabled()) { |
|
6515 | + $url_table = ", ".$tbl_url_rel_user." as url_users"; |
|
6516 | + $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'"; |
|
6517 | + } |
|
6518 | 6518 | |
6519 | 6519 | $invitedUsersCondition = ''; |
6520 | 6520 | |
@@ -6522,7 +6522,7 @@ discard block |
||
6522 | 6522 | $invitedUsersCondition = " AND user.status != " . INVITEE; |
6523 | 6523 | } |
6524 | 6524 | |
6525 | - $sql = "SELECT user.user_id as user_id, |
|
6525 | + $sql = "SELECT user.user_id as user_id, |
|
6526 | 6526 | user.official_code as col0, |
6527 | 6527 | user.lastname as col1, |
6528 | 6528 | user.firstname as col2, |
@@ -6530,16 +6530,16 @@ discard block |
||
6530 | 6530 | FROM $tbl_user as user $url_table |
6531 | 6531 | $condition_user $url_condition $invitedUsersCondition"; |
6532 | 6532 | |
6533 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
6534 | - $direction = 'ASC'; |
|
6535 | - } |
|
6533 | + if (!in_array($direction, array('ASC','DESC'))) { |
|
6534 | + $direction = 'ASC'; |
|
6535 | + } |
|
6536 | 6536 | |
6537 | - $column = intval($column); |
|
6538 | - $from = intval($from); |
|
6539 | - $number_of_items = intval($number_of_items); |
|
6537 | + $column = intval($column); |
|
6538 | + $from = intval($from); |
|
6539 | + $number_of_items = intval($number_of_items); |
|
6540 | 6540 | |
6541 | - $sql .= " ORDER BY col$column $direction "; |
|
6542 | - $sql .= " LIMIT $from,$number_of_items"; |
|
6541 | + $sql .= " ORDER BY col$column $direction "; |
|
6542 | + $sql .= " LIMIT $from,$number_of_items"; |
|
6543 | 6543 | |
6544 | 6544 | $res = Database::query($sql); |
6545 | 6545 | $users = array(); |
@@ -6573,7 +6573,7 @@ discard block |
||
6573 | 6573 | } |
6574 | 6574 | } |
6575 | 6575 | |
6576 | - while ($user = Database::fetch_array($res, 'ASSOC')) { |
|
6576 | + while ($user = Database::fetch_array($res, 'ASSOC')) { |
|
6577 | 6577 | $courseInfo = api_get_course_info($course_code); |
6578 | 6578 | $courseId = $courseInfo['real_id']; |
6579 | 6579 | |
@@ -6604,10 +6604,10 @@ discard block |
||
6604 | 6604 | $session_id |
6605 | 6605 | ); |
6606 | 6606 | |
6607 | - if (empty($avg_student_progress)) { |
|
6607 | + if (empty($avg_student_progress)) { |
|
6608 | 6608 | $avg_student_progress = 0; |
6609 | - } |
|
6610 | - $user['average_progress'] = $avg_student_progress.'%'; |
|
6609 | + } |
|
6610 | + $user['average_progress'] = $avg_student_progress.'%'; |
|
6611 | 6611 | |
6612 | 6612 | $total_user_exercise = Tracking::get_exercise_student_progress( |
6613 | 6613 | $total_exercises, |
@@ -6627,11 +6627,11 @@ discard block |
||
6627 | 6627 | |
6628 | 6628 | $user['exercise_average_best_attempt'] = $total_user_exercise; |
6629 | 6629 | |
6630 | - if (is_numeric($avg_student_score)) { |
|
6631 | - $user['student_score'] = $avg_student_score.'%'; |
|
6632 | - } else { |
|
6633 | - $user['student_score'] = $avg_student_score; |
|
6634 | - } |
|
6630 | + if (is_numeric($avg_student_score)) { |
|
6631 | + $user['student_score'] = $avg_student_score.'%'; |
|
6632 | + } else { |
|
6633 | + $user['student_score'] = $avg_student_score; |
|
6634 | + } |
|
6635 | 6635 | |
6636 | 6636 | $user['count_assignments'] = Tracking::count_student_assignments( |
6637 | 6637 | $user['user_id'], |
@@ -6654,29 +6654,29 @@ discard block |
||
6654 | 6654 | $session_id |
6655 | 6655 | ); |
6656 | 6656 | |
6657 | - // we need to display an additional profile field |
|
6658 | - $user['additional'] = ''; |
|
6657 | + // we need to display an additional profile field |
|
6658 | + $user['additional'] = ''; |
|
6659 | 6659 | |
6660 | - if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { |
|
6661 | - if (isset($additional_user_profile_info[$user['user_id']]) && |
|
6660 | + if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { |
|
6661 | + if (isset($additional_user_profile_info[$user['user_id']]) && |
|
6662 | 6662 | is_array($additional_user_profile_info[$user['user_id']]) |
6663 | 6663 | ) { |
6664 | - $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]); |
|
6665 | - } |
|
6666 | - } |
|
6664 | + $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]); |
|
6665 | + } |
|
6666 | + } |
|
6667 | 6667 | |
6668 | 6668 | if (empty($session_id)) { |
6669 | 6669 | $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys; |
6670 | 6670 | } |
6671 | 6671 | |
6672 | - $user['link'] = '<center> |
|
6672 | + $user['link'] = '<center> |
|
6673 | 6673 | <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"> |
6674 | 6674 | '.Display::return_icon('2rightarrow.png').' |
6675 | 6675 | </a> |
6676 | 6676 | </center>'; |
6677 | 6677 | |
6678 | - // store columns in array $users |
|
6679 | - $is_western_name_order = api_is_western_name_order(); |
|
6678 | + // store columns in array $users |
|
6679 | + $is_western_name_order = api_is_western_name_order(); |
|
6680 | 6680 | $user_row = array(); |
6681 | 6681 | $user_row[]= $user['official_code']; //0 |
6682 | 6682 | if ($is_western_name_order) { |
@@ -6712,21 +6712,21 @@ discard block |
||
6712 | 6712 | |
6713 | 6713 | $users[] = $user_row; |
6714 | 6714 | |
6715 | - if ($export_csv) { |
|
6716 | - if (empty($session_id)) { |
|
6715 | + if ($export_csv) { |
|
6716 | + if (empty($session_id)) { |
|
6717 | 6717 | $user_row = array_map('strip_tags', $user_row); |
6718 | - unset($user_row[14]); |
|
6719 | - unset($user_row[15]); |
|
6718 | + unset($user_row[14]); |
|
6719 | + unset($user_row[15]); |
|
6720 | 6720 | } else { |
6721 | 6721 | $user_row = array_map('strip_tags', $user_row); |
6722 | 6722 | unset($user_row[13]); |
6723 | 6723 | unset($user_row[14]); |
6724 | 6724 | } |
6725 | 6725 | |
6726 | - $csv_content[] = $user_row; |
|
6727 | - } |
|
6728 | - } |
|
6729 | - return $users; |
|
6726 | + $csv_content[] = $user_row; |
|
6727 | + } |
|
6728 | + } |
|
6729 | + return $users; |
|
6730 | 6730 | } |
6731 | 6731 | } |
6732 | 6732 | |
@@ -6744,18 +6744,18 @@ discard block |
||
6744 | 6744 | */ |
6745 | 6745 | public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0) |
6746 | 6746 | { |
6747 | - $MonthsLong = $GLOBALS['MonthsLong']; |
|
6748 | - |
|
6749 | - // protected data |
|
6750 | - $user_id = intval($user_id); |
|
6751 | - $session_id = intval($session_id); |
|
6752 | - $course_id = Database::escape_string($course_id); |
|
6753 | - |
|
6754 | - $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6755 | - $tempView = $view; |
|
6756 | - if(substr($view,0,1) == '1') { |
|
6757 | - $new_view = substr_replace($view,'0',0,1); |
|
6758 | - echo " |
|
6747 | + $MonthsLong = $GLOBALS['MonthsLong']; |
|
6748 | + |
|
6749 | + // protected data |
|
6750 | + $user_id = intval($user_id); |
|
6751 | + $session_id = intval($session_id); |
|
6752 | + $course_id = Database::escape_string($course_id); |
|
6753 | + |
|
6754 | + $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6755 | + $tempView = $view; |
|
6756 | + if(substr($view,0,1) == '1') { |
|
6757 | + $new_view = substr_replace($view,'0',0,1); |
|
6758 | + echo " |
|
6759 | 6759 | <tr> |
6760 | 6760 | <td valign='top'> |
6761 | 6761 | <font color='#0000FF'>- </font>" . |
@@ -6763,9 +6763,9 @@ discard block |
||
6763 | 6763 | </td> |
6764 | 6764 | </tr> |
6765 | 6765 | "; |
6766 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>"; |
|
6766 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>"; |
|
6767 | 6767 | |
6768 | - $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6768 | + $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6769 | 6769 | FROM $track_access_table |
6770 | 6770 | WHERE access_user_id = $user_id |
6771 | 6771 | AND c_id = $course_id |
@@ -6773,11 +6773,11 @@ discard block |
||
6773 | 6773 | GROUP BY YEAR(access_date),MONTH(access_date) |
6774 | 6774 | ORDER BY YEAR(access_date),MONTH(access_date) ASC"; |
6775 | 6775 | |
6776 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6777 | - $results = getManyResults3Col($sql); |
|
6776 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6777 | + $results = getManyResults3Col($sql); |
|
6778 | 6778 | |
6779 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6780 | - echo "<tr> |
|
6779 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6780 | + echo "<tr> |
|
6781 | 6781 | <td class='secLine'> |
6782 | 6782 | ".get_lang('LoginsTitleMonthColumn')." |
6783 | 6783 | </td> |
@@ -6785,36 +6785,36 @@ discard block |
||
6785 | 6785 | ".get_lang('LoginsTitleCountColumn')." |
6786 | 6786 | </td> |
6787 | 6787 | </tr>"; |
6788 | - $total = 0; |
|
6789 | - if (is_array($results)) { |
|
6790 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6791 | - echo "<tr>"; |
|
6792 | - echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>"; |
|
6793 | - echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>"; |
|
6794 | - echo"</tr>"; |
|
6795 | - $total = $total + $results[$j][1]; |
|
6796 | - } |
|
6797 | - echo "<tr>"; |
|
6798 | - echo "<td>".get_lang('Total')."</td>"; |
|
6799 | - echo "<td align='right' class='content'>".$total."</td>"; |
|
6800 | - echo"</tr>"; |
|
6801 | - } else { |
|
6802 | - echo "<tr>"; |
|
6803 | - echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>"; |
|
6804 | - echo"</tr>"; |
|
6805 | - } |
|
6806 | - echo "</table>"; |
|
6807 | - echo "</td></tr>"; |
|
6808 | - } else { |
|
6809 | - $new_view = substr_replace($view,'1',0,1); |
|
6810 | - echo " |
|
6788 | + $total = 0; |
|
6789 | + if (is_array($results)) { |
|
6790 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6791 | + echo "<tr>"; |
|
6792 | + echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>"; |
|
6793 | + echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>"; |
|
6794 | + echo"</tr>"; |
|
6795 | + $total = $total + $results[$j][1]; |
|
6796 | + } |
|
6797 | + echo "<tr>"; |
|
6798 | + echo "<td>".get_lang('Total')."</td>"; |
|
6799 | + echo "<td align='right' class='content'>".$total."</td>"; |
|
6800 | + echo"</tr>"; |
|
6801 | + } else { |
|
6802 | + echo "<tr>"; |
|
6803 | + echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>"; |
|
6804 | + echo"</tr>"; |
|
6805 | + } |
|
6806 | + echo "</table>"; |
|
6807 | + echo "</td></tr>"; |
|
6808 | + } else { |
|
6809 | + $new_view = substr_replace($view,'1',0,1); |
|
6810 | + echo " |
|
6811 | 6811 | <tr> |
6812 | 6812 | <td valign='top'> |
6813 | 6813 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a> |
6814 | 6814 | </td> |
6815 | 6815 | </tr> |
6816 | 6816 | "; |
6817 | - } |
|
6817 | + } |
|
6818 | 6818 | } |
6819 | 6819 | |
6820 | 6820 | /** |
@@ -6827,38 +6827,38 @@ discard block |
||
6827 | 6827 | */ |
6828 | 6828 | public static function display_exercise_tracking_info($view, $user_id, $courseCode) |
6829 | 6829 | { |
6830 | - global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong; |
|
6830 | + global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong; |
|
6831 | 6831 | $courseId = api_get_course_int_id($courseCode); |
6832 | - if(substr($view,1,1) == '1') { |
|
6833 | - $new_view = substr_replace($view,'0',1,1); |
|
6834 | - echo "<tr> |
|
6832 | + if(substr($view,1,1) == '1') { |
|
6833 | + $new_view = substr_replace($view,'0',1,1); |
|
6834 | + echo "<tr> |
|
6835 | 6835 | <td valign='top'> |
6836 | 6836 | <font color='#0000FF'>- </font><b>".get_lang('ExercicesResults')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>] |
6837 | 6837 | </td> |
6838 | 6838 | </tr>"; |
6839 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />"; |
|
6839 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />"; |
|
6840 | 6840 | |
6841 | - $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6841 | + $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6842 | 6842 | FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te |
6843 | 6843 | WHERE te.c_id = $courseId |
6844 | 6844 | AND te.exe_user_id = ".intval($user_id)." |
6845 | 6845 | AND te.exe_exo_id = ce.id |
6846 | 6846 | ORDER BY ce.title ASC, te.exe_date ASC"; |
6847 | 6847 | |
6848 | - $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6848 | + $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6849 | 6849 | FROM $TBL_TRACK_HOTPOTATOES AS te |
6850 | 6850 | WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId |
6851 | 6851 | ORDER BY te.c_id ASC, te.exe_date ASC"; |
6852 | 6852 | |
6853 | - $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6853 | + $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6854 | 6854 | |
6855 | - $NoTestRes = 0; |
|
6856 | - $NoHPTestRes = 0; |
|
6855 | + $NoTestRes = 0; |
|
6856 | + $NoHPTestRes = 0; |
|
6857 | 6857 | |
6858 | - echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n"; |
|
6859 | - $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6860 | - echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n"; |
|
6861 | - echo " |
|
6858 | + echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n"; |
|
6859 | + $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6860 | + echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n"; |
|
6861 | + echo " |
|
6862 | 6862 | <tr bgcolor='#E6E6E6'> |
6863 | 6863 | <td> |
6864 | 6864 | ".get_lang('ExercicesTitleExerciceColumn')." |
@@ -6871,28 +6871,28 @@ discard block |
||
6871 | 6871 | </td> |
6872 | 6872 | </tr>"; |
6873 | 6873 | |
6874 | - if (is_array($results)) { |
|
6875 | - for($i = 0; $i < sizeof($results); $i++) { |
|
6876 | - $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6877 | - echo "<tr>\n"; |
|
6878 | - echo "<td class='content'>".$results[$i][0]."</td>\n"; |
|
6879 | - echo "<td class='content'>".$display_date."</td>\n"; |
|
6880 | - echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n"; |
|
6881 | - echo "</tr>\n"; |
|
6882 | - } |
|
6883 | - } else { |
|
6884 | - // istvan begin |
|
6885 | - $NoTestRes = 1; |
|
6886 | - } |
|
6887 | - |
|
6888 | - // The Result of Tests |
|
6889 | - if (is_array($hpresults)) { |
|
6890 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6891 | - $title = GetQuizName($hpresults[$i][0],''); |
|
6892 | - if ($title == '') |
|
6893 | - $title = basename($hpresults[$i][0]); |
|
6894 | - $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6895 | - ?> |
|
6874 | + if (is_array($results)) { |
|
6875 | + for($i = 0; $i < sizeof($results); $i++) { |
|
6876 | + $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6877 | + echo "<tr>\n"; |
|
6878 | + echo "<td class='content'>".$results[$i][0]."</td>\n"; |
|
6879 | + echo "<td class='content'>".$display_date."</td>\n"; |
|
6880 | + echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n"; |
|
6881 | + echo "</tr>\n"; |
|
6882 | + } |
|
6883 | + } else { |
|
6884 | + // istvan begin |
|
6885 | + $NoTestRes = 1; |
|
6886 | + } |
|
6887 | + |
|
6888 | + // The Result of Tests |
|
6889 | + if (is_array($hpresults)) { |
|
6890 | + for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6891 | + $title = GetQuizName($hpresults[$i][0],''); |
|
6892 | + if ($title == '') |
|
6893 | + $title = basename($hpresults[$i][0]); |
|
6894 | + $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6895 | + ?> |
|
6896 | 6896 | <tr> |
6897 | 6897 | <td class="content"><?php echo $title; ?></td> |
6898 | 6898 | <td class="content" align="center"><?php echo $display_date; ?></td> |
@@ -6902,26 +6902,26 @@ discard block |
||
6902 | 6902 | |
6903 | 6903 | <?php |
6904 | 6904 | } |
6905 | - } else { |
|
6906 | - $NoHPTestRes = 1; |
|
6907 | - } |
|
6908 | - |
|
6909 | - if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6910 | - echo "<tr>\n"; |
|
6911 | - echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n"; |
|
6912 | - echo "</tr>\n"; |
|
6913 | - } |
|
6914 | - echo "</table>"; |
|
6915 | - echo "</td>\n</tr>\n"; |
|
6916 | - } else { |
|
6917 | - $new_view = substr_replace($view,'1',1,1); |
|
6918 | - echo " |
|
6905 | + } else { |
|
6906 | + $NoHPTestRes = 1; |
|
6907 | + } |
|
6908 | + |
|
6909 | + if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6910 | + echo "<tr>\n"; |
|
6911 | + echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n"; |
|
6912 | + echo "</tr>\n"; |
|
6913 | + } |
|
6914 | + echo "</table>"; |
|
6915 | + echo "</td>\n</tr>\n"; |
|
6916 | + } else { |
|
6917 | + $new_view = substr_replace($view,'1',1,1); |
|
6918 | + echo " |
|
6919 | 6919 | <tr> |
6920 | 6920 | <td valign='top'> |
6921 | 6921 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a> |
6922 | 6922 | </td> |
6923 | 6923 | </tr>"; |
6924 | - } |
|
6924 | + } |
|
6925 | 6925 | } |
6926 | 6926 | |
6927 | 6927 | /** |
@@ -6930,27 +6930,27 @@ discard block |
||
6930 | 6930 | */ |
6931 | 6931 | public static function display_student_publications_tracking_info($view, $user_id, $course_id) |
6932 | 6932 | { |
6933 | - global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
6933 | + global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
6934 | 6934 | $_course = api_get_course_info_by_id($course_id); |
6935 | 6935 | |
6936 | - if (substr($view,2,1) == '1') { |
|
6937 | - $new_view = substr_replace($view,'0',2,1); |
|
6938 | - echo "<tr> |
|
6936 | + if (substr($view,2,1) == '1') { |
|
6937 | + $new_view = substr_replace($view,'0',2,1); |
|
6938 | + echo "<tr> |
|
6939 | 6939 | <td valign='top'> |
6940 | 6940 | <font color='#0000FF'>- </font><b>".get_lang('WorkUploads')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>] |
6941 | 6941 | </td> |
6942 | 6942 | </tr>"; |
6943 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>"; |
|
6944 | - $sql = "SELECT u.upload_date, w.title, w.author,w.url |
|
6943 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>"; |
|
6944 | + $sql = "SELECT u.upload_date, w.title, w.author,w.url |
|
6945 | 6945 | FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w |
6946 | 6946 | WHERE u.upload_work_id = w.id |
6947 | 6947 | AND u.upload_user_id = '".intval($user_id)."' |
6948 | 6948 | AND u.c_id = '".intval($course_id)."' |
6949 | 6949 | ORDER BY u.upload_date DESC"; |
6950 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6951 | - $results = StatsUtils::getManyResultsXCol($sql,4); |
|
6952 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6953 | - echo "<tr> |
|
6950 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6951 | + $results = StatsUtils::getManyResultsXCol($sql,4); |
|
6952 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6953 | + echo "<tr> |
|
6954 | 6954 | <td class='secLine' width='40%'> |
6955 | 6955 | ".get_lang('WorkTitle')." |
6956 | 6956 | </td> |
@@ -6961,35 +6961,35 @@ discard block |
||
6961 | 6961 | ".get_lang('Date')." |
6962 | 6962 | </td> |
6963 | 6963 | </tr>"; |
6964 | - if (is_array($results)) { |
|
6965 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6966 | - $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
6967 | - $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
6968 | - echo "<tr>"; |
|
6969 | - echo "<td class='content'>" |
|
6970 | - ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>" |
|
6971 | - ."</td>"; |
|
6972 | - echo "<td class='content'>".$results[$j][2]."</td>"; |
|
6973 | - echo "<td class='content'>".$beautifulDate."</td>"; |
|
6974 | - echo"</tr>"; |
|
6975 | - } |
|
6976 | - } else { |
|
6977 | - echo "<tr>"; |
|
6978 | - echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>"; |
|
6979 | - echo"</tr>"; |
|
6980 | - } |
|
6981 | - echo "</table>"; |
|
6982 | - echo "</td></tr>"; |
|
6983 | - } else { |
|
6984 | - $new_view = substr_replace($view,'1',2,1); |
|
6985 | - echo " |
|
6964 | + if (is_array($results)) { |
|
6965 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6966 | + $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
6967 | + $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
6968 | + echo "<tr>"; |
|
6969 | + echo "<td class='content'>" |
|
6970 | + ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>" |
|
6971 | + ."</td>"; |
|
6972 | + echo "<td class='content'>".$results[$j][2]."</td>"; |
|
6973 | + echo "<td class='content'>".$beautifulDate."</td>"; |
|
6974 | + echo"</tr>"; |
|
6975 | + } |
|
6976 | + } else { |
|
6977 | + echo "<tr>"; |
|
6978 | + echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>"; |
|
6979 | + echo"</tr>"; |
|
6980 | + } |
|
6981 | + echo "</table>"; |
|
6982 | + echo "</td></tr>"; |
|
6983 | + } else { |
|
6984 | + $new_view = substr_replace($view,'1',2,1); |
|
6985 | + echo " |
|
6986 | 6986 | <tr> |
6987 | 6987 | <td valign='top'> |
6988 | 6988 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a> |
6989 | 6989 | </td> |
6990 | 6990 | </tr> |
6991 | 6991 | "; |
6992 | - } |
|
6992 | + } |
|
6993 | 6993 | } |
6994 | 6994 | |
6995 | 6995 | /** |
@@ -6998,55 +6998,55 @@ discard block |
||
6998 | 6998 | */ |
6999 | 6999 | public static function display_links_tracking_info($view, $user_id, $courseCode) |
7000 | 7000 | { |
7001 | - global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7001 | + global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7002 | 7002 | $courseId = api_get_course_int_id($courseCode); |
7003 | - if (substr($view,3,1) == '1') { |
|
7004 | - $new_view = substr_replace($view,'0',3,1); |
|
7005 | - echo " |
|
7003 | + if (substr($view,3,1) == '1') { |
|
7004 | + $new_view = substr_replace($view,'0',3,1); |
|
7005 | + echo " |
|
7006 | 7006 | <tr> |
7007 | 7007 | <td valign='top'> |
7008 | 7008 | <font color='#0000FF'>- </font><b>".get_lang('LinksAccess')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>] |
7009 | 7009 | </td> |
7010 | 7010 | </tr> |
7011 | 7011 | "; |
7012 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>"; |
|
7013 | - $sql = "SELECT cl.title, cl.url |
|
7012 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>"; |
|
7013 | + $sql = "SELECT cl.title, cl.url |
|
7014 | 7014 | FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl |
7015 | 7015 | WHERE sl.links_link_id = cl.id |
7016 | 7016 | AND sl.c_id = $courseId |
7017 | 7017 | AND sl.links_user_id = ".intval($user_id)." |
7018 | 7018 | GROUP BY cl.title, cl.url"; |
7019 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
7020 | - $results = StatsUtils::getManyResults2Col($sql); |
|
7021 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
7022 | - echo "<tr> |
|
7019 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
7020 | + $results = StatsUtils::getManyResults2Col($sql); |
|
7021 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
7022 | + echo "<tr> |
|
7023 | 7023 | <td class='secLine'> |
7024 | 7024 | ".get_lang('LinksTitleLinkColumn')." |
7025 | 7025 | </td> |
7026 | 7026 | </tr>"; |
7027 | - if (is_array($results)) { |
|
7028 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
7029 | - echo "<tr>"; |
|
7030 | - echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>"; |
|
7031 | - echo"</tr>"; |
|
7032 | - } |
|
7033 | - } else { |
|
7034 | - echo "<tr>"; |
|
7035 | - echo "<td ><center>".get_lang('NoResult')."</center></td>"; |
|
7036 | - echo"</tr>"; |
|
7037 | - } |
|
7038 | - echo "</table>"; |
|
7039 | - echo "</td></tr>"; |
|
7040 | - } else { |
|
7041 | - $new_view = substr_replace($view,'1',3,1); |
|
7042 | - echo " |
|
7027 | + if (is_array($results)) { |
|
7028 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
7029 | + echo "<tr>"; |
|
7030 | + echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>"; |
|
7031 | + echo"</tr>"; |
|
7032 | + } |
|
7033 | + } else { |
|
7034 | + echo "<tr>"; |
|
7035 | + echo "<td ><center>".get_lang('NoResult')."</center></td>"; |
|
7036 | + echo"</tr>"; |
|
7037 | + } |
|
7038 | + echo "</table>"; |
|
7039 | + echo "</td></tr>"; |
|
7040 | + } else { |
|
7041 | + $new_view = substr_replace($view,'1',3,1); |
|
7042 | + echo " |
|
7043 | 7043 | <tr> |
7044 | 7044 | <td valign='top'> |
7045 | 7045 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a> |
7046 | 7046 | </td> |
7047 | 7047 | </tr> |
7048 | 7048 | "; |
7049 | - } |
|
7049 | + } |
|
7050 | 7050 | } |
7051 | 7051 | |
7052 | 7052 | /** |
@@ -7059,61 +7059,61 @@ discard block |
||
7059 | 7059 | */ |
7060 | 7060 | public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0) |
7061 | 7061 | { |
7062 | - // protect data |
|
7062 | + // protect data |
|
7063 | 7063 | $user_id = intval($user_id); |
7064 | 7064 | $courseId = api_get_course_int_id($course_code); |
7065 | - $session_id = intval($session_id); |
|
7065 | + $session_id = intval($session_id); |
|
7066 | 7066 | |
7067 | - $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7068 | - if(substr($view,4,1) == '1') { |
|
7069 | - $new_view = substr_replace($view,'0',4,1); |
|
7070 | - echo " |
|
7067 | + $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7068 | + if(substr($view,4,1) == '1') { |
|
7069 | + $new_view = substr_replace($view,'0',4,1); |
|
7070 | + echo " |
|
7071 | 7071 | <tr> |
7072 | 7072 | <td valign='top'> |
7073 | 7073 | <font color='#0000FF'>- </font><b>".get_lang('DocumentsAccess')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>] |
7074 | 7074 | </td> |
7075 | 7075 | </tr> |
7076 | 7076 | "; |
7077 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>"; |
|
7077 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>"; |
|
7078 | 7078 | |
7079 | - $sql = "SELECT down_doc_path |
|
7079 | + $sql = "SELECT down_doc_path |
|
7080 | 7080 | FROM $downloads_table |
7081 | 7081 | WHERE c_id = $courseId |
7082 | 7082 | AND down_user_id = $user_id |
7083 | 7083 | AND down_session_id = $session_id |
7084 | 7084 | GROUP BY down_doc_path"; |
7085 | 7085 | |
7086 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
7087 | - $results = StatsUtils::getManyResults1Col($sql); |
|
7088 | - echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>"; |
|
7089 | - echo "<tr> |
|
7086 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
7087 | + $results = StatsUtils::getManyResults1Col($sql); |
|
7088 | + echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>"; |
|
7089 | + echo "<tr> |
|
7090 | 7090 | <td class='secLine'> |
7091 | 7091 | ".get_lang('DocumentsTitleDocumentColumn')." |
7092 | 7092 | </td> |
7093 | 7093 | </tr>"; |
7094 | - if (is_array($results)) { |
|
7095 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
7096 | - echo "<tr>"; |
|
7097 | - echo "<td class='content'>".$results[$j]."</td>"; |
|
7098 | - echo"</tr>"; |
|
7099 | - } |
|
7100 | - } else { |
|
7101 | - echo "<tr>"; |
|
7102 | - echo "<td><center>".get_lang('NoResult')."</center></td>"; |
|
7103 | - echo"</tr>"; |
|
7104 | - } |
|
7105 | - echo "</table>"; |
|
7106 | - echo "</td></tr>"; |
|
7107 | - } else { |
|
7108 | - $new_view = substr_replace($view,'1',4,1); |
|
7109 | - echo " |
|
7094 | + if (is_array($results)) { |
|
7095 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
7096 | + echo "<tr>"; |
|
7097 | + echo "<td class='content'>".$results[$j]."</td>"; |
|
7098 | + echo"</tr>"; |
|
7099 | + } |
|
7100 | + } else { |
|
7101 | + echo "<tr>"; |
|
7102 | + echo "<td><center>".get_lang('NoResult')."</center></td>"; |
|
7103 | + echo"</tr>"; |
|
7104 | + } |
|
7105 | + echo "</table>"; |
|
7106 | + echo "</td></tr>"; |
|
7107 | + } else { |
|
7108 | + $new_view = substr_replace($view,'1',4,1); |
|
7109 | + echo " |
|
7110 | 7110 | <tr> |
7111 | 7111 | <td valign='top'> |
7112 | 7112 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a> |
7113 | 7113 | </td> |
7114 | 7114 | </tr> |
7115 | 7115 | "; |
7116 | - } |
|
7116 | + } |
|
7117 | 7117 | } |
7118 | 7118 | |
7119 | 7119 | /** |
@@ -7170,43 +7170,43 @@ discard block |
||
7170 | 7170 | */ |
7171 | 7171 | public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0) |
7172 | 7172 | { |
7173 | - $MonthsLong = $GLOBALS['MonthsLong']; |
|
7174 | - $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
7175 | - |
|
7176 | - // protected data |
|
7177 | - $user_id = intval($user_id); |
|
7178 | - $session_id = intval($session_id); |
|
7179 | - $course_id = intval($course_id); |
|
7180 | - |
|
7181 | - $tempView = $view; |
|
7182 | - if (substr($view,0,1) == '1') { |
|
7183 | - $new_view = substr_replace($view,'0',0,1); |
|
7184 | - $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails'); |
|
7185 | - $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
7173 | + $MonthsLong = $GLOBALS['MonthsLong']; |
|
7174 | + $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
7175 | + |
|
7176 | + // protected data |
|
7177 | + $user_id = intval($user_id); |
|
7178 | + $session_id = intval($session_id); |
|
7179 | + $course_id = intval($course_id); |
|
7180 | + |
|
7181 | + $tempView = $view; |
|
7182 | + if (substr($view,0,1) == '1') { |
|
7183 | + $new_view = substr_replace($view,'0',0,1); |
|
7184 | + $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails'); |
|
7185 | + $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
7186 | 7186 | FROM $track_access_table |
7187 | 7187 | WHERE access_user_id = $user_id |
7188 | 7188 | AND c_id = $course_id |
7189 | 7189 | AND access_session_id = $session_id |
7190 | 7190 | GROUP BY YEAR(access_date),MONTH(access_date) |
7191 | 7191 | ORDER BY YEAR(access_date),MONTH(access_date) ASC"; |
7192 | - //$results = getManyResults2Col($sql); |
|
7193 | - $results = getManyResults3Col($sql); |
|
7194 | - $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n"; |
|
7195 | - $line=''; |
|
7196 | - $total = 0; |
|
7197 | - if (is_array($results)) { |
|
7198 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
7199 | - $line .= $results[$j][0].';'.$results[$j][1]."\n"; |
|
7200 | - $total = $total + $results[$j][1]; |
|
7201 | - } |
|
7202 | - $line .= get_lang('Total').";".$total."\n"; |
|
7203 | - } else { |
|
7204 | - $line= get_lang('NoResult')."</center></td>"; |
|
7205 | - } |
|
7206 | - } else { |
|
7207 | - $new_view = substr_replace($view,'1',0,1); |
|
7208 | - } |
|
7209 | - return array($title_line, $line); |
|
7192 | + //$results = getManyResults2Col($sql); |
|
7193 | + $results = getManyResults3Col($sql); |
|
7194 | + $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n"; |
|
7195 | + $line=''; |
|
7196 | + $total = 0; |
|
7197 | + if (is_array($results)) { |
|
7198 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
7199 | + $line .= $results[$j][0].';'.$results[$j][1]."\n"; |
|
7200 | + $total = $total + $results[$j][1]; |
|
7201 | + } |
|
7202 | + $line .= get_lang('Total').";".$total."\n"; |
|
7203 | + } else { |
|
7204 | + $line= get_lang('NoResult')."</center></td>"; |
|
7205 | + } |
|
7206 | + } else { |
|
7207 | + $new_view = substr_replace($view,'1',0,1); |
|
7208 | + } |
|
7209 | + return array($title_line, $line); |
|
7210 | 7210 | } |
7211 | 7211 | |
7212 | 7212 | /** |
@@ -7219,67 +7219,67 @@ discard block |
||
7219 | 7219 | */ |
7220 | 7220 | public function display_exercise_tracking_info($view, $userId, $courseCode) |
7221 | 7221 | { |
7222 | - global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong; |
|
7222 | + global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong; |
|
7223 | 7223 | $courseId = api_get_course_int_id($courseCode); |
7224 | 7224 | $userId = intval($userId); |
7225 | - if (substr($view,1,1) == '1') { |
|
7226 | - $new_view = substr_replace($view,'0',1,1); |
|
7227 | - $title[1] = get_lang('ExercicesDetails'); |
|
7228 | - $line = ''; |
|
7229 | - $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
7225 | + if (substr($view,1,1) == '1') { |
|
7226 | + $new_view = substr_replace($view,'0',1,1); |
|
7227 | + $title[1] = get_lang('ExercicesDetails'); |
|
7228 | + $line = ''; |
|
7229 | + $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
7230 | 7230 | FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te |
7231 | 7231 | WHERE te.c_id = $courseId |
7232 | 7232 | AND te.exe_user_id = $userId |
7233 | 7233 | AND te.exe_exo_id = ce.id |
7234 | 7234 | ORDER BY ce.title ASC, te.exe_date ASC"; |
7235 | 7235 | |
7236 | - $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
7236 | + $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
7237 | 7237 | FROM $TABLETRACK_HOTPOTATOES AS te |
7238 | 7238 | WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId |
7239 | 7239 | ORDER BY te.c_id ASC, te.exe_date ASC"; |
7240 | 7240 | |
7241 | - $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
7241 | + $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
7242 | 7242 | |
7243 | - $NoTestRes = 0; |
|
7244 | - $NoHPTestRes = 0; |
|
7243 | + $NoTestRes = 0; |
|
7244 | + $NoHPTestRes = 0; |
|
7245 | 7245 | |
7246 | - $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
7247 | - $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n"; |
|
7246 | + $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
7247 | + $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n"; |
|
7248 | 7248 | |
7249 | - if (is_array($results)) { |
|
7250 | - for($i = 0; $i < sizeof($results); $i++) |
|
7251 | - { |
|
7252 | - $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
7253 | - $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n"; |
|
7254 | - } |
|
7255 | - } else { |
|
7249 | + if (is_array($results)) { |
|
7250 | + for($i = 0; $i < sizeof($results); $i++) |
|
7251 | + { |
|
7252 | + $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
7253 | + $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n"; |
|
7254 | + } |
|
7255 | + } else { |
|
7256 | 7256 | // istvan begin |
7257 | - $NoTestRes = 1; |
|
7258 | - } |
|
7259 | - |
|
7260 | - // The Result of Tests |
|
7261 | - if (is_array($hpresults)) { |
|
7262 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
7263 | - $title = GetQuizName($hpresults[$i][0],''); |
|
7264 | - |
|
7265 | - if ($title == '') |
|
7266 | - $title = basename($hpresults[$i][0]); |
|
7267 | - |
|
7268 | - $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
7269 | - |
|
7270 | - $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n"; |
|
7271 | - } |
|
7272 | - } else { |
|
7273 | - $NoHPTestRes = 1; |
|
7274 | - } |
|
7275 | - |
|
7276 | - if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
7277 | - $line=get_lang('NoResult'); |
|
7278 | - } |
|
7279 | - } else { |
|
7280 | - $new_view = substr_replace($view,'1',1,1); |
|
7281 | - } |
|
7282 | - return array($title_line, $line); |
|
7257 | + $NoTestRes = 1; |
|
7258 | + } |
|
7259 | + |
|
7260 | + // The Result of Tests |
|
7261 | + if (is_array($hpresults)) { |
|
7262 | + for($i = 0; $i < sizeof($hpresults); $i++) { |
|
7263 | + $title = GetQuizName($hpresults[$i][0],''); |
|
7264 | + |
|
7265 | + if ($title == '') |
|
7266 | + $title = basename($hpresults[$i][0]); |
|
7267 | + |
|
7268 | + $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
7269 | + |
|
7270 | + $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n"; |
|
7271 | + } |
|
7272 | + } else { |
|
7273 | + $NoHPTestRes = 1; |
|
7274 | + } |
|
7275 | + |
|
7276 | + if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
7277 | + $line=get_lang('NoResult'); |
|
7278 | + } |
|
7279 | + } else { |
|
7280 | + $new_view = substr_replace($view,'1',1,1); |
|
7281 | + } |
|
7282 | + return array($title_line, $line); |
|
7283 | 7283 | } |
7284 | 7284 | |
7285 | 7285 | /** |
@@ -7288,37 +7288,37 @@ discard block |
||
7288 | 7288 | */ |
7289 | 7289 | public function display_student_publications_tracking_info($view, $user_id, $course_id) |
7290 | 7290 | { |
7291 | - global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
7291 | + global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
7292 | 7292 | $_course = api_get_course_info(); |
7293 | 7293 | $user_id = intval($user_id); |
7294 | 7294 | $course_id = intval($course_id); |
7295 | 7295 | |
7296 | - if (substr($view,2,1) == '1') { |
|
7297 | - $sql = "SELECT u.upload_date, w.title, w.author, w.url |
|
7296 | + if (substr($view,2,1) == '1') { |
|
7297 | + $sql = "SELECT u.upload_date, w.title, w.author, w.url |
|
7298 | 7298 | FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w |
7299 | 7299 | WHERE |
7300 | 7300 | u.upload_work_id = w.id AND |
7301 | 7301 | u.upload_user_id = '$user_id' AND |
7302 | 7302 | u.c_id = '$course_id' |
7303 | 7303 | ORDER BY u.upload_date DESC"; |
7304 | - $results = StatsUtils::getManyResultsXCol($sql,4); |
|
7305 | - |
|
7306 | - $title[1]=get_lang('WorksDetails'); |
|
7307 | - $line=''; |
|
7308 | - $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n"; |
|
7309 | - |
|
7310 | - if (is_array($results)) { |
|
7311 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
7312 | - $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
7313 | - $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
7314 | - $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n"; |
|
7315 | - } |
|
7316 | - |
|
7317 | - } else { |
|
7318 | - $line= get_lang('NoResult'); |
|
7319 | - } |
|
7320 | - } |
|
7321 | - return array($title_line, $line); |
|
7304 | + $results = StatsUtils::getManyResultsXCol($sql,4); |
|
7305 | + |
|
7306 | + $title[1]=get_lang('WorksDetails'); |
|
7307 | + $line=''; |
|
7308 | + $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n"; |
|
7309 | + |
|
7310 | + if (is_array($results)) { |
|
7311 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
7312 | + $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
7313 | + $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
7314 | + $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n"; |
|
7315 | + } |
|
7316 | + |
|
7317 | + } else { |
|
7318 | + $line= get_lang('NoResult'); |
|
7319 | + } |
|
7320 | + } |
|
7321 | + return array($title_line, $line); |
|
7322 | 7322 | } |
7323 | 7323 | |
7324 | 7324 | /** |
@@ -7327,32 +7327,32 @@ discard block |
||
7327 | 7327 | */ |
7328 | 7328 | public function display_links_tracking_info($view, $userId, $courseCode) |
7329 | 7329 | { |
7330 | - global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7330 | + global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7331 | 7331 | $courseId = api_get_course_int_id($courseCode); |
7332 | 7332 | $userId = intval($userId); |
7333 | 7333 | $line = null; |
7334 | - if (substr($view,3,1) == '1') { |
|
7335 | - $new_view = substr_replace($view,'0',3,1); |
|
7336 | - $title[1]=get_lang('LinksDetails'); |
|
7337 | - $sql = "SELECT cl.title, cl.url |
|
7334 | + if (substr($view,3,1) == '1') { |
|
7335 | + $new_view = substr_replace($view,'0',3,1); |
|
7336 | + $title[1]=get_lang('LinksDetails'); |
|
7337 | + $sql = "SELECT cl.title, cl.url |
|
7338 | 7338 | FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl |
7339 | 7339 | WHERE sl.links_link_id = cl.id |
7340 | 7340 | AND sl.c_id = $courseId |
7341 | 7341 | AND sl.links_user_id = $userId |
7342 | 7342 | GROUP BY cl.title, cl.url"; |
7343 | - $results = StatsUtils::getManyResults2Col($sql); |
|
7344 | - $title_line= get_lang('LinksTitleLinkColumn')."\n"; |
|
7345 | - if (is_array($results)) { |
|
7346 | - for ($j = 0 ; $j < count($results) ; $j++) { |
|
7347 | - $line .= $results[$j][0]."\n"; |
|
7348 | - } |
|
7349 | - } else { |
|
7350 | - $line=get_lang('NoResult'); |
|
7351 | - } |
|
7352 | - } else { |
|
7353 | - $new_view = substr_replace($view,'1',3,1); |
|
7354 | - } |
|
7355 | - return array($title_line, $line); |
|
7343 | + $results = StatsUtils::getManyResults2Col($sql); |
|
7344 | + $title_line= get_lang('LinksTitleLinkColumn')."\n"; |
|
7345 | + if (is_array($results)) { |
|
7346 | + for ($j = 0 ; $j < count($results) ; $j++) { |
|
7347 | + $line .= $results[$j][0]."\n"; |
|
7348 | + } |
|
7349 | + } else { |
|
7350 | + $line=get_lang('NoResult'); |
|
7351 | + } |
|
7352 | + } else { |
|
7353 | + $new_view = substr_replace($view,'1',3,1); |
|
7354 | + } |
|
7355 | + return array($title_line, $line); |
|
7356 | 7356 | } |
7357 | 7357 | |
7358 | 7358 | /** |
@@ -7365,38 +7365,38 @@ discard block |
||
7365 | 7365 | */ |
7366 | 7366 | public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0) |
7367 | 7367 | { |
7368 | - // protect data |
|
7369 | - $user_id = intval($user_id); |
|
7368 | + // protect data |
|
7369 | + $user_id = intval($user_id); |
|
7370 | 7370 | $courseId = api_get_course_int_id($courseCode); |
7371 | - $session_id = intval($session_id); |
|
7371 | + $session_id = intval($session_id); |
|
7372 | 7372 | |
7373 | - $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7373 | + $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7374 | 7374 | |
7375 | - if (substr($view,4,1) == '1') { |
|
7376 | - $new_view = substr_replace($view,'0',4,1); |
|
7377 | - $title[1]= get_lang('DocumentsDetails'); |
|
7375 | + if (substr($view,4,1) == '1') { |
|
7376 | + $new_view = substr_replace($view,'0',4,1); |
|
7377 | + $title[1]= get_lang('DocumentsDetails'); |
|
7378 | 7378 | |
7379 | - $sql = "SELECT down_doc_path |
|
7379 | + $sql = "SELECT down_doc_path |
|
7380 | 7380 | FROM $downloads_table |
7381 | 7381 | WHERE c_id = $courseId |
7382 | 7382 | AND down_user_id = $user_id |
7383 | 7383 | AND down_session_id = $session_id |
7384 | 7384 | GROUP BY down_doc_path"; |
7385 | 7385 | |
7386 | - $results = StatsUtils::getManyResults1Col($sql); |
|
7387 | - $title_line = get_lang('DocumentsTitleDocumentColumn')."\n"; |
|
7386 | + $results = StatsUtils::getManyResults1Col($sql); |
|
7387 | + $title_line = get_lang('DocumentsTitleDocumentColumn')."\n"; |
|
7388 | 7388 | $line = null; |
7389 | - if (is_array($results)) { |
|
7390 | - for ($j = 0 ; $j < count($results) ; $j++) { |
|
7391 | - $line .= $results[$j]."\n"; |
|
7392 | - } |
|
7393 | - } else { |
|
7394 | - $line = get_lang('NoResult'); |
|
7395 | - } |
|
7396 | - } else { |
|
7397 | - $new_view = substr_replace($view,'1',4,1); |
|
7398 | - } |
|
7399 | - return array($title_line, $line); |
|
7389 | + if (is_array($results)) { |
|
7390 | + for ($j = 0 ; $j < count($results) ; $j++) { |
|
7391 | + $line .= $results[$j]."\n"; |
|
7392 | + } |
|
7393 | + } else { |
|
7394 | + $line = get_lang('NoResult'); |
|
7395 | + } |
|
7396 | + } else { |
|
7397 | + $new_view = substr_replace($view,'1',4,1); |
|
7398 | + } |
|
7399 | + return array($title_line, $line); |
|
7400 | 7400 | } |
7401 | 7401 | |
7402 | 7402 | /** |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | // Query db for answers |
34 | 34 | if ($answer_type==HOT_SPOT_DELINEATION) { |
35 | - $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
35 | + $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
36 | 36 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY iid"; |
37 | 37 | } else { |
38 | - $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
38 | + $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS |
|
39 | 39 | WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY iid"; |
40 | 40 | } |
41 | 41 | $result = Database::query($sql); |
@@ -77,37 +77,37 @@ discard block |
||
77 | 77 | $hotSpot['iid'] = $hotspot['iid']; |
78 | 78 | $hotSpot['answer'] = $hotspot['answer']; |
79 | 79 | |
80 | - // Square or rectancle |
|
81 | - if ($hotspot['hotspot_type'] == 'square' ) |
|
82 | - { |
|
80 | + // Square or rectancle |
|
81 | + if ($hotspot['hotspot_type'] == 'square' ) |
|
82 | + { |
|
83 | 83 | $hotSpot['type'] = 'square'; |
84 | - } |
|
85 | - // Circle or ovale |
|
86 | - if ($hotspot['hotspot_type'] == 'circle') |
|
87 | - { |
|
84 | + } |
|
85 | + // Circle or ovale |
|
86 | + if ($hotspot['hotspot_type'] == 'circle') |
|
87 | + { |
|
88 | 88 | $hotSpot['type'] = 'circle'; |
89 | - } |
|
90 | - // Polygon |
|
91 | - if ($hotspot['hotspot_type'] == 'poly') |
|
92 | - { |
|
89 | + } |
|
90 | + // Polygon |
|
91 | + if ($hotspot['hotspot_type'] == 'poly') |
|
92 | + { |
|
93 | 93 | $hotSpot['type'] = 'poly'; |
94 | - } |
|
95 | - // Delineation |
|
96 | - if ($hotspot['hotspot_type'] == 'delineation') |
|
97 | - { |
|
94 | + } |
|
95 | + // Delineation |
|
96 | + if ($hotspot['hotspot_type'] == 'delineation') |
|
97 | + { |
|
98 | 98 | $hotSpot['type'] = 'delineation'; |
99 | - } |
|
100 | - // No error |
|
101 | - if ($hotspot['hotspot_type'] == 'noerror') |
|
102 | - { |
|
99 | + } |
|
100 | + // No error |
|
101 | + if ($hotspot['hotspot_type'] == 'noerror') |
|
102 | + { |
|
103 | 103 | $hotSpot['type'] = 'noerror'; |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | - // This is a good answer, count + 1 for nmbr of clicks |
|
107 | - if ($hotspot['hotspot_type'] > 0) |
|
108 | - { |
|
109 | - $nmbrTries++; |
|
110 | - } |
|
106 | + // This is a good answer, count + 1 for nmbr of clicks |
|
107 | + if ($hotspot['hotspot_type'] > 0) |
|
108 | + { |
|
109 | + $nmbrTries++; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | $hotSpot['coord'] = $hotspot['hotspot_coordinates']; |
113 | 113 |