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

www www at source.lon-capa.org
Wed Jan 4 14:27:04 EST 2012


www		Wed Jan  4 19:27:04 2012 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  Work towards bugs #2174 and #6543
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.318 loncom/interface/lonfeedback.pm:1.319
--- loncom/interface/lonfeedback.pm:1.318	Wed Jan  4 18:23:38 2012
+++ loncom/interface/lonfeedback.pm	Wed Jan  4 19:27:04 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.318 2012/01/04 18:23:38 www Exp $
+# $Id: lonfeedback.pm,v 1.319 2012/01/04 19:27:04 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2791,7 +2791,7 @@
 # There are two entries within the framework of a course:
 # - the URLs for which feedback was provided
 # - the total number of contributions
-    my %record=&Apache::lonnet::restore('_feedback');
+    my %record=&getdiscrecords();
     my ($temp)=keys(%record);
     unless ($temp=~/^error\:/) {
 	my %newrecord=();
@@ -2813,9 +2813,58 @@
     unless ($udom)  { $udom=$env{'user.domain'}; }
     unless ($course) { $course=$env{'request.course.id'}; }
     my %record=&Apache::lonnet::restore('_feedback',$course,$udom,$uname);
-   return %record;
+    return %record;
 }
 
+# Routine to get discussion statistics
+
+sub getdiscstats {
+    my %record=&getdiscrecords(@_);
+    my $subnumber=$record{'subnumber'};
+    my $points=0;
+    my $likes=0;
+    foreach my $key (keys(%record)) {
+        if ($key=~/^\d+\:points$/) {
+            $points+=$record{$key};
+        }
+        if ($key=~/^\d+\:likes$/) {
+            $likes+=$record{$key};
+        }
+    }
+    return ($subnumber,$points,$likes);
+}
+
+# Store discussion credit
+
+sub storediscpoints {
+    my ($points,$uname,$udom,$course)=@_;
+    unless ($points) { $points=0; }
+    unless ($uname) { $uname=$env{'user.name'}; }
+    unless ($udom)  { $udom=$env{'user.domain'}; }
+    unless ($course) { $course=$env{'request.course.id'}; }
+    my %record=('grader_user'   => $env{'user.name'},
+                'grader_domain' => $env{'user.domain'},
+                'points' => $points);
+    return &Apache::lonnet::cstore(\%record,'_feedback');
+}
+
+# Store discussion "likes"
+
+sub storedisclikes {
+    my ($likes,$uname,$udom,$course)=@_;
+    unless ($likes) { $likes=0; }
+    if ($likes>0) { $likes=1; }
+    if ($likes<0) { $likes=-1; }
+    unless ($uname) { $uname=$env{'user.name'}; }
+    unless ($udom)  { $udom=$env{'user.domain'}; }
+    unless ($course) { $course=$env{'request.course.id'}; }
+    my %record=('likes_user'   => $env{'user.name'},
+                'likes_domain' => $env{'user.domain'},
+                'likes' => $likes);
+    return &Apache::lonnet::cstore(\%record,'_feedback');
+}
+
+
 sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject,$group)=@_;
     my $status='';




More information about the LON-CAPA-cvs mailing list