$group) { if (!empty($_POST['same_tutor'])) { $group['tutor'] = $_POST['group_0_tutor']; } if (!empty($_POST['same_places'])) { $group['places'] = $_POST['group_0_places']; } if (api_get_setting('allow_group_categories') == 'false') { $group['category'] = DEFAULT_GROUP_CATEGORY; } elseif ($_POST['same_category']) { $group['category'] = $_POST['group_0_category']; } GroupManager :: create_group(strip_tags($group['name']),$group['category'],$group['tutor'] , $group['places']); } $msg = urlencode(count($groups).' '.get_lang('GroupsAdded')); header('Location: group.php?action=show_msg&msg='.$msg); break; case 'create_virtual_groups' : $ids = GroupManager :: create_groups_from_virtual_courses(); $msg = urlencode(count($ids).' '.get_lang('GroupsAdded')); header('Location: group.php?action=show_msg&msg='.$msg); break; case 'create_subgroups' : GroupManager :: create_subgroups($_POST['base_group'], $_POST['number_of_groups']); $msg = urlencode($_POST['number_of_groups'].' '.get_lang('GroupsAdded')); header('Location: group.php?action=show_msg&msg='.$msg); break; case 'create_class_groups' : $ids = GroupManager :: create_class_groups($_POST['group_category']); $msg = urlencode(count($ids).' '.get_lang('GroupsAdded')); header('Location: group.php?action=show_msg&msg='.$msg); break; } } $nameTools = get_lang('GroupCreation'); $interbreadcrumb[] = array ("url" => "group.php", "name" => get_lang('Groups')); Display :: display_header($nameTools, "Group"); if (!api_is_allowed_to_edit(false,true)) { api_not_allowed(); } /* =============================================================================== MAIN TOOL CODE =============================================================================== */ /* -------------------------------------- Show group-settings-form -------------------------------------- */ elseif (isset ($_POST['number_of_groups'])) { if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) { Display :: display_error_message(get_lang('PleaseEnterValidNumber').'

« '.get_lang('Back').'',false); } else { $number_of_groups = intval($_POST['number_of_groups']); if ($number_of_groups > 1) { ?> $tutor) { $tutor_options[$tutor['user_id']] = api_get_person_name($tutor['firstname'], $tutor['lastname']); } $cat_options = array (); */ foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! if ($category['id'] != VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } $form = new FormValidator('create_groups_step2'); // Modify the default templates $renderer = & $form->defaultRenderer(); $form_template = "
\n
\n\n{content}\n
\n
\n
"; $renderer->setFormTemplate($form_template); $element_template = << * {label} {error}
{element} EOT; $renderer->setElementTemplate($element_template); $form->addElement('header', '', $nameTools); $form->addElement('hidden', 'action'); $form->addElement('hidden', 'number_of_groups'); $defaults = array (); // Table heading $group_el = array (); $group_el[] = & $form->createElement('static', null, null, ''.get_lang('GroupName').''); if (api_get_setting('allow_group_categories') == 'true') { $group_el[] = & $form->createElement('static', null, null, ''.get_lang('GroupCategory').''); } //$group_el[] = & $form->createElement('static', null, null, ''.get_lang('GroupTutor').''); $group_el[] = & $form->createElement('static', null, null, ''.get_lang('GroupPlacesThis').''); $form->addGroup($group_el, 'groups', null, "\n\n\n", false); // Checkboxes if ($_POST['number_of_groups'] > 1) { $group_el = array (); $group_el[] = & $form->createElement('static', null, null, ' '); if (api_get_setting('allow_group_categories') == 'true') { $group_el[] = & $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('category')")); } //$group_el[] = & $form->createElement('checkbox', 'same_tutor', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('tutor')")); $group_el[] = & $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript:switch_state('places')")); $form->addGroup($group_el, 'groups', null, '', false); } // Properties for all groups for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) { $group_el = array (); $group_el[] = & $form->createElement('text', 'group_'.$group_number.'_name'); if (api_get_setting('allow_group_categories') == 'true') { $group_el[] = & $form->createElement('select', 'group_'.$group_number.'_category', null, $cat_options, array ('id' => 'category_'.$group_number)); } //$group_el[] = & $form->createElement('select', 'group_'.$group_number.'_tutor', null, $tutor_options, array ('id' => 'tutor_'.$group_number)); $group_el[] = & $form->createElement('text', 'group_'.$group_number.'_places', null, array ('size' => 3, 'id' => 'places_'.$group_number)); if($_POST['number_of_groups']<10000) { if ($group_id<10) { $prev='000'; } elseif ($group_id<100) { $prev='00'; } elseif ($group_id<1000) { $prev='0'; } else { $prev=''; } } $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++; $form->addGroup($group_el, 'group_'.$group_number, null, '', false); } $defaults['action'] = 'create_groups'; $defaults['number_of_groups'] = intval($_POST['number_of_groups']); $form->setDefaults($defaults); $form->addElement('style_submit_button', 'submit', get_lang('CreateGroup'), 'class="save"'); $form->display(); } } else { /* * Show form to generate new groups */ $categories = GroupManager :: get_categories(); //echo '
'; if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != VIRTUAL_COURSE_CATEGORY) { $create_groups_form = new FormValidator('create_groups'); $create_groups_form->addElement('header', '', $nameTools); $group_el = array (); $group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('Create')); $group_el[] = & $create_groups_form->createElement('text', 'number_of_groups', null, array ('size' => 3)); $group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('NewGroups')); $group_el[] = & $create_groups_form->createElement('style_submit_button', 'submit', get_lang('ProceedToCreateGroup'), 'class="save"'); $create_groups_form->addGroup($group_el, 'create_groups', null, ' ', false); $defaults = array (); $defaults['number_of_groups'] = 1; $create_groups_form->setDefaults($defaults); $create_groups_form->display(); } else { echo get_lang('NoCategoriesDefined'); } //echo '
'; /* * Show form to generate groups from virtual courses */ $virtual_courses = CourseManager :: get_virtual_courses_linked_to_real_course($_course['sysCode']); if (count($virtual_courses) > 0) { echo ''.get_lang('CreateGroupsFromVirtualCourses').''; echo '
'; echo get_lang('CreateGroupsFromVirtualCoursesInfo'); $create_virtual_groups_form = new FormValidator('create_virtual_groups'); $create_virtual_groups_form->addElement('hidden', 'action'); $create_virtual_groups_form->addElement('submit', 'submit', get_lang('Ok')); $create_virtual_groups_form->setDefaults(array ('action' => 'create_virtual_groups')); $create_virtual_groups_form->display(); echo '
'; } /* * Show form to generate subgroups */ if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { $base_group_options = array (); $groups = GroupManager :: get_group_list(); foreach ($groups as $index => $group) { $number_of_students = GroupManager :: number_of_students($group['id']); if ($number_of_students > 0) { $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; } } if (count($base_group_options) > 0) { echo ''.get_lang('CreateSubgroups').''; echo '
'; echo '

'.get_lang('CreateSubgroupsInfo').'

'; $create_subgroups_form = new FormValidator('create_subgroups'); $create_subgroups_form->addElement('hidden', 'action'); $group_el = array (); $group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); $group_el[] = & $create_subgroups_form->createElement('text', 'number_of_groups', null, array ('size' => 3)); $group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); $group_el[] = & $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); $group_el[] = & $create_subgroups_form->createElement('submit', 'submit', get_lang('Ok')); $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); $defaults = array (); $defaults['action'] = 'create_subgroups'; $create_subgroups_form->setDefaults($defaults); $create_subgroups_form->display(); echo '
'; } } /* * Show form to generate groups from classes subscribed to the course */ $classes = ClassManager :: get_classes_in_course($_course['sysCode']); if (count($classes) > 0) { echo ''.get_lang('GroupsFromClasses').''; echo '
'; echo '

'.get_lang('GroupsFromClassesInfo').'

'; echo ''; $create_class_groups_form = new FormValidator('create_class_groups_form'); $create_class_groups_form->addElement('hidden', 'action'); if (api_get_setting('allow_group_categories') == 'true') { $group_categories = GroupManager :: get_categories(); $cat_options = array (); foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! if ($category['id'] != VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); } else { $create_class_groups_form->addElement('hidden', 'group_category'); } $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); $defaults['group_category'] = DEFAULT_GROUP_CATEGORY; $defaults['action'] = 'create_class_groups'; $create_class_groups_form->setDefaults($defaults); $create_class_groups_form->display(); echo '
'; } } /* =============================================================================== DOKEOS FOOTER =============================================================================== */ Display :: display_footer(); ?>