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

www www@source.lon-capa.org
Sun, 20 Feb 2011 20:57:47 -0000


www		Sun Feb 20 20:57:47 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Create a new category
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.66 loncom/interface/lonquickgrades.pm:1.67
--- loncom/interface/lonquickgrades.pm:1.66	Mon Feb  7 19:16:34 2011
+++ loncom/interface/lonquickgrades.pm	Sun Feb 20 20:57:46 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.66 2011/02/07 19:16:34 www Exp $
+# $Id: lonquickgrades.pm,v 1.67 2011/02/20 20:57:46 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -173,8 +173,6 @@
 
     my ($showPoints,$uname,$udom)=@_;
 
-    &Apache::lonnet::logthis("About to call with $uname $udom");
-
     # Create the nav map
     my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom);
 
@@ -431,6 +429,7 @@
 # Process the changes
         %categories=&process_category_edits($r,$cangrade,%categories);
 # Actually store
+#        &Apache::lonnet::logthis("Storing ".$categories{'order'});
         &Apache::lonnet::put('grading_categories',\%categories,$cdom,$cnum);
     }
 # new categories loaded now
@@ -454,6 +453,10 @@
 sub process_category_edits {
     my ($r,$cangrade,%categories)=@_;
     unless ($cangrade) { return %categories; }
+    my $cmd=$env{'form.cmd'};
+    if ($cmd eq 'createnewcat') {
+       %categories=&make_new_category($r,$cangrade,undef,%categories);
+    } 
 #
 # Business logic here
 #
@@ -467,21 +470,21 @@
 sub output_category_table {
     my ($r,$cangrade,$navmaps,%categories)=@_;
     my $sum=0;
+    my $total=0;
     $r->print(&Apache::loncommon::start_data_table());
 #
     &output_category_table_header($r,$cangrade);
 #
     my @order=split(/\,/,$categories{'order'});
 #
-# FIXME: Debug only
-    @order=('3131_4123_42124','4124_34231_3412');
-#
     my $maxpos=$#order;
     for (my $i=0;$i<=$maxpos;$i++) {
         my ($value,$weight)=&output_and_calc_category($r,$cangrade,$navmaps,$order[$i],$i,$maxpos,%categories);
+        $sum+=$value*$weight;
+        $total+=$weight;
     }
 #
-    &bottom_line_category($r,$cangrade);
+    &bottom_line_category($r,$cangrade,$sum,$total);
 #
     $r->print(&Apache::loncommon::end_data_table());
     return $sum;
@@ -551,7 +554,12 @@
 #
 
 sub bottom_line_category {
-    my ($r,$cangrade)=@_;
+    my ($r,$cangrade,$sum,$total)=@_;
+    $r->print(&Apache::loncommon::start_data_table_row());
+    if ($cangrade) {
+        $r->print('<td colspan="3"><a href="/adm/quickgrades?cmd=createnewcat&storechanges=1">'.&mt('Create New Category').'</a></td>');
+    }
+    $r->print('<td colspan="5">'.&mt('Current:').$sum.'<br />'.&mt('Total:').$total.'<br /></td>');
 }
 
 #