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


PHP groups_create_grouping函数代码示例

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


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

示例1: test_groups_grouping_matches

 function test_groups_grouping_matches()
 {
     $groupinginfo->name = 'Grouping Testname:' . $this->getLabel();
     $groupinginfo->description = 'Grouing Test Description:' . $this->getLabel();
     $this->assertTrue($this->groupingid = groups_create_grouping($this->courseid, $groupinginfo));
     $this->assertTrue(groups_grouping_matches($this->courseid, $groupinginfo->name, $groupinginfo->description));
 }
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:test_groupinglib.php

示例2: groups_create_automatic_grouping

/**
 * Distributes students into groups randomly and creates a grouping with those 
 * groups.
 * 
 * You need to call groups_seed_random_number_generator() at some point in your 
 * script before calling this function. 
 * 
 * Note that this function does not distribute teachers into groups - this still 
 * needs to be done manually. 
 * 
 * @param int $courseid The id of the course that the grouping should belong to
 * @param int $nostudentspergroup The number of students to put in each group - 
 * this can be set to false if you prefer to specify the number of groups 
 * instead
 * @param int $nogroups The number of groups - this can be set to false if you 
 * prefer to specify the number of student in each group. If both are specified 
 * then $nostudentspergroup takes precedence. If neither is
 * specified then the function does nothing and returns false. 
 * @param boolean $distribevenly If $noofstudentspergroup is specified, then 
 * if this is set to true, any leftover students are distributed evenly among 
 * the groups, whereas if it is set to false then they are put in a separate 
 * group. 
 * @param object $groupsettings The default settings to give each group. 
 * This should contain prefix and defaultgroupdescription fields. The groups 
 * are named with the prefix followed by 1, 2, etc. and given the
 * default group description set. 
 * @param int $groupid If this is not set to false, then only students in the 
 * specified group are distributed into groups, not all the students enrolled on 
 * the course. 
 * @param boolean $alphabetical If this is set to true, then the students are 
 * not distributed randomly but in alphabetical order of last name. 
 * @return int The id of the grouping
 */
function groups_create_automatic_grouping($courseid, $nostudentspergroup, $nogroups, $distribevenly, $groupingsettings, $groupid = false, $alphabetical = false)
{
    if (!$nostudentspergroup and !$noteacherspergroup and !$nogroups) {
        $groupingid = false;
    } else {
        // Set $userids to the list of students that we want to put into groups
        // in the grouping
        if (!$groupid) {
            $users = get_course_students($courseid);
            $userids = groups_users_to_userids($users);
        } else {
            $userids = groups_get_members($groupid);
        }
        // Distribute the users into sets according to the parameters specified
        $userarrays = groups_distribute_in_random_sets($userids, $nostudentspergroup, $nogroups, $distribevenly, !$alphabetical);
        if (!$userarrays) {
            $groupingid = false;
        } else {
            // Create the grouping that the groups we create will go into
            $groupingid = groups_create_grouping($courseid, $groupingsettings);
            // Get the prefix for the names of each group and default group
            // description to give each group
            if (!$groupingsettings->prefix) {
                $prefix = get_string('defaultgroupprefix', 'groups');
            } else {
                $prefix = $groupingsettings->prefix;
            }
            if (!$groupingsettings->defaultgroupdescription) {
                $defaultgroupdescription = '';
            } else {
                $defaultgroupdescription = $groupingsettings->defaultgroupdescription;
            }
            // Now create a group for each set of students, add the group to the
            // grouping and then add the students
            $i = 1;
            foreach ($userarrays as $userids) {
                $groupsettings->name = $prefix . ' ' . $i;
                $groupsettings->description = $defaultgroupdescription;
                $i++;
                $groupid = groups_create_group($courseid, $groupsettings);
                $groupadded = groups_add_group_to_grouping($groupid, $groupingid);
                if (!$groupid or !$groupadded) {
                    $groupingid = false;
                } else {
                    if ($userids) {
                        foreach ($userids as $userid) {
                            $usersadded = groups_add_member($groupid, $userid);
                            // If unsuccessful just carry on I guess
                        }
                    }
                }
            }
        }
    }
    return $groupingid;
}
开发者ID:veritech,项目名称:pare-project,代码行数:89,代码来源:automaticgroupinglib.php

示例3: test_version1importdeletecoursedeletesassociations


