'.&mt('Delete?').' '
.&Apache::edit::deletelist($target,$token)
@@ -127,8 +128,8 @@ sub start_foilgroup {
maxcheck => 'Enter maximum number students may check (e.g., 3)',
mincheck => 'Enter minimum number students need to check (e.g., 1)',
);
- $result.= (<
$lt{'sel'}
+ $result.= sprintf(<
%s $lt{'sel'}
$lt{'add'}
@@ -299,6 +300,10 @@ sub end_foilgroup {
my $wrong=0;
my $ignored=0;
my $checked=0;
+ my $corrchkd=0;
+ my $corrunchkd=0;
+ my $incorrchkd=0;
+ my $incorrunchkd=0;
my ($numrows,$bubbles_per_row);
if ($Apache::lonhomework::scantronmode) {
my $numitems = scalar(@opt);
@@ -328,6 +333,10 @@ sub end_foilgroup {
}
}
}
+ my $part=$Apache::inputtags::part;
+ my $id = $Apache::inputtags::response['-1'];
+ my @relweights;
+ my $nonlenient=&grading_is_nonlenient($part,$id,\@relweights);
foreach $name (@whichopt) {
my $response;
if ($env{'form.submitted'} eq 'scantron') {
@@ -368,15 +377,23 @@ sub end_foilgroup {
if ($checkboxopt) {
if ($response eq $checkboxopt) {
$checked++;
+ if ($grade{$name}) {
+ $corrchkd ++;
+ } else {
+ $incorrchkd ++;
+ }
+ } else {
+ if ($grade{$name}) {
+ $corrunchkd ++;
+ } else {
+ $incorrunchkd ++;
+ }
}
- }
+ }
} else {
$ignored++;
}
}
- my $part=$Apache::inputtags::part;
- my $nonlenient=&grading_is_nonlenient($part);
- my $id = $Apache::inputtags::response['-1'];
my $responsestr=&Apache::lonnet::hash2str(%responsehash);
my $gradestr =&Apache::lonnet::hash2str(%grade);
my %previous=&Apache::response::check_for_previous($responsestr,
@@ -452,8 +469,22 @@ sub end_foilgroup {
$ad='ASSIGNED_SCORE';
}
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
+ my $awarded;
+ my $totalfoils = $#{ $Apache::response::foilgroup{'names'} }+1;
+ if (($checkboxopt) && ($max >= $totalfoils) && (@relweights > 0)) {
+ if ($right == scalar(@whichopt)) {
+ $awarded = 1;
+ } else {
+ $awarded = ($corrchkd*$relweights[0] + $corrunchkd*$relweights[1] +
+ $incorrchkd*$relweights[2] + $incorrunchkd*$relweights[3])/(scalar(@whichopt));
+ $awarded = 1 if ($awarded > 1);
+ $awarded = 0 if ($awarded < 0);
+ }
+ } else {
+ $awarded = $right/(scalar(@whichopt));
+ }
$Apache::lonhomework::results{"resource.$part.$id.awarded"}=
- $right/(scalar(@whichopt));
+ $awarded;
$Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
scalar(@whichopt);
}
@@ -491,21 +522,37 @@ sub end_foilgroup {
}
sub grading_is_nonlenient {
- my ($part) = @_;
+ my ($part,$id,$relweights) = @_;
# Web mode: we are non-lenient unless told otherwise
my $defaultparm = 'off';
- my $nonlenient = 0;
+ my $nonlenient = 1;
# Grading a bubblesheet exam: we are grading lenient unless told otherwise
if ($Apache::lonhomework::scantronmode) {
$defaultparm = 'on';
- $nonlenient = 1;
+ $nonlenient = 0;
}
my $lenientparm =
&Apache::response::get_response_param($part,'lenient',$defaultparm);
- if ($lenientparm=~/^0|off|no$/i) {
+ if ($lenientparm eq 'default') {
+ $lenientparm = $defaultparm;
+ }
+ $lenientparm =
+ &Apache::response::get_response_param($part.'_'.$id,'lenient',$lenientparm);
+ if ($lenientparm eq 'default') {
+ $lenientparm = $defaultparm;
+ }
+ if ($lenientparm=~/^(?:0|off|no)$/i) {
$nonlenient = 1;
- } elsif ($lenientparm=~/^1|on|yes$/i) {
+ } elsif ($lenientparm=~/^(?:1|on|yes)$/i) {
$nonlenient = 0;
+ } elsif ($lenientparm =~ /^\-?[.\d]+,\-?[.\d]+,\-?[.\d]+,\-?[.\d]+$/) {
+ if (ref($relweights) eq 'ARRAY') {
+ @{$relweights} = split(/,/,$lenientparm);
+ }
+ $nonlenient = 0;
+ }
+ if (!$nonlenient) {
+ $Apache::inputtags::leniency=1;
}
return $nonlenient;
}
@@ -748,7 +795,7 @@ sub displayfoils {
# fieldname is this input field's name after HWVAL_
$optionlist=''.
'\n";
+ $fieldname.'\'].checked) { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$esccheckboxopt.'\'; } else { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$escaltopt.'\'; };javascript:setSubmittedPart(\''.$part.'\');"'.($defopt eq $checkboxopt?' checked="checked"':'')." />\n";
} else {
# classic selection list
$optionlist='