[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface lonpreferences.pm

www lon-capa-cvs-allow@mail.lon-capa.org
Sun, 17 Jun 2007 02:11:57 -0000


www		Sat Jun 16 22:11:57 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
    /loncom/interface	lonpreferences.pm 
  Log:
  Clickers appear to be working
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.415 loncom/homework/grades.pm:1.416
--- loncom/homework/grades.pm:1.415	Sat Jun 16 19:00:09 2007
+++ loncom/homework/grades.pm	Sat Jun 16 22:11:44 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.415 2007/06/16 23:00:09 www Exp $
+# $Id: grades.pm,v 1.416 2007/06/17 02:11:44 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6453,7 +6453,13 @@
     my ($r)=@_;
     my ($symb)=&get_symb($r);
     if (!$symb) {return '';}
+# See which part we are saving to
+    my ($partlist,$handgrade,$responseType) = &response_type($symb);
+# FIXME: This should probably look for the first handgradeable part
+    my $part=$$partlist[0];
+# Start screen output
     my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
+
     my $heading=&mt('Assigning grades based on clicker file');
     $result.=(<<ENDHEADER);
 <br /><table width="100%" border="0"><tr><td bgcolor="#777777">
@@ -6493,6 +6499,7 @@
 # Start grading
     my $pcorrect=$env{'form.pcorrect'};
     my $pincorrect=$env{'form.pincorrect'};
+    my $storecount=0;
     foreach my $key (keys(%env)) {
        if ($key=~/^form\.student\:(.*)$/) {
           my $user=$1;
@@ -6511,12 +6518,26 @@
                 }
              }
           }
-          my $ave=$sum/$number;
-          $result.='<br />'.$user.' - '.$env{$key}.': '.$ave;
+          my $ave=$sum/(100*$number);
+# Store
+          my ($username,$domain)=split(/\:/,$user);
+          my %grades=();
+          $grades{"resource.$part.solved"}='correct_by_override';
+          $grades{"resource.$part.awarded"}=$ave;
+          $grades{"resource.regrader"}="$env{'user.name'}:$env{'user.domain'}";
+          my $returncode=&Apache::lonnet::cstore(\%grades,$symb,
+                                                 $env{'request.course.id'},
+                                                 $domain,$username);
+          if ($returncode ne 'ok') {
+             $result.="<br /><span class=\"LC_error\">Failed to save student $username:$domain. Message when trying to save was ($returncode)</span>";
+          } else {
+             $storecount++;
+          }
        }
     }
 # We are done
-    $result.='</td></tr></table>'."\n".
+    $result.='<br />'.&mt('Successfully stored grades for [_1] student(s).',$storecount).
+             '</td></tr></table>'."\n".
              '</td></tr></table><br /><br />'."\n";
     return $result.&show_grading_menu_form($symb);
 }
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.105 loncom/interface/lonpreferences.pm:1.106
--- loncom/interface/lonpreferences.pm:1.105	Sun May 20 17:10:53 2007
+++ loncom/interface/lonpreferences.pm	Sat Jun 16 22:11:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.105 2007/05/20 21:10:53 www Exp $
+# $Id: lonpreferences.pm,v 1.106 2007/06/17 02:11:57 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1801,21 +1801,21 @@
                       printmenu => 'yes',
                       }));
 
-#    push (@Options,({ action   => 'changeclicker',
-#                      linktext => 'Register Response Devices ("Clickers")',
-#                      href     => '/adm/preferences',
-#                      subroutine => \&clickerchanger,
-#                      breadcrumb =>
-#                          { href => '/adm/preferences?action=changeicons',
-#                            text => 'Register Clicker'},
-#                      },
-#                    { action   => 'verify_and_change_clicker',
-#                      subroutine => \&verify_and_change_clicker,
-#                      breadcrumb =>
-#                          { href => '/adm/preferences?action=changeclicker',
-#                            text => 'Register Clicker'},
-#                      printmenu => 'yes',
-#                      }));
+    push (@Options,({ action   => 'changeclicker',
+                      linktext => 'Register Response Devices ("Clickers")',
+                      href     => '/adm/preferences',
+                      subroutine => \&clickerchanger,
+                      breadcrumb =>
+                          { href => '/adm/preferences?action=changeicons',
+                            text => 'Register Clicker'},
+                      },
+                    { action   => 'verify_and_change_clicker',
+                      subroutine => \&verify_and_change_clicker,
+                      breadcrumb =>
+                          { href => '/adm/preferences?action=changeclicker',
+                            text => 'Register Clicker'},
+                      printmenu => 'yes',
+                      }));
 
 
     if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})