version 1.324, 2012/01/06 18:17:44
|
version 1.325, 2012/01/06 19:18:11
|
Line 975 sub build_posting_display {
|
Line 975 sub build_posting_display {
|
($skiptest,$roleregexp,$secregexp,$statusregexp) = |
($skiptest,$roleregexp,$secregexp,$statusregexp) = |
&filter_regexp($rolefilter,$sectionpick,$statusfilter); |
&filter_regexp($rolefilter,$sectionpick,$statusfilter); |
$rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp; |
$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 |
|
# &Apache::lonnet::logthis(join(',',@theselikes)." Ave $ave StdDev $stddev"); |
|
# |
|
# This is now the real loop. Go through all entries, pick up what we need |
|
# |
for (my $id=1;$id<=$contrib{'version'};$id++) { |
for (my $id=1;$id<=$contrib{'version'};$id++) { |
my $idx=$id; |
my $idx=$id; |
next if ($contrib{$idx.':deleted'}); |
next if ($contrib{$idx.':deleted'}); |
Line 1116 sub build_posting_display {
|
Line 1146 sub build_posting_display {
|
$sender.=' '.&discussion_link($symb,&mt('Unlike'),'unlike',$idx,$$newpostsflag,$prevread,&group_args($group)); |
$sender.=' '.&discussion_link($symb,&mt('Unlike'),'unlike',$idx,$$newpostsflag,$prevread,&group_args($group)); |
} |
} |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
my $thislikes=$likes{$symb.':'.$idx.':likes'}; |
push(@theselikes,$thislikes); |
|
if ($thislikes>0) { |
if ($thislikes>0) { |
$sender.=' ('.&mt("[_1] likes",$thislikes).')'; |
$sender.=' ('.&mt("[_1] likes",$thislikes).')'; |
} elsif ($thislikes<0) { |
} elsif ($thislikes<0) { |
Line 1334 sub build_posting_display {
|
Line 1363 sub build_posting_display {
|
} |
} |
# end of the loop over all discussion entries |
# end of the loop over all discussion entries |
} |
} |
# Figure out average likes and standard deviation if there are enough discussions to warrant that |
# end of "if there actually are any discussions |
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 subroutine "build_posting_display" |
# end of subroutine "build_posting_display" |
} |
} |