Beispiel #1
0
/**
 * Print group menu selector for activity.
 *
 * @category group
 * @param stdClass|cm_info $cm course module object
 * @param string|moodle_url $urlroot return address that users get to if they choose an option;
 *   should include any parameters needed, e.g. "$CFG->wwwroot/mod/forum/view.php?id=34"
 * @param bool $return return as string instead of printing
 * @param bool $hideallparticipants If true, this prevents the 'All participants'
 *   option from appearing in cases where it normally would. This is intended for
 *   use only by activities that cannot display all groups together. (Note that
 *   selecting this option does not prevent groups_get_activity_group from
 *   returning 0; it will still do that if the user has chosen 'all participants'
 *   in another activity, or not chosen anything.)
 * @return mixed void or string depending on $return param
 */
function groups_print_activity_menu($cm, $urlroot, $return = false, $hideallparticipants = false)
{
    global $USER, $OUTPUT;
    if ($urlroot instanceof moodle_url) {
        // no changes necessary
    } else {
        if (strpos($urlroot, 'http') !== 0) {
            // Will also work for https
            // Display error if urlroot is not absolute (this causes the non-JS version to break)
            debugging('groups_print_activity_menu requires absolute URL for ' . '$urlroot, not <tt>' . s($urlroot) . '</tt>. Example: ' . 'groups_print_activity_menu($cm, $CFG->wwwroot . \'/mod/mymodule/view.php?id=13\');', DEBUG_DEVELOPER);
        }
        $urlroot = new moodle_url($urlroot);
    }
    if (!($groupmode = groups_get_activity_groupmode($cm))) {
        if ($return) {
            return '';
        } else {
            return;
        }
    }
    $context = context_module::instance($cm->id);
    $aag = has_capability('moodle/site:accessallgroups', $context);
    $usergroups = array();
    if ($groupmode == VISIBLEGROUPS or $aag) {
        $allowedgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid);
        // any group in grouping
        // Get user's own groups and put to the top.
        $usergroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid);
    } else {
        $allowedgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid);
        // only assigned groups
    }
    $activegroup = groups_get_activity_group($cm, true, $allowedgroups);
    $groupsmenu = array();
    if ((!$allowedgroups or $groupmode == VISIBLEGROUPS or $aag) and !$hideallparticipants) {
        $groupsmenu[0] = get_string('allparticipants');
    }
    $groupsmenu += groups_sort_menu_options($allowedgroups, $usergroups);
    if ($groupmode == VISIBLEGROUPS) {
        $grouplabel = get_string('groupsvisible');
    } else {
        $grouplabel = get_string('groupsseparate');
    }
    if ($aag and $cm->groupingid) {
        if ($grouping = groups_get_grouping($cm->groupingid)) {
            $grouplabel = $grouplabel . ' (' . format_string($grouping->name) . ')';
        }
    }
    if (count($groupsmenu) == 1) {
        $groupname = reset($groupsmenu);
        $output = $grouplabel . ': ' . $groupname;
    } else {
        $select = new single_select($urlroot, 'group', $groupsmenu, $activegroup, null, 'selectgroup');
        $select->label = $grouplabel;
        $output = $OUTPUT->render($select);
    }
    $output = '<div class="groupselector">' . $output . '</div>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
 $failed = false;
 // prepare grouping
 if (!empty($data->grouping)) {
     $groupingname = trim($data->groupingname);
     if ($data->grouping < 0) {
         $grouping = new object();
         $grouping->courseid = $COURSE->id;
         $grouping->name = $groupingname;
         if (!($grouping->id = groups_create_grouping(addslashes_recursive($grouping)))) {
             $error = 'Can not create grouping';
             //should not happen
             $failed = true;
         }
         $createdgrouping = $grouping->id;
     } else {
         $grouping = groups_get_grouping($data->grouping);
     }
 }
 // Save the groups data
 foreach ($groups as $key => $group) {
     if (groups_get_group_by_name($courseid, $group['name'])) {
         $error = get_string('groupnameexists', 'group', $group['name']);
         $failed = true;
         break;
     }
     $newgroup = new object();
     $newgroup->courseid = $data->courseid;
     $newgroup->name = $group['name'];
     if (!($groupid = groups_create_group(addslashes_recursive($newgroup)))) {
         $error = 'Can not create group!';
         // should not happen
 /**
  * Unassign a group from a grouping
  *
  * @param array $unassignments of arrays with keys groupid, groupingid
  * @return void
  * @since Moodle 2.3
  */
 public static function unassign_grouping($unassignments)
 {
     global $CFG, $DB;
     require_once "{$CFG->dirroot}/group/lib.php";
     $params = self::validate_parameters(self::unassign_grouping_parameters(), array('unassignments' => $unassignments));
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['unassignments'] as $unassignment) {
         // Validate params.
         $groupingid = $unassignment['groupingid'];
         $groupid = $unassignment['groupid'];
         $grouping = groups_get_grouping($groupingid, 'id, courseid', MUST_EXIST);
         $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
         if (!$DB->record_exists('groupings_groups', array('groupingid' => $groupingid, 'groupid' => $groupid))) {
             // Continue silently if the group is not assigned to the grouping.
             continue;
         }
         // Now security checks.
         $context = context_course::instance($grouping->courseid);
         try {
             self::validate_context($context);
         } catch (Exception $e) {
             $exceptionparam = new stdClass();
             $exceptionparam->message = $e->getMessage();
             $exceptionparam->courseid = $group->courseid;
             throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
         }
         require_capability('moodle/course:managegroups', $context);
         groups_unassign_grouping($groupingid, $groupid);
     }
     $transaction->allow_commit();
 }
            $elluminate->name = $elluminate->name . ' - ' . $course->shortname . ' - ' . $groupname;
        }
        if (!empty($elluminate->customdescription)) {
            $elluminate->description = $groupname . ' - ' . $elluminate->description;
        }
    }
}
$formelements = array(get_string('name') => $elluminate->name, get_string('sessionnamedisplay', 'elluminate') => $elluminate->sessionname, get_string('description') => $elluminate->description, get_string('meetingbegins', 'elluminate') => userdate($elluminate->timestart), get_string('meetingends', 'elluminate') => userdate($elluminate->timeend));
echo '<table align="center" cellpadding="5">' . "\n";
foreach ($formelements as $key => $val) {
    echo '<tr valign="top">' . "\n";
    echo '<td align="right"><b>' . $key . ':</b></td><td align="left">' . $val . '</td>' . "\n";
    echo '</tr>' . "\n";
}
if ($elluminate->sessiontype == '3') {
    $grouping = groups_get_grouping($elluminate->groupingid);
    echo '<tr valign="top">' . "\n";
    echo '<td align="right"><b>Grouping:</b></td><td align="left">' . $grouping->name . '</td>' . "\n";
    echo '</tr>' . "\n";
}
echo '</table>';
echo '<div align="center" >';
if ($participant && $canmanagemoderators && !$hasfinished) {
    $link = '<a href="' . $CFG->wwwroot . '/mod/elluminate/moderators.php?id=' . $elluminate->id . '">' . get_string('editmoderatorsforthissession', 'elluminate') . '</a>';
    echo '<p class="elluminateeditmoderators">' . $link . '</p>';
}
if ($elluminate->sessiontype == 1) {
    if ($participant && $canmanageparticipants && !$hasfinished) {
        $link = '<a href="' . $CFG->wwwroot . '/mod/elluminate/participants.php?id=' . $elluminate->id . '">' . get_string('editparticipantsforthissession', 'elluminate') . '</a>';
        echo '<p class="elluminateeditparticipants">' . $link . '</p>';
    }
            $mform->display();
            echo $OUTPUT->footer();
            die;
        }
    }
}
echo $OUTPUT->header();
if ($manage) {
    echo '<div class="managelink"><a href="' . "{$CFG->wwwroot}/group/index.php?id={$course->id}" . '">' . get_string('managegroups', 'groupselect') . '</a></div>';
    $currenttab = 'view';
    include $CFG->dirroot . '/mod/groupselect/tabs.php';
}
if (empty($CFG->enablegroupings) or empty($cm->groupingid)) {
    echo $OUTPUT->heading(get_string('headingsimple', 'groupselect'));
} else {
    $grouping = groups_get_grouping($cm->groupingid);
    echo $OUTPUT->heading(get_string('headinggrouping', 'groupselect', format_string($grouping->name)));
}
if (!$accessall and $groupselect->timeavailable > time()) {
    notice(get_string('notavailableyet', 'groupselect', userdate($groupselect->timeavailable)), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
    die;
    // not reached
}
echo $OUTPUT->box(format_module_intro('groupselect', $groupselect, $cm->id), 'generalbox', 'intro');
if (!$accessall and $groupselect->timedue != 0 and $groupselect->timedue < time() and !$hasgroup) {
    echo $OUTPUT->notification(get_string('notavailableanymore', 'groupselect', userdate($groupselect->timedue)));
}
if ($groups) {
    $data = array();
    $limits = groupselect_get_limits($groupselect->id);
    foreach ($groups as $group) {
 /**
  * get instance name with groupping name if available
  *
  * @return string with name+(grouping name)
  **/
 function get_printable_name()
 {
     global $CFG;
     $ret = $this->instance->name;
     if (!empty($CFG->enablegroupings) && $this->cm->groupingid > 0) {
         $grouping = groups_get_grouping($this->cm->groupingid);
         if ($grouping !== false) {
             $ret .= ' (' . $grouping->name . ')';
         }
     }
     return $ret;
 }
Beispiel #7
0
/**
 * Updates all parent cluster's groupings with the existence of a group for this cluster
 *
 * @param    int      $clusterid         The cluster to check the parents for
 * @param    boolean  $include_children  If true, make child cluster-groups trickle up the tree
 * @return   boolean                     Returns true to satisfy event handlers
 */
function userset_groups_update_grouping_closure($clusterid, $include_children = false)
{
    global $CFG;
    $enabled = get_config('elisprogram_usetgroups', 'userset_groupings');
    if (empty($enabled) || !userset_groups_grouping_allowed($clusterid)) {
        return true;
    }
    $cluster = new userset($clusterid);
    //get the group id for this cluster
    if ($groupid = groups_get_group_by_name(SITEID, $cluster->name)) {
        //go through the chain of parent clusters
        while (!empty($cluster->parent)) {
            $cluster = new userset($cluster->parent);
            //add this to grouping if applicable
            $grouping = groups_get_grouping_by_name(SITEID, $cluster->name);
            if ($grouping = groups_get_grouping($grouping)) {
                groups_assign_grouping($grouping->id, $groupid);
                //recurse into children if possible
                if ($include_children) {
                    //get all child clusters
                    $child_cluster_ids = userset_groups_get_child_usersets($cluster->id);
                    foreach ($child_cluster_ids as $child_cluster_id) {
                        //children only
                        if ($child_cluster_id != $cluster->id) {
                            $child_cluster = new userset($child_cluster_id);
                            //make sure the group exists
                            if ($child_groupid = groups_get_group_by_name(SITEID, $child_cluster->name) and userset_groups_userset_allows_groups($child_cluster->id)) {
                                groups_assign_grouping($grouping->id, $child_groupid);
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
 /**
  * Outputs the content of the administration tab and manages actions taken in this tab
  */
 public function view_administration()
 {
     global $SESSION, $OUTPUT, $PAGE, $DB, $USER, $CFG;
     $output = $PAGE->get_renderer('mod_grouptool');
     $id = $this->cm->id;
     $context = context_course::instance($this->course->id);
     // Get applicable roles!
     $rolenames = array();
     if ($roles = get_profile_roles($context)) {
         foreach ($roles as $role) {
             $rolenames[$role->id] = strip_tags(role_get_name($role, $context));
         }
     }
     $filter = optional_param('filter', null, PARAM_INT);
     if ($filter !== null) {
         set_user_preference('mod_grouptool_group_filter', $filter, $USER->id);
     } else {
         $filter = get_user_preferences('mod_grouptool_group_filter', self::FILTER_ACTIVE, $USER->id);
     }
     $inactivetabs = array();
     $filtertabs['active'] = new tabobject(self::FILTER_ACTIVE, $CFG->wwwroot . '/mod/grouptool/view.php?id=' . $id . '&amp;tab=group_admin&filter=' . self::FILTER_ACTIVE, get_string('active', 'grouptool'), '', false);
     $filtertabs['inactive'] = new tabobject(self::FILTER_INACTIVE, $CFG->wwwroot . '/mod/grouptool/view.php?id=' . $id . '&amp;tab=group_admin&filter=' . self::FILTER_INACTIVE, get_string('inactive'), '', false);
     $filtertabs['all'] = new tabobject(self::FILTER_ALL, $CFG->wwwroot . '/mod/grouptool/view.php?id=' . $id . '&amp;tab=group_admin&filter=' . self::FILTER_ALL, get_string('all'), '', false);
     echo html_writer::tag('div', $OUTPUT->tabtree($filtertabs, $filter, $inactivetabs), array('id' => 'filtertabs'));
     // Check if everything has been confirmed, so we can finally start working!
     if (optional_param('confirm', 0, PARAM_BOOL)) {
         if (isset($SESSION->grouptool->view_administration->createGroupings)) {
             require_capability('mod/grouptool:create_groupings', $this->context);
             $target = required_param('target', PARAM_INT);
             switch ($target) {
                 // ...grpg_target | grpg_groupingname | use_all (0 sel | 1 all).
                 case 0:
                     // Invalid - no action! TODO Add message!
                     $error = true;
                     $preview = '';
                     break;
                 case -2:
                     // One grouping per group!
                     list($error, $preview) = $this->create_group_groupings();
                     break;
                 case -1:
                     // One new grouping for all!
                     list($error, $preview) = $this->update_grouping($target, required_param('name', PARAM_ALPHANUMEXT));
                     break;
                 default:
                     list($error, $preview) = $this->update_grouping($target);
                     break;
             }
             $preview = html_writer::tag('div', $preview, array('class' => 'centered'));
             echo $OUTPUT->box($preview, 'generalbox');
         }
         unset($SESSION->grouptool->view_administration);
     }
     if ($rename = optional_param('rename', 0, PARAM_INT)) {
         // Show Rename Form!
         $gform = new \mod_grouptool\group_rename_form(null, array('id' => $this->cm->id, 'instance' => $this->cm->instance, 'rename' => $rename));
         if (!$gform->is_cancelled() && ($fromform = $gform->get_data())) {
             $group = new stdClass();
             $group->id = $fromform->rename;
             $group->name = $fromform->name;
             $group->courseid = $fromform->courseid;
             groups_update_group($group);
         } else {
             if (!$gform->is_cancelled()) {
                 $data = new stdClass();
                 $data->name = $DB->get_field('groups', 'name', array('id' => $rename));
                 $gform->set_data($data);
                 $gform->display();
                 echo $OUTPUT->footer();
                 die;
             }
         }
     }
     if ($resize = optional_param('resize', 0, PARAM_INT)) {
         // Show Rename Form!
         $gform = new \mod_grouptool\group_resize_form(null, array('id' => $this->cm->id, 'instance' => $this->cm->instance, 'resize' => $resize));
         if (!$gform->is_cancelled() && ($fromform = $gform->get_data())) {
             if (empty($fromform->size)) {
                 $DB->set_field('grouptool_agrps', 'grpsize', null, array('groupid' => $fromform->resize, 'grouptoolid' => $this->cm->id));
             } else {
                 $group = new stdClass();
                 $group->id = $DB->get_field('grouptool_agrps', 'id', array('groupid' => $fromform->resize, 'grouptoolid' => $this->cm->instance));
                 $group->grpsize = $fromform->size;
                 $DB->update_record('grouptool_agrps', $group);
             }
         } else {
             if (!$gform->is_cancelled()) {
                 $data = new stdClass();
                 $data->size = $DB->get_field('grouptool_agrps', 'grpsize', array('groupid' => $resize, 'grouptoolid' => $this->cm->instance));
                 $gform->set_data($data);
                 $gform->display();
                 echo $OUTPUT->footer();
                 die;
             }
         }
     }
     if ($delete = optional_param('delete', 0, PARAM_INT)) {
         if (!optional_param('confirm', 0, PARAM_BOOL)) {
             // Show Confirm!
             $cancel = new moodle_url($PAGE->url);
             $continue = new moodle_url($cancel, array('confirm' => 1, 'delete' => $delete));
             $cancel = new single_button($cancel, get_string('no'), 'post');
             $continue = new single_button($continue, get_string('yes'), 'post');
             $confirmtext = get_string('confirm_delete', 'grouptool');
             echo $this->confirm($confirmtext, $continue, $cancel);
             echo $OUTPUT->footer();
             die;
         } else {
             // Delete it!
             groups_delete_group($delete);
         }
     }
     if ($toggle = optional_param('toggle', 0, PARAM_INT)) {
         if (!empty($toggle)) {
             $conditions = array('grouptoolid' => $this->cm->instance, 'groupid' => $toggle);
             if (!$DB->record_exists('grouptool_agrps', $conditions)) {
                 echo $OUTPUT->box($OUTPUT->notification(get_string('group_not_found', 'grouptool'), 'notifyproblem', $conditions), 'generalbox');
             } else {
                 $record = $DB->get_record('grouptool_agrps', $conditions);
                 if (!empty($record->active)) {
                     $DB->set_field('grouptool_agrps', 'active', 0, $conditions);
                 } else {
                     $DB->set_field('grouptool_agrps', 'active', 1, $conditions);
                 }
             }
         }
     }
     if (($bulkaction = optional_param('bulkaction', null, PARAM_ALPHA)) && ($selected = optional_param_array('selected', array(), PARAM_INT)) && optional_param('start_bulkaction', 0, PARAM_BOOL)) {
         switch ($bulkaction) {
             case 'activate':
                 // ...also via ajax bulk action?
                 // Activate now!
                 $groups = optional_param_array('selected', null, PARAM_INT);
                 if (!empty($groups)) {
                     list($grpsql, $grpparams) = $DB->get_in_or_equal($groups);
                     $DB->set_field_select("grouptool_agrps", "active", 1, " grouptoolid = ? AND groupid " . $grpsql, array_merge(array($this->cm->instance), $grpparams));
                 }
                 echo $OUTPUT->notification(get_string('activated_groups', 'grouptool'), 'notifysuccess');
                 $continue = new moodle_url($PAGE->url, array('tab' => 'group_admin'));
                 echo $this->confirm('', $continue);
                 break;
             case 'deactivate':
                 // ...also via ajax bulk action?
                 // Deactivate now!
                 $groups = optional_param_array('selected', null, PARAM_INT);
                 if (!empty($groups)) {
                     list($grpsql, $grpparams) = $DB->get_in_or_equal($groups);
                     $DB->set_field_select("grouptool_agrps", "active", 0, " grouptoolid = ? AND groupid " . $grpsql, array_merge(array($this->cm->instance), $grpparams));
                 }
                 echo $OUTPUT->notification(get_string('deactivated_groups', 'grouptool'), 'notifysuccess');
                 $continue = new moodle_url($PAGE->url, array('tab' => 'group_admin'));
                 echo $this->confirm('', $continue);
                 break;
             case 'delete':
                 // ...also via ajax bulk action?
                 // Show confirmation dialogue!
                 if (optional_param('confirm', 0, PARAM_BOOL)) {
                     $groups = optional_param_array('selected', null, PARAM_INT);
                     $groups = $DB->get_records_list('groups', 'id', $groups);
                     foreach ($groups as $group) {
                         groups_delete_group($group);
                     }
                     echo $OUTPUT->notification(get_string('successfully_deleted_groups', 'grouptool'), 'notifysuccess');
                     $continue = new moodle_url($PAGE->url, array('tab' => 'group_admin'));
                     echo $this->confirm('', $continue);
                 } else {
                     $cancel = new moodle_url($PAGE->url, array('tab' => 'group_admin'));
                     $params = array('confirm' => 1, 'bulkaction' => 'delete', 'start_bulkaction' => 1);
                     $text = get_string('confirm_delete', 'grouptool') . html_writer::start_tag('ul');
                     $groups = $DB->get_records_list('groups', 'id', $selected);
                     foreach ($selected as $select) {
                         $params['selected[' . $select . ']'] = $select;
                         $text .= html_writer::tag('li', $groups[$select]->name);
                     }
                     $text .= html_writer::end_tag('ul');
                     $continue = new moodle_url($cancel, $params);
                     echo $this->confirm($text, $continue, $cancel);
                     echo $OUTPUT->footer();
                     die;
                 }
                 break;
             case 'grouping':
                 // Show grouping creation form!
                 $selected = optional_param_array('selected', array(), PARAM_INT);
                 $mform = new \mod_grouptool\groupings_creation_form(null, array('id' => $id, 'selected' => $selected));
                 $groups = $DB->get_records_list('groups', 'id', $selected);
                 if ($mform->is_cancelled()) {
                     $bulkaction = null;
                     $selected = array();
                 } else {
                     if ($fromform = $mform->get_data()) {
                         // Some groupings should be created...
                         if ($fromform->target == -2) {
                             // One new grouping per group!
                             foreach ($groups as $group) {
                                 $grouping = new stdClass();
                                 if (!($grouping->id = groups_get_grouping_by_name($this->course->id, $group->name))) {
                                     $grouping = new stdClass();
                                     $grouping->courseid = $this->course->id;
                                     $grouping->name = $group->name;
                                     $grouping->id = groups_create_grouping($grouping);
                                 }
                                 // Insert group!
                                 groups_assign_grouping($grouping->id, $group->id);
                             }
                         } else {
                             if ($fromform->target == -1) {
                                 // One new grouping!
                                 // Create grouping if it doesn't exist...
                                 $grouping = new stdClass();
                                 if (!($grouping->id = groups_get_grouping_by_name($this->course->id, $fromform->name))) {
                                     $grouping = new stdClass();
                                     $grouping->courseid = $this->course->id;
                                     $grouping->name = trim($fromform->name);
                                     $grouping->id = groups_create_grouping($grouping);
                                 }
                                 // Insert groups!
                                 foreach ($groups as $group) {
                                     groups_assign_grouping($grouping->id, $group->id);
                                 }
                             } else {
                                 if ($fromform->target > 0) {
                                     // Existing Grouping!
                                     $grouping = groups_get_grouping($fromform->target);
                                     if ($grouping) {
                                         foreach ($groups as $group) {
                                             groups_assign_grouping($grouping->id, $group->id);
                                         }
                                     }
                                 }
                             }
                         }
                         // ...redirect to show sortlist again!
                         $url = new moodle_url('/mod/grouptool/view.php', array('id' => $this->cm->id, 'tab' => 'group_admin', 'filter' => $filter));
                         $text = $OUTPUT->notification(get_string('groupings_created_and_groups_added', 'grouptool'), 'notifymessage');
                         echo $this->confirm($text, $url);
                     } else {
                         $mform->display();
                     }
                 }
                 break;
         }
     }
     if (!$bulkaction || !$selected || !optional_param('start_bulkaction', 0, PARAM_BOOL)) {
         // Show form!
         $formaction = new moodle_url('/mod/grouptool/view.php', array('id' => $this->cm->id, 'tab' => 'group_admin', 'filter' => $filter));
         $mform = new MoodleQuickForm('bulk', 'post', $formaction, '');
         $mform->addElement('hidden', 'sesskey');
         $mform->setDefault('sesskey', sesskey());
         $sortlist = new \mod_grouptool\output\sortlist($this->course->id, $this->cm, $filter);
         $sortlistcontroller = new \mod_grouptool\output\sortlist_controller($sortlist);
         $mform->addElement('html', $output->render($sortlistcontroller));
         $mform->addElement('html', $output->render($sortlist));
         $actions = array('' => get_string('choose', 'grouptool'), 'activate' => get_string('setactive', 'grouptool'), 'deactivate' => get_string('setinactive', 'grouptool'), 'delete' => get_string('delete'), 'grouping' => get_string('createinsertgrouping', 'grouptool'));
         $grp = array();
         $grp[] =& $mform->createElement('static', 'with_selection', '', get_string('with_selection', 'grouptool'));
         $grp[] =& $mform->createElement('select', 'bulkaction', '', $actions);
         $grp[] =& $mform->createElement('submit', 'start_bulkaction', get_string('start', 'grouptool'));
         $mform->addGroup($grp, 'actiongrp', '', ' ', false);
         $mform->disable_form_change_checker();
         $mform->display();
         switch ($filter) {
             case self::FILTER_ACTIVE:
                 $curfilter = 'active';
                 break;
             case self::FILTER_INACTIVE:
                 $curfilter = 'inactive';
                 break;
             case self::FILTER_ALL:
                 $curfilter = 'all';
                 break;
         }
         $PAGE->requires->yui_module('moodle-mod_grouptool-administration', 'M.mod_grouptool.init_administration', array(array('lang' => current_language(), 'contextid' => $this->context->id, 'filter' => $curfilter, 'filterid' => $filter, 'globalsize' => $this->grouptool->grpsize)));
         $PAGE->requires->strings_for_js(array('active', 'inactive', 'confirm_delete'), 'mod_grouptool');
         $PAGE->requires->string_for_js('ajax_edit_size_help', 'mod_grouptool');
         $PAGE->requires->strings_for_js(array('yes', 'no'), 'moodle');
     }
 }
Beispiel #9
0
/**
 * Updates all parent cluster's groupings with the existence of a group for this cluster
 *
 * @param    int      $clusterid         The cluster to check the parents for
 * @param    boolean  $include_children  If true, make child cluster-groups trickle up the tree
 * @return   boolean                     Returns true to satisfy event handlers
 */
function cluster_groups_update_grouping_closure($clusterid, $include_children = false)
{
    global $CFG, $CURMAN;
    if (empty($CFG->enablegroupings) || empty($CURMAN->config->cluster_groupings) || !cluster_groups_grouping_allowed($clusterid)) {
        return true;
    }
    $cluster = new cluster($clusterid);
    //get the group id for this cluster
    if ($groupid = groups_get_group_by_name(SITEID, $cluster->name)) {
        //go through the chain of parent clusters
        while (!empty($cluster->parent)) {
            $cluster = new cluster($cluster->parent);
            //add this to grouping if applicable
            $grouping = groups_get_grouping_by_name(SITEID, $cluster->name);
            if ($grouping = groups_get_grouping($grouping)) {
                groups_assign_grouping($grouping->id, $groupid);
                //recurse into children if possible
                if ($include_children) {
                    //get all child clusters
                    $child_cluster_ids = cluster_groups_get_child_clusters($cluster->id);
                    foreach ($child_cluster_ids as $child_cluster_id) {
                        //children only
                        if ($child_cluster_id != $cluster->id) {
                            $child_cluster = new cluster($child_cluster_id);
                            //make sure the group exists
                            if ($child_groupid = groups_get_group_by_name(SITEID, $child_cluster->name) and cluster_groups_cluster_allows_groups($child_cluster->id)) {
                                groups_assign_grouping($grouping->id, $child_groupid);
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
    $groupingid = required_param('groupingid', PARAM_INT);
    $grouping = groups_get_grouping($groupingid);
    $a = new stdClass();
    $a->grouping_name = $grouping->name;
    $a->item = blended_get_item_html_title($item);
    $strcreatenewgroupingnotify = get_string('selectgroupingnotify', 'blended', $a);
    echo $OUTPUT->box($strcreatenewgroupingnotify);
} else {
    //Si el tipo de accion recogida es 'nuevo' procedente de introteams.php, se crear� un nuevo agrupamiento
    if ($action == 'create') {
        $creationmethod = required_param('creationmethod', PARAM_ALPHA);
        $numteams = required_param('numteams', PARAM_INT);
        //Creaci�n del agrupamiento
        $grouping_name = required_param('grouping_name', PARAM_ALPHANUMEXT);
        $groupingid = blended_create_unique_grouping($grouping_name, $course);
        $grouping = groups_get_grouping($groupingid);
        if (!$groupingid) {
            print_error("Can't create a new grouping.");
        }
        // Create empty teams
        for ($i = 0; $i < $numteams; $i++) {
            $team = new stdClass();
            $team->name = "{$grouping->name}-{$i}";
            $team->members = array();
            $teams[$i] = $team;
        }
        //populate teams with userids:
        if ($creationmethod == 'random') {
            list($students, $non_students, $active, $userrecs) = blended_get_users_by_type($context_course);
            //Si no hay ningun alumno ya sea activo o en el curso matriculado
            if (count($active) == 0) {