version 1.76, 2011/03/19 02:22:18
|
version 1.78, 2011/03/25 01:34:49
|
Line 495 sub process_category_edits {
|
Line 495 sub process_category_edits {
|
%categories=&add_category_content($1,$cangrade,$env{'form.addcont_'.$1.'_symb'},%categories); |
%categories=&add_category_content($1,$cangrade,$env{'form.addcont_'.$1.'_symb'},%categories); |
} elsif ($cmd=~/^delcont\_(.+)\_\_\_\_\_\_(.+)$/) { |
} elsif ($cmd=~/^delcont\_(.+)\_\_\_\_\_\_(.+)$/) { |
%categories=&del_category_content($1,$cangrade,$2,%categories); |
%categories=&del_category_content($1,$cangrade,$2,%categories); |
|
} elsif ($cmd=~/^newrule\_(.+)$/) { |
|
%categories=&add_calculation_rule($1,$cangrade,':',%categories); |
} |
} |
# Move to a new position |
# Move to a new position |
my $moveid=$env{'form.storemove'}; |
my $moveid=$env{'form.storemove'}; |
Line 610 ENDMOVE
|
Line 612 ENDMOVE
|
$r->print('<td><ul>'); |
$r->print('<td><ul>'); |
foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) { |
foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) { |
$r->print('<li>'); |
$r->print('<li>'); |
$r->print(&pretty_prt_rule($calcrule)); |
my ($code,$value)=split(/\:/,$calcrule); |
|
$r->print(&pretty_prt_rule($cangrade,$id,$code,$value)); |
if ($cangrade) { |
if ($cangrade) { |
$r->print(' <a href="javascript:storecmd(\'delcalc_'.$id.'______'.$calcrule.'\');">'.&mt('Delete').'</a>'); |
$r->print(' <a href="javascript:storecmd(\'delcalc_'.$id.'______'.$code.'\');">'.&mt('Delete').'</a>'); |
} |
} |
$r->print('</li>'); |
$r->print('</li>'); |
} |
} |
$r->print('</ul>'); |
$r->print('</ul>'); |
if ($cangrade) { |
if ($cangrade) { |
$r->print('<br />'.&mt('Add Calculation Rule').'<br />'. |
$r->print('<br />'.&new_calc_rule_form($id)); |
&new_calc_rule_form('addcalc_'.$id.'_','this.form.cmd.value="addcalc_'.$id.'";this.form.submit();')); |
|
} |
} |
$r->print('</td>'); |
$r->print('</td>'); |
|
|
Line 689 sub make_new_category {
|
Line 691 sub make_new_category {
|
# === Calculation Rule Editing |
# === Calculation Rule Editing |
|
|
sub pretty_prt_rule { |
sub pretty_prt_rule { |
my ($rule)=@_; |
my ($cangrade,$id,$code,$value)=@_; |
return $rule; |
my $cid=$id.'_'.$code; |
|
my %lt=&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'); |
|
my $ret='<span class="LC_nobreak">'; |
|
if ($cangrade) { |
|
$ret.='<select name="sel_'.$cid.'">'; |
|
foreach my $calc (''=>'',sort(keys(%lt))) { |
|
$ret.='<option value="'.$calc.'"'.($calc eq $code?' selected="selected"':'').' />'.$lt{$calc}.'</input>'; |
|
} |
|
$ret.='</select> N=<input type="text" size="5" name="val_'.$cid.'" /></span>'; |
|
} else { |
|
$ret.=$lt{$code}.'; N='.$value; |
|
} |
|
$ret.='</span>'; |
|
return $ret; |
} |
} |
|
|
sub new_calc_rule_form { |
sub new_calc_rule_form { |
return "New Rule"; |
my ($id)=@_; |
|
return '<a href="javascript:storecmd(\'newrule_'.$id.'\');">'.&mt('New Calculation Rule').'</a>'; |
} |
} |
|
|
# |
# |
Line 721 sub del_calculation_rule {
|
Line 741 sub del_calculation_rule {
|
unless ($cangrade) { return %categories; } |
unless ($cangrade) { return %categories; } |
my @newcontent=(); |
my @newcontent=(); |
foreach my $current (split(/\,/,$categories{$id.'_calculations'})) { |
foreach my $current (split(/\,/,$categories{$id.'_calculations'})) { |
unless ($current eq $delcontent) { |
unless ($current=~/^\Q$delcontent\E\:/) { |
push(@newcontent,$current); |
push(@newcontent,$current); |
} |
} |
} |
} |