[LON-CAPA-cvs] cvs: loncom /interface lonquickgrades.pm
www
www@source.lon-capa.org
Sat, 19 Mar 2011 02:22:18 -0000
www Sat Mar 19 02:22:18 2011 EDT
Modified files:
/loncom/interface lonquickgrades.pm
Log:
Work on calculation rule interface
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.75 loncom/interface/lonquickgrades.pm:1.76
--- loncom/interface/lonquickgrades.pm:1.75 Sat Mar 12 02:58:44 2011
+++ loncom/interface/lonquickgrades.pm Sat Mar 19 02:22:18 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Quick Student Grades Display
#
-# $Id: lonquickgrades.pm,v 1.75 2011/03/12 02:58:44 www Exp $
+# $Id: lonquickgrades.pm,v 1.76 2011/03/19 02:22:18 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -607,12 +607,23 @@
}
$r->print('</td>');
# Calculation
-# FIXME: just placeholders
+ $r->print('<td><ul>');
+ foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) {
+ $r->print('<li>');
+ $r->print(&pretty_prt_rule($calcrule));
+ if ($cangrade) {
+ $r->print(' <a href="javascript:storecmd(\'delcalc_'.$id.'______'.$calcrule.'\');">'.&mt('Delete').'</a>');
+ }
+ $r->print('</li>');
+ }
+ $r->print('</ul>');
if ($cangrade) {
- $r->print("<td>Calculation Edit</td>");
- } else {
- $r->print("<td>Calculation</td>");
+ $r->print('<br />'.&mt('Add Calculation Rule').'<br />'.
+ &new_calc_rule_form('addcalc_'.$id.'_','this.form.cmd.value="addcalc_'.$id.'";this.form.submit();'));
}
+ $r->print('</td>');
+
+
# Total
if ($cangrade) {
$r->print('<td>'.
@@ -674,6 +685,52 @@
return %categories;
}
+
+# === Calculation Rule Editing
+
+sub pretty_prt_rule {
+ my ($rule)=@_;
+ return $rule;
+}
+
+sub new_calc_rule_form {
+ return "New Rule";
+}
+
+#
+# Add a calculation rule
+#
+
+sub add_calculation_rule {
+ my ($id,$cangrade,$newcontent,%categories)=@_;
+ unless ($cangrade) { return %categories; }
+ my %newcontent=($newcontent => 1);
+ foreach my $current (split(/\,/,$categories{$id.'_calculations'})) {
+ $newcontent{$current}=1;
+ }
+ $categories{$id.'_calculations'}=join(',',sort(keys(%newcontent)));
+ return %categories;
+}
+
+#
+# Delete a calculation rule
+#
+
+sub del_calculation_rule {
+ my ($id,$cangrade,$delcontent,%categories)=@_;
+ unless ($cangrade) { return %categories; }
+ my @newcontent=();
+ foreach my $current (split(/\,/,$categories{$id.'_calculations'})) {
+ unless ($current eq $delcontent) {
+ push(@newcontent,$current);
+ }
+ }
+ $categories{$id.'_calculations'}=join(',',@newcontent);
+ return %categories;
+}
+
+# === Category Editing
+
#
# Add to category content
#