[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm
www
www at source.lon-capa.org
Fri Jan 6 13:17:44 EST 2012
www Fri Jan 6 18:17:44 2012 EDT
Modified files:
/loncom/interface lonfeedback.pm
Log:
Work on like/unlike
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.323 loncom/interface/lonfeedback.pm:1.324
--- loncom/interface/lonfeedback.pm:1.323 Fri Jan 6 01:59:53 2012
+++ loncom/interface/lonfeedback.pm Fri Jan 6 18:17:44 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.323 2012/01/06 01:59:53 www Exp $
+# $Id: lonfeedback.pm,v 1.324 2012/01/06 18:17:44 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -941,6 +941,8 @@
$env{'course.'.$env{'request.course.id'}.'.num'},
'^'.$symb.':');
my $thisuser=$env{'user.name'}.':'.$env{'user.domain'};
+# Array with likes to figure out averages, etc.
+ my @theselikes=();
# Is the user allowed to see the real name behind anonymous postings?
my $see_anonymous =
&Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
@@ -962,7 +964,7 @@
$hidden =~ s/\.$//;
%hiddens = map { $_ => 1 } (split(/\.\./,$hidden));
}
-# Versions ...
+# Versions if store/restore are used to actually store the messages.
if ($contrib{'version'}) {
my $oldest = $contrib{'1:timestamp'};
if ($prevread eq '0') {
@@ -978,6 +980,8 @@
my $idx=$id;
next if ($contrib{$idx.':deleted'});
next if ($contrib{$idx.':hidden'});
+# If we get here, we are actually going to display the message - we don't know where and we don't know if we display
+# previous edits, but it counts as one entry
my $posttime = $contrib{$idx.':timestamp'};
if ($prevread <= $posttime) {
$$newpostsflag = 1;
@@ -1112,6 +1116,7 @@
$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) {
@@ -1319,12 +1324,34 @@
$$discussionitems[$idx] .= '<b>'.$version.'.</b> - '.&Apache::lonlocal::locallocaltime($postversions[$i]).' ';
}
}
+# end of unless ($$notshown ...)
}
+# end of if ($message) ...
}
+# end of the else-branch of target being export
}
+# end of unless hidden or deleted
}
+# 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(',', at theselikes)." Ave $ave StdDev $stddev");
+ }
+# end of "if there actually are any discussion
}
+# end of subroutine "build_posting_display"
}
sub filter_regexp {
More information about the LON-CAPA-cvs
mailing list