]> git.mjollnir.org Git - moodle.git/commitdiff
New mini-feature. When choosing ratings in a forum, one can now
authormoodler <moodler>
Mon, 25 Aug 2003 07:39:06 +0000 (07:39 +0000)
committermoodler <moodler>
Mon, 25 Aug 2003 07:39:06 +0000 (07:39 +0000)
specify a range of dates.  Only posts within this range can be rated.
If the range isn't specified then all posts can be rated.

lang/en/forum.php
mod/forum/backuplib.php
mod/forum/db/mysql.php
mod/forum/db/mysql.sql
mod/forum/db/postgres7.php
mod/forum/db/postgres7.sql
mod/forum/lib.php
mod/forum/mod.html
mod/forum/restorelib.php
mod/forum/version.php

index 65a61f0c4af73d5fd65057e64db394b72408fc94..05b3e6ba0a4c1bee0898bb4912f55131f9e50271 100644 (file)
@@ -98,6 +98,7 @@ $string['ratingonlyteachers'] = "Only \$a can rate posts";
 $string['rating'] = "Rating";
 $string['ratings'] = "Ratings";
 $string['ratingssaved'] = "Ratings saved";
+$string['ratingtime'] = "Restrict ratings to posts with dates in this range:";
 $string['re'] = "Re:";    // Put in front of subjects that are replies to another post
 $string['readtherest'] = "Read the rest of this topic";
 $string['replies'] = "Replies";
index 6975fff10ef374c1e2f248d23980f5f1eda604ec..055bab1ca8a4e4ce9343bc25298b8a2fe6d0c80a 100644 (file)
@@ -51,6 +51,8 @@
                 fwrite ($bf,full_tag("INTRO",4,false,$forum->intro));
                 fwrite ($bf,full_tag("OPEN",4,false,$forum->open));
                 fwrite ($bf,full_tag("ASSESSED",4,false,$forum->assessed));
+                fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
+                fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
                 fwrite ($bf,full_tag("SCALE",4,false,$forum->scale));
                 fwrite ($bf,full_tag("FORCESUBSCRIBE",4,false,$forum->forcesubscribe));
                 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$forum->timemodified));
