[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm
www
www at source.lon-capa.org
Mon Jan 9 19:54:05 EST 2012
www Tue Jan 10 00:54:05 2012 EDT
Modified files:
/loncom/interface lonfeedback.pm
Log:
Work on Bug #6545
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.330 loncom/interface/lonfeedback.pm:1.331
--- loncom/interface/lonfeedback.pm:1.330 Mon Jan 9 19:56:28 2012
+++ loncom/interface/lonfeedback.pm Tue Jan 10 00:54:05 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.330 2012/01/09 19:56:28 www Exp $
+# $Id: lonfeedback.pm,v 1.331 2012/01/10 00:54:05 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1157,10 +1157,10 @@
}
if ($outputtarget ne 'tex') {
unless ($likes{$symb.':'.$idx.':likers'}=~/\,\Q$thisuser\E\,/) {
- $sender.=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like"));
+ $sender.=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsup.png" alt="'.&mt('Like').'" />','like',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Like this posting"));
}
unless ($likes{$symb.':'.$idx.':unlikers'}=~/\,\Q$thisuser\E\,/) {
- $sender.=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike"));
+ $sender.=' '.&discussion_link($symb,'<img border="0" src="/res/adm/pages/thumbsdown.png" alt="'.&mt('Unlike').'" />',,'unlike',$idx,$$newpostsflag,$prevread,&group_args($group),&mt("Unlike this posting"));
}
my $thislikes=$likes{$symb.':'.$idx.':likes'};
if ($thislikes>0) {
@@ -2935,7 +2935,7 @@
my %record=('grader_user' => $env{'user.name'},
'grader_domain' => $env{'user.domain'},
'points' => $points);
- return &Apache::lonnet::cstore(\%record,'_feedback');
+ return &Apache::lonnet::cstore(\%record,'_feedback',$course,$udom,$uname);
}
# Store feedback "likes"
@@ -2955,7 +2955,7 @@
'likes_domain' => $env{'user.domain'},
'likes' => $likes,
'totallikes' => $totallikes);
- return &Apache::lonnet::cstore(\%newrecord,'_feedback');
+ return &Apache::lonnet::cstore(\%newrecord,'_feedback',$course,$udom,$uname);
}
@@ -3088,9 +3088,31 @@
sub getdiscussionstats {
my %record=&getdiscussionrecords(@_);
- return ($record{'subnumber'},$record{'points'},$record{'totallikes'});
+ return ($record{'subnumber'},$record{'points'},$record{'totallikes'},$record{'totalvotes'});
+}
+
+# Calculate discussion karma
+
+sub calcdiscussionkarma {
+ my ($subs,$pts,$likes,$votes)=&getdiscussionstats(@_);
+ my $karma=0;
+ if ($votes>0) {
+ $karma=int(.1+5.*(1.-exp(-$subs/10.))*$likes/$votes);
+ if ($karma<0) { $karma=0; }
+ if ($karma>5) { $karma=5; }
+ }
+ return $karma;
}
+# Update karma
+
+sub updatekarma {
+ my ($uname,$udom,$course)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ unless ($course) { $course=$env{'request.course.id'}; }
+ my $karma=&calcdiscussionkarma($uname,$udom,$course);
+}
# Store discussion credit
@@ -3103,7 +3125,7 @@
my %record=('grader_user' => $env{'user.name'},
'grader_domain' => $env{'user.domain'},
'points' => $points);
- return &Apache::lonnet::cstore(\%record,'_discussion');
+ return &Apache::lonnet::cstore(\%record,'_discussion',$course,$udom,$uname);
}
# Store discussion "likes"
@@ -3118,12 +3140,15 @@
unless ($course) { $course=$env{'request.course.id'}; }
my %record=&getdiscussionrecords($uname,$udom,$course);
my $totallikes=$record{'totallikes'};
+ my $totalvotes=$record{'totalvotes'};
$totallikes+=$likes;
+ $totalvotes++;
my %newrecord=('likes_user' => $env{'user.name'},
'likes_domain' => $env{'user.domain'},
'likes' => $likes,
- 'totallikes' => $totallikes);
- return &Apache::lonnet::cstore(\%newrecord,'_discussion');
+ 'totallikes' => $totallikes,
+ 'totalvotes' => $totalvotes);
+ return &Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
}
sub get_discussion_info {
More information about the LON-CAPA-cvs
mailing list