version 1.197, 2015/04/09 09:48:02
|
version 1.201, 2018/02/28 13:20:50
|
Line 300 sub end_foilgroup {
|
Line 300 sub end_foilgroup {
|
my $wrong=0; |
my $wrong=0; |
my $ignored=0; |
my $ignored=0; |
my $checked=0; |
my $checked=0; |
|
my $corrchkd=0; |
|
my $corrunchkd=0; |
|
my $incorrchkd=0; |
|
my $incorrunchkd=0; |
my ($numrows,$bubbles_per_row); |
my ($numrows,$bubbles_per_row); |
if ($Apache::lonhomework::scantronmode) { |
if ($Apache::lonhomework::scantronmode) { |
my $numitems = scalar(@opt); |
my $numitems = scalar(@opt); |
Line 329 sub end_foilgroup {
|
Line 333 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) { |
foreach $name (@whichopt) { |
my $response; |
my $response; |
if ($env{'form.submitted'} eq 'scantron') { |
if ($env{'form.submitted'} eq 'scantron') { |
Line 369 sub end_foilgroup {
|
Line 377 sub end_foilgroup {
|
if ($checkboxopt) { |
if ($checkboxopt) { |
if ($response eq $checkboxopt) { |
if ($response eq $checkboxopt) { |
$checked++; |
$checked++; |
|
if ($grade{$name}) { |
|
$corrchkd ++; |
|
} else { |
|
$incorrchkd ++; |
|
} |
|
} else { |
|
if ($grade{$name}) { |
|
$corrunchkd ++; |
|
} else { |
|
$incorrunchkd ++; |
|
} |
} |
} |
} |
} |
} else { |
} else { |
$ignored++; |
$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 $responsestr=&Apache::lonnet::hash2str(%responsehash); |
my $gradestr =&Apache::lonnet::hash2str(%grade); |
my $gradestr =&Apache::lonnet::hash2str(%grade); |
my %previous=&Apache::response::check_for_previous($responsestr, |
my %previous=&Apache::response::check_for_previous($responsestr, |
Line 453 sub end_foilgroup {
|
Line 469 sub end_foilgroup {
|
$ad='ASSIGNED_SCORE'; |
$ad='ASSIGNED_SCORE'; |
} |
} |
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad; |
$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"}= |
$Apache::lonhomework::results{"resource.$part.$id.awarded"}= |
$right/(scalar(@whichopt)); |
$awarded; |
$Apache::lonhomework::results{"resource.$part.$id.numfoils"}= |
$Apache::lonhomework::results{"resource.$part.$id.numfoils"}= |
scalar(@whichopt); |
scalar(@whichopt); |
} |
} |
Line 492 sub end_foilgroup {
|
Line 522 sub end_foilgroup {
|
} |
} |
|
|
sub grading_is_nonlenient { |
sub grading_is_nonlenient { |
my ($part) = @_; |
my ($part,$id,$relweights) = @_; |
# Web mode: we are non-lenient unless told otherwise |
# Web mode: we are non-lenient unless told otherwise |
my $defaultparm = 'off'; |
my $defaultparm = 'off'; |
my $nonlenient = 0; |
my $nonlenient = 1; |
# Grading a bubblesheet exam: we are grading lenient unless told otherwise |
# Grading a bubblesheet exam: we are grading lenient unless told otherwise |
if ($Apache::lonhomework::scantronmode) { |
if ($Apache::lonhomework::scantronmode) { |
$defaultparm = 'on'; |
$defaultparm = 'on'; |
$nonlenient = 1; |
$nonlenient = 0; |
} |
} |
my $lenientparm = |
my $lenientparm = |
&Apache::response::get_response_param($part,'lenient',$defaultparm); |
&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; |
$nonlenient = 1; |
} elsif ($lenientparm=~/^1|on|yes$/i) { |
} elsif ($lenientparm=~/^(?:1|on|yes)$/i) { |
$nonlenient = 0; |
$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; |
return $nonlenient; |
} |
} |
Line 749 sub displayfoils {
|
Line 795 sub displayfoils {
|
# fieldname is this input field's name after HWVAL_ |
# fieldname is this input field's name after HWVAL_ |
$optionlist='<input type="hidden" name="HWVAL_'.$fieldname.'" value="'.$escdefopt.'" />'. |
$optionlist='<input type="hidden" name="HWVAL_'.$fieldname.'" value="'.$escdefopt.'" />'. |
'<input type="checkbox" name="HWCHK_'.$fieldname.'" onclick="javascript:if (this.form.elements[\'HWCHK_'. |
'<input type="checkbox" name="HWCHK_'.$fieldname.'" onclick="javascript:if (this.form.elements[\'HWCHK_'. |
$fieldname.'\'].checked) { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$esccheckboxopt.'\'; } else { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$escaltopt.'\'; };setSubmittedPart(\''.$part.'\');"'.($defopt eq $checkboxopt?' checked="checked"':'')." />\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 { |
} else { |
# classic selection list |
# classic selection list |
$optionlist='<select onchange="javascript:setSubmittedPart(\''. |
$optionlist='<select onchange="javascript:setSubmittedPart(\''. |