@@ -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,35 +151,35 @@ 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') { |
|
| 173 | - $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');")); |
|
| 174 | - } |
|
| 175 | - $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');")); |
|
| 176 | - $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
| 177 | - } |
|
| 178 | - // Properties for all groups |
|
| 179 | - for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
| 180 | - $group_el = array(); |
|
| 181 | - $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
| 182 | - 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 | + $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');")); |
|
| 174 | + } |
|
| 175 | + $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');")); |
|
| 176 | + $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
| 177 | + } |
|
| 178 | + // Properties for all groups |
|
| 179 | + for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
| 180 | + $group_el = array(); |
|
| 181 | + $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
| 182 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 183 | 183 | $group_el[] = $form->createElement( |
| 184 | 184 | 'select', |
| 185 | 185 | 'group_'.$group_number.'_category', |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $cat_options, |
| 188 | 188 | array('id' => 'category_'.$group_number) |
| 189 | 189 | ); |
| 190 | - } |
|
| 190 | + } |
|
| 191 | 191 | $group_el[] = $form->createElement( |
| 192 | 192 | 'text', |
| 193 | 193 | 'group_'.$group_number.'_places', |
@@ -195,111 +195,111 @@ discard block |
||
| 195 | 195 | array('class' => 'span1', 'id' => 'places_'.$group_number) |
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | - if ($_POST['number_of_groups'] < 10000) { |
|
| 199 | - if ($group_id < 10) { |
|
| 200 | - $prev = '000'; |
|
| 201 | - } elseif ($group_id < 100) { |
|
| 202 | - $prev = '00'; |
|
| 203 | - } elseif ($group_id<1000) { |
|
| 204 | - $prev = '0'; |
|
| 205 | - } else { |
|
| 206 | - $prev = ''; |
|
| 207 | - } |
|
| 208 | - } |
|
| 198 | + if ($_POST['number_of_groups'] < 10000) { |
|
| 199 | + if ($group_id < 10) { |
|
| 200 | + $prev = '000'; |
|
| 201 | + } elseif ($group_id < 100) { |
|
| 202 | + $prev = '00'; |
|
| 203 | + } elseif ($group_id<1000) { |
|
| 204 | + $prev = '0'; |
|
| 205 | + } else { |
|
| 206 | + $prev = ''; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
| 211 | - $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
| 212 | - } |
|
| 213 | - $defaults['action'] = 'create_groups'; |
|
| 214 | - $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
| 215 | - $form->setDefaults($defaults); |
|
| 216 | - $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
| 210 | + $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
| 211 | + $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
| 212 | + } |
|
| 213 | + $defaults['action'] = 'create_groups'; |
|
| 214 | + $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
| 215 | + $form->setDefaults($defaults); |
|
| 216 | + $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
| 217 | 217 | $form->display(); |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | } else { |
| 220 | - /* |
|
| 220 | + /* |
|
| 221 | 221 | * Show form to generate new groups |
| 222 | 222 | */ |
| 223 | 223 | |
| 224 | - $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 225 | - $create_groups_form->addElement('header', $nameTools); |
|
| 224 | + $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 225 | + $create_groups_form->addElement('header', $nameTools); |
|
| 226 | 226 | $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1')); |
| 227 | 227 | $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary'); |
| 228 | - $defaults = array(); |
|
| 229 | - $defaults['number_of_groups'] = 1; |
|
| 230 | - $create_groups_form->setDefaults($defaults); |
|
| 231 | - $create_groups_form->display(); |
|
| 228 | + $defaults = array(); |
|
| 229 | + $defaults['number_of_groups'] = 1; |
|
| 230 | + $create_groups_form->setDefaults($defaults); |
|
| 231 | + $create_groups_form->display(); |
|
| 232 | 232 | |
| 233 | - /* |
|
| 233 | + /* |
|
| 234 | 234 | * Show form to generate subgroups |
| 235 | 235 | */ |
| 236 | - if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
| 237 | - $base_group_options = array (); |
|
| 238 | - $groups = GroupManager :: get_group_list(); |
|
| 239 | - foreach ($groups as $index => $group) { |
|
| 240 | - $number_of_students = GroupManager :: number_of_students($group['id']); |
|
| 241 | - if ($number_of_students > 0) { |
|
| 242 | - $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - if (count($base_group_options) > 0) { |
|
| 246 | - $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 236 | + if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
| 237 | + $base_group_options = array (); |
|
| 238 | + $groups = GroupManager :: get_group_list(); |
|
| 239 | + foreach ($groups as $index => $group) { |
|
| 240 | + $number_of_students = GroupManager :: number_of_students($group['id']); |
|
| 241 | + if ($number_of_students > 0) { |
|
| 242 | + $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + if (count($base_group_options) > 0) { |
|
| 246 | + $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 247 | 247 | $create_subgroups_form->addElement('header', get_lang('CreateSubgroups')); |
| 248 | 248 | $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo')); |
| 249 | - $create_subgroups_form->addElement('hidden', 'action'); |
|
| 250 | - $group_el = array(); |
|
| 251 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
| 252 | - $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
| 253 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
| 254 | - $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
| 255 | - $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
| 256 | - $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); |
|
| 257 | - $defaults = array(); |
|
| 258 | - $defaults['action'] = 'create_subgroups'; |
|
| 259 | - $create_subgroups_form->setDefaults($defaults); |
|
| 260 | - $create_subgroups_form->display(); |
|
| 261 | - } |
|
| 262 | - } |
|
| 249 | + $create_subgroups_form->addElement('hidden', 'action'); |
|
| 250 | + $group_el = array(); |
|
| 251 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
| 252 | + $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
| 253 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
| 254 | + $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
| 255 | + $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
| 256 | + $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); |
|
| 257 | + $defaults = array(); |
|
| 258 | + $defaults['action'] = 'create_subgroups'; |
|
| 259 | + $create_subgroups_form->setDefaults($defaults); |
|
| 260 | + $create_subgroups_form->display(); |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /* |
|
| 264 | + /* |
|
| 265 | 265 | * Show form to generate groups from classes subscribed to the course |
| 266 | 266 | */ |
| 267 | 267 | $options['where'] = array(" usergroup.course_id = ? " => api_get_real_course_id()); |
| 268 | 268 | $obj = new UserGroup(); |
| 269 | 269 | $classes = $obj->getUserGroupInCourse($options); |
| 270 | - if (count($classes) > 0) { |
|
| 271 | - echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
| 272 | - echo '<blockquote>'; |
|
| 273 | - echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
| 274 | - echo '<ul>'; |
|
| 275 | - foreach ($classes as $index => $class) { |
|
| 276 | - $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
| 277 | - echo '<li>'; |
|
| 278 | - echo $class['name']; |
|
| 279 | - echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
| 280 | - echo '</li>'; |
|
| 281 | - } |
|
| 282 | - echo '</ul>'; |
|
| 270 | + if (count($classes) > 0) { |
|
| 271 | + echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
| 272 | + echo '<blockquote>'; |
|
| 273 | + echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
| 274 | + echo '<ul>'; |
|
| 275 | + foreach ($classes as $index => $class) { |
|
| 276 | + $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
| 277 | + echo '<li>'; |
|
| 278 | + echo $class['name']; |
|
| 279 | + echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
| 280 | + echo '</li>'; |
|
| 281 | + } |
|
| 282 | + echo '</ul>'; |
|
| 283 | 283 | |
| 284 | - $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 285 | - $create_class_groups_form->addElement('hidden', 'action'); |
|
| 286 | - if (api_get_setting('allow_group_categories') == 'true') { |
|
| 287 | - $group_categories = GroupManager :: get_categories(); |
|
| 288 | - $cat_options = array(); |
|
| 289 | - foreach ($group_categories as $index => $category) { |
|
| 290 | - $cat_options[$category['id']] = $category['title']; |
|
| 291 | - } |
|
| 292 | - $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
| 293 | - } else { |
|
| 294 | - $create_class_groups_form->addElement('hidden', 'group_category'); |
|
| 295 | - } |
|
| 296 | - $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
| 297 | - $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
| 298 | - $defaults['action'] = 'create_class_groups'; |
|
| 299 | - $create_class_groups_form->setDefaults($defaults); |
|
| 300 | - $create_class_groups_form->display(); |
|
| 301 | - echo '</blockquote>'; |
|
| 302 | - } |
|
| 284 | + $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 285 | + $create_class_groups_form->addElement('hidden', 'action'); |
|
| 286 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 287 | + $group_categories = GroupManager :: get_categories(); |
|
| 288 | + $cat_options = array(); |
|
| 289 | + foreach ($group_categories as $index => $category) { |
|
| 290 | + $cat_options[$category['id']] = $category['title']; |
|
| 291 | + } |
|
| 292 | + $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
| 293 | + } else { |
|
| 294 | + $create_class_groups_form->addElement('hidden', 'group_category'); |
|
| 295 | + } |
|
| 296 | + $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
| 297 | + $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
| 298 | + $defaults['action'] = 'create_class_groups'; |
|
| 299 | + $create_class_groups_form->setDefaults($defaults); |
|
| 300 | + $create_class_groups_form->display(); |
|
| 301 | + echo '</blockquote>'; |
|
| 302 | + } |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | Display :: display_footer(); |