[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm doc/loncapafiles loncapafiles.lpml

www www at source.lon-capa.org
Tue Jan 10 09:52:57 EST 2012


www		Tue Jan 10 14:52:57 2012 EDT

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/interface	lonfeedback.pm 
  Log:
  Bug #6545: discussion "karma"
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.780 doc/loncapafiles/loncapafiles.lpml:1.781
--- doc/loncapafiles/loncapafiles.lpml:1.780	Mon Jan  9 19:56:12 2012
+++ doc/loncapafiles/loncapafiles.lpml	Tue Jan 10 14:52:49 2012
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.780 2012/01/09 19:56:12 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.781 2012/01/10 14:52:49 www Exp $ -->
 
 <!--
 
@@ -7031,6 +7031,7 @@
 qempty.gif;
 show-all.gif;
 show-incomplete-problems.gif;
+star.gif;
 </filenames>
 </fileglob>
 <fileglob>
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.332 loncom/interface/lonfeedback.pm:1.333
--- loncom/interface/lonfeedback.pm:1.332	Tue Jan 10 01:06:26 2012
+++ loncom/interface/lonfeedback.pm	Tue Jan 10 14:52:57 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.332 2012/01/10 01:06:26 www Exp $
+# $Id: lonfeedback.pm,v 1.333 2012/01/10 14:52:57 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1019,7 +1019,6 @@
         my $twoplus=$ave+2.*$stddev;
         my $oneminus=$ave-$stddev;
         my $twominus=$ave-2.*$stddev;
-#            &Apache::lonnet::logthis(join(',', at theselikes)." Ave $ave StdDev $stddev $twominus $oneminus $oneplus $twoplus");
 #
 # This is now the real loop. Go through all entries, pick up what we need
 # 
@@ -1156,6 +1155,10 @@
                                 @{$$namesort{$lastname}{$firstname}} = ("$idx");
                             }
                             if ($outputtarget ne 'tex') {
+                                my $karma=&userkarma($contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'});
+                                for (my $i=1;$i<=$karma;$i++) {
+                                    $sender.='<img border="0" src="/res/adm/pages/star.gif" alt="'.&mt('Contributor Kudos').'" />';
+                                }
                                 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 this posting"));
                                 }
@@ -3065,6 +3068,7 @@
        $newrecord{'subnumber'}=$record{'subnumber'}+1;
        $status.='<br />'.&mt('Registering').': '.
                &Apache::lonnet::cstore(\%newrecord,'_discussion');
+       &updatekarma();
     }
     } else {
 	$status.='Failed.';
@@ -3112,6 +3116,27 @@
     unless ($udom)  { $udom=$env{'user.domain'}; }
     unless ($course) { $course=$env{'request.course.id'}; }
     my $karma=&calcdiscussionkarma($uname,$udom,$course);
+    &Apache::lonnet::cstore({ 'karma' => $karma },'_discussion',$course,$udom,$uname);
+    &Apache::lonnet::do_cache_new('karma',$uname.':'.$udom.':'.$course,$karma,3600);
+    return $karma;
+}
+
+# Retrieve karma
+
+sub userkarma {
+    my ($uname,$udom,$course)=@_;
+    unless ($uname) { $uname=$env{'user.name'}; }
+    unless ($udom)  { $udom=$env{'user.domain'}; }
+    unless ($course) { $course=$env{'request.course.id'}; }
+    my $hashkey=$uname.':'.$udom.':'.$course;
+    my ($karma,$cached)=&Apache::lonnet::is_cached_new('karma',$hashkey);
+    if ($cached) {
+        return $karma;
+    }
+    my %userdisc=&getdiscussionrecords($uname,$udom,$course);
+    $karma=$userdisc{'karma'};
+    &Apache::lonnet::do_cache_new('karma',$hashkey,$karma,3600);
+    return $karma;
 }
 
 # Store discussion credit
@@ -3148,7 +3173,11 @@
                    'likes' => $likes,
                    'totallikes' => $totallikes,
                    'totalvotes' => $totalvotes);
-    return &Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
+    my $status=&Apache::lonnet::cstore(\%newrecord,'_discussion',$course,$udom,$uname);
+    if ($status eq 'ok') {
+        &updatekarma($uname,$udom,$course);
+    }
+    return $status;
 }
 
 sub get_discussion_info {




More information about the LON-CAPA-cvs mailing list