[LON-CAPA-cvs] cvs: loncom /interface lonquickgrades.pm
www
www@source.lon-capa.org
Sun, 20 Feb 2011 23:57:35 -0000
www Sun Feb 20 23:57:35 2011 EDT
Modified files:
/loncom/interface lonquickgrades.pm
Log:
Total points and weight
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.70 loncom/interface/lonquickgrades.pm:1.71
--- loncom/interface/lonquickgrades.pm:1.70 Sun Feb 20 23:38:00 2011
+++ loncom/interface/lonquickgrades.pm Sun Feb 20 23:57:35 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Quick Student Grades Display
#
-# $Id: lonquickgrades.pm,v 1.70 2011/02/20 23:38:00 www Exp $
+# $Id: lonquickgrades.pm,v 1.71 2011/02/20 23:57:35 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -462,7 +462,8 @@
# Simply store the rest of the stuff
foreach my $id (split(/\,/,$categories{'order'})) {
%categories=&set_category_name($cangrade,$id,$env{'form.name_'.$id},%categories);
- %categories=&set_category_weight($cangrade,$id,$env{'form.weighttype_'.$id},$env{'form.weight_'.$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);
# More changes here
}
}
@@ -505,8 +506,8 @@
$r->print('<th>'.&mt('Category').'</th>'.
'<th>'.&mt('Contents').'</th>'.
'<th>'.&mt('Calculation').'</th>'.
- '<th>'.&mt('Weight').'</th>'.
- '<th>'.&mt('Percent Overall').'</th>');
+ '<th>'.&mt('Total Points').'</th>'.
+ '<th>'.&mt('Relative Weight').'</th>');
$r->print(&Apache::loncommon::end_data_table_header_row());
}
@@ -569,17 +570,25 @@
} else {
$r->print("<td>Calculation</td>");
}
-# Weight
+# Total
if ($cangrade) {
$r->print('<td>'.
- '<select name="weighttype_'.$id.'">'.
- '<option value="default"'.($categories{$id.'_weighttype'} eq 'default'?' selected="selected"':'').'>'.&mt('default').'</option>'.
- '<option value="typein"'.($categories{$id.'_weighttype'} eq 'typein'?' selected="selected"':'').'>'.&mt('Type-in value').'</option>'.
+ '<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>'.
'<input type="text" size="4" name="weight_'.$id.
'" value="'.&Apache::lonhtmlcommon::entity_encode($categories{$id.'_weight'}).'" /></td>');
} else {
- $r->print('<td>'.($categories{$id.'_weighttype'} eq 'default'?&mt('default'):$categories{$id.'_weight'}).'</td>');
+ $r->print('<td>'.$categories{$id.'_weight'}.'</td>');
}
return ($value,$weight);
@@ -617,7 +626,8 @@
if (defined($ordernum)) {
%categories=&move_category($id,$cangrade,$ordernum,%categories);
}
- $categories{$id.'_weighttype'}='default';
+ $categories{$id.'_weight'}=0;
+ $categories{$id.'_totaltype'}='default';
return %categories;
}
@@ -696,25 +706,33 @@
}
#
-# Set weight of a category
+# Set total of a category
#
-sub set_category_weight {
- my ($cangrade,$id,$weighttype,$weight,%categories)=@_;
+sub set_category_total {
+ my ($cangrade,$id,$totaltype,$total,%categories)=@_;
unless ($cangrade) { return %categories; }
- if (($categories{$id.'_weight'} eq '') && ($weight=~/\d/)) {
- $weighttype='typein';
+ if (($categories{$id.'_total'} eq '') && ($total=~/\d/)) {
+ $totaltype='typein';
}
- $categories{$id.'_weighttype'}=$weighttype;
- if ($weighttype eq 'default') {
- $categories{$id.'_weight'}='';
+ $categories{$id.'_totaltype'}=$totaltype;
+ if ($totaltype eq 'default') {
+ $categories{$id.'_total'}='';
} else {
- $weight=~s/\D//gs;
- unless ($weight) { $weight=0; }
- $categories{$id.'_weight'}=$weight;
+ $total=~s/\D//gs;
+ unless ($total) { $total=0; }
+ $categories{$id.'_total'}=$total;
}
return %categories;
}
+sub set_category_weight {
+ my ($cangrade,$id,$weight,%categories)=@_;
+ unless ($cangrade) { return %categories; }
+ $weight=~s/\D//gs;
+ unless ($weight) { $weight=0; }
+ $categories{$id.'_weight'}=$weight;
+ return %categories;
+}
#
# === end category-related