//.........这里部分代码省略.........
     $forum->instance = $forum->id;
     $cmid = add_course_module($forum);
     // Set up a completion record.
     $completion = new stdClass();
     $completion->coursemoduleid = $cmid;
     $completion->completionstate = 0;
     $completion->userid = 9999;
     $completion->timemodified = time();
     $DB->insert_record('course_modules_completion', $completion);
     // Set up a completion condition.
     $forum->id = $cmid;
     $ci = new condition_info($forum, CONDITION_MISSING_EVERYTHING, false);
     $ci->add_completion_condition($cmid, COMPLETION_ENABLED);
     // Set the blocks position.
     $instances = $DB->get_records('block_instances', array('parentcontextid' => $coursecontext->id));
     $page = new stdClass();
     $page->context = $coursecontext;
     $page->pagetype = 'course-view-*';
     $page->subpage = false;
     foreach ($instances as $instance) {
         blocks_set_visibility($instance, $page, 1);
     }
     // Create a group.
     $group = new stdClass();
     $group->name = 'testgroup';
     $group->courseid = $courseid;
     $groupid = groups_create_group($group);
     // Add the user to the group.
     groups_add_member($groupid, $userid);
     // Create a grouping containing our group.
     $grouping = new stdClass();
     $grouping->name = 'testgrouping';
     $grouping->courseid = $courseid;
     $groupingid = groups_create_grouping($grouping);
     groups_assign_grouping($groupingid, $groupid);
     // Set up a user tag.
     tag_set('course', $courseid, array('testtag'));
     // Add a course-level log.
     add_to_log($courseid, 'bogus', 'bogus');
     // Set up the default course question category.
     $newcategory = question_make_default_categories(array($coursecontext));
     // Create a test question.
     $question = new stdClass();
     $question->qtype = 'truefalse';
     $form = new stdClass();
     $form->category = $newcategory->id;
     $form->name = 'testquestion';
     $form->correctanswer = 1;
     $form->feedbacktrue = array('text' => 'bogustext', 'format' => FORMAT_HTML);
     $form->feedbackfalse = array('text' => 'bogustext', 'format' => FORMAT_HTML);
     $question = question_bank::get_qtype('truefalse')->save_question($question, $form);
     if (function_exists('course_set_display')) {
         // Set a "course display" setting.
         course_set_display($courseid, 1);
     }
     // Make a bogus backup record.
     $backupcourse = new stdClass();
     $backupcourse->courseid = $courseid;
     $DB->insert_record('backup_courses', $backupcourse);
     // Add a user lastaccess record.
     $lastaccess = new stdClass();
     $lastaccess->userid = $userid;
     $lastaccess->courseid = $courseid;
     $DB->insert_record('user_lastaccess', $lastaccess);
     // Make a bogus backup log record.
     $log = new stdClass();
开发者ID:jamesmcq,项目名称:elis,代码行数:67,代码来源:version1_course_import_test.php

