本文整理汇总了PHP中set_coursemodule_groupmode函数的典型用法代码示例。如果您正苦于以下问题:PHP set_coursemodule_groupmode函数的具体用法?PHP set_coursemodule_groupmode怎么用?PHP set_coursemodule_groupmode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_coursemodule_groupmode函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: require_capability
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
break;
case 'duplicate':
require_capability('moodle/course:manageactivities', $modcontext);
require_capability('moodle/backup:backuptargetimport', $modcontext);
require_capability('moodle/restore:restoretargetimport', $modcontext);
if (!course_allowed_module($course, $cm->modname)) {
throw new moodle_exception('No permission to create that activity');
}
$sr = optional_param('sr', null, PARAM_INT);
$result = mod_duplicate_activity($course, $cm, $sr);
echo json_encode($result);
break;
case 'groupmode':
require_capability('moodle/course:manageactivities', $modcontext);
set_coursemodule_groupmode($cm->id, $value);
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
break;
case 'indent':
require_capability('moodle/course:manageactivities', $modcontext);
$cm->indent = $value;
if ($cm->indent >= 0) {
$DB->update_record('course_modules', $cm);
rebuild_course_cache($cm->course);
}
break;
case 'move':
require_capability('moodle/course:manageactivities', $modcontext);
if (!($section = $DB->get_record('course_sections', array('course' => $course->id, 'section' => $sectionid)))) {
throw new moodle_exception('AJAX commands.php: Bad section ID ' . $sectionid);
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:31,代码来源:rest.php
示例2: redirect
}
if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id={$cm->course}#{$sectionreturn}");
}
exit;
} else {
if (isset($_GET['groupmode']) and confirm_sesskey()) {
if (!($cm = get_record("course_modules", "id", $_GET['id']))) {
error("This course module doesn't exist");
}
if (!isteacheredit($cm->course)) {
error("You can't modify this course!");
}
set_coursemodule_groupmode($cm->id, $_GET['groupmode']);
rebuild_course_cache($cm->course);
if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id={$cm->course}#{$sectionreturn}");
}
exit;
} else {
if (isset($_GET['copy']) and confirm_sesskey()) {
// value = course module
if (!($cm = get_record("course_modules", "id", $_GET['copy']))) {
error("This course module doesn't exist");
}
if (!isteacheredit($cm->course)) {
error("You can't modify this course!");
开发者ID:ronniebrito,项目名称:moodle_hiperbook,代码行数:31,代码来源:exercise.php
示例3: redirect
redirect($CFG->wwwroot);
} else {
redirect("view.php?id={$cm->course}#section-{$sectionreturn}");
}
exit;
} else {
if ($groupmode > -1 and confirm_sesskey()) {
$id = required_param('id', PARAM_INT);
if (!($cm = get_record("course_modules", "id", $id))) {
error("This course module doesn't exist");
}
require_login($cm->course);
// needed to setup proper $COURSE
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
require_capability('moodle/course:manageactivities', $context);
set_coursemodule_groupmode($cm->id, $groupmode);
rebuild_course_cache($cm->course);
if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id={$cm->course}#section-{$sectionreturn}");
}
exit;
} else {
if (!empty($copy) and confirm_sesskey()) {
// value = course module
if (!($cm = get_record("course_modules", "id", $copy))) {
error("This course module doesn't exist");
}
require_login($cm->course);
// needed to setup proper $COURSE
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:mod.php
示例4: error
$fromform->name = $fromform->modulename;
}
if (!empty($fromform->update)) {
if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
$fromform->groupmode = $cm->groupmode;
// keep original
}
$returnfromfunc = $updateinstancefunction($fromform);
if (!$returnfromfunc) {
error("Could not update the {$fromform->modulename}", "view.php?id={$course->id}");
}
if (is_string($returnfromfunc)) {
error($returnfromfunc, "view.php?id={$course->id}");
}
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
set_coursemodule_groupmode($fromform->coursemodule, $fromform->groupmode);
set_coursemodule_groupingid($fromform->coursemodule, $fromform->groupingid);
set_coursemodule_groupmembersonly($fromform->coursemodule, $fromform->groupmembersonly);
if (isset($fromform->cmidnumber)) {
//label
// set cm idnumber
set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
}
add_to_log($course->id, "course", "update mod", "../mod/{$fromform->modulename}/view.php?id={$fromform->coursemodule}", "{$fromform->modulename} {$fromform->instance}");
add_to_log($course->id, $fromform->modulename, "update", "view.php?id={$fromform->coursemodule}", "{$fromform->instance}", $fromform->coursemodule);
} else {
if (!empty($fromform->add)) {
if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
$fromform->groupmode = 0;
// do not set groupmode
}
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:modedit.php
示例5: test_get_graders
public function test_get_graders() {
$this->create_extra_users();
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
$this->assertCount(self::DEFAULT_TEACHER_COUNT +
self::DEFAULT_EDITING_TEACHER_COUNT +
self::EXTRA_TEACHER_COUNT +
self::EXTRA_EDITING_TEACHER_COUNT,
$assign->testable_get_graders($this->students[0]->id));
$assign = $this->create_instance();
// Force create an assignment with SEPARATEGROUPS.
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
$params = array('course'=>$this->course->id);
$instance = $generator->create_instance($params);
$cm = get_coursemodule_from_instance('assign', $instance->id);
set_coursemodule_groupmode($cm->id, SEPARATEGROUPS);
$cm->groupmode = SEPARATEGROUPS;
$context = context_module::instance($cm->id);
$assign = new testable_assign($context, $cm, $this->course);
$this->setUser($this->students[1]);
$this->assertCount(4, $assign->testable_get_graders($this->students[0]->id));
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:25,代码来源:locallib_test.php
示例6: test_get_item_ratings
//.........这里部分代码省略.........
$record->course = $course->id;
// Set Aggregate type = Average of ratings.
$record->assessed = RATING_AGGREGATE_AVERAGE;
$forum = self::getDataGenerator()->create_module('forum', $record);
$contextid = context_module::instance($forum->cmid)->id;
// Add discussion to the forums.
$record = new stdClass();
$record->course = $course->id;
$record->userid = $student->id;
$record->forum = $forum->id;
$discussion = self::getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
// Retrieve the first post.
$post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
// Rete the discussion as teacher1.
$rating1 = new stdClass();
$rating1->contextid = $contextid;
$rating1->component = 'mod_forum';
$rating1->ratingarea = 'post';
$rating1->itemid = $post->id;
$rating1->rating = 90;
$rating1->scaleid = 100;
$rating1->userid = $teacher1->id;
$rating1->timecreated = time();
$rating1->timemodified = time();
$rating1->id = $DB->insert_record('rating', $rating1);
// Rete the discussion as teacher2.
$rating2 = new stdClass();
$rating2->contextid = $contextid;
$rating2->component = 'mod_forum';
$rating2->ratingarea = 'post';
$rating2->itemid = $post->id;
$rating2->rating = 95;
$rating2->scaleid = 100;
$rating2->userid = $teacher2->id;
$rating2->timecreated = time() + 1;
$rating2->timemodified = time() + 1;
$rating2->id = $DB->insert_record('rating', $rating2);
// Delete teacher2, we must still receive the ratings.
delete_user($teacher2);
// Teachers can see all the ratings.
$this->setUser($teacher1);
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'post', $post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
$indexedratings = array();
foreach ($ratings['ratings'] as $rating) {
$indexedratings[$rating['id']] = $rating;
}
$this->assertEquals($rating1->rating . ' / ' . $rating1->scaleid, $indexedratings[$rating1->id]['rating']);
$this->assertEquals($rating2->rating . ' / ' . $rating2->scaleid, $indexedratings[$rating2->id]['rating']);
$this->assertEquals($rating1->userid, $indexedratings[$rating1->id]['userid']);
$this->assertEquals($rating2->userid, $indexedratings[$rating2->id]['userid']);
// Student can see ratings.
$this->setUser($student);
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'post', $post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
// Invalid item.
try {
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'post', 0, 100, '');
$this->fail('Exception expected due invalid itemid.');
} catch (moodle_exception $e) {
$this->assertEquals('invalidrecord', $e->errorcode);
}
// Invalid area.
try {
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'xyz', $post->id, 100, '');
$this->fail('Exception expected due invalid rating area.');
} catch (moodle_exception $e) {
$this->assertEquals('invalidratingarea', $e->errorcode);
}
// Invalid context. invalid_parameter_exception.
try {
$ratings = core_rating_external::get_item_ratings('module', 0, 'mod_forum', 'post', $post->id, 100, '');
$this->fail('Exception expected due invalid context.');
} catch (invalid_parameter_exception $e) {
$this->assertEquals('invalidparameter', $e->errorcode);
}
// Test for groupmode.
set_coursemodule_groupmode($forum->cmid, SEPARATEGROUPS);
$group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
groups_add_member($group, $teacher1);
$discussion->groupid = $group->id;
$DB->update_record('forum_discussions', $discussion);
// Error for teacher3 and 2 ratings for teacher1 should be returned.
$this->setUser($teacher1);
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'post', $post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
$this->setUser($teacher3);
try {
$ratings = core_rating_external::get_item_ratings('module', $forum->cmid, 'mod_forum', 'post', $post->id, 100, '');
$this->fail('Exception expected due invalid group permissions.');
} catch (moodle_exception $e) {
$this->assertEquals('noviewrate', $e->errorcode);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:externallib_test.php
示例7: test_get_graders
public function test_get_graders() {
$this->create_extra_users();
$this->setUser($this->editingteachers[0]);
// Create an assignment with no groups.
$assign = $this->create_instance();
$this->assertCount(self::DEFAULT_TEACHER_COUNT +
self::DEFAULT_EDITING_TEACHER_COUNT +
self::EXTRA_TEACHER_COUNT +
self::EXTRA_EDITING_TEACHER_COUNT,
$assign->testable_get_graders($this->students[0]->id));
// Force create an assignment with SEPARATEGROUPS.
$data = new stdClass();
$data->courseid = $this->course->id;
$data->name = 'Grouping';
$groupingid = groups_create_grouping($data);
groups_assign_grouping($groupingid, $this->groups[0]->id);
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
$params = array('course'=>$this->course->id);
$instance = $generator->create_instance($params);
$cm = get_coursemodule_from_instance('assign', $instance->id);
set_coursemodule_groupmode($cm->id, SEPARATEGROUPS);
$cm->groupmode = SEPARATEGROUPS;
$cm->groupingid = $groupingid;
$context = context_module::instance($cm->id);
$assign = new testable_assign($context, $cm, $this->course);
$this->setUser($this->students[1]);
$this->assertCount(4, $assign->testable_get_graders($this->students[0]->id));
// Note the second student is in a group that is not in the grouping.
// This means that we get all graders that are not in a group in the grouping.
$this->assertCount(10, $assign->testable_get_graders($this->students[1]->id));
}
开发者ID:verbazend,项目名称:AWFA,代码行数:35,代码来源:locallib_test.php
示例8: test_get_item_ratings
/**
* Test get_item_ratings
*/
public function test_get_item_ratings()
{
global $DB;
// Rete the discussion as teacher1.
$rating1 = new stdClass();
$rating1->contextid = $this->contextid;
$rating1->component = 'mod_forum';
$rating1->ratingarea = 'post';
$rating1->itemid = $this->post->id;
$rating1->rating = 90;
$rating1->scaleid = 100;
$rating1->userid = $this->teacher1->id;
$rating1->timecreated = time();
$rating1->timemodified = time();
$rating1->id = $DB->insert_record('rating', $rating1);
// Rete the discussion as teacher2.
$rating2 = new stdClass();
$rating2->contextid = $this->contextid;
$rating2->component = 'mod_forum';
$rating2->ratingarea = 'post';
$rating2->itemid = $this->post->id;
$rating2->rating = 95;
$rating2->scaleid = 100;
$rating2->userid = $this->teacher2->id;
$rating2->timecreated = time() + 1;
$rating2->timemodified = time() + 1;
$rating2->id = $DB->insert_record('rating', $rating2);
// Delete teacher2, we must still receive the ratings.
delete_user($this->teacher2);
// Teachers can see all the ratings.
$this->setUser($this->teacher1);
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'post', $this->post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
$indexedratings = array();
foreach ($ratings['ratings'] as $rating) {
$indexedratings[$rating['id']] = $rating;
}
$this->assertEquals($rating1->rating . ' / ' . $rating1->scaleid, $indexedratings[$rating1->id]['rating']);
$this->assertEquals($rating2->rating . ' / ' . $rating2->scaleid, $indexedratings[$rating2->id]['rating']);
$this->assertEquals($rating1->userid, $indexedratings[$rating1->id]['userid']);
$this->assertEquals($rating2->userid, $indexedratings[$rating2->id]['userid']);
// Student can see ratings.
$this->setUser($this->student1);
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'post', $this->post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
// Invalid item.
try {
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'post', 0, 100, '');
$this->fail('Exception expected due invalid itemid.');
} catch (moodle_exception $e) {
$this->assertEquals('invalidrecord', $e->errorcode);
}
// Invalid area.
try {
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'xyz', $this->post->id, 100, '');
$this->fail('Exception expected due invalid rating area.');
} catch (moodle_exception $e) {
$this->assertEquals('invalidratingarea', $e->errorcode);
}
// Invalid context. invalid_parameter_exception.
try {
$ratings = core_rating_external::get_item_ratings('module', 0, 'mod_forum', 'post', $this->post->id, 100, '');
$this->fail('Exception expected due invalid context.');
} catch (invalid_parameter_exception $e) {
$this->assertEquals('invalidparameter', $e->errorcode);
}
// Test for groupmode.
set_coursemodule_groupmode($this->forum->cmid, SEPARATEGROUPS);
$group = $this->getDataGenerator()->create_group(array('courseid' => $this->course->id));
groups_add_member($group, $this->teacher1);
$this->discussion->groupid = $group->id;
$DB->update_record('forum_discussions', $this->discussion);
// Error for teacher3 and 2 ratings for teacher1 should be returned.
$this->setUser($this->teacher1);
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'post', $this->post->id, 100, '');
// We need to execute the return values cleaning process to simulate the web service server.
$ratings = external_api::clean_returnvalue(core_rating_external::get_item_ratings_returns(), $ratings);
$this->assertCount(2, $ratings['ratings']);
$this->setUser($this->teacher3);
try {
$ratings = core_rating_external::get_item_ratings('module', $this->forum->cmid, 'mod_forum', 'post', $this->post->id, 100, '');
$this->fail('Exception expected due invalid group permissions.');
} catch (moodle_exception $e) {
$this->assertEquals('noviewrate', $e->errorcode);
}
}
开发者ID:janeklb,项目名称:moodle,代码行数:93,代码来源:externallib_test.php
注:本文中的set_coursemodule_groupmode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论