MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 18:51:37 +0000 (18:51 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 18:51:37 +0000 (18:51 +0000)
15 files changed:
mod/assignment/db/upgrade.php
mod/choice/db/upgrade.php
mod/data/db/install.xml
mod/data/db/upgrade.php
mod/data/index.php
mod/data/version.php
mod/data/view.php
mod/feedback/backuplib.php
mod/feedback/db/install.xml
mod/feedback/db/upgrade.php
mod/feedback/lib.php
mod/feedback/mod_form.php
mod/feedback/restorelib.php
mod/feedback/version.php
mod/feedback/view.php

index 6d01ab6..a1c145a 100644 (file)
@@ -149,7 +149,7 @@ function xmldb_assignment_upgrade($oldversion) {
 
     /// Rename field format on table assignment to introformat
         $table = new xmldb_table('assignment');
-        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'description');
+        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
 
     /// Launch rename field format
         $dbman->rename_field($table, $field, 'introformat');
index de45ecc..2c7eb5f 100644 (file)
@@ -45,7 +45,7 @@ function xmldb_choice_upgrade($oldversion) {
 
     /// 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');
+        $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
 
     /// Launch rename field format
         $dbman->rename_field($table, $field, 'introformat');
index 079518a..7920a2f 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/data/db" VERSION="20080226" COMMENT="XMLDB file for Moodle mod/data"
+<XMLDB PATH="mod/data/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/data"
     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" PREVIOUS="id" NEXT="name"/>
         <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="comments"/>
-        <FIELD NAME="comments" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="timeavailablefrom"/>
+        <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="comments"/>
+        <FIELD NAME="comments" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="timeavailablefrom"/>
         <FIELD NAME="timeavailablefrom" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="comments" NEXT="timeavailableto"/>
         <FIELD NAME="timeavailableto" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timeavailablefrom" NEXT="timeviewfrom"/>
         <FIELD NAME="timeviewfrom" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timeavailableto" NEXT="timeviewto"/>
       </KEYS>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index eccbde4..0847570 100644 (file)
@@ -167,6 +167,19 @@ function xmldb_data_upgrade($oldversion) {
         upgrade_mod_savepoint($result, 2008112700, 'data');
     }
 
+    if ($result && $oldversion < 2009042000) {
+
+    /// Define field introformat to be added to data
+        $table = new xmldb_table('data');
+        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
+
+    /// Launch add field introformat
+        $dbman->add_field($table, $field);
+
+    /// data savepoint reached
+        upgrade_mod_savepoint($result, 2009042000, 'data');
+    }
+
     return $result;
 }
 
index f4e325b..93e9c2a 100755 (executable)
                 }
                 $currentsection = $data->section;
             }
-            $row = array ($printsection, $link, format_text($data->intro, FORMAT_MOODLE, $options), $numrecords, $numunapprovedrecords);
+            $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords);
 
         } else {
-            $row = array ($link, format_text($data->intro, FORMAT_MOODLE, $options), $numrecords, $numunapprovedrecords);
+            $row = array ($link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords);
         }
 
         if ($rss) {
index 7c61de2..b40155e 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2008112700;
-$module->requires = 2008080701;  // Requires this Moodle version
+$module->version  = 2009042000;
+$module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>
index 93b11b5..9a67927 100755 (executable)
     if ($data->intro and empty($page) and empty($record) and $mode != 'single') {
         $options = new object();
         $options->noclean = true;
-        print_box(format_text($data->intro, FORMAT_MOODLE, $options), 'generalbox', 'intro');
+        print_box(format_text($data->intro, $data->introformat, $options), 'generalbox', 'intro');
     }
 
 /// Delete any requested records
index 2b56b9e..caa1ef1 100644 (file)
@@ -58,7 +58,7 @@
       fwrite ($bf,full_tag("MODTYPE",4,false,"feedback"));
       fwrite ($bf,full_tag("VERSION",4,false,1)); //version 1 steht fuer die neue Version
       fwrite ($bf,full_tag("NAME",4,false,$feedback->name));
-      fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->summary));
+      fwrite ($bf,full_tag("SUMMARY",4,false,$feedback->intro));
       fwrite ($bf,full_tag("ANONYMOUS",4,false,$feedback->anonymous));
       fwrite ($bf,full_tag("EMAILNOTIFICATION",4,false,$feedback->email_notification));
       fwrite ($bf,full_tag("MULTIPLESUBMIT",4,false,$feedback->multiple_submit));
index 89e276e..ae6a4e5 100644 (file)
@@ -1,13 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/feedback/db" VERSION="20070101" COMMENT="XMLDB file for Moodle mod/feedback">
+<XMLDB PATH="mod/feedback/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/feedback"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
   <TABLES>
     <TABLE NAME="feedback" COMMENT="all feedbacks" NEXT="feedback_template">
       <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="summary"/>
