gradetest.php

来自「很棒的在线教学系统」· PHP 代码 · 共 1,205 行 · 第 1/5 页

PHP
1,205
字号
            $table->addFieldInfo('droplow', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('aggregateonlygraded', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('aggregateoutcomes', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('aggregatesubcats', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');        /// Adding keys to table grade_categories_history            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));            $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_categories', array('id'));            $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));            $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id'));        /// Adding indexes to table grade_categories_history            $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));        /// Launch create table for grade_categories_history            $result = $result && create_table($table, true, false);        } else {            delete_records($table->name);        }        /// Define table grade_grades to be created        $table = new XMLDBTable('grade_grades_history');        if ($result && !table_exists($table)) {        /// Adding fields to table grade_grades_history            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);            $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('rawgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null);            $table->addFieldInfo('rawgrademax', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '100');            $table->addFieldInfo('rawgrademin', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('rawscaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('finalgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null, null, null);            $table->addFieldInfo('hidden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('locked', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('locktime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('excluded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);            $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);            $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');        /// Adding keys to table grade_grades_history            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));            $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_grades', array('id'));            $table->addKeyInfo('itemid', XMLDB_KEY_FOREIGN, array('itemid'), 'grade_items', array('id'));            $table->addKeyInfo('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));            $table->addKeyInfo('rawscaleid', XMLDB_KEY_FOREIGN, array('rawscaleid'), 'scale', array('id'));            $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));            $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));        /// Adding indexes to table grade_grades_history            $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));        /// Launch create table for grade_grades_history            $result = $result && create_table($table, true, false);        } else {            delete_records($table->name);        }        /// Define table grade_outcomes to be created        $table = new XMLDBTable('grade_outcomes_history');        if ($result && !table_exists($table)) {        /// Adding fields to table grade_outcomes_history            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);            $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('fullname', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);        /// Adding keys to table grade_outcomes_history            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));            $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_outcomes', array('id'));            $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));            $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id'));            $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));        /// Adding indexes to table grade_outcomes_history            $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));        /// Launch create table for grade_outcomes_history            $result = $result && create_table($table, true, false);        } else {            delete_records($table->name);        }        /// Define table scale to be created        $table = new XMLDBTable('scale_history');        if ($result && !table_exists($table)) {        /// Adding fields to table scale_history            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);            $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);            $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');            $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('scale', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);            $table->addFieldInfo('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null);        /// Adding keys to table scale_history            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));            $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'scales', array('id'));            $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));        /// Adding indexes to table scale_history            $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));        /// Launch create table for scale_history            $result = $result && create_table($table, true, false);        } else {            delete_records($table->name);        }        return $result;    }    /**     * Drop test tables from DB.     * Restore original $CFG->prefix.     */    function tearDown() {        global $CFG;        // delete the contents of tables before the test run - the unit test might fail on fatal error and the data would not be deleted!        foreach ($this->tables as $table) {            unset($this->$table);        }        $CFG->prefix = $CFG->old_prefix;    }    /**     * Load scale data into the database, and adds the corresponding objects to this class' variable.     */    function load_scale() {        $scale = new stdClass();        $scale->name        = 'unittestscale1';        $scale->courseid    = $this->courseid;        $scale->userid      = $this->userid;        $scale->scale       = 'Way off topic, Not very helpful, Fairly neutral, Fairly helpful, Supportive, Some good information, Perfect answer!';        $scale->description = 'This scale defines some of qualities that make posts helpful within the Moodle help forums.\n Your feedback will help others see how their posts are being received.';        $scale->timemodified = mktime();        if ($scale->id = insert_record('scale', $scale)) {            $this->scale[0] = $scale;            $temp = explode(',', $scale->scale);            $this->scalemax[0] = count($temp) -1;        }        $scale = new stdClass();        $scale->name        = 'unittestscale2';        $scale->courseid    = $this->courseid;        $scale->userid      = $this->userid;        $scale->scale       = 'Distinction, Very Good, Good, Pass, Fail';        $scale->description = 'This scale is used to mark standard assignments.';        $scale->timemodified = mktime();        if ($scale->id = insert_record('scale', $scale)) {            $this->scale[1] = $scale;            $temp = explode(',', $scale->scale);            $this->scalemax[1] = count($temp) -1;        }        $scale = new stdClass();        $scale->name        = 'unittestscale3';        $scale->courseid    = $this->courseid;        $scale->userid      = $this->userid;        $scale->scale       = 'Loner, Contentious, Disinterested, Participative, Follower, Leader';        $scale->description = 'Describes the level of teamwork of a student.';        $scale->timemodified = mktime();        $temp  = explode(',', $scale->scale);        $scale->max         = count($temp) -1;        if ($scale->id = insert_record('scale', $scale)) {            $this->scale[2] = $scale;            $temp = explode(',', $scale->scale);            $this->scalemax[2] = count($temp) -1;        }        $scale->name        = 'unittestscale4';        $scale->courseid    = $this->courseid;        $scale->userid      = $this->userid;        $scale->scale       = 'Does not understand theory, Understands theory but fails practice, Manages through, Excels';        $scale->description = 'Level of expertise at a technical task, with a theoretical framework.';        $scale->timemodified = mktime();        $temp  = explode(',', $scale->scale);        $scale->max         = count($temp) -1;        if ($scale->id = insert_record('scale', $scale)) {            $this->scale[3] = $scale;            $temp = explode(',', $scale->scale);            $this->scalemax[3] = count($temp) -1;        }        $scale->name        = 'unittestscale5';        $scale->courseid    = $this->courseid;        $scale->userid      = $this->userid;        $scale->scale       = 'Insufficient, Acceptable, Excellent.';        $scale->description = 'Description of skills.';        $scale->timemodified = mktime();        $temp  = explode(',', $scale->scale);        $scale->max         = count($temp) -1;        if ($scale->id = insert_record('scale', $scale)) {            $this->scale[4] = $scale;            $temp = explode(',', $scale->scale);            $this->scalemax[4] = count($temp) -1;        }    }    /**     * Load grade_category data into the database, and adds the corresponding objects to this class' variable.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?