]> git.mjollnir.org Git - moodle.git/commitdiff
New option to allow students to see aggregate ratings on other posts (anonymous)
authormoodler <moodler>
Thu, 1 Jan 2004 04:48:55 +0000 (04:48 +0000)
committermoodler <moodler>
Thu, 1 Jan 2004 04:48:55 +0000 (04:48 +0000)
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 c7945844f0e7b5b29f24018310f17ef175fb1bab..e096a39141ffe86016b4d5fb94d66948c0bc866f 100644 (file)
@@ -51,6 +51,7 @@
                 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("ASSESSPUBLIC",4,false,$forum->assesspublic));
                 fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
                 fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
                 fwrite ($bf,full_tag("MAXBYTES",4,false,$forum->maxbytes));
index 8f51b7a0ab53771cdf50e0fef44200bf0ee37f3f..14ed763964659e623d32bf3a7a91523f258bed2a 100644 (file)
@@ -79,6 +79,10 @@ function forum_upgrade($oldversion) {
   if ($oldversion < 2003100600) {
       table_column("forum", "", "maxbytes", "integer", "10", "unsigned", "0", "", "scale");
   }
+
+  if ($oldversion < 2004010100) {
+      table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
+  }
   
   return true;
 
index ac037783606cfb5ef1ff6b98adc763aeeaf534c1..8729497d8f756e53c0e12448f24d2e16fb5d9b08 100644 (file)
@@ -10,6 +10,7 @@ CREATE TABLE prefix_forum (
   intro text NOT NULL,
   open tinyint(2) unsigned NOT NULL default '2',
   assessed int(10) unsigned NOT NULL default '0',
+  assesspublic int(4) unsigned NOT NULL default '0',
   assesstimestart int(10) unsigned NOT NULL default '0',
   assesstimefinish int(10) unsigned NOT NULL default '0',
   scale int(10) NOT NULL default '0',
index 149b8af39185e70fe2cad4dc817026c10ec67834..b5a92de5e8864aeaeb6e4ddad8d5009e5167064a 100644 (file)
@@ -23,6 +23,10 @@ function forum_upgrade($oldversion) {
       table_column("forum", "", "maxbytes", "integer", "10", "unsigned", "0", "", "scale");
   }
 
+  if ($oldversion < 2004010100) {
+      table_column("forum", "", "assesspublic", "integer", "4", "unsigned", "0", "", "assessed");
+  }
+
   return true;
 
 }
index c77bffccef3403cc045af62c52b95fbaad55bc74..ed6308938b5ecfbf52c4e832fcb7363aa6cf8703 100644 (file)
@@ -10,6 +10,7 @@ CREATE TABLE prefix_forum (
   intro text NOT NULL default '',
   open integer NOT NULL default '2',
   assessed integer NOT NULL default '0',
+  assesspublic integer NOT NULL default '0',
   assesstimestart integer NOT NULL default '0',
   assesstimefinish integer NOT NULL default '0',
   scale integer NOT NULL default '0',
index 340bfff7976e24d92d0f96ba1992ffcc955075a4..edffc746a5b179a72bf9444957e7a14235689bb0 100644 (file)
@@ -1098,7 +1098,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
 
     global $THEME, $USER, $CFG;
 
-    static $stredit, $strdelete, $strreply, $strparent, $threadedmode;
+    static $stredit, $strdelete, $strreply, $strparent, $threadedmode, $isteacher;
 
     if (empty($stredit)) {
         $stredit = get_string("edit", "forum");
@@ -1106,6 +1106,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
         $strreply = get_string("reply", "forum");
         $strparent = get_string("parent", "forum");
         $threadedmode = (!empty($USER->mode) and ($USER->mode == FORUM_MODE_THREADED));
+        $isteacher = isteacher($courseid);
     }
 
     echo "<a name=\"$post->id\"></a>";
@@ -1128,7 +1129,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
     echo "<font size=3><b>$post->subject</b></font><br \>";
     echo "<font size=2>";
 
-    $fullname = fullname($post, isteacher($courseid));
+    $fullname = fullname($post, $isteacher);
     $by->name = "<a href=\"$CFG->wwwroot/user/view.php?id=$post->userid&course=$courseid\">$fullname</a>";
     $by->date = userdate($post->modified);
     print_string("bynameondate", "forum", $by);
@@ -1185,7 +1186,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
             echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?edit=$post->id\">$stredit</a> | ";
         }
     }
-    if ($ownpost or isteacher($courseid)) {
+    if ($ownpost or $isteacher) {
         echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete</a>";
         if ($reply) {
             echo "| ";
@@ -1210,14 +1211,16 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
             }
         }
         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);
