--- loncom/interface/lonquickgrades.pm 2011/03/25 01:34:49 1.78
+++ loncom/interface/lonquickgrades.pm 2011/03/26 22:37:47 1.82
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Quick Student Grades Display
#
-# $Id: lonquickgrades.pm,v 1.78 2011/03/25 01:34:49 www Exp $
+# $Id: lonquickgrades.pm,v 1.82 2011/03/26 22:37:47 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -464,6 +464,39 @@ sub outputCategories {
''.
'');
}
+#
+# Debug
+#
+# my %data=&dumpdata($navmap);
+# foreach (keys(%data)) {
+# $r->print("\n
".$_.'='.$data{$_});
+# }
+}
+
+#
+# Get data for all symbs
+#
+
+sub dumpdata {
+ my ($navmap)=@_;
+ my %returndata=();
+
+# Run through the map and get all data
+
+ my $iterator = $navmap->getIterator(undef, undef, undef, 1);
+ my $depth = 1;
+ $iterator->next(); # ignore first BEGIN_MAP
+ my $curRes = $iterator->next();
+
+ while ($depth > 0) {
+ if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
+ if ($curRes == $iterator->END_MAP()) { $depth--; }
+ if (ref($curRes) && $curRes->is_map()) {
+ $returndata{$curRes->symb()}=$curRes->{DATA}->{CHILD_PARTS}.':'.$curRes->{DATA}->{CHILD_ATTEMPTED}.':'.$curRes->{DATA}->{CHILD_CORRECT};
+ }
+ $curRes = $iterator->next();
+ }
+ return %returndata;
}
#
@@ -475,10 +508,13 @@ sub process_category_edits {
unless ($cangrade) { return %categories; }
# First store everything
foreach my $id (split(/\,/,$categories{'order'})) {
+# Set names, types, and weight (there is only one of each per category)
%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);
-# More changes here
+ %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);
}
# Now deal with commands
@@ -497,6 +533,8 @@ sub process_category_edits {
%categories=&del_category_content($1,$cangrade,$2,%categories);
} elsif ($cmd=~/^newrule\_(.+)$/) {
%categories=&add_calculation_rule($1,$cangrade,':',%categories);
+ } elsif ($cmd=~/^delrule\_(.+)\_\_\_\_\_\_(.*)$/) {
+ %categories=&del_calculation_rule($1,$cangrade,$2,%categories);
}
# Move to a new position
my $moveid=$env{'form.storemove'};
@@ -541,9 +579,10 @@ sub output_category_table_header {
}
$r->print('
'.&mt('Category').' | '.
''.&mt('Contents').' | '.
- ''.&mt('Calculation').' | '.
''.&mt('Total Points').' | '.
- ''.&mt('Relative Weight').' | ');
+ ''.&mt('Calculation').' | '.
+ ''.&mt('Relative Weight').' | '.
+ ''.&mt('Achieved').' | ');
$r->print(&Apache::loncommon::end_data_table_header_row());
}
@@ -604,10 +643,25 @@ ENDMOVE
}
$r->print('');
if ($cangrade) {
- $r->print('
'.&mt('Add Problem or Sequence').'
'.
+ $r->print('
'.&mt('Add Problem or Folder').'
'.
&Apache::lonstathelpers::problem_selector('.',undef,1,1,'addcont_'.$id.'_',1,'this.form.cmd.value="addcont_'.$id.'";this.form.submit();'));
}
$r->print('');
+
+# Total
+ if ($cangrade) {
+ $r->print(''.
+ ''.
+ ' | ');
+ } else {
+ $r->print(''.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).' | ');
+ }
+
+
# Calculation
$r->print('');
foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) {
@@ -615,7 +669,7 @@ ENDMOVE
my ($code,$value)=split(/\:/,$calcrule);
$r->print(&pretty_prt_rule($cangrade,$id,$code,$value));
if ($cangrade) {
- $r->print(' '.&mt('Delete').'');
+ $r->print(' '.&mt('Delete').'');
}
$r->print('');
}
@@ -625,19 +679,6 @@ ENDMOVE
}
$r->print(' | ');
-
-# Total
- if ($cangrade) {
- $r->print(''.
- ''.
- ' | ');
- } else {
- $r->print(''.($categories{$id.'_totaltype'} eq 'default'?&mt('default'):$categories{$id.'_total'}).' | ');
- }
# Weight
if ($cangrade) {
$r->print(''.
@@ -646,6 +687,21 @@ ENDMOVE
} else {
$r->print(' | '.$categories{$id.'_weight'}.' | ');
}
+# Achieved
+ $r->print('');
+ if ($cangrade) {
+ $r->print('');
+ } else {
+ if ($categories{$id.'_displayachieved'} eq 'percent') {
+ $r->print(&mt('percent'));
+ } else {
+ $r->print(&mt('points'));
+ }
+ }
+ $r->print(' | ');
return ($value,$weight);
}
@@ -660,7 +716,7 @@ sub bottom_line_category {
if ($cangrade) {
$r->print(''.&mt('Create New Category').' | ');
}
- $r->print(''.&mt('Current:').$sum.' '.&mt('Total:').$total.'
| ');
+ $r->print(''.&mt('Current:').$sum.' '.&mt('Total:').$total.'
| ');
}
#
@@ -684,27 +740,32 @@ sub make_new_category {
}
$categories{$id.'_weight'}=0;
$categories{$id.'_totaltype'}='default';
+ $categories{$id.'_displayachieved'}='percent';
return %categories;
}
# === Calculation Rule Editing
-sub pretty_prt_rule {
- my ($cangrade,$id,$code,$value)=@_;
- my $cid=$id.'_'.$code;
- my %lt=&Apache::lonlocal::texthash(
+sub category_rule_codes {
+ return &Apache::lonlocal::texthash(
'droplow' => 'Drop N lowest grade assignments',
'drophigh' => 'Drop N highest grade assignments',
'capabove' => 'Cap percentage above N percent',
'capbelow' => 'Cap percentage below N percent');
+}
+
+sub pretty_prt_rule {
+ my ($cangrade,$id,$code,$value)=@_;
+ my $cid=$id.'_'.$code;
+ my %lt=&category_rule_codes();
my $ret='';
if ($cangrade) {
$ret.=' N=';
+ $ret.=' N=';
} else {
$ret.=$lt{$code}.'; N='.$value;
}
@@ -749,6 +810,21 @@ sub del_calculation_rule {
return %categories;
}
+sub set_category_rules {
+ my ($cangrade,$id,%categories)=@_;
+ unless ($cangrade) { return %categories; }
+ my %lt=&category_rule_codes();
+ my @newrules=();
+ foreach my $code ('',(keys(%lt))) {
+ if ($env{'form.sel_'.$id.'_'.$code}) {
+ push(@newrules,$env{'form.sel_'.$id.'_'.$code}.':'.$env{'form.val_'.$id.'_'.$code});
+ }
+ }
+ $categories{$id.'_calculations'}=join(',',sort(@newrules));
+ return %categories;
+}
+
+
# === Category Editing
#
@@ -910,6 +986,15 @@ sub set_category_weight {
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
#