From 18b5df9155fbb88d01f5555bc9ece0621d27fab0 Mon Sep 17 00:00:00 2001 From: skodak <skodak> Date: Mon, 20 Apr 2009 19:29:15 +0000 Subject: [PATCH] MDL-18910 normalised module intro and introformat --- mod/forum/db/upgrade.php | 8 ++++++++ mod/forum/version.php | 2 +- mod/quiz/accessrules.php | 2 +- mod/quiz/db/install.xml | 9 +++++---- mod/quiz/db/upgrade.php | 16 ++++++++++++++++ mod/quiz/version.php | 4 ++-- mod/quiz/view.php | 3 ++- 7 files changed, 35 insertions(+), 9 deletions(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index d95bc90a1e..2ff19731d6 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -233,6 +233,14 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint($result, 2009042003, 'forum'); } + if ($result && $oldversion < 2009042004) { + /// set format to current + $DB->set_field('forum', 'introformat', FORMAT_MOODLE, array()); + + /// quiz savepoint reached + upgrade_mod_savepoint($result, 2009042004, 'forum'); + } + return $result; } diff --git a/mod/forum/version.php b/mod/forum/version.php index 4207a94270..11567b9981 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2009042003; +$module->version = 2009042004; $module->requires = 2009041700; // Requires this Moodle version $module->cron = 60; diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index 0d41aa593d..7d74f41b81 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -623,7 +623,7 @@ class password_access_rule extends quiz_access_rule_base { if (trim(strip_tags($this->_quiz->intro))) { $formatoptions = new stdClass; $formatoptions->noclean = true; - $output .= print_box(format_text($this->_quiz->intro, FORMAT_MOODLE, $formatoptions), + $output .= print_box(format_text($this->_quiz->intro, $this->_quiz->introformat, $formatoptions), 'generalbox', 'intro', true); } $output .= print_box_start('generalbox', 'passwordbox', true); diff --git a/mod/quiz/db/install.xml b/mod/quiz/db/install.xml index 1f73ef8658..c07a2c851c 100755 --- a/mod/quiz/db/install.xml +++ b/mod/quiz/db/install.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<XMLDB PATH="mod/quiz/db" VERSION="20090107" COMMENT="XMLDB file for Moodle mod/quiz" +<XMLDB PATH="mod/quiz/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/quiz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" > @@ -9,8 +9,9 @@ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/> <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Foreign key references course.id." PREVIOUS="id" NEXT="name"/> <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The name of this quiz." PREVIOUS="course" NEXT="intro"/> - <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The introductory text desplayed on the view.php page." PREVIOUS="name" NEXT="timeopen"/> - <FIELD NAME="timeopen" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Time at which students may start attempting this quiz." PREVIOUS="intro" NEXT="timeclose"/> + <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="The introductory text desplayed on the view.php page." PREVIOUS="name" NEXT="introformat"/> + <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="timeopen"/> + <FIELD NAME="timeopen" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Time at which students may start attempting this quiz." PREVIOUS="introformat" NEXT="timeclose"/> <FIELD NAME="timeclose" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Time by which students must have completed their attempt." PREVIOUS="timeopen" NEXT="optionflags"/> <FIELD NAME="optionflags" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="This stores the adaptive mode setting for this quiz." PREVIOUS="timeclose" NEXT="penaltyscheme"/> <FIELD NAME="penaltyscheme" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Stores the apply penaties setting." PREVIOUS="optionflags" NEXT="attempts"/> @@ -71,7 +72,7 @@ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="quiz"/> <FIELD NAME="quiz" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Foreign key references quiz.id." PREVIOUS="id" NEXT="userid"/> <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Foreign key references user.id." PREVIOUS="quiz" NEXT="grade"/> - <FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="The overall grade from the quiz. Not affected by overrides in the gradebook." DECIMALS="5" PREVIOUS="userid" NEXT="timemodified"/> + <FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="The overall grade from the quiz. Not affected by overrides in the gradebook." PREVIOUS="userid" NEXT="timemodified"/> <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="The last time this grade changed." PREVIOUS="grade"/> </FIELDS> <KEYS> diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php index a81a5ecc03..9b3444f4e1 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -276,6 +276,22 @@ function xmldb_quiz_upgrade($oldversion) { upgrade_mod_savepoint($result, 2009031001, 'quiz'); } + if ($result && $oldversion < 2009042000) { + + /// Define field introformat to be added to quiz + $table = new xmldb_table('quiz'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + + /// Launch add field introformat + $dbman->add_field($table, $field); + + /// set format to current + $DB->set_field('quiz', 'introformat', FORMAT_MOODLE, array()); + + /// quiz savepoint reached + upgrade_mod_savepoint($result, 2009042000, 'quiz'); + } + return $result; } diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 8b8359c7a4..f10172d34e 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,8 +5,8 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2009031001; // The (date) version of this module -$module->requires = 2008072401; // Requires this Moodle version +$module->version = 2009042000; // The (date) version of this module +$module->requires = 2009041700; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? ?> diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 84f0e68afb..1412aa9999 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -97,7 +97,8 @@ if (trim(strip_tags($quiz->intro))) { $formatoptions->noclean = true; $formatoptions->para = false; - print_box(format_text($quiz->intro, FORMAT_MOODLE, $formatoptions), 'generalbox', 'intro'); + $formatoptions->noclean = true; + print_box(format_text($quiz->intro, $quiz->introformat, $formatoptions), 'generalbox', 'intro'); } /// Display information about this quiz. -- 2.39.5