index bb7a3186e90c2b63e9e1f43399c807d07bbc8fd9..18725af12fbd83142a052f615b939b4ef79d9f71 100644 (file)
@@ -65,6 +65,11 @@ function forum_upgrade($oldversion) {
   if ($oldversion < 2003081403) {
       table_column("forum", "assessed", "assessed", "integer", "10", "unsigned", "0");
   }
+
+  if ($oldversion < 2003082500) {
+      table_column("forum", "", "assesstimestart", "integer", "10", "unsigned", "0", "", "assessed");
+      table_column("forum", "", "assesstimefinish", "integer", "10", "unsigned", "0", "", "assesstimestart");
+  }
   
   return true;
 
index 730cf625c412cfdd549eb98eec988defe90f4a9c..e1a61200866e6c6dc3441800b01c089738ea842f 100644 (file)
@@ -10,6 +10,8 @@ CREATE TABLE prefix_forum (
   intro text NOT NULL,
   open tinyint(2) unsigned NOT NULL default '2',
   assessed int(10) unsigned NOT NULL default '0',
+  assesstimestart int(10) unsigned NOT NULL default '0',
+  assesstimefinish int(10) unsigned NOT NULL default '0',
   scale int(10) unsigned NOT NULL default '0',
   forcesubscribe tinyint(1) unsigned NOT NULL default '0',
   timemodified int(10) unsigned NOT NULL default '0',
index 997ec5dbb642a74b4e4289a5ae7ea33ee63ed31d..81603528219c72cbc43c59a09b883b3cea610042 100644 (file)
@@ -10,6 +10,10 @@ function forum_upgrade($oldversion) {
       execute_sql("INSERT INTO {$CFG->prefix}log_display VALUES ('forum', 'move discussion', 'forum_discussions', 'name')");
   }
 
+  if ($oldversion < 2003082500) {
+      table_column("forum", "", "assesstimestart", "integer", "10", "unsigned", "0", "", "assessed");
+      table_column("forum", "", "assesstimefinish", "integer", "10", "unsigned", "0", "", "assesstimestart");
+  }
 
   return true;
 
index 1cfad41b887dc54862349bae478fcedb2ee11eb9..7ac576c5284c3c0011d376de890e75b32fab75b9 100644 (file)
@@ -10,6 +10,8 @@ CREATE TABLE prefix_forum (
   intro text NOT NULL default '',
   open integer NOT NULL default '2',
   assessed integer NOT NULL default '0',
+  assesstimestart integer NOT NULL default '0',
+  assesstimefinish integer NOT NULL default '0',
   scale integer NOT NULL default '0',
   forcesubscribe integer NOT NULL default '0',
   timemodified integer NOT NULL default '0'
index 61ce4fcd2e9b0c6ffd67afa887606fcf7d434957..1622b8b67076270df0ab15a5569265553a4c07af 100644 (file)
@@ -51,8 +51,17 @@ function forum_add_instance($forum) {
         return false;
     }
 
-    if ($forum->type == "single") {  // Create related discussion.
+    if (!empty($forum->ratingtime)) {
+        $forum->assesstimestart  = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday, 
+                                                  $forum->starthour, $forum->startminute, 0);
+        $forum->assesstimefinish = make_timestamp($forum->finishyear, $forum->finishmonth, $forum->finishday, 
+                                                  $forum->finishhour, $forum->finishminute, 0);
+    } else {
+        $forum->assesstimestart  = 0;
+        $forum->assesstimefinish = 0;
+    }
 
+    if ($forum->type == "single") {  // Create related discussion.
         $discussion->course   = $forum->course;
         $discussion->forum    = $forum->id;
         $discussion->name     = $forum->name;
@@ -77,6 +86,16 @@ function forum_update_instance($forum) {
     $forum->timemodified = time();
     $forum->id = $forum->instance;
 
+    if (!empty($forum->ratingtime)) {
+        $forum->assesstimestart  = make_timestamp($forum->startyear, $forum->startmonth, $forum->startday, 
+                                                  $forum->starthour, $forum->startminute, 0);
+        $forum->assesstimefinish = make_timestamp($forum->finishyear, $forum->finishmonth, $forum->finishday, 
+                                                  $forum->finishhour, $forum->finishminute, 0);
+    } else {
+        $forum->assesstimestart  = 0;
+        $forum->assesstimefinish = 0;
+    }
+
     if ($forum->type == "single") {  // Update related discussion and post.
         if (! $discussion = get_record("forum_discussions", "forum", $forum->id)) {
             if ($discussions = get_records("forum_discussions", "forum", $forum->id, "timemodified ASC")) {
@@ -968,7 +987,8 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
 }
 
 
-function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $ratings=NULL, $footer="", $highlight="") {
+function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link=false, 
+                          $ratings=NULL, $footer="", $highlight="") {
     global $THEME, $USER, $CFG;
 
     echo "<a name=\"$post->id\"></a>";
@@ -1049,15 +1069,23 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
 
     echo "<div align=right><p align=right>";
     if (!empty($ratings) and !empty($USER->id)) {
-        if (isteacher($courseid)) {
-            forum_print_ratings_mean($post->id, $ratings->scale);
-            if ($USER->id != $post->userid) {
-                 forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
+        $useratings = true;
+        if ($ratings->assesstimestart and $ratings->assesstimefinish) {
+            if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) {
+                $useratings = false;
+            }
+        }
+        if ($useratings) {
+            if (isteacher($courseid)) {
+                forum_print_ratings_mean($post->id, $ratings->scale);
+                if ($USER->id != $post->userid) {
+                     forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
+                }
+            } else if ($USER->id == $post->userid) {
+                forum_print_ratings_mean($post->id, $ratings->scale);
+            } else if (!empty($ratings->allow) ) {
+                forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
             }
-        } else if ($USER->id == $post->userid) {
-            forum_print_ratings_mean($post->id, $ratings->scale);
-        } else if (!empty($ratings->allow) ) {
-            forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
         }
     }
     
@@ -1913,6 +1941,8 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) {
     if ($forum->assessed and !empty($USER->id)) {
         if ($scale = get_record("scale", "id", $forum->scale)) {
             $ratings->scale = make_menu_from_list($scale->scale);
+            $ratings->assesstimestart = $forum->assesstimestart;
+            $ratings->assesstimefinish = $forum->assesstimefinish;
             if ($forum->assessed == 2 and !isteacher($course->id)) {
                 $ratings->allow = false;
             } else {
index 3d3cc7fed7696c02ecbe8f101e379136bd5ad9f0..7c10a3d1d44b39250d307931036fddd7ecdce80e 100644 (file)
             helpbutton("ratings", get_string("allowratings", "forum"), "forum");
             echo "<br />";
             print_scale_menu($course->id, "scale", $form->scale);
+            echo "<br />";
+            echo "<script>";
+            echo "  var subitems = ['startday','startmonth','startyear','starthour', 'startminute',".
+                                   "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
+            echo "</script>";
+            echo "<input name=\"ratingtime\" type=checkbox value=1 ";
+            echo " onclick=\"return lockoptions('form','ratingtime', subitems)\" ";
+            if ($form->assesstimestart and $form->assesstimefinish and $form->assessed) {
+                $form->ratingtime = 1;
+                echo " checked ";
+            }
+            echo ">";
+            print_string("ratingtime", "forum");
+            echo "<table align=left><tr><td align=right nowrap>";
+            echo get_string("from").":";
+            print_date_selector("startday", "startmonth", "startyear", $form->assesstimestart);
+            print_time_selector("starthour", "startminute", $form->assesstimestart);
+            echo "<br />";
+            echo get_string("to").":";
+            print_date_selector("finishday", "finishmonth", "finishyear", $form->assesstimefinish);
+            print_time_selector("finishhour", "finishminute", $form->assesstimefinish);
+            echo "<br />";
+            echo "</td></tr></table>";
+            echo "<input type=\"hidden\" name=\"hstartday\" value=0>";
+            echo "<input type=\"hidden\" name=\"hstartmonth\" value=0>";
+            echo "<input type=\"hidden\" name=\"hstartyear\" value=0>";
+            echo "<input type=\"hidden\" name=\"hstarthour\" value=0>";
+            echo "<input type=\"hidden\" name=\"hstartminute\" value=0>";
+            echo "<input type=\"hidden\" name=\"hfinishday\" value=0>";
+            echo "<input type=\"hidden\" name=\"hfinishmonth\" value=0>";
+            echo "<input type=\"hidden\" name=\"hfinishyear\" value=0>";
+            echo "<input type=\"hidden\" name=\"hfinishhour\" value=0>";
+            echo "<input type=\"hidden\" name=\"hfinishminute\" value=0>";
+
+            if (empty($form->ratingtime)) {
+                echo "<script>";
+                echo "lockoptions('form','ratingtime', subitems);";
+                echo "</script>";
+            }
         ?>
     </td>
 </tr>
index d65495612a680d5a4f1b00824b159bc5c8b12a5d..0712389e839d45a75bf116d496fe86c7c78dfe8a 100644 (file)
@@ -54,6 +54,8 @@
             $forum->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
             $forum->open = backup_todb($info['MOD']['#']['OPEN']['0']['#']);
             $forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
+            $forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
+            $forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
             $forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
             $forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']);
             $forum->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
index 1521d4267916d1c5d3e979d310eaa1fe9b884940..f35a99a5d0f2b16ddef351fe4ce96c8727762d9e 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003081403;
+$module->version  = 2003082500;
 $module->cron     = 60;
 
 ?>