]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 18:28:49 +0000 (18:28 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 18:28:49 +0000 (18:28 +0000)
mod/assignment/backuplib.php
mod/assignment/db/install.xml
mod/assignment/db/upgrade.php
mod/assignment/grade.php
mod/assignment/lib.php
mod/assignment/mod_form.php
mod/assignment/restorelib.php
mod/assignment/type/online/all.php
mod/assignment/version.php

index ce963d6e467f72bb76835ccdf727dd5e88f502f9..06f24a94f5c86d639a097e1e9f718a658c7851c6 100644 (file)
@@ -55,8 +55,8 @@
         fwrite ($bf,full_tag("ID",4,false,$assignment->id));
         fwrite ($bf,full_tag("MODTYPE",4,false,"assignment"));
         fwrite ($bf,full_tag("NAME",4,false,$assignment->name));
-        fwrite ($bf,full_tag("DESCRIPTION",4,false,$assignment->description));
-        fwrite ($bf,full_tag("FORMAT",4,false,$assignment->format));
+        fwrite ($bf,full_tag("DESCRIPTION",4,false,$assignment->intro));
+        fwrite ($bf,full_tag("FORMAT",4,false,$assignment->introformat));
         fwrite ($bf,full_tag("RESUBMIT",4,false,$assignment->resubmit));
         fwrite ($bf,full_tag("PREVENTLATE",4,false,$assignment->preventlate));
         fwrite ($bf,full_tag("EMAILTEACHERS",4,false,$assignment->emailteachers));
index 467ec70abbd6c343e4fba38905ef28a59242cfe2..327007c1dc9e774d907d99802315384ad1e6fc5c 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/assignment/db" VERSION="20070919" COMMENT="XMLDB file for Moodle mod/assignment"
+<XMLDB PATH="mod/assignment/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/assignment"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -8,10 +8,10 @@
       <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="description"/>
-        <FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="format"/>
-        <FIELD NAME="format" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="description" NEXT="assignmenttype"/>
-        <FIELD NAME="assignmenttype" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="resubmit"/>
+        <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="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="assignmenttype"/>
+        <FIELD NAME="assignmenttype" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="resubmit"/>
         <FIELD NAME="resubmit" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="assignmenttype" NEXT="preventlate"/>
         <FIELD NAME="preventlate" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="resubmit" NEXT="emailteachers"/>
         <FIELD NAME="emailteachers" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="preventlate" NEXT="var1"/>
@@ -27,7 +27,7 @@
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="grade"/>
       </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"/>
@@ -61,4 +61,4 @@
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 81fedf5f4a3cd51af2e896c758d769e9c3c0bb35..6d01ab6ac04121d02710d6c0fe570574595dc18d 100644 (file)
@@ -132,6 +132,32 @@ function xmldb_assignment_upgrade($oldversion) {
         upgrade_mod_savepoint($result, 2008081900, 'assignment');
     }
 
+    if ($result && $oldversion < 2009042000) {
+
+    /// Rename field description on table assignment to intro
+        $table = new xmldb_table('assignment');
+        $field = new xmldb_field('description', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
+
+    /// Launch rename field description
+        $dbman->rename_field($table, $field, 'intro');
+
+    /// assignment savepoint reached
+        upgrade_mod_savepoint($result, 2009042000, 'assignment');
+    }
+
+    if ($result && $oldversion < 2009042001) {
+
+    /// 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');
+
+    /// Launch rename field format
+        $dbman->rename_field($table, $field, 'introformat');
+
+    /// assignment savepoint reached
+        upgrade_mod_savepoint($result, 2009042001, 'assignment');
+    }
+
     return $result;
 }
 
index 4bb2cb313b26ecdefa94728c59f9532420e48f5d..ccc06556961bcb623277cf2a2635b4d90de43a20 100644 (file)
@@ -16,7 +16,7 @@
         print_error('coursemisconf', 'assignment');
     }
 
