コード例 #1
0
    protected function process_lti($data) {
        global $DB, $CFG;

        $data = (object)$data;
        $oldid = $data->id;
        $data->course = $this->get_courseid();

        require_once($CFG->dirroot.'/mod/lti/lib.php');

        $newitemid = lti_add_instance($data, null);

        // insert the basiclti record
        //$newitemid = $DB->insert_record('lti', $data);
        // immediately after inserting "activity" record, call this
        $this->apply_activity_instance($newitemid);
    }
コード例 #2
0
    protected function process_lti($data) {
        global $DB, $CFG;

        $data = (object)$data;
        $oldid = $data->id;
        $data->course = $this->get_courseid();

        require_once($CFG->dirroot.'/mod/lti/lib.php');
        // Clean any course or site typeid. All modules
        // are restored as self-contained. Note this is
        // an interim solution until the issue below is implemented.
        // TODO: MDL-34161 - Fix restore to support course/site tools & submissions.
        $data->typeid = 0;

        $newitemid = lti_add_instance($data, null);

        // immediately after inserting "activity" record, call this
        $this->apply_activity_instance($newitemid);
    }
コード例 #3
0
ファイル: lib.php プロジェクト: Jtgadbois/Pedadida
    /**
     * Create new lti module instance
     *
     * @param array|stdClass $record
     * @param array $options
     * @throws coding_exception
     * @return stdClass activity record with extra cmid field
     */
    public function create_instance($record = null, array $options = null) {
        global $CFG;

        require_once("$CFG->dirroot/mod/lti/lib.php");

        $this->instancecount++;
        $i = $this->instancecount;

        $record  = (object) (array) $record;
        $options = (array) $options;

        if (empty($record->course)) {
            throw new coding_exception('module generator requires $record->course');
        }
        if (!isset($record->name)) {
            $record->name = get_string('pluginname', 'lti').' '.$i;
        }
        if (!isset($record->intro)) {
            $record->intro = 'Test lti '.$i;
        }
        if (!isset($record->introformat)) {
            $record->introformat = FORMAT_MOODLE;
        }
        if (!isset($record->toolurl)) {
            $record->toolurl = 'http://www.imsglobal.org/developers/LTI/test/v1p1/tool.php';
        }
        if (!isset($record->resourcekey)) {
            $record->resourcekey = '12345';
        }
        if (!isset($record->password)) {
            $record->password = '******';
        }
        if (!isset($record->grade)) {
            $record->grade = 100;
        }
        if (!isset($record->instructorchoicesendname)) {
            $record->instructorchoicesendname = 1;
        }
        if (!isset($record->instructorchoicesendemailaddr)) {
            $record->instructorchoicesendemailaddr = 1;
        }
        if (!isset($record->instructorchoiceacceptgrades)) {
            $record->instructorchoiceacceptgrades = 1;
        }
        if (isset($options['idnumber'])) {
            $record->cmidnumber = $options['idnumber'];
        } else {
            $record->cmidnumber = '';
        }
        $record->coursemodule = $this->precreate_course_module($record->course, $options);
        $id = lti_add_instance($record, null);
        return $this->post_add_instance($id, $record->coursemodule);
    }