@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | exit; |
58 | 58 | break; |
59 | 59 | case 'create_subgroups': |
60 | - GroupManager::create_subgroups( |
|
61 | - $_POST['base_group'], |
|
62 | - $_POST['number_of_groups'] |
|
63 | - ); |
|
60 | + GroupManager::create_subgroups( |
|
61 | + $_POST['base_group'], |
|
62 | + $_POST['number_of_groups'] |
|
63 | + ); |
|
64 | 64 | Display::addFlash(Display::return_message(get_lang('GroupsAdded'))); |
65 | 65 | header("Location: ".$currentUrl); |
66 | 66 | exit; |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | if (isset($_POST['number_of_groups'])) { |
85 | 85 | if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) { |
86 | 86 | Display :: display_error_message( |
87 | - get_lang('PleaseEnterValidNumber').'<br /><br /> |
|
87 | + get_lang('PleaseEnterValidNumber').'<br /><br /> |
|
88 | 88 | <a href="group_creation.php?'.api_get_cidreq().'">« '.get_lang('Back').'</a>', |
89 | - false |
|
90 | - ); |
|
89 | + false |
|
90 | + ); |
|
91 | 91 | } else { |
92 | 92 | $number_of_groups = intval($_POST['number_of_groups']); |
93 | 93 | if ($number_of_groups > 1) { |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | } |
126 | 126 | </script> |
127 | 127 | <?php |
128 | - } |
|
129 | - $group_categories = GroupManager::get_categories(); |
|
130 | - $group_id = GroupManager :: get_number_of_groups() + 1; |
|
131 | - $cat_options = []; |
|
132 | - foreach ($group_categories as $index => $category) { |
|
133 | - $cat_options[$category['id']] = $category['title']; |
|
134 | - } |
|
128 | + } |
|
129 | + $group_categories = GroupManager::get_categories(); |
|
130 | + $group_id = GroupManager :: get_number_of_groups() + 1; |
|
131 | + $cat_options = []; |
|
132 | + foreach ($group_categories as $index => $category) { |
|
133 | + $cat_options[$category['id']] = $category['title']; |
|
134 | + } |
|
135 | 135 | $form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq()); |
136 | 136 | |
137 | - // Modify the default templates |
|
138 | - $renderer = $form->defaultRenderer(); |
|
139 | - $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>"; |
|
140 | - $renderer->setFormTemplate($form_template); |
|
141 | - $element_template = <<<EOT |
|
137 | + // Modify the default templates |
|
138 | + $renderer = $form->defaultRenderer(); |
|
139 | + $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>"; |
|
140 | + $renderer->setFormTemplate($form_template); |
|
141 | + $element_template = <<<EOT |
|
142 | 142 | <tr class="separate"> |
143 | 143 | <td> |
144 | 144 | <!-- BEGIN required --> |
@@ -151,25 +151,25 @@ discard block |
||
151 | 151 | </tr> |
152 | 152 | |
153 | 153 | EOT; |
154 | - $renderer->setCustomElementTemplate($element_template); |
|
154 | + $renderer->setCustomElementTemplate($element_template); |
|
155 | 155 | $form->addElement('header', $nameTools); |
156 | - $form->addElement('hidden', 'action'); |
|
157 | - $form->addElement('hidden', 'number_of_groups'); |
|
158 | - $defaults = array(); |
|
159 | - // Table heading |
|
160 | - $group_el = array(); |
|
161 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>'); |
|
156 | + $form->addElement('hidden', 'action'); |
|
157 | + $form->addElement('hidden', 'number_of_groups'); |
|
158 | + $defaults = array(); |
|
159 | + // Table heading |
|
160 | + $group_el = array(); |
|
161 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>'); |
|
162 | 162 | |
163 | - if (api_get_setting('allow_group_categories') === 'true') { |
|
164 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>'); |
|
165 | - } |
|
166 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>'); |
|
167 | - $form->addGroup($group_el, 'groups', null, "</td><td>", false); |
|
168 | - // Checkboxes |
|
169 | - if ($_POST['number_of_groups'] > 1) { |
|
170 | - $group_el = array (); |
|
171 | - $group_el[] = $form->createElement('static', null, null, ' '); |
|
172 | - if (api_get_setting('allow_group_categories') === 'true') { |
|
163 | + if (api_get_setting('allow_group_categories') === 'true') { |
|
164 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>'); |
|
165 | + } |
|
166 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>'); |
|
167 | + $form->addGroup($group_el, 'groups', null, "</td><td>", false); |
|
168 | + // Checkboxes |
|
169 | + if ($_POST['number_of_groups'] > 1) { |
|
170 | + $group_el = array (); |
|
171 | + $group_el[] = $form->createElement('static', null, null, ' '); |
|
172 | + if (api_get_setting('allow_group_categories') === 'true') { |
|
173 | 173 | $group_el[] = $form->createElement( |
174 | 174 | 'checkbox', |
175 | 175 | 'same_category', |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | get_lang('SameForAll'), |
178 | 178 | array('onclick' => "javascript: switch_state('category');") |
179 | 179 | ); |
180 | - } |
|
180 | + } |
|
181 | 181 | $group_el[] = $form->createElement( |
182 | 182 | 'checkbox', |
183 | 183 | 'same_places', |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | get_lang('SameForAll'), |
186 | 186 | array('onclick' => "javascript: switch_state('places');") |
187 | 187 | ); |
188 | - $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
189 | - } |
|
190 | - // Properties for all groups |
|
191 | - for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
192 | - $group_el = array(); |
|
193 | - $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
194 | - if (api_get_setting('allow_group_categories') === 'true') { |
|
188 | + $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
189 | + } |
|
190 | + // Properties for all groups |
|
191 | + for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
192 | + $group_el = array(); |
|
193 | + $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
194 | + if (api_get_setting('allow_group_categories') === 'true') { |
|
195 | 195 | $group_el[] = $form->createElement( |
196 | 196 | 'select', |
197 | 197 | 'group_'.$group_number.'_category', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $cat_options, |
200 | 200 | array('id' => 'category_'.$group_number) |
201 | 201 | ); |
202 | - } |
|
202 | + } |
|
203 | 203 | $group_el[] = $form->createElement( |
204 | 204 | 'text', |
205 | 205 | 'group_'.$group_number.'_places', |
@@ -207,110 +207,110 @@ discard block |
||
207 | 207 | array('class' => 'span1', 'id' => 'places_'.$group_number) |
208 | 208 | ); |
209 | 209 | |
210 | - if ($_POST['number_of_groups'] < 10000) { |
|
211 | - if ($group_id < 10) { |
|
212 | - $prev = '000'; |
|
213 | - } elseif ($group_id < 100) { |
|
214 | - $prev = '00'; |
|
215 | - } elseif ($group_id<1000) { |
|
216 | - $prev = '0'; |
|
217 | - } else { |
|
218 | - $prev = ''; |
|
219 | - } |
|
220 | - } |
|
210 | + if ($_POST['number_of_groups'] < 10000) { |
|
211 | + if ($group_id < 10) { |
|
212 | + $prev = '000'; |
|
213 | + } elseif ($group_id < 100) { |
|
214 | + $prev = '00'; |
|
215 | + } elseif ($group_id<1000) { |
|
216 | + $prev = '0'; |
|
217 | + } else { |
|
218 | + $prev = ''; |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
223 | - $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
224 | - } |
|
225 | - $defaults['action'] = 'create_groups'; |
|
226 | - $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
227 | - $form->setDefaults($defaults); |
|
228 | - $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
222 | + $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
223 | + $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
224 | + } |
|
225 | + $defaults['action'] = 'create_groups'; |
|
226 | + $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
227 | + $form->setDefaults($defaults); |
|
228 | + $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
229 | 229 | $form->display(); |
230 | - } |
|
230 | + } |
|
231 | 231 | } else { |
232 | - /* |
|
232 | + /* |
|
233 | 233 | * Show form to generate new groups |
234 | 234 | */ |
235 | - $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
236 | - $create_groups_form->addElement('header', $nameTools); |
|
235 | + $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
236 | + $create_groups_form->addElement('header', $nameTools); |
|
237 | 237 | $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1')); |
238 | 238 | $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary'); |
239 | - $defaults = array(); |
|
240 | - $defaults['number_of_groups'] = 1; |
|
241 | - $create_groups_form->setDefaults($defaults); |
|
242 | - $create_groups_form->display(); |
|
239 | + $defaults = array(); |
|
240 | + $defaults['number_of_groups'] = 1; |
|
241 | + $create_groups_form->setDefaults($defaults); |
|
242 | + $create_groups_form->display(); |
|
243 | 243 | |
244 | - /* |
|
244 | + /* |
|
245 | 245 | * Show form to generate subgroups |
246 | 246 | */ |
247 | - if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
248 | - $base_group_options = array (); |
|
249 | - $groups = GroupManager :: get_group_list(); |
|
250 | - foreach ($groups as $index => $group) { |
|
251 | - $number_of_students = GroupManager :: number_of_students($group['id']); |
|
252 | - if ($number_of_students > 0) { |
|
253 | - $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
254 | - } |
|
255 | - } |
|
256 | - if (count($base_group_options) > 0) { |
|
257 | - $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
247 | + if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
248 | + $base_group_options = array (); |
|
249 | + $groups = GroupManager :: get_group_list(); |
|
250 | + foreach ($groups as $index => $group) { |
|
251 | + $number_of_students = GroupManager :: number_of_students($group['id']); |
|
252 | + if ($number_of_students > 0) { |
|
253 | + $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
254 | + } |
|
255 | + } |
|
256 | + if (count($base_group_options) > 0) { |
|
257 | + $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
258 | 258 | $create_subgroups_form->addElement('header', get_lang('CreateSubgroups')); |
259 | 259 | $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo')); |
260 | - $create_subgroups_form->addElement('hidden', 'action'); |
|
261 | - $group_el = array(); |
|
262 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
263 | - $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
264 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
265 | - $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
266 | - $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
267 | - $create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false); |
|
268 | - $defaults = array(); |
|
269 | - $defaults['action'] = 'create_subgroups'; |
|
270 | - $create_subgroups_form->setDefaults($defaults); |
|
271 | - $create_subgroups_form->display(); |
|
272 | - } |
|
273 | - } |
|
260 | + $create_subgroups_form->addElement('hidden', 'action'); |
|
261 | + $group_el = array(); |
|
262 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
263 | + $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
264 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
265 | + $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
266 | + $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
267 | + $create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false); |
|
268 | + $defaults = array(); |
|
269 | + $defaults['action'] = 'create_subgroups'; |
|
270 | + $create_subgroups_form->setDefaults($defaults); |
|
271 | + $create_subgroups_form->display(); |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - /* |
|
275 | + /* |
|
276 | 276 | * Show form to generate groups from classes subscribed to the course |
277 | 277 | */ |
278 | 278 | $options['where'] = array(" usergroup.course_id = ? " => api_get_course_int_id()); |
279 | 279 | $obj = new UserGroup(); |
280 | 280 | $classes = $obj->getUserGroupInCourse($options); |
281 | - if (count($classes) > 0) { |
|
282 | - echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
283 | - echo '<blockquote>'; |
|
284 | - echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
285 | - echo '<ul>'; |
|
286 | - foreach ($classes as $index => $class) { |
|
287 | - $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
288 | - echo '<li>'; |
|
289 | - echo $class['name']; |
|
290 | - echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
291 | - echo '</li>'; |
|
292 | - } |
|
293 | - echo '</ul>'; |
|
281 | + if (count($classes) > 0) { |
|
282 | + echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
283 | + echo '<blockquote>'; |
|
284 | + echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
285 | + echo '<ul>'; |
|
286 | + foreach ($classes as $index => $class) { |
|
287 | + $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
288 | + echo '<li>'; |
|
289 | + echo $class['name']; |
|
290 | + echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
291 | + echo '</li>'; |
|
292 | + } |
|
293 | + echo '</ul>'; |
|
294 | 294 | |
295 | - $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
296 | - $create_class_groups_form->addElement('hidden', 'action'); |
|
297 | - if (api_get_setting('allow_group_categories') === 'true') { |
|
298 | - $group_categories = GroupManager :: get_categories(); |
|
299 | - $cat_options = array(); |
|
300 | - foreach ($group_categories as $index => $category) { |
|
301 | - $cat_options[$category['id']] = $category['title']; |
|
302 | - } |
|
303 | - $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
304 | - } else { |
|
305 | - $create_class_groups_form->addElement('hidden', 'group_category'); |
|
306 | - } |
|
307 | - $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
308 | - $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
309 | - $defaults['action'] = 'create_class_groups'; |
|
310 | - $create_class_groups_form->setDefaults($defaults); |
|
311 | - $create_class_groups_form->display(); |
|
312 | - echo '</blockquote>'; |
|
313 | - } |
|
295 | + $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
296 | + $create_class_groups_form->addElement('hidden', 'action'); |
|
297 | + if (api_get_setting('allow_group_categories') === 'true') { |
|
298 | + $group_categories = GroupManager :: get_categories(); |
|
299 | + $cat_options = array(); |
|
300 | + foreach ($group_categories as $index => $category) { |
|
301 | + $cat_options[$category['id']] = $category['title']; |
|
302 | + } |
|
303 | + $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
304 | + } else { |
|
305 | + $create_class_groups_form->addElement('hidden', 'group_category'); |
|
306 | + } |
|
307 | + $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
308 | + $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
309 | + $defaults['action'] = 'create_class_groups'; |
|
310 | + $create_class_groups_form->setDefaults($defaults); |
|
311 | + $create_class_groups_form->display(); |
|
312 | + echo '</blockquote>'; |
|
313 | + } |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | Display :: display_footer(); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | //user has submitted a file |
49 | 49 | if (isset($_FILES['user_upload'])) { |
50 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
51 | - if ($upload_ok) { |
|
52 | - //file got on the server without problems, now process it |
|
50 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
51 | + if ($upload_ok) { |
|
52 | + //file got on the server without problems, now process it |
|
53 | 53 | $new_path = handle_uploaded_document( |
54 | 54 | $_course, |
55 | 55 | $_FILES['user_upload'], |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | $_POST['unzip'], |
62 | 62 | $_POST['if_exists'] |
63 | 63 | ); |
64 | - $new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : ''; |
|
65 | - $new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : ''; |
|
64 | + $new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : ''; |
|
65 | + $new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : ''; |
|
66 | 66 | |
67 | - if ($new_path && ($new_comment || $new_title)) |
|
68 | - if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
69 | - $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
70 | - $ct = ''; |
|
67 | + if ($new_path && ($new_comment || $new_title)) |
|
68 | + if (($docid = DocumentManager::get_document_id($_course, $new_path))) { |
|
69 | + $table_document = Database::get_course_table(TABLE_DOCUMENT); |
|
70 | + $ct = ''; |
|
71 | 71 | if ($new_comment) { |
72 | 72 | $ct .= ", comment='$new_comment'"; |
73 | 73 | } |
74 | 74 | if ($new_title) { |
75 | 75 | $ct .= ", title='$new_title'"; |
76 | 76 | } |
77 | - Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
78 | - } |
|
77 | + Database::query("UPDATE $table_document SET" . substr($ct, 1) ." WHERE id = '$docid'"); |
|
78 | + } |
|
79 | 79 | //check for missing images in html files |
80 | 80 | $missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path); |
81 | 81 | if ($missing_files) { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | //they want to create a directory |
134 | 134 | if (isset($_POST['create_dir']) && $_POST['dirname']!='') { |
135 | 135 | $added_slash = $path == '/' ? '' : '/'; |
136 | - $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
136 | + $dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']); |
|
137 | 137 | $created_dir = create_unexisting_directory( |
138 | 138 | $_course, |
139 | 139 | api_get_user_id(), |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | if (isset($_GET['createdir'])) { |
156 | - //create the form that asks for the directory name |
|
157 | - $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
158 | - $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
159 | - $new_folder_text .= get_lang('NewDir') .' '; |
|
160 | - $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
161 | - $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
162 | - $new_folder_text .= '</form>'; |
|
163 | - //show the form |
|
164 | - Display::display_normal_message($new_folder_text); |
|
156 | + //create the form that asks for the directory name |
|
157 | + $new_folder_text = '<form action="'.api_get_self().'" method="POST">'; |
|
158 | + $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>'; |
|
159 | + $new_folder_text .= get_lang('NewDir') .' '; |
|
160 | + $new_folder_text .= '<input type="text" name="dirname"/>'; |
|
161 | + $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>'; |
|
162 | + $new_folder_text .= '</form>'; |
|
163 | + //show the form |
|
164 | + Display::display_normal_message($new_folder_text); |
|
165 | 165 | } else { //give them a link to create a directory |
166 | 166 | ?> |
167 | 167 | <p> |
@@ -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,37 +225,37 @@ 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($line,$column,get_lang('Email')); |
|
254 | - $column++; |
|
252 | + if ($with_column_user) { |
|
253 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('Email')); |
|
254 | + $column++; |
|
255 | 255 | |
256 | 256 | if (api_is_western_name_order()) { |
257 | - $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
258 | - $column++; |
|
257 | + $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
|
258 | + $column++; |
|
259 | 259 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('LastName')); |
260 | 260 | $column++; |
261 | 261 | } else { |
@@ -264,36 +264,36 @@ discard block |
||
264 | 264 | $worksheet->SetCellValueByColumnAndRow($line,$column,get_lang('FirstName')); |
265 | 265 | $column++; |
266 | 266 | } |
267 | - } |
|
267 | + } |
|
268 | 268 | |
269 | - if ($export_user_fields) { |
|
270 | - //show user fields section with a big th colspan that spans over all fields |
|
271 | - $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
269 | + if ($export_user_fields) { |
|
270 | + //show user fields section with a big th colspan that spans over all fields |
|
271 | + $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1); |
|
272 | 272 | |
273 | - //show the fields names for user fields |
|
274 | - foreach ($extra_user_fields as $field) { |
|
275 | - $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
276 | - $column++; |
|
277 | - } |
|
278 | - } |
|
273 | + //show the fields names for user fields |
|
274 | + foreach ($extra_user_fields as $field) { |
|
275 | + $worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)); |
|
276 | + $column++; |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
281 | - $column++; |
|
282 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
280 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Title')); |
|
281 | + $column++; |
|
282 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('StartDate')); |
|
283 | 283 | $column++; |
284 | 284 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('EndDate')); |
285 | 285 | $column++; |
286 | 286 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')'); |
287 | - $column++; |
|
288 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
289 | - $column++; |
|
290 | - $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
291 | - $column++; |
|
287 | + $column++; |
|
288 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Score')); |
|
289 | + $column++; |
|
290 | + $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Total')); |
|
291 | + $column++; |
|
292 | 292 | $worksheet->SetCellValueByColumnAndRow($line,$column, get_lang('Status')); |
293 | - $line++; |
|
293 | + $line++; |
|
294 | 294 | |
295 | - foreach ($this->results as $row) { |
|
296 | - $column = 0; |
|
295 | + foreach ($this->results as $row) { |
|
296 | + $column = 0; |
|
297 | 297 | |
298 | 298 | if ($with_column_user) { |
299 | 299 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)); |
@@ -310,38 +310,38 @@ discard block |
||
310 | 310 | $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); |
311 | 311 | $column++; |
312 | 312 | } |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - if ($export_user_fields) { |
|
316 | - //show user fields data, if any, for this user |
|
317 | - $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
318 | - foreach($user_fields_values as $value) { |
|
319 | - $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
320 | - $column++; |
|
321 | - } |
|
322 | - } |
|
315 | + if ($export_user_fields) { |
|
316 | + //show user fields data, if any, for this user |
|
317 | + $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
318 | + foreach($user_fields_values as $value) { |
|
319 | + $worksheet->SetCellValueByColumnAndRow($line,$column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); |
|
320 | + $column++; |
|
321 | + } |
|
322 | + } |
|
323 | 323 | |
324 | - $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
325 | - $column++; |
|
326 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
324 | + $worksheet->SetCellValueByColumnAndRow($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); |
|
325 | + $column++; |
|
326 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['start_date']); |
|
327 | 327 | $column++; |
328 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
328 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['end_date']); |
|
329 | + $column++; |
|
330 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
331 | + $column++; |
|
332 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
333 | + $column++; |
|
334 | + $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
329 | 335 | $column++; |
330 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['duration']); |
|
331 | - $column++; |
|
332 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['result']); |
|
333 | - $column++; |
|
334 | - $worksheet->SetCellValueByColumnAndRow($line,$column,$row['max']); |
|
335 | - $column++; |
|
336 | 336 | $worksheet->SetCellValueByColumnAndRow($line,$column,$row['status']); |
337 | - $line++; |
|
338 | - } |
|
337 | + $line++; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename); |
341 | 341 | $writer = new PHPExcel_Writer_Excel2007($spreadsheet); |
342 | 342 | $writer->save($file); |
343 | 343 | DocumentManager::file_send_for_download($file, true, $filename); |
344 | 344 | |
345 | - return true; |
|
346 | - } |
|
345 | + return true; |
|
346 | + } |
|
347 | 347 | } |
@@ -12,31 +12,31 @@ discard block |
||
12 | 12 | **/ |
13 | 13 | class HotSpot extends Question |
14 | 14 | { |
15 | - public static $typePicture = 'hotspot.png'; |
|
16 | - public static $explanationLangVar = 'HotSpot'; |
|
15 | + public static $typePicture = 'hotspot.png'; |
|
16 | + public static $explanationLangVar = 'HotSpot'; |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * HotSpot constructor. |
20 | 20 | */ |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - $this->type = HOT_SPOT; |
|
25 | - } |
|
26 | - |
|
27 | - public function display() |
|
28 | - { |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @param FormValidator $form |
|
33 | - * @param int $fck_config |
|
34 | - */ |
|
35 | - public function createForm (&$form, $fck_config=0) |
|
36 | - { |
|
37 | - parent::createForm($form, $fck_config); |
|
38 | - |
|
39 | - if (!isset($_GET['editQuestion'])) { |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + $this->type = HOT_SPOT; |
|
25 | + } |
|
26 | + |
|
27 | + public function display() |
|
28 | + { |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @param FormValidator $form |
|
33 | + * @param int $fck_config |
|
34 | + */ |
|
35 | + public function createForm (&$form, $fck_config=0) |
|
36 | + { |
|
37 | + parent::createForm($form, $fck_config); |
|
38 | + |
|
39 | + if (!isset($_GET['editQuestion'])) { |
|
40 | 40 | $form->addElement( |
41 | 41 | 'file', |
42 | 42 | 'imageUpload', |
@@ -46,54 +46,54 @@ discard block |
||
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | |
49 | - // setting the save button here and not in the question class.php |
|
50 | - // Saving a question |
|
51 | - $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
52 | - //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
53 | - $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); |
|
54 | - $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
|
55 | - } else { |
|
56 | - // setting the save button here and not in the question class.php |
|
57 | - // Editing a question |
|
58 | - $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion'); |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @param FormValidator $form |
|
64 | - * @param null $objExercise |
|
65 | - * @return null|false |
|
66 | - */ |
|
67 | - public function processCreation($form, $objExercise = null) |
|
68 | - { |
|
69 | - $file_info = $form->getSubmitValue('imageUpload'); |
|
70 | - $_course = api_get_course_info(); |
|
71 | - parent::processCreation($form, $objExercise); |
|
72 | - |
|
73 | - if(!empty($file_info['tmp_name'])) { |
|
74 | - $this->uploadPicture($file_info['tmp_name'], $file_info['name']); |
|
75 | - $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
76 | - $picturePath = $documentPath.'/images'; |
|
77 | - |
|
78 | - // fixed width ang height |
|
79 | - if (file_exists($picturePath.'/'.$this->picture)) { |
|
80 | - $this->resizePicture('width', 800); |
|
81 | - $this->save(); |
|
82 | - } else { |
|
83 | - return false; |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - function createAnswersForm($form) |
|
89 | - { |
|
90 | - // nothing |
|
91 | - } |
|
92 | - |
|
93 | - function processAnswersCreation($form) |
|
94 | - { |
|
95 | - // nothing |
|
96 | - } |
|
49 | + // setting the save button here and not in the question class.php |
|
50 | + // Saving a question |
|
51 | + $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
52 | + //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
|
53 | + $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif')); |
|
54 | + $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
|
55 | + } else { |
|
56 | + // setting the save button here and not in the question class.php |
|
57 | + // Editing a question |
|
58 | + $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion'); |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @param FormValidator $form |
|
64 | + * @param null $objExercise |
|
65 | + * @return null|false |
|
66 | + */ |
|
67 | + public function processCreation($form, $objExercise = null) |
|
68 | + { |
|
69 | + $file_info = $form->getSubmitValue('imageUpload'); |
|
70 | + $_course = api_get_course_info(); |
|
71 | + parent::processCreation($form, $objExercise); |
|
72 | + |
|
73 | + if(!empty($file_info['tmp_name'])) { |
|
74 | + $this->uploadPicture($file_info['tmp_name'], $file_info['name']); |
|
75 | + $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
76 | + $picturePath = $documentPath.'/images'; |
|
77 | + |
|
78 | + // fixed width ang height |
|
79 | + if (file_exists($picturePath.'/'.$this->picture)) { |
|
80 | + $this->resizePicture('width', 800); |
|
81 | + $this->save(); |
|
82 | + } else { |
|
83 | + return false; |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + function createAnswersForm($form) |
|
89 | + { |
|
90 | + // nothing |
|
91 | + } |
|
92 | + |
|
93 | + function processAnswersCreation($form) |
|
94 | + { |
|
95 | + // nothing |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -101,38 +101,38 @@ discard block |
||
101 | 101 | */ |
102 | 102 | class HotSpotDelineation extends HotSpot |
103 | 103 | { |
104 | - public static $typePicture = 'hotspot-delineation.png'; |
|
105 | - public static $explanationLangVar = 'HotspotDelineation'; |
|
104 | + public static $typePicture = 'hotspot-delineation.png'; |
|
105 | + public static $explanationLangVar = 'HotspotDelineation'; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * HotSpotDelineation constructor. |
109 | 109 | */ |
110 | - public function __construct() |
|
111 | - { |
|
112 | - parent::__construct(); |
|
113 | - $this -> type = HOT_SPOT_DELINEATION; |
|
114 | - |
|
115 | - } |
|
116 | - |
|
117 | - function createForm(&$form, $fck_config=0) |
|
118 | - { |
|
119 | - parent::createForm ($form, $fck_config); |
|
120 | - } |
|
121 | - |
|
122 | - function processCreation ($form, $objExercise = null) |
|
123 | - { |
|
124 | - $file_info = $form -> getSubmitValue('imageUpload'); |
|
125 | - parent::processCreation ($form, $objExercise); |
|
126 | - } |
|
127 | - |
|
128 | - function createAnswersForm ($form) |
|
129 | - { |
|
130 | - parent::createAnswersForm ($form); |
|
131 | - } |
|
132 | - |
|
133 | - function processAnswersCreation ($form) |
|
134 | - { |
|
135 | - parent::processAnswersCreation ($form); |
|
136 | - } |
|
110 | + public function __construct() |
|
111 | + { |
|
112 | + parent::__construct(); |
|
113 | + $this -> type = HOT_SPOT_DELINEATION; |
|
114 | + |
|
115 | + } |
|
116 | + |
|
117 | + function createForm(&$form, $fck_config=0) |
|
118 | + { |
|
119 | + parent::createForm ($form, $fck_config); |
|
120 | + } |
|
121 | + |
|
122 | + function processCreation ($form, $objExercise = null) |
|
123 | + { |
|
124 | + $file_info = $form -> getSubmitValue('imageUpload'); |
|
125 | + parent::processCreation ($form, $objExercise); |
|
126 | + } |
|
127 | + |
|
128 | + function createAnswersForm ($form) |
|
129 | + { |
|
130 | + parent::createAnswersForm ($form); |
|
131 | + } |
|
132 | + |
|
133 | + function processAnswersCreation ($form) |
|
134 | + { |
|
135 | + parent::processAnswersCreation ($form); |
|
136 | + } |
|
137 | 137 | } |
138 | 138 |
@@ -6,7 +6,6 @@ discard block |
||
6 | 6 | * |
7 | 7 | * Contains several functions dealing with displaying, |
8 | 8 | * editing,... of a blog |
9 | - |
|
10 | 9 | * @package chamilo.blogs |
11 | 10 | * @author Toon Keppens <[email protected]> |
12 | 11 | * @author Julio Montoya - Cleaning code |
@@ -333,7 +332,7 @@ discard block |
||
333 | 332 | // Storing the attachments if any |
334 | 333 | if ($result) { |
335 | 334 | $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
336 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
335 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
337 | 336 | Database::query($sql); |
338 | 337 | $id = Database::insert_id(); |
339 | 338 | if ($id) { |
@@ -470,7 +469,7 @@ discard block |
||
470 | 469 | // Storing the attachments if any |
471 | 470 | if ($result) { |
472 | 471 | $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
473 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
472 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
474 | 473 | Database::query($sql); |
475 | 474 | |
476 | 475 | $id = Database::insert_id(); |
@@ -1389,10 +1388,10 @@ discard block |
||
1389 | 1388 | echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
1390 | 1389 | echo "<table class=\"data_table\">"; |
1391 | 1390 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1392 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1393 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1394 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1395 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1391 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1392 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1393 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1394 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1396 | 1395 | "</tr>"; |
1397 | 1396 | |
1398 | 1397 | |
@@ -1424,14 +1423,14 @@ discard block |
||
1424 | 1423 | echo '<td width="50">'; |
1425 | 1424 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1426 | 1425 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1427 | - echo "</a>"; |
|
1428 | - echo '<a href="'.$delete_link.'"'; |
|
1429 | - echo $delete_confirm; |
|
1430 | - echo '>'; |
|
1426 | + echo "</a>"; |
|
1427 | + echo '<a href="'.$delete_link.'"'; |
|
1428 | + echo $delete_confirm; |
|
1429 | + echo '>'; |
|
1431 | 1430 | echo Display::return_icon($delete_icon, $delete_title); |
1432 | - echo "</a>"; |
|
1433 | - echo '</td>'; |
|
1434 | - echo '</tr>'; |
|
1431 | + echo "</a>"; |
|
1432 | + echo '</td>'; |
|
1433 | + echo '</tr>'; |
|
1435 | 1434 | } |
1436 | 1435 | echo "</table>"; |
1437 | 1436 | } |
@@ -1455,11 +1454,11 @@ discard block |
||
1455 | 1454 | echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
1456 | 1455 | echo "<table class=\"data_table\">"; |
1457 | 1456 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1458 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1459 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1460 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1461 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1462 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1457 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1458 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1459 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1460 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1461 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1463 | 1462 | "</tr>"; |
1464 | 1463 | |
1465 | 1464 | $course_id = api_get_course_int_id(); |
@@ -2307,7 +2306,7 @@ discard block |
||
2307 | 2306 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
2308 | 2307 | * |
2309 | 2308 | * @return html code |
2310 | - */ |
|
2309 | + */ |
|
2311 | 2310 | public static function display_minimonthcalendar($month, $year, $blog_id) |
2312 | 2311 | { |
2313 | 2312 | // Init |
@@ -2600,34 +2599,34 @@ discard block |
||
2600 | 2599 | */ |
2601 | 2600 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2602 | 2601 | { |
2603 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2604 | - |
|
2605 | - $blog_id = intval($blog_id); |
|
2606 | - $comment_id = intval($comment_id); |
|
2607 | - $post_id = intval($post_id); |
|
2608 | - $row=array(); |
|
2609 | - $where=''; |
|
2610 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2611 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2612 | - } |
|
2613 | - |
|
2614 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2615 | - if (!empty ($post_id)) { |
|
2616 | - $where.= ' AND '; |
|
2617 | - } |
|
2618 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2619 | - } |
|
2602 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2603 | + |
|
2604 | + $blog_id = intval($blog_id); |
|
2605 | + $comment_id = intval($comment_id); |
|
2606 | + $post_id = intval($post_id); |
|
2607 | + $row=array(); |
|
2608 | + $where=''; |
|
2609 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2610 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2611 | + } |
|
2612 | + |
|
2613 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2614 | + if (!empty ($post_id)) { |
|
2615 | + $where.= ' AND '; |
|
2616 | + } |
|
2617 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2618 | + } |
|
2620 | 2619 | |
2621 | 2620 | $course_id = api_get_course_int_id(); |
2622 | 2621 | |
2623 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2622 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2624 | 2623 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2625 | 2624 | |
2626 | - $result=Database::query($sql); |
|
2627 | - if (Database::num_rows($result)!=0) { |
|
2628 | - $row=Database::fetch_array($result); |
|
2629 | - } |
|
2630 | - return $row; |
|
2625 | + $result=Database::query($sql); |
|
2626 | + if (Database::num_rows($result)!=0) { |
|
2627 | + $row=Database::fetch_array($result); |
|
2628 | + } |
|
2629 | + return $row; |
|
2631 | 2630 | } |
2632 | 2631 | |
2633 | 2632 | /** |
@@ -2644,16 +2643,16 @@ discard block |
||
2644 | 2643 | |
2645 | 2644 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2646 | 2645 | { |
2647 | - $_course = api_get_course_info(); |
|
2648 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2649 | - $blog_id = intval($blog_id); |
|
2650 | - $comment_id = intval($comment_id); |
|
2651 | - $post_id = intval($post_id); |
|
2646 | + $_course = api_get_course_info(); |
|
2647 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2648 | + $blog_id = intval($blog_id); |
|
2649 | + $comment_id = intval($comment_id); |
|
2650 | + $post_id = intval($post_id); |
|
2652 | 2651 | |
2653 | 2652 | $course_id = api_get_course_int_id(); |
2654 | - $where = null; |
|
2653 | + $where = null; |
|
2655 | 2654 | |
2656 | - // delete files in DB |
|
2655 | + // delete files in DB |
|
2657 | 2656 | if (!empty ($post_id) && is_numeric($post_id)) { |
2658 | 2657 | $where .= ' AND post_id ="'.$post_id.'" '; |
2659 | 2658 | } |
@@ -2665,25 +2664,25 @@ discard block |
||
2665 | 2664 | $where .= ' comment_id ="'.$comment_id.'" '; |
2666 | 2665 | } |
2667 | 2666 | |
2668 | - // delete all files in directory |
|
2669 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2670 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2671 | - $updir = $sys_course_path.$courseDir; |
|
2667 | + // delete all files in directory |
|
2668 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2669 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2670 | + $updir = $sys_course_path.$courseDir; |
|
2672 | 2671 | |
2673 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2672 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2674 | 2673 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2675 | - $result=Database::query($sql); |
|
2676 | - |
|
2677 | - while ($row=Database::fetch_row($result)) { |
|
2678 | - $file=$updir.'/'.$row[0]; |
|
2679 | - if (Security::check_abs_path($file,$updir) ) |
|
2680 | - { |
|
2681 | - @ unlink($file); |
|
2682 | - } |
|
2683 | - } |
|
2684 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2674 | + $result=Database::query($sql); |
|
2675 | + |
|
2676 | + while ($row=Database::fetch_row($result)) { |
|
2677 | + $file=$updir.'/'.$row[0]; |
|
2678 | + if (Security::check_abs_path($file,$updir) ) |
|
2679 | + { |
|
2680 | + @ unlink($file); |
|
2681 | + } |
|
2682 | + } |
|
2683 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2685 | 2684 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2686 | - Database::query($sql); |
|
2685 | + Database::query($sql); |
|
2687 | 2686 | } |
2688 | 2687 | |
2689 | 2688 | /** |
@@ -2693,12 +2692,12 @@ discard block |
||
2693 | 2692 | */ |
2694 | 2693 | function get_blog_post_from_user($course_code, $user_id) |
2695 | 2694 | { |
2696 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2697 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2698 | - $course_info = api_get_course_info($course_code); |
|
2699 | - $course_id = $course_info['real_id']; |
|
2695 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2696 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2697 | + $course_info = api_get_course_info($course_code); |
|
2698 | + $course_id = $course_info['real_id']; |
|
2700 | 2699 | |
2701 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2700 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2702 | 2701 | FROM $tbl_blogs blog |
2703 | 2702 | INNER JOIN $tbl_blog_post post |
2704 | 2703 | ON (blog.blog_id = post.blog_id) |
@@ -2707,19 +2706,19 @@ discard block |
||
2707 | 2706 | post.c_id = $course_id AND |
2708 | 2707 | author_id = $user_id AND visibility = 1 |
2709 | 2708 | ORDER BY post.date_creation DESC "; |
2710 | - $result = Database::query($sql); |
|
2711 | - $return_data = ''; |
|
2712 | - |
|
2713 | - if (Database::num_rows($result)!=0) { |
|
2714 | - while ($row=Database::fetch_array($result)) { |
|
2715 | - $return_data.= '<div class="clear"></div><br />'; |
|
2716 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2717 | - $return_data.= '<br / >'; |
|
2718 | - $return_data.= $row['full_text']; |
|
2719 | - $return_data.= '<br /><br />'; |
|
2720 | - } |
|
2721 | - } |
|
2722 | - return $return_data; |
|
2709 | + $result = Database::query($sql); |
|
2710 | + $return_data = ''; |
|
2711 | + |
|
2712 | + if (Database::num_rows($result)!=0) { |
|
2713 | + while ($row=Database::fetch_array($result)) { |
|
2714 | + $return_data.= '<div class="clear"></div><br />'; |
|
2715 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2716 | + $return_data.= '<br / >'; |
|
2717 | + $return_data.= $row['full_text']; |
|
2718 | + $return_data.= '<br /><br />'; |
|
2719 | + } |
|
2720 | + } |
|
2721 | + return $return_data; |
|
2723 | 2722 | } |
2724 | 2723 | |
2725 | 2724 | /** |
@@ -2736,7 +2735,7 @@ discard block |
||
2736 | 2735 | $course_info = api_get_course_info($course_code); |
2737 | 2736 | $course_id = $course_info['real_id']; |
2738 | 2737 | |
2739 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2738 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2740 | 2739 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2741 | 2740 | ON (blog.blog_id = comment.blog_id) |
2742 | 2741 | WHERE blog.c_id = $course_id AND |
@@ -2744,18 +2743,18 @@ discard block |
||
2744 | 2743 | author_id = $user_id AND |
2745 | 2744 | visibility = 1 |
2746 | 2745 | ORDER BY blog_name"; |
2747 | - $result = Database::query($sql); |
|
2748 | - $return_data = ''; |
|
2749 | - if (Database::num_rows($result)!=0) { |
|
2750 | - while ($row=Database::fetch_array($result)) { |
|
2751 | - $return_data.= '<div class="clear"></div><br />'; |
|
2752 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2753 | - $return_data.= '<br / >'; |
|
2754 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2755 | - $return_data.= $row['comment']; |
|
2756 | - $return_data.= '<br />'; |
|
2757 | - } |
|
2758 | - } |
|
2759 | - return $return_data; |
|
2746 | + $result = Database::query($sql); |
|
2747 | + $return_data = ''; |
|
2748 | + if (Database::num_rows($result)!=0) { |
|
2749 | + while ($row=Database::fetch_array($result)) { |
|
2750 | + $return_data.= '<div class="clear"></div><br />'; |
|
2751 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2752 | + $return_data.= '<br / >'; |
|
2753 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2754 | + $return_data.= $row['comment']; |
|
2755 | + $return_data.= '<br />'; |
|
2756 | + } |
|
2757 | + } |
|
2758 | + return $return_data; |
|
2760 | 2759 | } |
2761 | 2760 |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Displays the title + grid |
53 | 53 | */ |
54 | - public function display() |
|
54 | + public function display() |
|
55 | 55 | { |
56 | - // action links |
|
57 | - echo '<div class="actions" style="margin-bottom:20px">'; |
|
56 | + // action links |
|
57 | + echo '<div class="actions" style="margin-bottom:20px">'; |
|
58 | 58 | echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'', ICON_SIZE_MEDIUM).'</a>'; |
59 | - echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
60 | - echo '</div>'; |
|
59 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
60 | + echo '</div>'; |
|
61 | 61 | echo Display::grid_html('grade_model'); |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Returns a Form validator Obj |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $form->addElement('hidden', 'maxvalue', '100'); |
120 | - $form->addElement('hidden', 'minvalue', '0'); |
|
120 | + $form->addElement('hidden', 'minvalue', '0'); |
|
121 | 121 | $renderer = & $form->defaultRenderer(); |
122 | 122 | |
123 | 123 | $component_array = array(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // Setting the rules |
193 | 193 | $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
194 | 194 | |
195 | - return $form; |
|
195 | + return $form; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function delete($id) |
257 | 257 | { |
258 | - parent::delete($id); |
|
258 | + parent::delete($id); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * GradeModelComponents constructor. |
311 | 311 | */ |
312 | - public function __construct() |
|
312 | + public function __construct() |
|
313 | 313 | { |
314 | 314 | parent::__construct(); |
315 | 315 | $this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS); |
316 | - } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * @param array $params |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function save($params, $show_query = false) |
324 | 324 | { |
325 | - $id = parent::save($params, $show_query); |
|
325 | + $id = parent::save($params, $show_query); |
|
326 | 326 | |
327 | 327 | return $id; |
328 | 328 | } |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - return $block_data; |
|
311 | - } |
|
310 | + return $block_data; |
|
311 | + } |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * get data about enabled dashboard block (stored insise block table) |
@@ -491,42 +491,42 @@ discard block |
||
491 | 491 | return $data; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * This function update extra user blocks data after closing a dashboard block |
|
496 | - * @param int User id |
|
497 | - * @param string plugin path |
|
498 | - * @param integer $user_id |
|
499 | - * @return bool |
|
500 | - */ |
|
501 | - public static function close_user_block($user_id, $path) |
|
494 | + /** |
|
495 | + * This function update extra user blocks data after closing a dashboard block |
|
496 | + * @param int User id |
|
497 | + * @param string plugin path |
|
498 | + * @param integer $user_id |
|
499 | + * @return bool |
|
500 | + */ |
|
501 | + public static function close_user_block($user_id, $path) |
|
502 | 502 | { |
503 | - $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
504 | - $user_block_data = self::get_user_block_data($user_id); |
|
505 | - |
|
506 | - foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
507 | - unset($user_block_data[$enabled_block['id']]); |
|
508 | - } |
|
509 | - |
|
510 | - // get columns and blocks id for updating extra user data |
|
511 | - $columns = array(); |
|
512 | - $user_blocks_id = array(); |
|
513 | - foreach ($user_block_data as $data) { |
|
514 | - $user_blocks_id[$data['block_id']] = true; |
|
515 | - $columns[$data['block_id']] = $data['column']; |
|
516 | - } |
|
517 | - |
|
518 | - // update extra user blocks data |
|
519 | - $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
520 | - |
|
521 | - return $upd_extra_field; |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * get links for styles from dashboard plugins |
|
526 | - * @return string links |
|
527 | - */ |
|
528 | - public static function get_links_for_styles_from_dashboard_plugins() { |
|
529 | - |
|
530 | - return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
531 | - } |
|
503 | + $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
504 | + $user_block_data = self::get_user_block_data($user_id); |
|
505 | + |
|
506 | + foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
507 | + unset($user_block_data[$enabled_block['id']]); |
|
508 | + } |
|
509 | + |
|
510 | + // get columns and blocks id for updating extra user data |
|
511 | + $columns = array(); |
|
512 | + $user_blocks_id = array(); |
|
513 | + foreach ($user_block_data as $data) { |
|
514 | + $user_blocks_id[$data['block_id']] = true; |
|
515 | + $columns[$data['block_id']] = $data['column']; |
|
516 | + } |
|
517 | + |
|
518 | + // update extra user blocks data |
|
519 | + $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
520 | + |
|
521 | + return $upd_extra_field; |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * get links for styles from dashboard plugins |
|
526 | + * @return string links |
|
527 | + */ |
|
528 | + public static function get_links_for_styles_from_dashboard_plugins() { |
|
529 | + |
|
530 | + return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
531 | + } |
|
532 | 532 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | - /** |
|
19 | - * Add a new Term and Condition |
|
20 | - * @param int $language language id |
|
21 | - * @param string $content content |
|
22 | - * @param int $type term and condition type (0 or 1) |
|
23 | - * @param string $changes explain changes |
|
24 | - * @return boolean success |
|
25 | - */ |
|
26 | - public static function add($language, $content, $type, $changes) |
|
18 | + /** |
|
19 | + * Add a new Term and Condition |
|
20 | + * @param int $language language id |
|
21 | + * @param string $content content |
|
22 | + * @param int $type term and condition type (0 or 1) |
|
23 | + * @param string $changes explain changes |
|
24 | + * @return boolean success |
|
25 | + */ |
|
26 | + public static function add($language, $content, $type, $changes) |
|
27 | 27 | { |
28 | 28 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
29 | 29 | $last = self::get_last_condition($language); |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Gets the data of a Term and condition by language |
|
101 | - * @param int $language language id |
|
102 | - * @return array all the info of a Term and condition |
|
103 | - */ |
|
104 | - public static function get_last_condition($language) |
|
99 | + /** |
|
100 | + * Gets the data of a Term and condition by language |
|
101 | + * @param int $language language id |
|
102 | + * @return array all the info of a Term and condition |
|
103 | + */ |
|
104 | + public static function get_last_condition($language) |
|
105 | 105 | { |
106 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | - $language= Database::escape_string($language); |
|
108 | - $sql = "SELECT * FROM $legal_conditions_table |
|
106 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | + $language= Database::escape_string($language); |
|
108 | + $sql = "SELECT * FROM $legal_conditions_table |
|
109 | 109 | WHERE language_id = '".$language."' |
110 | 110 | ORDER BY version DESC |
111 | 111 | LIMIT 1 "; |
112 | - $result = Database::query($sql); |
|
113 | - $result = Database::fetch_array($result, 'ASSOC'); |
|
112 | + $result = Database::query($sql); |
|
113 | + $result = Database::fetch_array($result, 'ASSOC'); |
|
114 | 114 | |
115 | 115 | if (isset($result['content'])) { |
116 | 116 | $result['content'] = self::replaceTags($result['content']); |
117 | 117 | } |
118 | 118 | return $result; |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param string $content |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | return $content; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Gets the last version of a Term and condition by language |
|
145 | - * @param int $language language id |
|
146 | - * @return boolean | int the version or false if does not exist |
|
147 | - */ |
|
148 | - public static function get_last_version($language) |
|
143 | + /** |
|
144 | + * Gets the last version of a Term and condition by language |
|
145 | + * @param int $language language id |
|
146 | + * @return boolean | int the version or false if does not exist |
|
147 | + */ |
|
148 | + public static function get_last_version($language) |
|
149 | 149 | { |
150 | 150 | $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
151 | 151 | $language = intval($language); |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | |
164 | 164 | return false; |
165 | 165 | } |
166 | - } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * Show the last condition |
|
170 | - * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
168 | + /** |
|
169 | + * Show the last condition |
|
170 | + * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
171 | 171 | * |
172 | - * @return string html preview |
|
173 | - */ |
|
174 | - public static function show_last_condition($term_preview) |
|
172 | + * @return string html preview |
|
173 | + */ |
|
174 | + public static function show_last_condition($term_preview) |
|
175 | 175 | { |
176 | 176 | $preview = ''; |
177 | 177 | switch ($term_preview['type']) { |
@@ -201,37 +201,37 @@ discard block |
||
201 | 201 | default: |
202 | 202 | break; |
203 | 203 | } |
204 | - return $preview; |
|
205 | - } |
|
204 | + return $preview; |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Get the terms and condition table (only for maintenance) |
|
209 | - * @param int $from |
|
210 | - * @param int $number_of_items |
|
211 | - * @param int $column |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - public static function get_legal_data($from, $number_of_items, $column) |
|
207 | + /** |
|
208 | + * Get the terms and condition table (only for maintenance) |
|
209 | + * @param int $from |
|
210 | + * @param int $number_of_items |
|
211 | + * @param int $column |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + public static function get_legal_data($from, $number_of_items, $column) |
|
215 | 215 | { |
216 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | - $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | - $from = intval($from); |
|
219 | - $number_of_items = intval($number_of_items); |
|
220 | - $column = intval($column); |
|
216 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | + $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | + $from = intval($from); |
|
219 | + $number_of_items = intval($number_of_items); |
|
220 | + $column = intval($column); |
|
221 | 221 | |
222 | - $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
222 | + $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
223 | 223 | FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) "; |
224 | - $sql .= "ORDER BY language, version ASC "; |
|
225 | - $sql .= "LIMIT $from, $number_of_items "; |
|
224 | + $sql .= "ORDER BY language, version ASC "; |
|
225 | + $sql .= "LIMIT $from, $number_of_items "; |
|
226 | 226 | |
227 | - $result = Database::query($sql); |
|
228 | - $legals = array(); |
|
229 | - $versions = array(); |
|
230 | - while ($legal = Database::fetch_array($result)) { |
|
231 | - // max 2000 chars |
|
232 | - //echo strlen($legal[1]); echo '<br>'; |
|
233 | - $versions[] = $legal[0]; |
|
234 | - $languages[] = $legal[1]; |
|
227 | + $result = Database::query($sql); |
|
228 | + $legals = array(); |
|
229 | + $versions = array(); |
|
230 | + while ($legal = Database::fetch_array($result)) { |
|
231 | + // max 2000 chars |
|
232 | + //echo strlen($legal[1]); echo '<br>'; |
|
233 | + $versions[] = $legal[0]; |
|
234 | + $languages[] = $legal[1]; |
|
235 | 235 | if (strlen($legal[2]) > 2000) { |
236 | 236 | $legal[2] = substr($legal[2], 0, 2000).' ... '; |
237 | 237 | } |
@@ -240,50 +240,50 @@ discard block |
||
240 | 240 | } elseif ($legal[4] == 1) { |
241 | 241 | $legal[4] = get_lang('PageLink'); |
242 | 242 | } |
243 | - $legals[] = $legal; |
|
244 | - } |
|
245 | - return $legals; |
|
246 | - } |
|
243 | + $legals[] = $legal; |
|
244 | + } |
|
245 | + return $legals; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Gets the number of terms and conditions available |
|
250 | - * @return int |
|
251 | - */ |
|
252 | - public static function count() |
|
248 | + /** |
|
249 | + * Gets the number of terms and conditions available |
|
250 | + * @return int |
|
251 | + */ |
|
252 | + public static function count() |
|
253 | 253 | { |
254 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | - $sql = "SELECT count(*) as count_result |
|
254 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | + $sql = "SELECT count(*) as count_result |
|
256 | 256 | FROM $legal_conditions_table |
257 | 257 | ORDER BY id DESC "; |
258 | - $result = Database::query($sql); |
|
259 | - $url = Database::fetch_array($result,'ASSOC'); |
|
260 | - $result = $url['count_result']; |
|
258 | + $result = Database::query($sql); |
|
259 | + $url = Database::fetch_array($result,'ASSOC'); |
|
260 | + $result = $url['count_result']; |
|
261 | 261 | |
262 | - return $result; |
|
263 | - } |
|
262 | + return $result; |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * Get type of terms and conditions |
|
267 | - * @param int $legal_id |
|
268 | - * @param int $language_id |
|
269 | - * @return int The current type of terms and conditions |
|
270 | - */ |
|
271 | - public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
265 | + /** |
|
266 | + * Get type of terms and conditions |
|
267 | + * @param int $legal_id |
|
268 | + * @param int $language_id |
|
269 | + * @return int The current type of terms and conditions |
|
270 | + */ |
|
271 | + public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
272 | 272 | { |
273 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | - $legal_id = intval($legal_id); |
|
275 | - $language_id = intval($language_id); |
|
276 | - $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
273 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | + $legal_id = intval($legal_id); |
|
275 | + $language_id = intval($language_id); |
|
276 | + $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
277 | 277 | WHERE id = "'.$legal_id.'" AND language_id="'.$language_id.'"'; |
278 | - $rs = Database::query($sql); |
|
278 | + $rs = Database::query($sql); |
|
279 | 279 | |
280 | - return Database::result($rs,0,'type'); |
|
281 | - } |
|
280 | + return Database::result($rs,0,'type'); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * @param int $userId |
285 | 285 | */ |
286 | - public static function sendLegal($userId) |
|
286 | + public static function sendLegal($userId) |
|
287 | 287 | { |
288 | 288 | $subject = get_lang('SendTermsSubject'); |
289 | 289 | $content = sprintf( |
@@ -8,101 +8,101 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class StudentPublicationLink extends AbstractLink |
10 | 10 | { |
11 | - private $studpub_table = null; |
|
12 | - private $itemprop_table = null; |
|
13 | - |
|
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * Returns the URL of a document |
|
26 | - * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | - * see issue #2705 |
|
28 | - * |
|
29 | - */ |
|
30 | - public function get_view_url($stud_id) |
|
31 | - { |
|
32 | - // find a file uploaded by the given student, |
|
33 | - // with the same title as the evaluation name |
|
34 | - |
|
35 | - $eval = $this->get_evaluation(); |
|
36 | - $stud_id = intval($stud_id); |
|
37 | - |
|
38 | - $sql = 'SELECT pub.url |
|
11 | + private $studpub_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | + |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * Returns the URL of a document |
|
26 | + * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | + * see issue #2705 |
|
28 | + * |
|
29 | + */ |
|
30 | + public function get_view_url($stud_id) |
|
31 | + { |
|
32 | + // find a file uploaded by the given student, |
|
33 | + // with the same title as the evaluation name |
|
34 | + |
|
35 | + $eval = $this->get_evaluation(); |
|
36 | + $stud_id = intval($stud_id); |
|
37 | + |
|
38 | + $sql = 'SELECT pub.url |
|
39 | 39 | FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' |
40 | - ." WHERE |
|
40 | + ." WHERE |
|
41 | 41 | prop.c_id = ".$this->course_id." AND |
42 | 42 | pub.c_id = ".$this->course_id." AND |
43 | 43 | prop.tool = 'work'" |
44 | - .' AND prop.insert_user_id = '.$stud_id |
|
45 | - .' AND prop.ref = pub.id' |
|
46 | - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | - |
|
48 | - $result = Database::query($sql); |
|
49 | - if ($fileurl = Database::fetch_row($result)) { |
|
50 | - return null; |
|
51 | - } else { |
|
52 | - return null; |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - public function get_type_name() |
|
57 | - { |
|
58 | - return get_lang('Works'); |
|
59 | - } |
|
60 | - |
|
61 | - public function is_allowed_to_change_name() |
|
62 | - { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | - */ |
|
70 | - public function get_not_created_links() |
|
71 | - { |
|
72 | - return false; |
|
73 | - if (empty($this->course_code)) { |
|
74 | - die('Error in get_not_created_links() : course code not set'); |
|
75 | - } |
|
76 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | - |
|
78 | - $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | - .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | - .') AND pub.session_id='.api_get_session_id().''; |
|
84 | - |
|
85 | - $result = Database::query($sql); |
|
86 | - |
|
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
90 | - } |
|
91 | - return $cats; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generate an array of all exercises available. |
|
96 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | - */ |
|
98 | - public function get_all_links() |
|
99 | - { |
|
100 | - if (empty($this->course_code)) { |
|
101 | - die('Error in get_not_created_links() : course code not set'); |
|
102 | - } |
|
103 | - $em = Database::getManager(); |
|
44 | + .' AND prop.insert_user_id = '.$stud_id |
|
45 | + .' AND prop.ref = pub.id' |
|
46 | + ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | + |
|
48 | + $result = Database::query($sql); |
|
49 | + if ($fileurl = Database::fetch_row($result)) { |
|
50 | + return null; |
|
51 | + } else { |
|
52 | + return null; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + public function get_type_name() |
|
57 | + { |
|
58 | + return get_lang('Works'); |
|
59 | + } |
|
60 | + |
|
61 | + public function is_allowed_to_change_name() |
|
62 | + { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | + */ |
|
70 | + public function get_not_created_links() |
|
71 | + { |
|
72 | + return false; |
|
73 | + if (empty($this->course_code)) { |
|
74 | + die('Error in get_not_created_links() : course code not set'); |
|
75 | + } |
|
76 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | + |
|
78 | + $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | + .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | + .') AND pub.session_id='.api_get_session_id().''; |
|
84 | + |
|
85 | + $result = Database::query($sql); |
|
86 | + |
|
87 | + $cats=array(); |
|
88 | + while ($data=Database::fetch_array($result)) { |
|
89 | + $cats[] = array ($data['id'], $data['url']); |
|
90 | + } |
|
91 | + return $cats; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generate an array of all exercises available. |
|
96 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | + */ |
|
98 | + public function get_all_links() |
|
99 | + { |
|
100 | + if (empty($this->course_code)) { |
|
101 | + die('Error in get_not_created_links() : course code not set'); |
|
102 | + } |
|
103 | + $em = Database::getManager(); |
|
104 | 104 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
105 | - /* |
|
105 | + /* |
|
106 | 106 | if (empty($session_id)) { |
107 | 107 | $session_condition = api_get_session_condition(0, true); |
108 | 108 | } else { |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | $sql = "SELECT id, url, title FROM $tbl_grade_links |
112 | 112 | WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ |
113 | 113 | |
114 | - //Only show works from the session |
|
115 | - //AND has_properties != '' |
|
114 | + //Only show works from the session |
|
115 | + //AND has_properties != '' |
|
116 | 116 | $links = $em |
117 | 117 | ->getRepository('ChamiloCourseBundle:CStudentPublication') |
118 | 118 | ->findBy([ |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | ]); |
124 | 124 | |
125 | 125 | foreach ($links as $data) { |
126 | - $work_name = $data->getTitle(); |
|
127 | - if (empty($work_name)) { |
|
128 | - $work_name = basename($data->getUrl()); |
|
129 | - } |
|
130 | - $cats[] = array ($data->getId(), $work_name); |
|
131 | - } |
|
132 | - $cats=isset($cats) ? $cats : array(); |
|
133 | - return $cats; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Has anyone done this exercise yet ? |
|
138 | - */ |
|
139 | - public function has_results() |
|
140 | - { |
|
141 | - $em = Database::getManager(); |
|
126 | + $work_name = $data->getTitle(); |
|
127 | + if (empty($work_name)) { |
|
128 | + $work_name = basename($data->getUrl()); |
|
129 | + } |
|
130 | + $cats[] = array ($data->getId(), $work_name); |
|
131 | + } |
|
132 | + $cats=isset($cats) ? $cats : array(); |
|
133 | + return $cats; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Has anyone done this exercise yet ? |
|
138 | + */ |
|
139 | + public function has_results() |
|
140 | + { |
|
141 | + $em = Database::getManager(); |
|
142 | 142 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
143 | 143 | $results = $em |
144 | 144 | ->getRepository('ChamiloCourseBundle:CStudentPublication') |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | ]); |
150 | 150 | |
151 | 151 | return count($results) != 0; |
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param null $stud_id |
|
156 | - * @return array|null |
|
157 | - */ |
|
158 | - public function calc_score($stud_id = null, $type = null) |
|
159 | - { |
|
160 | - $stud_id = intval($stud_id); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param null $stud_id |
|
156 | + * @return array|null |
|
157 | + */ |
|
158 | + public function calc_score($stud_id = null, $type = null) |
|
159 | + { |
|
160 | + $stud_id = intval($stud_id); |
|
161 | 161 | $em = Database::getManager(); |
162 | 162 | |
163 | 163 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $parentId = !$assignment ? 0 : $assignment->getId(); |
174 | 174 | |
175 | - $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
175 | + $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
176 | 176 | WHERE |
177 | 177 | a.cId = :course AND |
178 | 178 | active = 1 AND |
@@ -182,31 +182,31 @@ discard block |
||
182 | 182 | '; |
183 | 183 | $params = ['course' => $this->course_id, 'parent' => $parentId, 'session' => $session]; |
184 | 184 | |
185 | - if (!empty($stud_id)) { |
|
186 | - $dql .= ' AND a.userId = :student '; |
|
185 | + if (!empty($stud_id)) { |
|
186 | + $dql .= ' AND a.userId = :student '; |
|
187 | 187 | $params['student'] = $stud_id; |
188 | - } |
|
189 | - |
|
190 | - $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
191 | - |
|
192 | - switch ($order) { |
|
193 | - case 'last': |
|
194 | - // latest attempt |
|
195 | - $dql .= ' ORDER BY a.sentDate DESC'; |
|
196 | - break; |
|
197 | - case 'first': |
|
198 | - default: |
|
199 | - // first attempt |
|
200 | - $dql .= ' ORDER BY a.id'; |
|
201 | - break; |
|
202 | - } |
|
188 | + } |
|
189 | + |
|
190 | + $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
191 | + |
|
192 | + switch ($order) { |
|
193 | + case 'last': |
|
194 | + // latest attempt |
|
195 | + $dql .= ' ORDER BY a.sentDate DESC'; |
|
196 | + break; |
|
197 | + case 'first': |
|
198 | + default: |
|
199 | + // first attempt |
|
200 | + $dql .= ' ORDER BY a.id'; |
|
201 | + break; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | $scores = $em->createQuery($dql)->execute([$params]); |
205 | 205 | |
206 | - // for 1 student |
|
207 | - if (!empty($stud_id)) { |
|
208 | - if (!count($scores)) { |
|
209 | - return ''; |
|
206 | + // for 1 student |
|
207 | + if (!empty($stud_id)) { |
|
208 | + if (!count($scores)) { |
|
209 | + return ''; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $data = $scores[0]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $data->getQualification(), |
216 | 216 | $assignment->getQualification() |
217 | 217 | ]; |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | $students = array(); // user list, needed to make sure we only |
221 | 221 | // take first attempts into account |
@@ -259,116 +259,116 @@ discard block |
||
259 | 259 | return array($sum, $rescount); |
260 | 260 | break; |
261 | 261 | } |
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Lazy load function to get the database table of the student publications |
|
266 | - */ |
|
267 | - private function get_studpub_table() |
|
268 | - { |
|
269 | - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Lazy load function to get the database table of the item properties |
|
274 | - */ |
|
275 | - private function get_itemprop_table() |
|
276 | - { |
|
277 | - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
278 | - } |
|
279 | - |
|
280 | - public function needs_name_and_description() |
|
281 | - { |
|
282 | - return false; |
|
283 | - } |
|
284 | - |
|
285 | - public function get_name() |
|
286 | - { |
|
287 | - $this->get_exercise_data(); |
|
288 | - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
289 | - } |
|
290 | - |
|
291 | - public function get_description() |
|
292 | - { |
|
293 | - $this->get_exercise_data(); |
|
294 | - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
295 | - } |
|
296 | - |
|
297 | - public function get_test_id() |
|
298 | - { |
|
299 | - return 'DEBUG:ID'; |
|
300 | - } |
|
301 | - |
|
302 | - public function get_link() |
|
303 | - { |
|
304 | - $session_id = api_get_session_id(); |
|
305 | - $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
306 | - |
|
307 | - return $url; |
|
308 | - } |
|
309 | - |
|
310 | - private function get_exercise_data() |
|
311 | - { |
|
312 | - $tbl_name = $this->get_studpub_table(); |
|
313 | - $course_info = api_get_course_info($this->get_course_code()); |
|
314 | - if ($tbl_name=='') { |
|
315 | - return false; |
|
316 | - } elseif (!isset($this->exercise_data)) { |
|
317 | - $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Lazy load function to get the database table of the student publications |
|
266 | + */ |
|
267 | + private function get_studpub_table() |
|
268 | + { |
|
269 | + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Lazy load function to get the database table of the item properties |
|
274 | + */ |
|
275 | + private function get_itemprop_table() |
|
276 | + { |
|
277 | + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
278 | + } |
|
279 | + |
|
280 | + public function needs_name_and_description() |
|
281 | + { |
|
282 | + return false; |
|
283 | + } |
|
284 | + |
|
285 | + public function get_name() |
|
286 | + { |
|
287 | + $this->get_exercise_data(); |
|
288 | + return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
289 | + } |
|
290 | + |
|
291 | + public function get_description() |
|
292 | + { |
|
293 | + $this->get_exercise_data(); |
|
294 | + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
295 | + } |
|
296 | + |
|
297 | + public function get_test_id() |
|
298 | + { |
|
299 | + return 'DEBUG:ID'; |
|
300 | + } |
|
301 | + |
|
302 | + public function get_link() |
|
303 | + { |
|
304 | + $session_id = api_get_session_id(); |
|
305 | + $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
306 | + |
|
307 | + return $url; |
|
308 | + } |
|
309 | + |
|
310 | + private function get_exercise_data() |
|
311 | + { |
|
312 | + $tbl_name = $this->get_studpub_table(); |
|
313 | + $course_info = api_get_course_info($this->get_course_code()); |
|
314 | + if ($tbl_name=='') { |
|
315 | + return false; |
|
316 | + } elseif (!isset($this->exercise_data)) { |
|
317 | + $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
318 | 318 | WHERE |
319 | 319 | c_id ='".$course_info['real_id']."' AND |
320 | 320 | id = '".intval($this->get_ref_id())."' "; |
321 | - $query = Database::query($sql); |
|
322 | - $this->exercise_data = Database::fetch_array($query); |
|
323 | - } |
|
324 | - return $this->exercise_data; |
|
325 | - } |
|
326 | - |
|
327 | - public function needs_max() |
|
328 | - { |
|
329 | - return false; |
|
330 | - } |
|
331 | - |
|
332 | - public function needs_results() |
|
333 | - { |
|
334 | - return false; |
|
335 | - } |
|
336 | - |
|
337 | - public function is_valid_link() |
|
338 | - { |
|
339 | - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
321 | + $query = Database::query($sql); |
|
322 | + $this->exercise_data = Database::fetch_array($query); |
|
323 | + } |
|
324 | + return $this->exercise_data; |
|
325 | + } |
|
326 | + |
|
327 | + public function needs_max() |
|
328 | + { |
|
329 | + return false; |
|
330 | + } |
|
331 | + |
|
332 | + public function needs_results() |
|
333 | + { |
|
334 | + return false; |
|
335 | + } |
|
336 | + |
|
337 | + public function is_valid_link() |
|
338 | + { |
|
339 | + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
340 | 340 | WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; |
341 | - $result = Database::query($sql); |
|
342 | - $number = Database::fetch_row($result); |
|
343 | - return ($number[0] != 0); |
|
344 | - } |
|
345 | - |
|
346 | - public function get_icon_name() |
|
347 | - { |
|
348 | - return 'studentpublication'; |
|
349 | - } |
|
350 | - |
|
351 | - public function save_linked_data() |
|
352 | - { |
|
353 | - $weight = (float)$this->get_weight(); |
|
354 | - $ref_id = $this->get_ref_id(); |
|
355 | - |
|
356 | - if (!empty($ref_id)) { |
|
357 | - //Cleans works |
|
358 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
341 | + $result = Database::query($sql); |
|
342 | + $number = Database::fetch_row($result); |
|
343 | + return ($number[0] != 0); |
|
344 | + } |
|
345 | + |
|
346 | + public function get_icon_name() |
|
347 | + { |
|
348 | + return 'studentpublication'; |
|
349 | + } |
|
350 | + |
|
351 | + public function save_linked_data() |
|
352 | + { |
|
353 | + $weight = (float)$this->get_weight(); |
|
354 | + $ref_id = $this->get_ref_id(); |
|
355 | + |
|
356 | + if (!empty($ref_id)) { |
|
357 | + //Cleans works |
|
358 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
359 | 359 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
360 | - Database::query($sql); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - public function delete_linked_data() |
|
365 | - { |
|
366 | - $ref_id = $this->get_ref_id(); |
|
367 | - if (!empty($ref_id)) { |
|
368 | - //Cleans works |
|
369 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
360 | + Database::query($sql); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + public function delete_linked_data() |
|
365 | + { |
|
366 | + $ref_id = $this->get_ref_id(); |
|
367 | + if (!empty($ref_id)) { |
|
368 | + //Cleans works |
|
369 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
370 | 370 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
371 | - Database::query($sql); |
|
372 | - } |
|
373 | - } |
|
371 | + Database::query($sql); |
|
372 | + } |
|
373 | + } |
|
374 | 374 | } |