+$lt{'title'}:
ENDDISCUSS
if ($env{'form.origpage'}) {
@@ -975,7 +987,42 @@ sub build_posting_display {
($skiptest,$roleregexp,$secregexp,$statusregexp) =
&filter_regexp($rolefilter,$sectionpick,$statusfilter);
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
- }
+ }
+# We need to go through this twice, first to get the likes/dislikes, then to actually build the display
+ for (my $id=1;$id<=$contrib{'version'};$id++) {
+ my $idx=$id;
+ next if ($contrib{$idx.':deleted'});
+ next if ($contrib{$idx.':hidden'});
+ unless ((($hiddens{$idx}) && (!$seeid)) || ($deletions{$idx}) || (!$contrib{$idx.':message'})) {
+ push(@theselikes,$likes{$symb.':'.$idx.':likes'});
+ }
+ }
+# Figure out average likes and standard deviation if there are enough discussions to warrant that
+ my $ave=0;
+ my $stddev=10000;
+ if ($#theselikes>1) {
+ my $sum=0;
+ my $num=$#theselikes+1;
+ foreach my $thislike (@theselikes) {
+ $sum+=$thislike;
+ }
+ $ave=$sum/$num;
+ my $sumsq=0;
+ foreach my $thislike (@theselikes) {
+ $sumsq+=($thislike-$ave)*($thislike-$ave);
+ }
+ $stddev=sqrt($sumsq/$num);
+ }
+# Now we know the average likes $ave and the standard deviation $stddev
+# Get the boundaries for markup
+ my $oneplus=$ave+$stddev;
+ my $twoplus=$ave+2.*$stddev;
+ my $oneminus=$ave-$stddev;
+ my $twominus=$ave-2.*$stddev;
+# &Apache::lonnet::logthis(join(',',@theselikes)." Ave $ave StdDev $stddev $twominus $oneminus $oneplus $twoplus");
+#
+# This is now the real loop. Go through all entries, pick up what we need
+#
for (my $id=1;$id<=$contrib{'version'};$id++) {
my $idx=$id;
next if ($contrib{$idx.':deleted'});
@@ -1116,7 +1163,6 @@ sub build_posting_display {
$sender.=' '.&discussion_link($symb,&mt('Unlike'),'unlike',$idx,$$newpostsflag,$prevread,&group_args($group));
}
my $thislikes=$likes{$symb.':'.$idx.':likes'};
- push(@theselikes,$thislikes);
if ($thislikes>0) {
$sender.=' ('.&mt("[_1] likes",$thislikes).')';
} elsif ($thislikes<0) {
@@ -1304,8 +1350,23 @@ sub build_posting_display {
if ($$dischash{$toggkey}) {
$$discussionitems[$idx].=' '.$ctlink;
}
+# Figure out size based on likes
+ my $thislikes=$likes{$symb.':'.$idx.':likes'};
+ my $likesize="100";
+ if ($thislikes>$twoplus) {
+ $likesize="200";
+ } elsif ($thislikes>$oneplus) {
+ $likesize="150";
+ }
+ if ($thislikes<$twominus) {
+ $likesize="50";
+ } elsif ($thislikes<$oneminus) {
+ $likesize="75";
+ }
$$discussionitems[$idx].= '
'.
- $message.'
';
+ "
".
+ $message.
+ '
';
if ($contrib{$idx.':history'}) {
my @postversions = ();
$$discussionitems[$idx] .= &mt('This post has been edited by the author.');
@@ -1334,22 +1395,7 @@ sub build_posting_display {
}
# end of the loop over all discussion entries
}
-# Figure out average likes and standard deviation if there are enough discussions to warrant that
- if ($#theselikes>1) {
- my $sum=0;
- my $num=$#theselikes+1;
- foreach my $thislike (@theselikes) {
- $sum.=$thislike;
- }
- my $ave=$sum/$num;
- my $sumsq=0;
- foreach my $thislike (@theselikes) {
- $sumsq+=($thislike-$ave)*($thislike-$ave);
- }
- my $stddev=sqrt($sumsq/$num);
-# &Apache::lonnet::logthis(join(',',@theselikes)." Ave $ave StdDev $stddev");
- }
-# end of "if there actually are any discussion
+# end of "if there actually are any discussions
}
# end of subroutine "build_posting_display"
}
@@ -2679,8 +2725,8 @@ sub screen_header {
unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {
$msgoptions=
- '';
+ ' ';
}
my %optionhash=();
foreach my $type ('question','comment','policy') {
@@ -2688,20 +2734,20 @@ sub screen_header {
}
if (&feedback_available(1)) {
$msgoptions.=
- '';
+ ' ';
}
if (&feedback_available(0,1)) {
$msgoptions.=
- '';
+ ' ';
}
if (&feedback_available(0,0,1)) {
$msgoptions.=
- '