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

www www@source.lon-capa.org
Sat, 26 Mar 2011 20:04:15 -0000


www		Sat Mar 26 20:04:15 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Achieved points/percent
  - this finishes the editor, now need to display the calculations
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.80 loncom/interface/lonquickgrades.pm:1.81
--- loncom/interface/lonquickgrades.pm:1.80	Sat Mar 26 16:09:33 2011
+++ loncom/interface/lonquickgrades.pm	Sat Mar 26 20:04:15 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.80 2011/03/26 16:09:33 www Exp $
+# $Id: lonquickgrades.pm,v 1.81 2011/03/26 20:04:15 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -479,6 +479,7 @@
         %categories=&set_category_name($cangrade,$id,$env{'form.name_'.$id},%categories);
         %categories=&set_category_total($cangrade,$id,$env{'form.totaltype_'.$id},$env{'form.total_'.$id},%categories);
         %categories=&set_category_weight($cangrade,$id,$env{'form.weight_'.$id},%categories);
+        %categories=&set_category_displayachieved($cangrade,$id,$env{'form.displayachieved_'.$id},%categories);
 # Set values for category rules (before names may change)
         %categories=&set_category_rules($cangrade,$id,%categories);
     }
@@ -545,9 +546,10 @@
     }
     $r->print('<th>'.&mt('Category').'</th>'.
               '<th>'.&mt('Contents').'</th>'.
-              '<th>'.&mt('Calculation').'</th>'.
               '<th>'.&mt('Total Points').'</th>'.
-              '<th>'.&mt('Relative Weight').'</th>');
+              '<th>'.&mt('Calculation').'</th>'.
+              '<th>'.&mt('Relative Weight').'</th>'.
+              '<th>'.&mt('Achieved').'</th>');
     $r->print(&Apache::loncommon::end_data_table_header_row());
 }
 
@@ -612,6 +614,21 @@
                   &Apache::lonstathelpers::problem_selector('.',undef,1,1,'addcont_'.$id.'_',1,'this.form.cmd.value="addcont_'.$id.'";this.form.submit();'));
     }
     $r->print('</td>'); 
+
+# Total
+    if ($cangrade) {
+       $r->print('<td>'.
+                  '<select name="totaltype_'.$id.'">'.
+                  '<option value="default"'.($categories{$id.'_totaltype'} eq 'default'?' selected="selected"':'').'>'.&mt('default').'</option>'.
+                  '<option value="typein"'.($categories{$id.'_totaltype'} eq 'typein'?' selected="selected"':'').'>'.&mt('Type-in value').'</option>'.
+                  '</select>'.
+                  '<input type="text" size="4" name="total_'.$id.
+                  '" value="'.&Apache::lonhtmlcommon::entity_encode($categories{$id.'_total'}).'" /></td>');
+    } else {
+        $r->print('<td>'.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).'</td>');
+    }
+
+
 # Calculation
     $r->print('<td><ul>');
     foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) {
@@ -629,19 +646,6 @@
     }
     $r->print('</td>');
 
-
-# Total
-    if ($cangrade) {
-       $r->print('<td>'.
-                  '<select name="totaltype_'.$id.'">'.
-                  '<option value="default"'.($categories{$id.'_totaltype'} eq 'default'?' selected="selected"':'').'>'.&mt('default').'</option>'.
-                  '<option value="typein"'.($categories{$id.'_totaltype'} eq 'typein'?' selected="selected"':'').'>'.&mt('Type-in value').'</option>'.
-                  '</select>'.
-                  '<input type="text" size="4" name="total_'.$id.
-                  '" value="'.&Apache::lonhtmlcommon::entity_encode($categories{$id.'_total'}).'" /></td>');
-    } else {
-        $r->print('<td>'.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).'</td>');
-    }
 # Weight
     if ($cangrade) {
        $r->print('<td>'.
@@ -650,6 +654,21 @@
     } else {
         $r->print('<td>'.$categories{$id.'_weight'}.'</td>');
     }
+# Achieved
+    $r->print('<td>');
+    if ($cangrade) {
+        $r->print('<select name="displayachieved_'.$id.'">'.
+                  '<option value="percent"'.($categories{$id.'_displayachieved'} eq 'percent'?' selected="selected"':'').'>'.&mt('percent').'</option>'.
+                  '<option value="points"'.($categories{$id.'_displayachieved'} eq 'points'?' selected="selected"':'').'>'.&mt('points').'</option>'.
+                  '</select>');
+    } else {
+        if ($categories{$id.'_displayachieved'} eq 'percent') {
+            $r->print(&mt('percent'));
+        } else {
+            $r->print(&mt('points'));
+        }
+    }
+    $r->print('</td>');
 
     return ($value,$weight);
 }
@@ -664,7 +683,7 @@
     if ($cangrade) {
         $r->print('<td colspan="3"><a href="javascript:storecmd(\'createnewcat\');">'.&mt('Create New Category').'</a></td>');
     }
-    $r->print('<td colspan="5">'.&mt('Current:').$sum.'<br />'.&mt('Total:').$total.'<br /></td>');
+    $r->print('<td colspan="6">'.&mt('Current:').$sum.'<br />'.&mt('Total:').$total.'<br /></td>');
 }
 
 #
@@ -688,6 +707,7 @@
     }
     $categories{$id.'_weight'}=0;
     $categories{$id.'_totaltype'}='default';
+    $categories{$id.'_displayachieved'}='percent';
     return %categories;
 }
 
@@ -933,6 +953,15 @@
     return %categories;
 }
 
+sub set_category_displayachieved {
+    my ($cangrade,$id,$value,%categories)=@_;
+    unless ($cangrade) { return %categories; }
+    unless (($value eq 'percent') || ($value eq 'points')) { $value='percent'; }
+    $categories{$id.'_displayachieved'}=$value;
+    return %categories;
+}
+
+
 #
 # === end category-related
 #