本文整理汇总了PHP中can_add_moduleinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP can_add_moduleinfo函数的具体用法?PHP can_add_moduleinfo怎么用?PHP can_add_moduleinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_add_moduleinfo函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: required_param
$url->param('return', $return);
}
if (!empty($add)) {
$section = required_param('section', PARAM_INT);
$course = required_param('course', PARAM_INT);
$url->param('add', $add);
$url->param('section', $section);
$url->param('course', $course);
$PAGE->set_url($url);
$course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
require_login($course);
// There is no page for this in the navigation. The closest we'll have is the course section.
// If the course section isn't displayed on the navigation this will fall back to the course which
// will be the closest match we have.
navigation_node::override_active_url(course_get_url($course, $section));
list($module, $context, $cw) = can_add_moduleinfo($course, $add, $section);
$cm = null;
$data = new stdClass();
$data->section = $section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cw->visible;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->groupmode = $course->groupmode;
$data->groupingid = $course->defaultgroupingid;
$data->id = '';
$data->instance = '';
$data->coursemodule = '';
$data->add = $add;
$data->return = 0;
示例2: create_module
/**
* Create a module.
*
* It includes:
* - capability checks and other checks
* - create the module from the module info
*
* @param object $module
* @return object the created module info
* @throws moodle_exception if user is not allowed to perform the action or module is not allowed in this course
*/
function create_module($moduleinfo)
{
global $DB, $CFG;
require_once $CFG->dirroot . '/course/modlib.php';
// Check manadatory attributs.
$mandatoryfields = array('modulename', 'course', 'section', 'visible');
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_MOD_INTRO, true)) {
$mandatoryfields[] = 'introeditor';
}
foreach ($mandatoryfields as $mandatoryfield) {
if (!isset($moduleinfo->{$mandatoryfield})) {
throw new moodle_exception('createmodulemissingattribut', '', '', $mandatoryfield);
}
}
// Some additional checks (capability / existing instances).
$course = $DB->get_record('course', array('id' => $moduleinfo->course), '*', MUST_EXIST);
list($module, $context, $cw) = can_add_moduleinfo($course, $moduleinfo->modulename, $moduleinfo->section);
// Add the module.
$moduleinfo->module = $module->id;
$moduleinfo = add_moduleinfo($moduleinfo, $course, null);
return $moduleinfo;
}
示例3: prepare_new_moduleinfo_data
/**
* Prepare the standard module information for a new module instance.
*
* @param stdClass $course course object
* @param string $modulename module name
* @param int $section section number
* @return array module information about other required data
* @since Moodle 3.2
*/
function prepare_new_moduleinfo_data($course, $modulename, $section)
{
global $CFG;
list($module, $context, $cw) = can_add_moduleinfo($course, $modulename, $section);
$cm = null;
$data = new stdClass();
$data->section = $section;
// The section number itself - relative!!! (section column in course_sections)
$data->visible = $cw->visible;
$data->course = $course->id;
$data->module = $module->id;
$data->modulename = $module->name;
$data->groupmode = $course->groupmode;
$data->groupingid = $course->defaultgroupingid;
$data->id = '';
$data->instance = '';
$data->coursemodule = '';
if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
file_prepare_draft_area($draftid_editor, null, null, null, null, array('subdirs' => true));
$data->introeditor = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => $draftid_editor);
// TODO: add better default
}
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';
$data->_advancedgradingdata['methods'] = grading_manager::available_methods();
$areas = grading_manager::available_areas('mod_' . $module->name);
foreach ($areas as $areaname => $areatitle) {
$data->_advancedgradingdata['areas'][$areaname] = array('title' => $areatitle, 'method' => '');
$formfield = 'advancedgradingmethod_' . $areaname;
$data->{$formfield} = '';
}
}
return array($module, $context, $cw, $cm, $data);
}