当前位置: 首页>>代码示例>>PHP>>正文


PHP groups_get_grouping函数代码示例

本文整理汇总了PHP中groups_get_grouping函数的典型用法代码示例。如果您正苦于以下问题:PHP groups_get_grouping函数的具体用法?PHP groups_get_grouping怎么用?PHP groups_get_grouping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了groups_get_grouping函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: groups_print_activity_menu

/**
 * 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;
    }
}
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:79,代码来源:grouplib.php

示例2: trim

 $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
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:autogroup.php

示例3: unassign_grouping

 /**
  * 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();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:externallib.php

示例4: array

            $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>';
    }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:31,代码来源:view.php

示例5: get_string

            $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) {
开发者ID:netspotau,项目名称:moodle-mod_groupselect,代码行数:31,代码来源:view.php

示例6: get_printable_name

 /**
  * 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;
 }
开发者ID:shivam12345,项目名称:moodle-mod_vpl,代码行数:17,代码来源:vpl.class.php

示例7: userset_groups_update_grouping_closure

/**
 * 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;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:44,代码来源:lib.php

示例8: view_administration


//.........这里部分代码省略.........
                     $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);
                                         }
                                     }
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:67,代码来源:locallib.php

示例9: cluster_groups_update_grouping_closure

/**
 * 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;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:43,代码来源:lib.php

示例10: required_param

    $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) {
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:31,代码来源:createTeams.php


注:本文中的groups_get_grouping函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。