@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | exit; |
| 53 | 53 | break; |
| 54 | 54 | case 'create_subgroups': |
| 55 | - GroupManager::create_subgroups( |
|
| 56 | - $_POST['base_group'], |
|
| 57 | - $_POST['number_of_groups'] |
|
| 58 | - ); |
|
| 55 | + GroupManager::create_subgroups( |
|
| 56 | + $_POST['base_group'], |
|
| 57 | + $_POST['number_of_groups'] |
|
| 58 | + ); |
|
| 59 | 59 | Display::addFlash(Display::return_message(get_lang('GroupsAdded'))); |
| 60 | 60 | header("Location: ".$currentUrl); |
| 61 | 61 | exit; |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | if (isset($_POST['number_of_groups'])) { |
| 80 | 80 | if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) { |
| 81 | 81 | Display :: display_error_message( |
| 82 | - get_lang('PleaseEnterValidNumber').'<br /><br /> |
|
| 82 | + get_lang('PleaseEnterValidNumber').'<br /><br /> |
|
| 83 | 83 | <a href="group_creation.php?'.api_get_cidreq().'">« '.get_lang('Back').'</a>', |
| 84 | - false |
|
| 85 | - ); |
|
| 84 | + false |
|
| 85 | + ); |
|
| 86 | 86 | } else { |
| 87 | 87 | $number_of_groups = intval($_POST['number_of_groups']); |
| 88 | 88 | if ($number_of_groups > 1) { |
@@ -120,20 +120,20 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | </script> |
| 122 | 122 | <?php |
| 123 | - } |
|
| 124 | - $group_categories = GroupManager::get_categories(); |
|
| 125 | - $group_id = GroupManager :: get_number_of_groups() + 1; |
|
| 126 | - $cat_options = []; |
|
| 127 | - foreach ($group_categories as $index => $category) { |
|
| 128 | - $cat_options[$category['id']] = $category['title']; |
|
| 129 | - } |
|
| 123 | + } |
|
| 124 | + $group_categories = GroupManager::get_categories(); |
|
| 125 | + $group_id = GroupManager :: get_number_of_groups() + 1; |
|
| 126 | + $cat_options = []; |
|
| 127 | + foreach ($group_categories as $index => $category) { |
|
| 128 | + $cat_options[$category['id']] = $category['title']; |
|
| 129 | + } |
|
| 130 | 130 | $form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq()); |
| 131 | 131 | |
| 132 | - // Modify the default templates |
|
| 133 | - $renderer = $form->defaultRenderer(); |
|
| 134 | - $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>"; |
|
| 135 | - $renderer->setFormTemplate($form_template); |
|
| 136 | - $element_template = <<<EOT |
|
| 132 | + // Modify the default templates |
|
| 133 | + $renderer = $form->defaultRenderer(); |
|
| 134 | + $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>"; |
|
| 135 | + $renderer->setFormTemplate($form_template); |
|
| 136 | + $element_template = <<<EOT |
|
| 137 | 137 | <tr class="separate"> |
| 138 | 138 | <td> |
| 139 | 139 | <!-- BEGIN required --> |
@@ -146,35 +146,35 @@ discard block |
||
| 146 | 146 | </tr> |
| 147 | 147 | |
| 148 | 148 | EOT; |
| 149 | - $renderer->setCustomElementTemplate($element_template); |
|
| 149 | + $renderer->setCustomElementTemplate($element_template); |
|
| 150 | 150 | $form->addElement('header', $nameTools); |
| 151 | - $form->addElement('hidden', 'action'); |
|
| 152 | - $form->addElement('hidden', 'number_of_groups'); |
|
| 153 | - $defaults = array(); |
|
| 154 | - // Table heading |
|
| 155 | - $group_el = array(); |
|
| 156 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>'); |
|
| 151 | + $form->addElement('hidden', 'action'); |
|
| 152 | + $form->addElement('hidden', 'number_of_groups'); |
|
| 153 | + $defaults = array(); |
|
| 154 | + // Table heading |
|
| 155 | + $group_el = array(); |
|
| 156 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>'); |
|
| 157 | 157 | |
| 158 | - if (api_get_setting('allow_group_categories') == 'true') { |
|
| 159 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>'); |
|
| 160 | - } |
|
| 161 | - $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>'); |
|
| 162 | - $form->addGroup($group_el, 'groups', null, "</td><td>", false); |
|
| 163 | - // Checkboxes |
|
| 164 | - if ($_POST['number_of_groups'] > 1) { |
|
| 165 | - $group_el = array (); |
|
| 166 | - $group_el[] = $form->createElement('static', null, null, ' '); |
|
| 167 | - if (api_get_setting('allow_group_categories') == 'true') { |
|
| 168 | - $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');")); |
|
| 169 | - } |
|
| 170 | - $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');")); |
|
| 171 | - $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
| 172 | - } |
|
| 173 | - // Properties for all groups |
|
| 174 | - for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
| 175 | - $group_el = array(); |
|
| 176 | - $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
| 177 | - if (api_get_setting('allow_group_categories') == 'true') { |
|
| 158 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 159 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>'); |
|
| 160 | + } |
|
| 161 | + $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>'); |
|
| 162 | + $form->addGroup($group_el, 'groups', null, "</td><td>", false); |
|
| 163 | + // Checkboxes |
|
| 164 | + if ($_POST['number_of_groups'] > 1) { |
|
| 165 | + $group_el = array (); |
|
| 166 | + $group_el[] = $form->createElement('static', null, null, ' '); |
|
| 167 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 168 | + $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');")); |
|
| 169 | + } |
|
| 170 | + $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');")); |
|
| 171 | + $form->addGroup($group_el, 'groups', null, '</td><td>', false); |
|
| 172 | + } |
|
| 173 | + // Properties for all groups |
|
| 174 | + for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { |
|
| 175 | + $group_el = array(); |
|
| 176 | + $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); |
|
| 177 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 178 | 178 | $group_el[] = $form->createElement( |
| 179 | 179 | 'select', |
| 180 | 180 | 'group_'.$group_number.'_category', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $cat_options, |
| 183 | 183 | array('id' => 'category_'.$group_number) |
| 184 | 184 | ); |
| 185 | - } else { |
|
| 185 | + } else { |
|
| 186 | 186 | $group_el[] = $form->createElement('hidden', 'group_'.$group_number.'_category', 0); |
| 187 | 187 | $defaults['group_'.$group_number.'_category'] = array_keys($cat_options)[0]; |
| 188 | 188 | } |
@@ -193,111 +193,111 @@ discard block |
||
| 193 | 193 | array('class' => 'span1', 'id' => 'places_'.$group_number) |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - if ($_POST['number_of_groups'] < 10000) { |
|
| 197 | - if ($group_id < 10) { |
|
| 198 | - $prev = '000'; |
|
| 199 | - } elseif ($group_id < 100) { |
|
| 200 | - $prev = '00'; |
|
| 201 | - } elseif ($group_id<1000) { |
|
| 202 | - $prev = '0'; |
|
| 203 | - } else { |
|
| 204 | - $prev = ''; |
|
| 205 | - } |
|
| 206 | - } |
|
| 196 | + if ($_POST['number_of_groups'] < 10000) { |
|
| 197 | + if ($group_id < 10) { |
|
| 198 | + $prev = '000'; |
|
| 199 | + } elseif ($group_id < 100) { |
|
| 200 | + $prev = '00'; |
|
| 201 | + } elseif ($group_id<1000) { |
|
| 202 | + $prev = '0'; |
|
| 203 | + } else { |
|
| 204 | + $prev = ''; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
| 209 | - $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
| 210 | - } |
|
| 211 | - $defaults['action'] = 'create_groups'; |
|
| 212 | - $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
| 213 | - $form->setDefaults($defaults); |
|
| 214 | - $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
| 208 | + $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; |
|
| 209 | + $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false); |
|
| 210 | + } |
|
| 211 | + $defaults['action'] = 'create_groups'; |
|
| 212 | + $defaults['number_of_groups'] = intval($_POST['number_of_groups']); |
|
| 213 | + $form->setDefaults($defaults); |
|
| 214 | + $form->addButtonCreate(get_lang('CreateGroup'), 'submit'); |
|
| 215 | 215 | $form->display(); |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | } else { |
| 218 | - /* |
|
| 218 | + /* |
|
| 219 | 219 | * Show form to generate new groups |
| 220 | 220 | */ |
| 221 | 221 | |
| 222 | - $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 223 | - $create_groups_form->addElement('header', $nameTools); |
|
| 222 | + $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 223 | + $create_groups_form->addElement('header', $nameTools); |
|
| 224 | 224 | $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1')); |
| 225 | 225 | $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary'); |
| 226 | - $defaults = array(); |
|
| 227 | - $defaults['number_of_groups'] = 1; |
|
| 228 | - $create_groups_form->setDefaults($defaults); |
|
| 229 | - $create_groups_form->display(); |
|
| 226 | + $defaults = array(); |
|
| 227 | + $defaults['number_of_groups'] = 1; |
|
| 228 | + $create_groups_form->setDefaults($defaults); |
|
| 229 | + $create_groups_form->display(); |
|
| 230 | 230 | |
| 231 | - /* |
|
| 231 | + /* |
|
| 232 | 232 | * Show form to generate subgroups |
| 233 | 233 | */ |
| 234 | - if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
| 235 | - $base_group_options = array (); |
|
| 236 | - $groups = GroupManager :: get_group_list(); |
|
| 237 | - foreach ($groups as $index => $group) { |
|
| 238 | - $number_of_students = GroupManager :: number_of_students($group['id']); |
|
| 239 | - if ($number_of_students > 0) { |
|
| 240 | - $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - if (count($base_group_options) > 0) { |
|
| 244 | - $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 234 | + if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { |
|
| 235 | + $base_group_options = array (); |
|
| 236 | + $groups = GroupManager :: get_group_list(); |
|
| 237 | + foreach ($groups as $index => $group) { |
|
| 238 | + $number_of_students = GroupManager :: number_of_students($group['id']); |
|
| 239 | + if ($number_of_students > 0) { |
|
| 240 | + $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + if (count($base_group_options) > 0) { |
|
| 244 | + $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 245 | 245 | $create_subgroups_form->addElement('header', get_lang('CreateSubgroups')); |
| 246 | 246 | $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo')); |
| 247 | - $create_subgroups_form->addElement('hidden', 'action'); |
|
| 248 | - $group_el = array(); |
|
| 249 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
| 250 | - $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
| 251 | - $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
| 252 | - $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
| 253 | - $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
| 254 | - $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); |
|
| 255 | - $defaults = array(); |
|
| 256 | - $defaults['action'] = 'create_subgroups'; |
|
| 257 | - $create_subgroups_form->setDefaults($defaults); |
|
| 258 | - $create_subgroups_form->display(); |
|
| 259 | - } |
|
| 260 | - } |
|
| 247 | + $create_subgroups_form->addElement('hidden', 'action'); |
|
| 248 | + $group_el = array(); |
|
| 249 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); |
|
| 250 | + $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); |
|
| 251 | + $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); |
|
| 252 | + $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); |
|
| 253 | + $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok')); |
|
| 254 | + $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); |
|
| 255 | + $defaults = array(); |
|
| 256 | + $defaults['action'] = 'create_subgroups'; |
|
| 257 | + $create_subgroups_form->setDefaults($defaults); |
|
| 258 | + $create_subgroups_form->display(); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - /* |
|
| 262 | + /* |
|
| 263 | 263 | * Show form to generate groups from classes subscribed to the course |
| 264 | 264 | */ |
| 265 | 265 | $options['where'] = array(" usergroup.course_id = ? " => api_get_real_course_id()); |
| 266 | 266 | $obj = new UserGroup(); |
| 267 | 267 | $classes = $obj->getUserGroupInCourse($options); |
| 268 | - if (count($classes) > 0) { |
|
| 269 | - echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
| 270 | - echo '<blockquote>'; |
|
| 271 | - echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
| 272 | - echo '<ul>'; |
|
| 273 | - foreach ($classes as $index => $class) { |
|
| 274 | - $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
| 275 | - echo '<li>'; |
|
| 276 | - echo $class['name']; |
|
| 277 | - echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
| 278 | - echo '</li>'; |
|
| 279 | - } |
|
| 280 | - echo '</ul>'; |
|
| 268 | + if (count($classes) > 0) { |
|
| 269 | + echo '<b>'.get_lang('GroupsFromClasses').'</b>'; |
|
| 270 | + echo '<blockquote>'; |
|
| 271 | + echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>'; |
|
| 272 | + echo '<ul>'; |
|
| 273 | + foreach ($classes as $index => $class) { |
|
| 274 | + $number_of_users = count($obj->get_users_by_usergroup($class['id'])); |
|
| 275 | + echo '<li>'; |
|
| 276 | + echo $class['name']; |
|
| 277 | + echo ' ('.$number_of_users.' '.get_lang('Users').')'; |
|
| 278 | + echo '</li>'; |
|
| 279 | + } |
|
| 280 | + echo '</ul>'; |
|
| 281 | 281 | |
| 282 | - $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 283 | - $create_class_groups_form->addElement('hidden', 'action'); |
|
| 284 | - if (api_get_setting('allow_group_categories') == 'true') { |
|
| 285 | - $group_categories = GroupManager :: get_categories(); |
|
| 286 | - $cat_options = array(); |
|
| 287 | - foreach ($group_categories as $index => $category) { |
|
| 288 | - $cat_options[$category['id']] = $category['title']; |
|
| 289 | - } |
|
| 290 | - $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
| 291 | - } else { |
|
| 292 | - $create_class_groups_form->addElement('hidden', 'group_category'); |
|
| 293 | - } |
|
| 294 | - $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
| 295 | - $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
| 296 | - $defaults['action'] = 'create_class_groups'; |
|
| 297 | - $create_class_groups_form->setDefaults($defaults); |
|
| 298 | - $create_class_groups_form->display(); |
|
| 299 | - echo '</blockquote>'; |
|
| 300 | - } |
|
| 282 | + $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq()); |
|
| 283 | + $create_class_groups_form->addElement('hidden', 'action'); |
|
| 284 | + if (api_get_setting('allow_group_categories') == 'true') { |
|
| 285 | + $group_categories = GroupManager :: get_categories(); |
|
| 286 | + $cat_options = array(); |
|
| 287 | + foreach ($group_categories as $index => $category) { |
|
| 288 | + $cat_options[$category['id']] = $category['title']; |
|
| 289 | + } |
|
| 290 | + $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); |
|
| 291 | + } else { |
|
| 292 | + $create_class_groups_form->addElement('hidden', 'group_category'); |
|
| 293 | + } |
|
| 294 | + $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); |
|
| 295 | + $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; |
|
| 296 | + $defaults['action'] = 'create_class_groups'; |
|
| 297 | + $create_class_groups_form->setDefaults($defaults); |
|
| 298 | + $create_class_groups_form->display(); |
|
| 299 | + echo '</blockquote>'; |
|
| 300 | + } |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | Display :: display_footer(); |