-        <FIELD NAME="summary" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="anonymous"/>
-        <FIELD NAME="anonymous" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="summary" NEXT="email_notification"/>
+        <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="anonymous"/>
+        <FIELD NAME="anonymous" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="email_notification"/>
         <FIELD NAME="email_notification" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="anonymous" NEXT="multiple_submit"/>
         <FIELD NAME="multiple_submit" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="email_notification" NEXT="autonumbering"/>
         <FIELD NAME="autonumbering" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="multiple_submit" NEXT="site_after_submit"/>
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 3aa24f3..ba7e0e8 100644 (file)
@@ -250,7 +250,33 @@ function xmldb_feedback_upgrade($oldversion) {
 
         upgrade_mod_savepoint($result, 2009031301, 'feedback');
     }
-    
+
+    if ($result && $oldversion < 2009042000) {
+
+    /// Rename field summary on table feedback to intro
+        $table = new xmldb_table('feedback');
+        $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
+
+    /// Launch rename field summary
+        $dbman->rename_field($table, $field, 'intro');
+
+    /// feedback savepoint reached
+        upgrade_mod_savepoint($result, 2009042000, 'feedback');
+    }
+
+    if ($result && $oldversion < 2009042001) {
+
+    /// Define field introformat to be added to feedback
+        $table = new xmldb_table('feedback');
+        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro');
+
+    /// Launch add field introformat
+        $dbman->add_field($table, $field);
+
+    /// feedback savepoint reached
+        upgrade_mod_savepoint($result, 2009042001, 'feedback');
+    }
+
     return $result;
 }
 
index ce42b11..8715854 100644 (file)
@@ -454,7 +454,7 @@ function feedback_set_events($feedback) {
     if($feedback->timeopen > 0) {
         $event = NULL;
         $event->name          = get_string('start', 'feedback').' '.$feedback->name;
-        $event->description = $feedback->summary;
+        $event->description = $feedback->intro;
         $event->courseid     = $feedback->course;
         $event->groupid      = 0;
         $event->userid        = 0;
@@ -476,7 +476,7 @@ function feedback_set_events($feedback) {
     if($feedback->timeclose > 0) {
         $event = NULL;
         $event->name          = get_string('stop', 'feedback').' '.$feedback->name;
-        $event->description = $feedback->summary;
+        $event->description = $feedback->intro;
         $event->courseid     = $feedback->course;
         $event->groupid      = 0;
         $event->userid        = 0;
index a96dc11..1365def 100644 (file)
@@ -24,9 +24,9 @@ class mod_feedback_mod_form extends moodleform_mod {
         $mform->setType('name', PARAM_TEXT);
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'summary', get_string("description", "feedback"), array('rows' => 20));
-        $mform->setType('summary', PARAM_RAW);
-        $mform->addRule('summary', null, 'required', null, 'client');
+        $mform->addElement('htmleditor', 'intro', get_string("description", "feedback"), array('rows' => 20));
+        $mform->setType('intro', PARAM_RAW);
+        $mform->addRule('intro', null, 'required', null, 'client');
 
         //-------------------------------------------------------------------------------
         $mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
index 279aa1d..7a6f885 100644 (file)
@@ -49,7 +49,7 @@
             //Now, build the feedback record structure
             $feedback->course = $restore->course_id;
             $feedback->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $feedback->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
+            $feedback->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
             $feedback->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']);
             $feedback->email_notification = backup_todb($info['MOD']['#']['EMAILNOTIFICATION']['0']['#']);
             $feedback->multiple_submit = backup_todb($info['MOD']['#']['MULTIPLESUBMIT']['0']['#']);
@@ -69,7 +69,7 @@
             if($feedback->timeopen > 0) {
                 $event = NULL;
                 $event->name          = get_string('start', 'feedback').' '.$feedback->name;
-                $event->description = $feedback->summary;
+                $event->description = $feedback->intro;
                 $event->courseid     = $feedback->course;
                 $event->groupid      = 0;
                 $event->userid        = 0;
@@ -91,7 +91,7 @@
             if($feedback->timeclose > 0) {
                 $event = NULL;
                 $event->name          = get_string('stop', 'feedback').' '.$feedback->name;
-                $event->description = $feedback->summary;
+                $event->description = $feedback->intro;
                 $event->courseid     = $feedback->course;
                 $event->groupid      = 0;
                 $event->userid        = 0;
index 1320f8a..b1bb96e 100644 (file)
@@ -10,8 +10,8 @@
 */
 
    
-    $module->version = 2009031301; // The current module version (Date: YYYYMMDDXX)
-    $module->requires = 2008072401;  // Requires this Moodle version
+    $module->version = 2009042001; // The current module version (Date: YYYYMMDDXX)
+    $module->requires = 2009041700;  // Requires this Moodle version
     $feedback_version_intern = 1; //this version is used for restore older backups
     $module->cron = 0; // Period for cron to check this module (secs)
 
index abb656f..c34a184 100644 (file)
 
     // print_simple_box_start('center', '80%');
     print_box_start('generalbox boxaligncenter boxwidthwide');
-    echo format_text($feedback->summary);
+    $options = (object)array('noclean'=>true);
+    echo format_text($feedback->intro, $feedback->introformat, $options);
     // print_simple_box_end();
     print_box_end();