本文整理汇总了PHP中can_update_moduleinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP can_update_moduleinfo函数的具体用法?PHP can_update_moduleinfo怎么用?PHP can_update_moduleinfo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_update_moduleinfo函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moodle_url
}
$navbaraddition = $pageheading;
} else {
if (!empty($update)) {
$url->param('update', $update);
$PAGE->set_url($url);
// Select the "Edit settings" from navigation.
navigation_node::override_active_url(new moodle_url('/course/modedit.php', array('update' => $update, 'return' => 1)));
// Check the course module exists.
$cm = get_coursemodule_from_id('', $update, 0, false, MUST_EXIST);
// Check the course exists.
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
// require_login
require_login($course, false, $cm);
// needed to setup proper $COURSE
list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
$data->coursemodule = $cm->id;
$data->section = $cw->section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cm->visible;
//?? $cw->visible ? $cm->visible : 0; // section hiding overrides
$data->cmidnumber = $cm->idnumber;
// The cm IDnumber
$data->groupmode = groups_get_activity_groupmode($cm);
// locked later if forced
$data->groupingid = $cm->groupingid;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->instance = $cm->instance;
$data->return = $return;
示例2: update_module
/**
* Update a module.
*
* It includes:
* - capability and other checks
* - update the module
*
* @param object $module
* @return object the updated module info
* @throws moodle_exception if current user is not allowed to update the module
*/
function update_module($moduleinfo)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/modlib.php';
// Check the course module exists.
$cm = get_coursemodule_from_id('', $moduleinfo->coursemodule, 0, false, MUST_EXIST);
// Check the course exists.
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
// Some checks (capaibility / existing instances).
list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
// Retrieve few information needed by update_moduleinfo.
$moduleinfo->modulename = $cm->modname;
if (!isset($moduleinfo->scale)) {
$moduleinfo->scale = 0;
}
$moduleinfo->type = 'mod';
// Update the module.
list($cm, $moduleinfo) = update_moduleinfo($cm, $moduleinfo, $course, null);
return $moduleinfo;
}
示例3: get_moduleinfo_data
/**
* Get module information data required for updating the module.
*
* @param stdClass $cm course module object
* @param stdClass $course course object
* @return array required data for updating a module
* @since Moodle 3.2
*/
function get_moduleinfo_data($cm, $course)
{
global $CFG;
list($cm, $context, $module, $data, $cw) = can_update_moduleinfo($cm);
$data->coursemodule = $cm->id;
$data->section = $cw->section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cm->visible;
//?? $cw->visible ? $cm->visible : 0; // section hiding overrides
$data->cmidnumber = $cm->idnumber;
// The cm IDnumber
$data->groupmode = groups_get_activity_groupmode($cm);
// locked later if forced
$data->groupingid = $cm->groupingid;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->instance = $cm->instance;
$data->completion = $cm->completion;
$data->completionview = $cm->completionview;
$data->completionexpected = $cm->completionexpected;
$data->completionusegrade = is_null($cm->completiongradeitemnumber) ? 0 : 1;
$data->showdescription = $cm->showdescription;
$data->tags = core_tag_tag::get_item_tags_array('core', 'course_modules', $cm->id);
if (!empty($CFG->enableavailability)) {
$data->availabilityconditionsjson = $cm->availability;
}
if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
$currentintro = file_prepare_draft_area($draftid_editor, $context->id, 'mod_' . $data->modulename, 'intro', 0, array('subdirs' => true), $data->intro);
$data->introeditor = array('text' => $currentintro, 'format' => $data->introformat, 'itemid' => $draftid_editor);
}
if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false) and has_capability('moodle/grade:managegradingforms', $context)) {
require_once $CFG->dirroot . '/grade/grading/lib.php';
$gradingman = get_grading_manager($context, 'mod_' . $data->modulename);
$data->_advancedgradingdata['methods'] = $gradingman->get_available_methods();
$areas = $gradingman->get_available_areas();
foreach ($areas as $areaname => $areatitle) {
$gradingman->set_area($areaname);
$method = $gradingman->get_active_method();
$data->_advancedgradingdata['areas'][$areaname] = array('title' => $areatitle, 'method' => $method);
$formfield = 'advancedgradingmethod_' . $areaname;
$data->{$formfield} = $method;
}
}
if ($items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $data->modulename, 'iteminstance' => $data->instance, 'courseid' => $course->id))) {
// Add existing outcomes.
foreach ($items as $item) {
if (!empty($item->outcomeid)) {
$data->{'outcome_' . $item->outcomeid} = 1;
} else {
if (isset($item->gradepass)) {
$decimalpoints = $item->get_decimals();
$data->gradepass = format_float($item->gradepass, $decimalpoints);
}
}
}
// set category if present
$gradecat = false;
foreach ($items as $item) {
if ($gradecat === false) {
$gradecat = $item->categoryid;
continue;
}
if ($gradecat != $item->categoryid) {
//mixed categories
$gradecat = false;
break;
}
}
if ($gradecat !== false) {
// do not set if mixed categories present
$data->gradecat = $gradecat;
}
}
return array($cm, $context, $module, $data, $cw);
}