コード例 #1
0
ファイル: modedit.php プロジェクト: sriysk/moodle-integration
    }
    $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
0
ファイル: lib.php プロジェクト: EmmanuelYupit/educursos
/**
 * 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
0
ファイル: modlib.php プロジェクト: rajeshtaneja/moodle
/**
 * 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);
}