コード例 #1
0
            window.close();
        }, {$timeout});
EOF;
    if ($data = $form->get_data()) {
        $type = new stdClass();
        if (!empty($typeid)) {
            $type->id = $typeid;
            lti_load_type_if_cartridge($data);
            lti_update_type($type, $data);
            $fromdb = lti_get_type($typeid);
            $json = json_encode($fromdb);
            // Output script to update the calling window.
            $script = <<<EOF
                window.opener.M.mod_lti.editor.updateToolType({$json});
EOF;
        } else {
            $type->state = LTI_TOOL_STATE_CONFIGURED;
            $type->course = $COURSE->id;
            lti_load_type_if_cartridge($data);
            $id = lti_add_type($type, $data);
            $fromdb = lti_get_type($id);
            $json = json_encode($fromdb);
            // Output script to update the calling window.
            $script = <<<EOF
                window.opener.M.mod_lti.editor.addToolType({$json});
EOF;
        }
    }
    echo html_writer::script($script . $closewindow);
}
echo $OUTPUT->footer();
コード例 #2
0
ファイル: locallib_test.php プロジェクト: evltuma/moodle
 /**
  * Tests lti_load_type_from_cartridge and lti_load_type_if_cartridge
  */
 public function test_lti_load_type_from_cartridge()
 {
     $type = new stdClass();
     $type->lti_toolurl = $this->getExternalTestFileUrl('/ims_cartridge_basic_lti_link.xml');
     lti_load_type_if_cartridge($type);
     $this->assertEquals('Example tool', $type->lti_typename);
     $this->assertEquals('Example tool description', $type->lti_description);
     $this->assertEquals('http://www.example.com/lti/provider.php', $type->lti_toolurl);
     $this->assertEquals('http://download.moodle.org/unittest/test.jpg', $type->lti_icon);
     $this->assertEquals('https://download.moodle.org/unittest/test.jpg', $type->lti_secureicon);
 }