コード例 #1
0
ファイル: lib.php プロジェクト: Gavinthisisit/Moodle
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod.html) this function
 * will update an existing instance with new data.
 *
 * @param object $instance An object from the form in mod.html
 * @return boolean Success/Fail
 **/
function lti_update_instance($lti, $mform)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/lti/locallib.php';
    $lti->timemodified = time();
    $lti->id = $lti->instance;
    if (!isset($lti->showtitlelaunch)) {
        $lti->showtitlelaunch = 0;
    }
    if (!isset($lti->showdescriptionlaunch)) {
        $lti->showdescriptionlaunch = 0;
    }
    lti_force_type_config_settings($lti, lti_get_type_config_by_instance($lti));
    if (isset($lti->instructorchoiceacceptgrades) && $lti->instructorchoiceacceptgrades == LTI_SETTING_ALWAYS) {
        lti_grade_item_update($lti);
    } else {
        // Instance is no longer accepting grades from Provider, set grade to "No grade" value 0.
        $lti->grade = 0;
        $lti->instructorchoiceacceptgrades = 0;
        lti_grade_item_delete($lti);
    }
    if ($lti->typeid == 0 && isset($lti->urlmatchedtypeid)) {
        $lti->typeid = $lti->urlmatchedtypeid;
    }
    return $DB->update_record('lti', $lti);
}
コード例 #2
0
ファイル: lib.php プロジェクト: numbas/moodle
/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod.html) this function
 * will update an existing instance with new data.
 *
 * @param object $instance An object from the form in mod.html
 * @return boolean Success/Fail
 **/
function lti_update_instance($lti, $mform) {
    global $DB, $CFG;
    require_once($CFG->dirroot.'/mod/lti/locallib.php');

    $lti->timemodified = time();
    $lti->id = $lti->instance;

    if (!isset($lti->showtitlelaunch)) {
        $lti->showtitlelaunch = 0;
    }

    if (!isset($lti->showdescriptionlaunch)) {
        $lti->showdescriptionlaunch = 0;
    }

    if (!isset($lti->grade)) {
        $lti->grade = $DB->get_field('lti', 'grade', array('id' => $lti->id));
    }

    if ($lti->instructorchoiceacceptgrades == LTI_SETTING_ALWAYS) {
        lti_grade_item_update($lti);
    } else {
        lti_grade_item_delete($lti);
    }

    return $DB->update_record('lti', $lti);
}