]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 18:45:31 +0000 (18:45 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 18:45:31 +0000 (18:45 +0000)
mod/choice/backuplib.php
mod/choice/db/install.xml
mod/choice/db/upgrade.php
mod/choice/mod_form.php
mod/choice/restorelib.php
mod/choice/version.php
mod/choice/view.php

index 2b1439894dec942b13b20dc4e3380ec8cade62cb..ec2d7b7760094ccc5012f1797747d4a60ab321ca 100644 (file)
@@ -60,8 +60,8 @@
         fwrite ($bf,full_tag("ID",4,false,$choice->id));
         fwrite ($bf,full_tag("MODTYPE",4,false,"choice"));
         fwrite ($bf,full_tag("NAME",4,false,$choice->name));
-        fwrite ($bf,full_tag("TEXT",4,false,$choice->text));
-        fwrite ($bf,full_tag("FORMAT",4,false,$choice->format));
+        fwrite ($bf,full_tag("TEXT",4,false,$choice->intro));
+        fwrite ($bf,full_tag("FORMAT",4,false,$choice->introformat));
         fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
         fwrite ($bf,full_tag("SHOWRESULTS",4,false,$choice->showresults));
         fwrite ($bf,full_tag("DISPLAY",4,false,$choice->display));
index f0d47f28d0355fcf1ee0f3e5a0d74527f8e46fb9..b6f1889f3455523b57b7bf8e452e8e3cad648715 100644 (file)
@@ -1,14 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/choice/db" VERSION="20060808" COMMENT="XMLDB file for Moodle mod/choice">
+<XMLDB PATH="mod/choice/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/choice"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
   <TABLES>
     <TABLE NAME="choice" COMMENT="Available choices are stored here" NEXT="choice_options">
       <FIELDS>
         <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" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="text"/>
-        <FIELD NAME="text" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="format"/>
-        <FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="text" NEXT="publish"/>
-        <FIELD NAME="publish" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="showresults"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="publish"/>
+        <FIELD NAME="publish" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="showresults"/>
         <FIELD NAME="showresults" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="publish" NEXT="display"/>
         <FIELD NAME="display" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="showresults" NEXT="allowupdate"/>
         <FIELD NAME="allowupdate" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="display" NEXT="showunanswered"/>
@@ -19,7 +22,7 @@
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timeclose"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
@@ -56,4 +59,4 @@
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index e57af6195918b53982eb7d0bb3f4f5b4615b701c..de45eccfcc8835c1473336a643dd6f1600995db6 100644 (file)
@@ -28,6 +28,32 @@ function xmldb_choice_upgrade($oldversion) {
 
 //===== 1.9.0 upgrade line ======//
 
+    if ($result && $oldversion < 2009042000) {
+
+    /// Rename field text on table choice to NEWNAMEGOESHERE
+        $table = new xmldb_table('choice');
+        $field = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
+
+    /// Launch rename field text
+        $dbman->rename_field($table, $field, 'intro');
+
+    /// choice savepoint reached
+        upgrade_mod_savepoint($result, 2009042000, 'choice');
+    }
+
+    if ($result && $oldversion < 2009042001) {
+
+    /// Rename field format on table choice to NEWNAMEGOESHERE
+        $table = new xmldb_table('choice');
+        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'text');
+
+    /// Launch rename field format
+        $dbman->rename_field($table, $field, 'introformat');
+
+    /// choice savepoint reached
+        upgrade_mod_savepoint($result, 2009042001, 'choice');
+    }
+
     return $result;
 }
 
index bf19b4f78edadcf37ca4ac4e3841a7a308f9b203..d54ef3e9b27aa06a7fd20a62af4055d2e74a2ac2 100644 (file)
@@ -19,12 +19,12 @@ class mod_choice_mod_form extends moodleform_mod {
         }
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'text', get_string('choicetext', 'choice'));
-        $mform->setType('text', PARAM_RAW);
-        $mform->addRule('text', null, 'required', null, 'client');
-        $mform->setHelpButton('text', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
+        $mform->addElement('htmleditor', 'intro', get_string('choicetext', 'choice'));
+        $mform->setType('intro', PARAM_RAW);
+        $mform->addRule('intro', null, 'required', null, 'client');
+        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
 
-        $mform->addElement('format', 'format', get_string('format'));
+        $mform->addElement('format', 'introformat', get_string('format'));
 
 //-------------------------------------------------------------------------------
         $repeatarray=array();
index f137efc74fdb24cf19decbdc9c5716b098e58178..3249c097e10c4fa00b8ab5ec8433b2fc58e7f05b 100644 (file)
@@ -49,8 +49,8 @@
             //Now, build the CHOICE record structure
             $choice->course = $restore->course_id;
             $choice->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $choice->text = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
-            $choice->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
+            $choice->intro = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
+            $choice->introformat = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
             $choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']);
             $choice->showresults = isset($info['MOD']['#']['SHOWRESULTS']['0']['#'])?backup_todb($info['MOD']['#']['SHOWRESULTS']['0']['#']):'';
             $choice->display = backup_todb($info['MOD']['#']['DISPLAY']['0']['#']);
@@ -376,7 +376,7 @@ function choice_options_restore_mods($choiceid,$info,$restore) {
         $status = true;
 
         //Convert choice->text
-        if ($records = $DB->get_records_sql("SELECT c.id, c.text, c.format
+        if ($records = $DB->get_records_sql("SELECT c.id, c.intro, c.introformat
                                                FROM {choice} c, {backup_ids} b
                                               WHERE c.course = ? AND
                                                     c.format = ".FORMAT_WIKI. " AND
@@ -385,11 +385,11 @@ function choice_options_restore_mods($choiceid,$info,$restore) {
                                                     b.new_id = c.id", array($restore->course_id, $restore->backup_unique_code))) {
             foreach ($records as $record) {
                 //Rebuild wiki links
-                $record->text = restore_decode_wiki_content($record->text, $restore);
+                $record->intro = restore_decode_wiki_content($record->intro, $restore);
                 //Convert to Markdown
                 $wtm = new WikiToMarkdown();
-                $record->text = $wtm->convert($record->text, $restore->course_id);
-                $record->format = FORMAT_MARKDOWN;
+                $record->intro = $wtm->convert($record->intro, $restore->course_id);
+                $record->introformat = FORMAT_MARKDOWN;
                 $status = $DB->update_record('choice', $record);
                 //Do some output
                 $i++;
index 51a67c370cc3cbb22b3f61edbc50a5c57d2df3bb..dfebaf1e04f09ee82469e76e2cf608c7ff482f5e 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101509;
-$module->requires = 2007101509;  // Requires this Moodle version
+$module->version  = 2009042001;
+$module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 0;
 
 ?>
index 3c8b4decf188486a6eb4aa4da687908e8cd1bc79..e93feb7b5b282ea7664f46d9e76aa178a1c92225 100644 (file)
@@ -78,8 +78,9 @@
 
     echo '<div class="clearer"></div>';
 
-    if ($choice->text) {
-        print_box(format_text($choice->text, $choice->format), 'generalbox', 'intro');
+    if ($choice->intro) {
+        $options = (object)array('noclean'=>true);
+        print_box(format_text($choice->intro, $choice->introformat, $options), 'generalbox', 'intro');
     }
 
     $current = false;  // Initialise for later