version 1.75, 2011/03/12 02:58:44
|
version 1.76, 2011/03/19 02:22:18
|
Line 607 ENDMOVE
|
Line 607 ENDMOVE
|
} |
} |
$r->print('</td>'); |
$r->print('</td>'); |
# Calculation |
# 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) { |
if ($cangrade) { |
$r->print("<td>Calculation Edit</td>"); |
$r->print('<br />'.&mt('Add Calculation Rule').'<br />'. |
} else { |
&new_calc_rule_form('addcalc_'.$id.'_','this.form.cmd.value="addcalc_'.$id.'";this.form.submit();')); |
$r->print("<td>Calculation</td>"); |
|
} |
} |
|
$r->print('</td>'); |
|
|
|
|
# Total |
# Total |
if ($cangrade) { |
if ($cangrade) { |
$r->print('<td>'. |
$r->print('<td>'. |
Line 674 sub make_new_category {
|
Line 685 sub make_new_category {
|
return %categories; |
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 |
# Add to category content |
# |
# |