⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postgres7.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_question_datasets (                               id SERIAL8 PRIMARY KEY,                               question INT8  NOT NULL default '0',                               datasetdefinition INT8  NOT NULL default '0'            ) ; ");        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_question_datasets_question_datasetdefinition_idx ON prefix_quiz_question_datasets (question,datasetdefinition);");        // One table for new question type calculated        //  - the first dataset dependent question type        $success = $success && modify_database ("", " CREATE TABLE prefix_quiz_calculated (                               id SERIAL8 PRIMARY KEY,                               question INT8  NOT NULL default '0',                               answer INT8  NOT NULL default '0',                               tolerance varchar(20) NOT NULL default '0.0',                               tolerancetype INT8 NOT NULL default '1',                               correctanswerlength INT8 NOT NULL default '2'                ) ; ");        $success = $success && modify_database ("", "CREATE INDEX prefix_quiz_calculated_question_idx ON  prefix_quiz_calculated (question);");        $success = $success && modify_database ( "", "COMMIT;");    }    if ($success && $oldversion < 2004111400) {        $success = $success && table_column("quiz_responses", "answer", "answer", "text", "", "", "", "not null");    }    if ($success && $oldversion < 2004111700) {        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_course_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_answers_question_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_quiz_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_attempts_userid_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_calculated_answer_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_categories_course_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_dataset_definitions_category_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_quiz_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_grades_userid_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_question_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_numerical_units_question_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_quiz_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_question_grades_question_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_questions_category_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_randomsamatch_question_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_attempt_idx;",false);        $success = $success && execute_sql("DROP INDEX {$CFG->prefix}quiz_responses_question_idx;",false);        $success = $success && modify_database('','CREATE INDEX prefix_quiz_course_idx ON prefix_quiz (course);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_answers_question_idx ON prefix_quiz_answers (question);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_attempts_quiz_idx ON prefix_quiz_attempts (quiz);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_attempts_userid_idx ON prefix_quiz_attempts (userid);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_calculated_answer_idx ON prefix_quiz_calculated (answer);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_categories_course_idx ON prefix_quiz_categories (course);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_dataset_definitions_category_idx ON prefix_quiz_dataset_definitions (category);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_grades_quiz_idx ON prefix_quiz_grades (quiz);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_grades_userid_idx ON prefix_quiz_grades (userid);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_numerical_units_question_idx ON prefix_quiz_numerical_units (question);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_question_grades_quiz_idx ON prefix_quiz_question_grades (quiz);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_question_grades_question_idx ON prefix_quiz_question_grades (question);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_questions_category_idx ON prefix_quiz_questions (category);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_randomsamatch_question_idx ON prefix_quiz_randomsamatch (question);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_responses_attempt_idx ON prefix_quiz_responses (attempt);');        $success = $success && modify_database('','CREATE INDEX prefix_quiz_responses_question_idx ON prefix_quiz_responses (question);');    }    if ($success && $oldversion < 2004112300) { //try and clean up an old mistake - try and bring us up to what is in postgres7.sql today.        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT category;",false);        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}quiz_attemptonlast_datasets_category_userid;",false);        $success = $success && execute_sql("ALTER TABLE {$CFG->prefix}quiz_attemptonlast_datasets DROP CONSTRAINT {$CFG->prefix}quiz_category_userid_unique;",false);        $success = $success && modify_database('','ALTER TABLE prefix_quiz_attemptonlast_datasets ADD CONSTRAINT prefix_quiz_category_userid_unique UNIQUE (category,userid);');    }    if ($success && $oldversion < 2004120501) {        $success = $success && table_column("quiz_calculated", "", "correctanswerformat", "integer", "10", "", "0", "not null", "correctanswerlength");    }    if ($success && $oldversion < 2004121400) {  // New field to determine popup window behaviour        $success = $success && table_column("quiz", "", "popup", "integer", "4", "", "0", "not null", "subnet");    }    if ($success && $oldversion < 2005010201) {        $success = $success && table_column('quiz_categories', '', 'parent');        $success = $success && table_column('quiz_categories', '', 'sortorder', 'integer', '10', '', '999');    }    if ($success && $oldversion < 2005010300) {        $success = $success && table_column("quiz", "", "questionsperpage", "integer", "10", "", "0", "not null", "review");    }    if ($success && $oldversion < 2005012700) {        $success = $success && table_column('quiz_grades', 'grade', 'grade', 'real', 2, '');    }    if ($success && $oldversion < 2005021400) {        $success = $success && table_column("quiz", "", "decimalpoints", "integer", "4", "", "2", "not null", "grademethod");    }    if($success && $oldversion < 2005022800) {        $success = $success && table_column('quiz_questions', '', 'hidden', 'integer', '1', 'unsigned', '0', 'not null', 'version');        $success = $success && table_column('quiz_responses', '', 'originalquestion', 'integer', '10', 'unsigned', '0', 'not null', 'question');        $success = $success && modify_database ('', "CREATE TABLE prefix_quiz_question_version (                              id SERIAL PRIMARY KEY,                              quiz integer NOT NULL default '0',                              oldquestion integer NOT NULL default '0',                              newquestion integer NOT NULL default '0',                              userid integer NOT NULL default '0',                              timestamp integer NOT NULL default '0');");    }    if ($success && $oldversion < 2005032000) {        $success = $success && execute_sql(" INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('quiz', 'editquestions', 'quiz', 'name') ");    }    if ($success && $oldversion < 2005032300) {        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_version RENAME TO prefix_quiz_question_versions;');    }    if ($success && $oldversion < 2005041200) { // replace wiki-like with markdown        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );        $wtm = new WikiToMarkdown();        $sql = "select course from {$CFG->prefix}quiz_categories, {$CFG->prefix}quiz_questions ";        $sql .= "where {$CFG->prefix}quiz_category.id = {$CFG->prefix}quiz_questions.category ";        $sql .= "and {$CFG->prefix}quiz_questions.id = ";        $wtm->update( 'quiz_questions', 'questiontext', 'questiontextformat', $sql );    }    if ($success && $oldversion < 2005041300) {        $success = $success && modify_database('', "UPDATE prefix_quiz_questions SET hidden = '1' WHERE qtype ='".RANDOM."';");    }    if ($success && $oldversion < 2005042002) {        $success = $success && table_column('quiz_answers', 'answer', 'answer', 'text', '', '', '', 'not null', '');    }    if ($success && $oldversion < 2005042400) {        begin_sql();        // Changes to quiz table        // The bits of the optionflags field will hold various option flags        $success = $success && table_column('quiz', '', 'optionflags', 'integer', '10', 'unsigned', '0', 'not null', 'timeclose');        // The penalty scheme        $success = $success && table_column('quiz', '', 'penaltyscheme', 'integer', '4', 'unsigned', '0', 'not null', 'optionflags');        // The review options are now all stored in the bits of the review field        $success = $success && table_column('quiz', 'review', 'review', 'integer', 10, 'unsigned', 0, 'not null', '');        /// Changes to quiz_attempts table        // The preview flag marks teacher previews        $success = $success && table_column('quiz_attempts', '', 'preview', 'tinyint', '2', 'unsigned', '0', 'not null', 'timemodified');        // The layout is the list of questions with inserted page breaks.        $success = $success && table_column('quiz_attempts', '', 'layout', 'text', '', '', '', 'not null', 'timemodified');        // For old quiz attempts we will set this to the repaginated question list from $quiz->questions        /// The following updates of field values require a loop through all quizzes        // This is because earlier versions of mysql don't allow joins in UPDATE        if ($quizzes = get_records('quiz')) {            // turn reporting off temporarily to avoid one line output per set_field            $olddebug = $db->debug;            $db->debug = false;            foreach ($quizzes as $quiz) {                // repaginate                $quiz->questions = ($quiz->questionsperpage) ? quiz_repaginate($quiz->questions, $quiz->questionsperpage) : $quiz->questions;                if ($quiz->questionsperpage) {                    $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);                    $success = $success && set_field('quiz', 'questions', $quiz->questions, 'id', $quiz->id);                }                set_field('quiz_attempts', 'layout', $quiz->questions, 'quiz', $quiz->id);                // set preview flag                if ($teachers = get_course_teachers($quiz->course)) {                    $teacherids = implode(',', array_keys($teachers));                    $success = $success && execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET preview = 1 WHERE userid IN ($teacherids)");                }                // set review flags in quiz table                $review = (QUIZ_REVIEW_IMMEDIATELY & (QUIZ_REVIEW_RESPONSES + QUIZ_REVIEW_SCORES));                if ($quiz->feedback) {                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK);                }                if ($quiz->correctanswers) {                    $review += (QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS);                }                if ($quiz->review & 1) {                    $review += QUIZ_REVIEW_CLOSED;                }                if ($quiz->review & 2) {                    $review += QUIZ_REVIEW_OPEN;                }                $success = $success && set_field('quiz', 'review', $review, 'id', $quiz->id);            }            $db->debug = $olddebug;        }        // We can now drop the fields whose data has been moved to the review field        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz DROP COLUMN feedback");        $success = $success && execute_sql(" ALTER TABLE {$CFG->prefix}quiz DROP COLUMN correctanswers");        /// Renaming tables        // rename the quiz_question_grades table to quiz_question_instances        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_grades RENAME TO prefix_quiz_question_instances;');        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_grades_id_seq RENAME TO prefix_quiz_question_instances_id_seq;');        $success = $success && modify_database ('', 'ALTER TABLE prefix_quiz_question_instances ALTER COLUMN id SET DEFAULT nextval(\'prefix_quiz_question_instances_id_seq\');');

⌨️ 快捷键说明

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