From: moodler Date: Thu, 1 Jan 2004 04:48:55 +0000 (+0000) Subject: New option to allow students to see aggregate ratings on other posts (anonymous) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3bd98ad4bcbb97b4b2fb1ab767fe42174c9bace7;p=moodle.git New option to allow students to see aggregate ratings on other posts (anonymous) --- diff --git a/mod/forum/backuplib.php b/mod/forum/backuplib.php index c7945844f0..e096a39141 100644 --- a/mod/forum/backuplib.php +++ b/mod/forum/backuplib.php @@ -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)); diff --git a/mod/forum/db/mysql.php b/mod/forum/db/mysql.php index 8f51b7a0ab..14ed763964 100644 --- a/mod/forum/db/mysql.php +++ b/mod/forum/db/mysql.php @@ -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; diff --git a/mod/forum/db/mysql.sql b/mod/forum/db/mysql.sql index ac03778360..8729497d8f 100644 --- a/mod/forum/db/mysql.sql +++ b/mod/forum/db/mysql.sql @@ -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', diff --git a/mod/forum/db/postgres7.php b/mod/forum/db/postgres7.php index 149b8af391..b5a92de5e8 100644 --- a/mod/forum/db/postgres7.php +++ b/mod/forum/db/postgres7.php @@ -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; } diff --git a/mod/forum/db/postgres7.sql b/mod/forum/db/postgres7.sql index c77bffccef..ed6308938b 100644 --- a/mod/forum/db/postgres7.sql +++ b/mod/forum/db/postgres7.sql @@ -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', diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 340bfff797..edffc746a5 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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 "id\">"; @@ -1128,7 +1129,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link echo "$post->subject
"; echo ""; - $fullname = fullname($post, isteacher($courseid)); + $fullname = fullname($post, $isteacher); $by->name = "wwwroot/user/view.php?id=$post->userid&course=$courseid\">$fullname"; $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 "wwwroot/mod/forum/post.php?edit=$post->id\">$stredit | "; } } - if ($ownpost or isteacher($courseid)) { + if ($ownpost or $isteacher) { echo "wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete"; 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 "
"; echo "id\">"; } diff --git a/mod/forum/mod.html b/mod/forum/mod.html index 51586ce959..268109d096 100644 --- a/mod/forum/mod.html +++ b/mod/forum/mod.html @@ -12,10 +12,13 @@ $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; @@ -112,9 +115,10 @@ "; 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 ""; echo "assessed, ""); echo "
"; + 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 "
"; + echo get_string("grade").":"; print_grade_menu($course->id, "scale", $form->scale, false); echo "
"; @@ -159,6 +170,7 @@ echo ""; echo ""; echo ""; + echo ""; echo ""; echo ""; echo ""; diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index 5ba94f3df5..8632378eb6 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -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']['#']); diff --git a/mod/forum/version.php b/mod/forum/version.php index 8fab844995..af0a26b036 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2003100600; +$module->version = 2004010100; $module->cron = 60; ?>