示例4: stdClass

 } else {
     if ($groupid = groups_create_group($newgroup)) {
         echo $OUTPUT->notification(get_string('groupaddedsuccesfully', 'group', $groupname), 'notifysuccess');
     } else {
         echo $OUTPUT->notification(get_string('groupnotaddederror', 'error', $groupname));
         continue;
     }
 }
 // Add group to grouping
 if (!empty($newgroup->groupingname) || is_numeric($newgroup->groupingname)) {
     $groupingname = $newgroup->groupingname;
     if (!($groupingid = groups_get_grouping_by_name($newgroup->courseid, $groupingname))) {
         $data = new stdClass();
         $data->courseid = $newgroup->courseid;
         $data->name = $groupingname;
         if ($groupingid = groups_create_grouping($data)) {
             echo $OUTPUT->notification(get_string('groupingaddedsuccesfully', 'group', $groupingname), 'notifysuccess');
         } else {
             echo $OUTPUT->notification(get_string('groupingnotaddederror', 'error', $groupingname));
             continue;
         }
     }
     // if we have reached here we definitely have a groupingid
     $a = array('groupname' => $groupname, 'groupingname' => $groupingname);
     try {
         groups_assign_grouping($groupingid, $groupid);
         echo $OUTPUT->notification(get_string('groupaddedtogroupingsuccesfully', 'group', $a), 'notifysuccess');
     } catch (Exception $e) {
         echo $OUTPUT->notification(get_string('groupnotaddedtogroupingerror', 'error', $a));
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:import.php

示例5: print_table

         $table->data[] = $line;
     }
     $preview .= print_table($table, true);
 } else {
     $grouping = null;
     $createdgrouping = null;
     $createdgroups = array();
     $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;
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:autogroup.php

示例6: array

         }
         $table->data[] = $line;
     }
     $preview .= html_writer::table($table);
 } else {
     $grouping = null;
     $createdgrouping = null;
     $createdgroups = array();
     $failed = false;
     // prepare grouping
     if (!empty($data->grouping)) {
         if ($data->grouping < 0) {
             $grouping = new stdClass();
             $grouping->courseid = $COURSE->id;
             $grouping->name = trim($data->groupingname);
             $grouping->id = groups_create_grouping($grouping);
             $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 stdClass();
         $newgroup->courseid = $data->courseid;
         $newgroup->name = $group['name'];
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:autogroup.php

示例7: mass_enroll_add_grouping

/**
 * Enter description here ...
 * @param string $newgroupingname
 * @param int $courseid
 * @return int id Moodle id of inserted record
 */
function mass_enroll_add_grouping($newgroupingname, $courseid) {
    $newgrouping = new StdClass();
    $newgrouping->name = $newgroupingname;
    $newgrouping->courseid = $courseid;
    return groups_create_grouping($newgrouping);
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:12,代码来源:lib.php

示例8: redirect

}
// preprocess data
if ($delete) {
    if (groups_delete_grouping($id)) {
        redirect(groups_home_url($course->id));
    } else {
        print_error('erroreditgrouping', 'group', groups_home_url($course->id));
    }
}
if ($editform->is_cancelled()) {
    redirect(groups_home_url($courseid, false, $id, false));
} elseif ($data = $editform->get_data()) {
    $success = true;
    if (empty($grouping)) {
        // New grouping
        if (!($id = groups_create_grouping($course->id, $data))) {
            print_error('erroreditgrouping');
        } else {
            $success = (bool) $id;
            $data->id = $id;
        }
    } else {
        // Updating grouping
        if (!groups_update_grouping($data, $course->id)) {
            print_error('groupingnotupdated');
        }
    }
    if ($success) {
        redirect(groups_home_url($courseid, false, $id, false));
    } else {
        print_error('erroreditgrouping', 'group', groups_home_url($courseid));
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:grouping.php

示例9: grouping_form

}
/// First create the form
$editform = new grouping_form(null, compact('editoroptions'));
$editform->set_data($grouping);
if ($editform->is_cancelled()) {
    redirect($returnurl);
} elseif ($data = $editform->get_data()) {
    $success = true;
    if (!has_capability('moodle/course:changeidnumber', $context)) {
        // Remove the idnumber if the user doesn't have permission to modify it
        unset($data->idnumber);
    }
    if ($data->id) {
        groups_update_grouping($data, $editoroptions);
    } else {
        groups_create_grouping($data, $editoroptions);
    }
    redirect($returnurl);
}
$strgroupings = get_string('groupings', 'group');
$strparticipants = get_string('participants');
if ($id) {
    $strheading = get_string('editgroupingsettings', 'group');
} else {
    $strheading = get_string('creategrouping', 'group');
}
$PAGE->navbar->add($strparticipants, new moodle_url('/user/index.php', array('id' => $courseid)));
$PAGE->navbar->add($strgroupings, new moodle_url('/group/groupings.php', array('id' => $courseid)));
$PAGE->navbar->add($strheading);
/// Print header
$PAGE->set_title($strgroupings);
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:grouping.php

示例10: create_test_grouping

 /**
  * Creates a grouping for testing purposes
  *
  * @param int $courseid The id of the course where the grouping should live
  * @param string $name The name of the grouping to create
  * @return int The id of the grouping created
  */
 private function create_test_grouping($courseid, $name = 'rlipgrouping')
 {
     global $CFG;
     require_once $CFG->dirroot . '/group/lib.php';
     $data = new stdClass();
     $data->courseid = $courseid;
     $data->name = $name;
     return groups_create_grouping($data);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:16,代码来源:version1_enrolment_import_test.php

示例11: test_version1importlogsduplicategroupingassignment

 /**
  * Validate log message for assigning a group to a grouping is already
  * belongs to
  */
 public function test_version1importlogsduplicategroupingassignment()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/group/lib.php';
     $userid = $this->create_test_user();
     $courseid = $this->create_test_course();
     $context = context_course::instance($courseid);
     $roleid = $this->create_test_role();
     $group = new stdClass();
     $group->courseid = $courseid;
     $group->name = 'rlipname';
     $group->id = groups_create_group($group);
     $grouping = new stdClass();
     $grouping->courseid = $courseid;
     $grouping->name = 'rlipname';
     $grouping->id = groups_create_grouping($grouping);
     groups_assign_grouping($grouping->id, $group->id);
     // Make sure they already have a role assignment.
     role_assign($roleid, $userid, $context->id);
     // Base data used every time.
     $basedata = array('action' => 'create', 'context' => 'course', 'instance' => 'rlipshortname', 'role' => 'rlipshortname', 'group' => 'rlipname', 'grouping' => 'rlipname');
     // Username.
     $data = $basedata;
     $data['username'] = 'rlipusername';
     $expectedmessage = "[enrolment.csv line 2] User with username \"rlipusername\" enrolled in course with shortname ";
     $expectedmessage .= "\"rlipshortname\". Assigned user with username \"rlipusername\" to group with name \"rlipname\". ";
     $expectedmessage .= "Group with name \"rlipname\" is already assigned to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Email.
     $data = $basedata;
     $data['email'] = 'rlipuser@rlipdomain.com';
     $expectedmessage = "[enrolment.csv line 2] User with email \"rlipuser@rlipdomain.com\" enrolled in course with shortname ";
     $expectedmessage .= "\"rlipshortname\". Assigned user with email \"rlipuser@rlipdomain.com\" to group with name ";
     $expectedmessage .= "\"rlipname\". Group with name \"rlipname\" is already assigned to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Idnumber.
     $data = $basedata;
     $data['idnumber'] = 'rlipidnumber';
     $expectedmessage = "[enrolment.csv line 2] User with idnumber \"rlipidnumber\" enrolled in course with shortname ";
     $expectedmessage .= "\"rlipshortname\". Assigned user with idnumber \"rlipidnumber\" to group with name \"rlipname\". ";
     $expectedmessage .= "Group with name \"rlipname\" is already assigned to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Username, email.
     $data = $basedata;
     $data['username'] = 'rlipusername';
     $data['email'] = 'rlipuser@rlipdomain.com';
     $expectedmessage = "[enrolment.csv line 2] User with username \"rlipusername\", email \"rlipuser@rlipdomain.com\" ";
     $expectedmessage .= "enrolled in course with shortname \"rlipshortname\". Assigned user with username \"rlipusername\", ";
     $expectedmessage .= "email \"rlipuser@rlipdomain.com\" to group with name \"rlipname\". Group with name \"rlipname\" is ";
     $expectedmessage .= "already assigned to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Username, idnumber.
     $data = $basedata;
     $data['username'] = 'rlipusername';
     $data['idnumber'] = 'rlipidnumber';
     $expectedmessage = "[enrolment.csv line 2] User with username \"rlipusername\", idnumber \"rlipidnumber\" enrolled in ";
     $expectedmessage .= "course with shortname \"rlipshortname\". Assigned user with username \"rlipusername\", idnumber ";
     $expectedmessage .= "\"rlipidnumber\" to group with name \"rlipname\". Group with name \"rlipname\" is already assigned ";
     $expectedmessage .= "to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Email, idnumber.
     $data = $basedata;
     $data['email'] = 'rlipuser@rlipdomain.com';
     $data['idnumber'] = 'rlipidnumber';
     $expectedmessage = "[enrolment.csv line 2] User with email \"rlipuser@rlipdomain.com\", idnumber \"rlipidnumber\" ";
     $expectedmessage .= "enrolled in course with shortname \"rlipshortname\". Assigned user with email ";
     $expectedmessage .= "\"rlipuser@rlipdomain.com\", idnumber \"rlipidnumber\" to group with name \"rlipname\". Group with ";
     $expectedmessage .= "name \"rlipname\" is already assigned to grouping with name \"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
     // Username, email, idnumber.
     $data = $basedata;
     $data['username'] = 'rlipusername';
     $data['email'] = 'rlipuser@rlipdomain.com';
     $data['idnumber'] = 'rlipidnumber';
     $expectedmessage = "[enrolment.csv line 2] User with username \"rlipusername\", email \"rlipuser@rlipdomain.com\", ";
     $expectedmessage .= "idnumber \"rlipidnumber\" enrolled in course with shortname \"rlipshortname\". Assigned user with ";
     $expectedmessage .= "username \"rlipusername\", email \"rlipuser@rlipdomain.com\", idnumber \"rlipidnumber\" to group ";
     $expectedmessage .= "with name \"rlipname\". Group with name \"rlipname\" is already assigned to grouping with name ";
     $expectedmessage .= "\"rlipname\".\n";
     $this->assert_data_produces_error($data, $expectedmessage, 'enrolment');
     $DB->delete_records('user_enrolments');
     $DB->delete_records('groups_members');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:99,代码来源:version1_filesystem_logging_test.php

示例12: process_action_allocation_to_grouping

 private function process_action_allocation_to_grouping()
 {
     $now = time();
     if ($this->ratingallocate->accesstimestop < $now) {
         global $OUTPUT;
         $allgroupings = groups_get_all_groupings($this->course->id);
         $groupingidname = ratingallocate_MOD_NAME . '_instid_' . $this->ratingallocateid;
         // search if there is already a grouping from us
         $grouping = groups_get_grouping_by_idnumber($this->course->id, $groupingidname);
         $groupingid = null;
         if (!$grouping) {
             // create grouping
             $data = new stdClass();
             $data->name = get_string('groupingname', ratingallocate_MOD_NAME, $this->ratingallocate->name);
             $data->idnumber = $groupingidname;
             $data->courseid = $this->course->id;
             $groupingid = groups_create_grouping($data);
         } else {
             $groupingid = $grouping->id;
         }
         $group_identifier_from_choice_id = function ($choiceid) {
             return ratingallocate_MOD_NAME . '_c_' . $choiceid;
         };
         $choices = $this->get_choices_with_allocationcount();
         // make a new array containing only the identifiers of the choices
         $choice_identifiers = array();
         foreach ($choices as $id => $choice) {
             $choice_identifiers[$group_identifier_from_choice_id($choice->id)] = array('key' => $id);
         }
         // find all associated groups in this grouping
         $groups = groups_get_all_groups($this->course->id, 0, $groupingid);
         // loop through the groups in the grouping: if the choice does not exist anymore -> delete
         // otherwise mark it
         foreach ($groups as $group) {
             if (array_key_exists($group->idnumber, $choice_identifiers)) {
                 // group exists, mark
                 $choice_identifiers[$group->idnumber]['exists'] = true;
                 $choice_identifiers[$group->idnumber]['groupid'] = $group->id;
             } else {
                 // delete group $group->id
                 groups_delete_group($group->id);
             }
         }
         // create groups groups for new identifiers or empty group if it exists
         foreach ($choice_identifiers as $group_idnumber => $choice) {
             if (key_exists('exists', $choice)) {
                 // remove all members
                 groups_delete_group_members_by_group($choice['groupid']);
             } else {
                 $data = new stdClass();
                 $data->courseid = $this->course->id;
                 $data->name = $choices[$choice['key']]->title;
                 $data->idnumber = $group_idnumber;
                 $createdid = groups_create_group($data);
                 groups_assign_grouping($groupingid, $createdid);
                 $choice_identifiers[$group_idnumber]['groupid'] = $createdid;
             }
         }
         // add all participants in the correct group
         $allocations = $this->get_allocations();
         foreach ($allocations as $id => $allocation) {
             $choice_id = $allocation->choiceid;
             $user_id = $allocation->userid;
             $choiceidnumber = $group_identifier_from_choice_id($choice_id);
             groups_add_member($choice_identifiers[$choiceidnumber]['groupid'], $user_id);
         }
         // Invalidate the grouping cache for the course
         cache_helper::invalidate_by_definition('core', 'groupdata', array(), array($this->course->id));
         $renderer = $this->get_renderer();
         $renderer->add_notification(get_string('moodlegroups_created', ratingallocate_MOD_NAME), self::NOTIFY_SUCCESS);
     }
     return $this->process_default();
 }
开发者ID:Kathrin84,项目名称:moodle-mod_ratingallocate,代码行数:73,代码来源:locallib.php

示例13: restore_create_groupings

function restore_create_groupings($restore, $xml_file)
{
    global $CFG, $db;
    $status = true;
    $status2 = true;
    //Check it exists
    if (!file_exists($xml_file)) {
        $status = false;
    }
    //Get info from xml
    if ($status) {
        //groupings will contain the old_id of every group
        //in backup_ids->info will be the real info (serialized)
        $groupings = restore_read_xml_groupings($restore, $xml_file);
    }
    //Now, if we have anything in groupings, we have to restore that grouping
    if ($groupings) {
        if ($groupings !== true) {
            //Iterate over each group
            foreach ($groupings as $grouping) {
                //Get record from backup_ids
                $data = backup_getid($restore->backup_unique_code, "groupings", $grouping->id);
                //Init variables
                $create_grouping = false;
                if ($data) {
                    //Now get completed xmlized object
                    $info = $data->info;
                    //Now build the GROUPING record structure
                    $gro = new Object();
                    ///$gro->id = backup_todb($info['GROUPING']['#']['ID']['0']['#']);
                    $gro->name = backup_todb($info['GROUPING']['#']['NAME']['0']['#']);
                    $gro->description = backup_todb($info['GROUPING']['#']['DESCRIPTION']['0']['#']);
                    $gro->timecreated = backup_todb($info['GROUPING']['#']['TIMECREATED']['0']['#']);
                    //Now search if that group exists (by name and description field) in
                    //restore->course_id course
                    $gro_db = groups_grouping_matches($restore->course_id, $gro->name, $gro->description);
                    //If it doesn't exist, create
                    if (!$gro_db) {
                        $create_grouping = true;
                    }
                    //If we must create the group
                    if ($create_grouping) {
                        //The structure is equal to the db, so insert the grouping TODO: RESTORE.
                        $newid = groups_create_grouping($restore->course_id, $gro);
                    } else {
                        //get current group id
                        $newid = $gro_db->id;
                    }
                    if ($newid) {
                        //We have the newid, update backup_ids
                        backup_putid($restore->backup_unique_code, "groupings", $grouping->id, $newid);
                    }
                    //Now restore links from groupings to groups
                    $status2 = restore_create_groupings_groups($newid, $info, $restore);
                }
            }
            //(Now, restore grouping_files)
        }
    } else {
        $status = false;
    }
    return $status && $status2;
}
开发者ID:veritech,项目名称:pare-project,代码行数:63,代码来源:restorelib.php

示例14: groups_create_group

         $newgroup->enrolmentkey = '';
         $newgroup->picture = 0;
         $newgroup->hidepicture = 0;
         $newgroup->id = groups_create_group($newgroup);
         if (!empty($data->groups) && !is_numeric($data->groups)) {
             $groupingid = substr($data->groups, 2);
             groups_assign_grouping($groupingid, $newgroup->id);
         }
     }
 } else {
     if (!empty($data->groupingsadd)) {
         /// Create a new grouping
         if (!empty($data->newgroupingsname)) {
             $newgrouping->name = $data->newgroupingsname;
             $newgrouping->courseid = $course->id;
             groups_create_grouping($newgrouping);
         }
     } else {
         if (!empty($data->groupsremovefrom)) {
             /// Remove group from groupings
             if (!empty($data->groups) && is_numeric($data->groups)) {
                 if ($groupings = get_records('groupings_groups', 'groupid', $data->groups)) {
                     foreach ($groupings as $grouping) {
                         groups_unassign_grouping($grouping->groupingid, $data->groups);
                     }
                 }
             }
         } else {
             if (!empty($data->groupingsmove)) {
                 /// Move group to groupings
                 if (!empty($data->groups) && is_numeric($data->groups)) {
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:sitegroups.php

示例15: blended_create_unique_grouping

function blended_create_unique_grouping($grouping_name, $course)
{
    $data = new stdClass();
    if ($grouping_name == '') {
        $grouping_name = get_string('newgrouping', 'group');
    }
    $data->name = $grouping_name;
    $data->courseid = $course->id;
    $data->description_editor['text'] = ' ';
    $data->description_editor['format'] = 1;
    // Check existence of grouping name
    $count = 1;
    do {
        $prev_grouping = groups_get_grouping_by_name($course->id, $data->name);
        if ($prev_grouping !== 0) {
            $data->name = $grouping_name . " ({$count})";
        } else {
            $data->name = $grouping_name;
        }
        $count++;
    } while ($prev_grouping);
    $groupingid = groups_create_grouping($data);
    return $groupingid;
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:24,代码来源:locallib.php


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