]> git.mjollnir.org Git - moodle.git/commitdiff
Teacher can now use the richtext editor to edit the assignment text
authormoodler <moodler>
Wed, 16 Oct 2002 05:31:56 +0000 (05:31 +0000)
committermoodler <moodler>
Wed, 16 Oct 2002 05:31:56 +0000 (05:31 +0000)
mod/assignment/db/mysql.php
mod/assignment/db/mysql.sql
mod/assignment/mod.html
mod/assignment/version.php
mod/assignment/view.php

index 0c12d56212adfb8a4f7d70f8e1e72b2a2921d4f7..873d04fb88b396c7aed4a294564e2cd2c53e2a38 100644 (file)
@@ -79,6 +79,10 @@ function assignment_upgrade($oldversion) {
         }
     }
 
+    if ($oldversion < 2002101600) {
+        execute_sql(" ALTER TABLE `assignment` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `description` ");
+    }
+
     return true;
 }
 
index 6f6b8b8e3bdc73b43d0d07e940a942e74fb635c6..812a92ededca018c975f0e9eabe546f78c0f98bf 100644 (file)
@@ -7,6 +7,7 @@ CREATE TABLE `assignment` (
   `course` int(10) unsigned NOT NULL default '0',
   `name` varchar(255) NOT NULL default '',
   `description` text NOT NULL,
+  `format` tinyint(2) unsigned NOT NULL default '0',
   `type` int(10) unsigned NOT NULL default '1',
   `maxbytes` int(10) unsigned NOT NULL default '100000',
   `timedue` int(10) unsigned NOT NULL default '0',
index fcab3f18d395a3365da311591293293d031b6403..f53f72106e8014c496f721db9eb45ff5236c55dd 100644 (file)
@@ -1,15 +1,41 @@
-<form name="form" method="post" action="<?=$ME ?>">
+<?
+    if ($usehtmleditor = can_use_richtext_editor()) {
+        $defaultformat = FORMAT_HTML;
+        $onsubmit = "onsubmit=\"copyrichtext(document.form.description);\"";
+    } else {
+        $defaultformat = FORMAT_MOODLE;
+        $onsubmit = "";
+    }
+?>
+
+<form name="form" method="post" <?=$onsubmit ?> action="<?=$ME ?>">
 <table cellpadding=5>
 <tr valign=top>
     <td align=right><P><B><? print_string("assignmentname", "assignment") ?>:</B></P></TD>
     <td>
-        <input type="text" name="name" size=30 value="<? p($form->name) ?>">
+        <input type="text" name="name" size=60 value="<? p($form->name) ?>">
     </td>
 </tr>
 <tr valign=top>
     <td align=right><P><B><? print_string("description", "assignment") ?>:</B></P></TD>
     <td>
-        <textarea name="description" rows=15 cols=30 wrap="virtual"><? p($form->description) ?></textarea>
+    <? 
+       print_textarea($usehtmleditor, 20, 60, 595, 400, "description", $form->description);
+    
+       if ($usehtmleditor) { 
+           helpbutton("richtext", get_string("helprichtext"));
+       } else { 
+           helpbutton("text", get_string("helptext"));
+       }
+       echo "<P>";
+       print_string("formattexttype");
+       echo ":&nbsp;";
+       if (!$form->format) {
+           $form->format = $defaultformat;
+       }
+       choose_from_menu(format_text_menu(), "format", $form->format, ""); 
+       echo "</P>";
+    ?>
     </td>
 </tr>
 <tr valign=top>
@@ -57,6 +83,7 @@
     ?></td>
 </tr>
 </table>
+<BR>
 <CENTER>
 <input type="hidden" name=course     value="<? p($form->course) ?>">
 <input type="hidden" name=coursemodule  value="<? p($form->coursemodule) ?>">
 <input type="submit" name=cancel value="<? print_string("cancel") ?>">
 </CENTER>
 </FORM>
+
+<? 
+   if ($usehtmleditor) { 
+       print_richedit_javascript("form", "description", "no");
+   }
+?>
+
index 8571ceb30d0dc57df3ef822af68a5791d6243054..67f92314af2f9167d57bf810838c5364d6f0f50d 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2002082806;
+$module->version  = 2002101606;
 $module->cron     = 60;
 
 ?>
index 32b22cbc539c8998e380b3708148424b3b195860..05e04c2a5d3d8389d1171e1b461a3f33b211381d 100644 (file)
@@ -66,7 +66,7 @@
     echo "<B>".get_string("maximumgrade")."</B>: $assignment->grade<BR>";
     print_simple_box_end();
     echo "<BR>";
-    echo text_to_html($assignment->description);
+    echo format_text($assignment->description, $assignment->format);
     print_simple_box_end();
     echo "<BR>";