-                     $ratingsmenuused = true;
-                }
-            } else if ($USER->id == $post->userid) {
-                forum_print_ratings_mean($post->id, $ratings->scale);
+            $mypost = ($USER->id == $post->userid);
+
+            if (($isteacher or $ratings->assesspublic) and !$mypost) {
+                forum_print_ratings_mean($post->id, $ratings->scale, $isteacher);
+                forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
+                $ratingsmenuused = true;
+
+            } else if ($mypost) {
+                forum_print_ratings_mean($post->id, $ratings->scale, true);
+
             } else if (!empty($ratings->allow) ) {
                 forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
                 $ratingsmenuused = true;
@@ -1335,7 +1338,7 @@ function forum_shorten_post($message) {
 }
 
 
-function forum_print_ratings_mean($postid, $scale) {
+function forum_print_ratings_mean($postid, $scale, $link=true) {
 /// Print the multiple ratings on a post given to the current user by others.
 /// Scale is an array of ratings
 
@@ -1350,7 +1353,11 @@ function forum_print_ratings_mean($postid, $scale) {
         }
 
         echo "$strratings: ";
-        link_to_popup_window ("/mod/forum/report.php?id=$postid", "ratings", $mean, 400, 600);
+        if ($link) {
+            link_to_popup_window ("/mod/forum/report.php?id=$postid", "ratings", $mean, 400, 600);
+        } else {
+            echo "$mean ";
+        }
     }
 }
 
@@ -2089,19 +2096,17 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) {
     } else {
         $ownpost = false;
     }
-    $reply   = forum_user_can_post($forum);
+    $reply = forum_user_can_post($forum);
 
     $ratings = NULL;
     $ratingsmenuused = false;
     if ($forum->assessed and !empty($USER->id)) {
         if ($ratings->scale = make_grades_menu($forum->scale)) {
+            $ratings->assesspublic = $forum->assesspublic;
             $ratings->assesstimestart = $forum->assesstimestart;
             $ratings->assesstimefinish = $forum->assesstimefinish;
-            if ($forum->assessed == 2 and !isteacher($course->id)) {
-                $ratings->allow = false;
-            } else {
-                $ratings->allow = true;
-            }
+            $ratings->allow = ($forum->assessed != 2 or isteacher($course->id));
+
             echo "<form name=form method=post action=rate.php>";
             echo "<input type=hidden name=id value=\"$course->id\">";
         }
index 51586ce9597c25a8fe4b2321c52c1dca1f499e7b..268109d096a2ba4b0fbc93b8bd112db7408244f3 100644 (file)
         $form->open = 2;
     }
     if (!isset($form->assessed)) {
-        $form->assessed = "";
+        $form->assessed = 0;
+    }
+    if (!isset($form->assesspublic)) {
+        $form->assesspublic = 0;
     }
     if (!isset($form->forcesubscribe)) {
-        $form->forcesubscribe = "";
+        $form->forcesubscribe = 0;
     }
     if (!isset($form->maxbytes)) {
         $form->maxbytes = $CFG->forum_maxbytes;
         <?php 
             echo "<script>";
             echo "  var subitemstime = ['startday','startmonth','startyear','starthour', 'startminute',".
-                                   "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
-            echo "  var subitemsall = ['assessed', 'ratingtime', 'scale', 'startday','startmonth','startyear','starthour', 'startminute',".
-                                   "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
+                                       "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
+            echo "  var subitemsall = ['assessed', 'assesspublic', 'ratingtime', 'scale', ".
+                                      "'startday','startmonth','startyear','starthour', 'startminute',".
+                                      "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
             echo "</script>";
 
             echo "<input name=\"userating\" type=checkbox value=1 ";
             choose_from_menu($options, "assessed", $form->assessed, "");
             echo "<br />";
 
+            unset($options);
+            $options[0] = get_string("ratingpublicnot", "forum", $course->students);
+            $options[1] = get_string("ratingpublic", "forum", $course->students);
+            echo get_string("view").":";
+            choose_from_menu($options, "assesspublic", $form->assesspublic, "");
+            echo "<br />";
+
             echo get_string("grade").":";
             print_grade_menu($course->id, "scale", $form->scale, false);
             echo "<br />";
             echo "</td></tr></table>";
             echo "<input type=\"hidden\" name=\"hratingtime\" value=0>";
             echo "<input type=\"hidden\" name=\"hassessed\" value=0>";
+            echo "<input type=\"hidden\" name=\"hassesspublic\" value=0>";
             echo "<input type=\"hidden\" name=\"hscale\" value=0>";
             echo "<input type=\"hidden\" name=\"hstartday\" value=0>";
             echo "<input type=\"hidden\" name=\"hstartmonth\" value=0>";
index 5ba94f3df57c6238d7316c1db9c71c6e88faeefa..8632378eb6f52694bd6051b25c187f2aa53932e5 100644 (file)
@@ -54,6 +54,7 @@
             $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->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']);
             $forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
             $forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']);
             $forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
index 8fab844995d5ab5942280eb7fb9ed7153f67211d..af0a26b03697aa411998fef5dd9368f5d23a4b6c 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2003100600;
+$module->version  = 2004010100;
 $module->cron     = 60;
 
 ?>