-    require_login($course->id, false, $cm);
+    require_login($course, false, $cm);
 
     if (has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
         redirect('submissions.php?id='.$cm->id);
index 8d5c2ff430192c10ddbb3fad9847929c1b1d1fb1..28a143d57c42a0a4c2b36bdd1c6ea3ab2e6f1247 100644 (file)
@@ -162,7 +162,7 @@ class assignment_base {
         print_simple_box_start('center', '', '', 0, 'generalbox', 'intro');
         $formatoptions = new stdClass;
         $formatoptions->noclean = true;
-        echo format_text($this->assignment->description, $this->assignment->format, $formatoptions);
+        echo format_text($this->assignment->intro, $this->assignment->introformat, $formatoptions);
         print_simple_box_end();
     }
 
@@ -358,7 +358,7 @@ class assignment_base {
             if ($assignment->timedue) {
                 $event = new object();
                 $event->name        = $assignment->name;
-                $event->description = $assignment->description;
+                $event->description = $assignment->intro;
                 $event->courseid    = $assignment->course;
                 $event->groupid     = 0;
                 $event->userid      = 0;
@@ -447,14 +447,14 @@ class assignment_base {
             if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
 
                 $event->name        = $assignment->name;
-                $event->description = $assignment->description;
+                $event->description = $assignment->intro;
                 $event->timestart   = $assignment->timedue;
 
                 update_event($event);
             } else {
                 $event = new object();
                 $event->name        = $assignment->name;
-                $event->description = $assignment->description;
+                $event->description = $assignment->intro;
                 $event->courseid    = $assignment->course;
                 $event->groupid     = 0;
                 $event->userid      = 0;
@@ -2431,7 +2431,7 @@ function assignment_refresh_events($courseid = 0) {
     foreach ($assignments as $assignment) {
         $event = NULL;
         $event->name        = $assignment->name;
-        $event->description = $assignment->description;
+        $event->description = $assignment->intro;
         $event->timestart   = $assignment->timedue;
 
         if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
index 3d84e3acb94cd153ae4a722674d4c6fb665cedaa..be17f2b437a67c79e53b54b0e6bafed2b65f630d 100644 (file)
@@ -39,10 +39,10 @@ class mod_assignment_mod_form extends moodleform_mod {
         }
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'description', get_string('description', 'assignment'));
-        $mform->setType('description', PARAM_RAW);
-        $mform->setHelpButton('description', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
-        $mform->addRule('description', get_string('required'), 'required', null, 'client');
+        $mform->addElement('htmleditor', 'intro', get_string('description', 'assignment'));
+        $mform->setType('intro', PARAM_RAW);
+        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
+        $mform->addRule('intro', get_string('required'), 'required', null, 'client');
 
         $mform->addElement('modgrade', 'grade', get_string('grade'));
         $mform->setDefault('grade', 100);
index 3939800778c434f2530685874e62ecf69377a39a..370d6ab95dec40dee3363cc5e2c9ab1a405d11d8 100644 (file)
@@ -44,8 +44,8 @@
             //Now, build the ASSIGNMENT record structure
             $assignment->course = $restore->course_id;
             $assignment->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $assignment->description = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
-            $assignment->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
+            $assignment->intro = backup_todb($info['MOD']['#']['DESCRIPTION']['0']['#']);
+            $assignment->introformat = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
             $assignment->resubmit = backup_todb($info['MOD']['#']['RESUBMIT']['0']['#']);
             $assignment->preventlate = backup_todb($info['MOD']['#']['PREVENTLATE']['0']['#']);
             $assignment->emailteachers = backup_todb($info['MOD']['#']['EMAILTEACHERS']['0']['#']);
         $status = true;
 
         //Convert assignment->description
-        if ($records = $DB->get_records_sql ("SELECT a.id, a.description, a.format
+        if ($records = $DB->get_records_sql ("SELECT a.id, a.intro, a.introformat
                                                 FROM {assignment} a, {backup_ids} b
                                                WHERE a.course = ? AND
                                                a.format = ".FORMAT_WIKI. " AND
                                                b.new_id = a.id", array($restore->course_id, $restore->backup_unique_code))) {
             foreach ($records as $record) {
                 //Rebuild wiki links
-                $record->description = restore_decode_wiki_content($record->description, $restore);
+                $record->intro = restore_decode_wiki_content($record->intro, $restore);
                 //Convert to Markdown
                 $wtm = new WikiToMarkdown();
-                $record->description = $wtm->convert($record->description, $restore->course_id);
-                $record->format = FORMAT_MARKDOWN;
+                $record->intro = $wtm->convert($record->intro, $restore->course_id);
+                $record->introformat = FORMAT_MARKDOWN;
                 $status = $DB->update_record('assignment', $record);
                 //Do some output
                 $i++;
index 5394de8428ae3f72a110e13ee509f009ca2da079..8e1500a860d49f80ad34a55ce9afe5ffef6c1e0e 100644 (file)
 
         $view->name = $assignment->name;
         $view->submitted = $submitted;
-        $view->description = format_text( $assignment->description, $assignment->format, $formatoptions );
+        $view->description = format_text( $assignment->intro, $assignment->introformat, $formatoptions );
         $view->editlink = $editlink;
         $view->submissiontext = $submissiontext;
         $view->submissiondate = $submissiondate;
index 258e0a7dc4e0c55ca532a212014c08835b43be42..b00df242e4ded01c705ed7b9e008a2bde6b3ca8c 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2008081900;
-$module->requires = 2008080701;  // Requires this Moodle version
+$module->version  = 2009042001;
+$module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 60;
 
 ?>