version 1.200, 2004/05/14 19:15:49
|
version 1.217, 2004/09/28 20:35:08
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# 2/9,2/13 Guy Albertelli |
|
# 6/8 Gerd Kortemeyer |
|
# 7/26 H.K. Ng |
|
# 8/20 Gerd Kortemeyer |
|
# Year 2002 |
|
# June-August H.K. Ng |
|
# Year 2003 |
|
# February, March H.K. Ng |
|
# July, H. K. Ng |
|
# |
|
|
|
package Apache::grades; |
package Apache::grades; |
use strict; |
use strict; |
Line 167 sub response_type {
|
Line 157 sub response_type {
|
return \@partlist,\%handgrade,\%responseType; |
return \@partlist,\%handgrade,\%responseType; |
} |
} |
|
|
|
sub get_display_part { |
|
my ($partID,$url,$symb)=@_; |
|
if (!defined($symb) || $symb eq '') { |
|
$symb=$ENV{'form.symb'}; |
|
if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) } |
|
} |
|
my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb); |
|
if (defined($display) and $display ne '') { |
|
$display.= " (<font color=\"#999900\">id $partID</font>)"; |
|
} else { |
|
$display=$partID; |
|
} |
|
return $display; |
|
} |
#--- Show resource title |
#--- Show resource title |
#--- and parts and response type |
#--- and parts and response type |
sub showResourceInfo { |
sub showResourceInfo { |
Line 194 sub showResourceInfo {
|
Line 198 sub showResourceInfo {
|
} |
} |
$partsseen{$partID}=1; |
$partsseen{$partID}=1; |
} |
} |
$result.='<td><b>Part </b>'.$partID.' <font color="#999999">'. |
my $display_part=&get_display_part($partID,$url); |
|
$result.='<td><b>Part: </b>'.$display_part.' <font color="#999999">'. |
$resID.'</font></td>'. |
$resID.'</font></td>'. |
'<td><b>Type: </b>'.$responsetype.'</td></tr>'; |
'<td><b>Type: </b>'.$responsetype.'</td></tr>'; |
# '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>'; |
# '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>'; |
Line 349 sub getclasslist {
|
Line 354 sub getclasslist {
|
# |
# |
my %sections; |
my %sections; |
my %fullnames; |
my %fullnames; |
foreach (keys(%$classlist)) { |
foreach my $student (keys(%$classlist)) { |
# the following undefs are for 'domain', and 'username' respectively. |
my $end = |
my (undef,undef,$end,$start,$id,$section,$fullname,$status)= |
$classlist->{$student}->[&Apache::loncoursedata::CL_END()]; |
@{$classlist->{$_}}; |
my $start = |
|
$classlist->{$student}->[&Apache::loncoursedata::CL_START()]; |
|
my $id = |
|
$classlist->{$student}->[&Apache::loncoursedata::CL_ID()]; |
|
my $section = |
|
$classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()]; |
|
my $fullname = |
|
$classlist->{$student}->[&Apache::loncoursedata::CL_FULLNAME()]; |
|
my $status = |
|
$classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()]; |
# filter students according to status selected |
# filter students according to status selected |
if ($filterlist && $ENV{'form.Status'} ne 'Any') { |
if ($filterlist && $ENV{'form.Status'} ne 'Any') { |
if ($ENV{'form.Status'} ne $status) { |
if ($ENV{'form.Status'} ne $status) { |
delete ($classlist->{$_}); |
delete ($classlist->{$student}); |
next; |
next; |
} |
} |
} |
} |
$section = ($section ne '' ? $section : 'no'); |
$section = ($section ne '' ? $section : 'none'); |
if (&canview($section)) { |
if (&canview($section)) { |
if ($getsec eq 'all' || $getsec eq $section) { |
if ($getsec eq 'all' || $getsec eq $section) { |
$sections{$section}++; |
$sections{$section}++; |
$fullnames{$_}=$fullname; |
$fullnames{$student}=$fullname; |
} else { |
} else { |
delete($classlist->{$_}); |
delete($classlist->{$student}); |
} |
} |
} else { |
} else { |
delete($classlist->{$_}); |
delete($classlist->{$student}); |
} |
} |
} |
} |
my %seen = (); |
my %seen = (); |
Line 682 LISTJAVASCRIPT
|
Line 696 LISTJAVASCRIPT
|
'<td>'.&nameUserString('header').'</td>'; |
'<td>'.&nameUserString('header').'</td>'; |
if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { |
if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') { |
foreach (sort(@$partlist)) { |
foreach (sort(@$partlist)) { |
$gradeTable.='<td><b> Part '.(split(/_/))[0].' Status </b></td>'; |
my $display_part=&get_display_part((split(/_/))[0],$url,$symb); |
|
$gradeTable.='<td><b> Part: '.$display_part. |
|
' Status </b></td>'; |
} |
} |
} |
} |
$loop++; |
$loop++; |
Line 1084 sub sub_page_kw_js {
|
Line 1100 sub sub_page_kw_js {
|
var ypos = (screen.height-height)/2-30; |
var ypos = (screen.height-height)/2-30; |
ypos = (ypos < 0) ? '0' : ypos; |
ypos = (ypos < 0) ? '0' : ypos; |
|
|
pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height); |
pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=600,height='+height); |
pWin.focus(); |
pWin.focus(); |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.open('text/html','replace'); |
pDoc.open('text/html','replace'); |
Line 1215 sub sub_page_kw_js {
|
Line 1231 sub sub_page_kw_js {
|
var ypos = (screen.height-330)/2-30; |
var ypos = (screen.height-330)/2-30; |
ypos = (ypos < 0) ? '0' : ypos; |
ypos = (ypos < 0) ? '0' : ypos; |
|
|
hwdWin = window.open('', 'KeywordHighlightCentral', 'toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos); |
hwdWin = window.open('', 'KeywordHighlightCentral', 'resizeable=yes,toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx='+xpos+',screeny='+ypos); |
hwdWin.focus(); |
hwdWin.focus(); |
var hDoc = hwdWin.document; |
var hDoc = hwdWin.document; |
hDoc.open('text/html','replace'); |
hDoc.open('text/html','replace'); |
Line 1289 sub gradeBox {
|
Line 1305 sub gradeBox {
|
'' : $$record{'resource.'.$partid.'.awarded'}*$wgt); |
'' : $$record{'resource.'.$partid.'.awarded'}*$wgt); |
my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n"; |
my $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />'."\n"; |
|
|
|
my $display_part=&get_display_part($partid,undef,$symb); |
$result.='<table border="0"><tr><td>'. |
$result.='<table border="0"><tr><td>'. |
'<b>Part </b>'.$partid.' <b>Points: </b></td><td>'."\n"; |
'<b>Part: </b>'.$display_part.' <b>Points: </b></td><td>'."\n"; |
|
|
my $ctr = 0; |
my $ctr = 0; |
$result.='<table border="0"><tr>'."\n"; # display radio buttons in a nice table 10 across |
$result.='<table border="0"><tr>'."\n"; # display radio buttons in a nice table 10 across |
Line 1622 KEYWORDS
|
Line 1639 KEYWORDS
|
my %seenparts; |
my %seenparts; |
for my $part (sort keys(%$handgrade)) { |
for my $part (sort keys(%$handgrade)) { |
my ($partid,$respid) = split(/_/,$part); |
my ($partid,$respid) = split(/_/,$part); |
|
my $display_part=&get_display_part($partid,$url,$symb); |
if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) { |
if ($ENV{"form.$uname:$udom:$partid:submitted_by"}) { |
if (exists($seenparts{$partid})) { next; } |
if (exists($seenparts{$partid})) { next; } |
$seenparts{$partid}=1; |
$seenparts{$partid}=1; |
my $submitby='<b>Part '.$partid. |
my $submitby='<b>Part:</b> '.$display_part. |
' Collaborative submission by: </b>'. |
' <b>Collaborative submission by:</b> '. |
'<a href="javascript:viewSubmitter(\''. |
'<a href="javascript:viewSubmitter(\''. |
$ENV{"form.$uname:$udom:$partid:submitted_by"}. |
$ENV{"form.$uname:$udom:$partid:submitted_by"}. |
'\')"; TARGET=_self>'. |
'\')"; TARGET=_self>'. |
Line 1636 KEYWORDS
|
Line 1654 KEYWORDS
|
} |
} |
my $responsetype = $responseType->{$partid}->{$respid}; |
my $responsetype = $responseType->{$partid}->{$respid}; |
if (!exists($record{"resource.$partid.$respid.submission"})) { |
if (!exists($record{"resource.$partid.$respid.submission"})) { |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '. |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '. |
$partid.'</b> <font color="#999999">( ID '.$respid. |
$display_part.' <font color="#999999">( ID '.$respid. |
' )</font> '. |
' )</font> '. |
'<font color="red">Nothing submitted - no attempts</font><br /><br />'; |
'<font color="red">Nothing submitted - no attempts</font><br /><br />'; |
next; |
next; |
Line 1665 KEYWORDS
|
Line 1683 KEYWORDS
|
if ($ENV{'form.lastSub'} eq 'lastonly' || |
if ($ENV{'form.lastSub'} eq 'lastonly' || |
($ENV{'form.lastSub'} eq 'hdgrade' && |
($ENV{'form.lastSub'} eq 'hdgrade' && |
$$handgrade{$part} eq 'yes')) { |
$$handgrade{$part} eq 'yes')) { |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '. |
my $display_part=&get_display_part($partid,$url,$symb); |
$partid.'</b> <font color="#999999">( ID '.$respid. |
$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part:</b> '. |
|
$display_part.' <font color="#999999">( ID '.$respid. |
' )</font> '; |
' )</font> '; |
if ($record{"resource.$partid.$respid.uploadedurl"}) { |
if ($record{"resource.$partid.$respid.uploadedurl"}) { |
&Apache::lonnet::allowuploaded('/adm/grades', |
&Apache::lonnet::allowuploaded('/adm/grades', |
Line 2299 sub viewgrades {
|
Line 2318 sub viewgrades {
|
my $sectionClass; |
my $sectionClass; |
if ($ENV{'form.section'} eq 'all') { |
if ($ENV{'form.section'} eq 'all') { |
$sectionClass='Class </h3>'; |
$sectionClass='Class </h3>'; |
} elsif ($ENV{'form.section'} eq 'no') { |
} elsif ($ENV{'form.section'} eq 'none') { |
$sectionClass='Students in no Section </h3>'; |
$sectionClass='Students in no Section </h3>'; |
} else { |
} else { |
$sectionClass='Students in Section '.$ENV{'form.section'}.'</h3>'; |
$sectionClass='Students in Section '.$ENV{'form.section'}.'</h3>'; |
Line 2326 sub viewgrades {
|
Line 2345 sub viewgrades {
|
$ctsparts.'" value="'.$partid.'" />'."\n"; |
$ctsparts.'" value="'.$partid.'" />'."\n"; |
$result.='<input type="hidden" name="weight_'. |
$result.='<input type="hidden" name="weight_'. |
$partid.'" value="'.$weight{$partid}.'" />'."\n"; |
$partid.'" value="'.$weight{$partid}.'" />'."\n"; |
$result.='<tr><td><b>Part '.$partid.' Point:</b> </td><td>'; |
my $display_part=&get_display_part($partid,$url,$symb); |
|
$result.='<tr><td><b>Part:</b> '.$display_part.' <b>Point:</b> </td><td>'; |
$result.='<table border="0"><tr>'; |
$result.='<table border="0"><tr>'; |
my $ctr = 0; |
my $ctr = 0; |
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across |
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across |
Line 2365 sub viewgrades {
|
Line 2385 sub viewgrades {
|
my $display=&Apache::lonnet::metadata($url,$part.'.display'); |
my $display=&Apache::lonnet::metadata($url,$part.'.display'); |
$display =~ s|^Number of Attempts|Tries<br />|; # makes the column narrower |
$display =~ s|^Number of Attempts|Tries<br />|; # makes the column narrower |
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } |
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } |
|
my ($partid) = &split_part_type($part); |
|
my $display_part=&get_display_part($partid,$url,$symb); |
if ($display =~ /^Partial Credit Factor/) { |
if ($display =~ /^Partial Credit Factor/) { |
my ($partid) = &split_part_type($part); |
$result.='<td><b>Score Part:</b> '.$display_part. |
$result.='<td><b>Score Part '.$partid.'<br />(weight = '. |
' <br /><b>(weight = '.$weight{$partid}.')</b></td>'."\n"; |
$weight{$partid}.')</b></td>'."\n"; |
|
next; |
next; |
|
} else { |
|
$display =~s/\[Part: \Q$partid\E\]/Part:<\/b> $display_part/; |
} |
} |
$display =~ s|Problem Status|Grade Status<br />|; |
$display =~ s|Problem Status|Grade Status<br />|; |
$result.='<td><b>'.$display.'</b></td>'."\n"; |
$result.='<td><b>'.$display.'</td>'."\n"; |
} |
} |
$result.='</tr>'; |
$result.='</tr>'; |
|
|
Line 2502 sub editgrades {
|
Line 2525 sub editgrades {
|
} |
} |
} |
} |
foreach my $partid (@partid) { |
foreach my $partid (@partid) { |
|
my $display_part=&get_display_part($partid,$url,$symb); |
$result .= '<td colspan="'.$columns{$partid}. |
$result .= '<td colspan="'.$columns{$partid}. |
'" align="center"><b>Part '.$partid. |
'" align="center"><b>Part:</b> '.$display_part. |
'</b> (Weight = '.$weight{$partid}.')</td>'; |
' (Weight = '.$weight{$partid}.')</td>'; |
|
|
} |
} |
$result .= '</tr><tr bgcolor="#deffff">'; |
$result .= '</tr><tr bgcolor="#deffff">'; |
Line 2598 sub editgrades {
|
Line 2622 sub editgrades {
|
if ($noupdate) { |
if ($noupdate) { |
# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3; |
# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3; |
my $numcols=scalar(@partid)*4+2; |
my $numcols=scalar(@partid)*4+2; |
$result .= '<tr bgcolor="#ffffff"><td align="center" colspan="'.$numcols.'">No Changes Occurred For the Students Below</td></tr>'.$noupdate; |
$result .= '<tr bgcolor="#ffffff"><td align="center" colspan="'.$numcols.'">No Changes Occurred For the Students Below</td></tr><tr bgcolor="#ffffde">'.$noupdate; |
} |
} |
$result .= '</table></td></tr></table>'."\n". |
$result .= '</table></td></tr></table>'."\n". |
&show_grading_menu_form ($symb,$url); |
&show_grading_menu_form ($symb,$url); |
Line 3213 sub displaySubByDates {
|
Line 3237 sub displaySubByDates {
|
foreach my $partid (@{$parts}) { |
foreach my $partid (@{$parts}) { |
my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys); |
my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys); |
# next if ($$record{"$version:resource.$partid.solved"} eq ''); |
# next if ($$record{"$version:resource.$partid.solved"} eq ''); |
|
my $display_part=&get_display_part($partid,undef,$symb); |
foreach my $matchKey (@matchKey) { |
foreach my $matchKey (@matchKey) { |
if (exists($$record{$version.':'.$matchKey}) && |
if (exists($$record{$version.':'.$matchKey}) && |
$$record{$version.':'.$matchKey} ne '') { |
$$record{$version.':'.$matchKey} ne '') { |
my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/); |
my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/); |
$displaySub[0].='<b>Part '.$partid.' '; |
$displaySub[0].='<b>Part:</b> '.$display_part.' '; |
$displaySub[0].='<font color="#999999">(ID '. |
$displaySub[0].='<font color="#999999">(ID '. |
$responseId.')</font> '; |
$responseId.')</font> <b>'; |
if ($$record{"$version:resource.$partid.tries"} eq '') { |
if ($$record{"$version:resource.$partid.tries"} eq '') { |
$displaySub[0].='Trial not counted'; |
$displaySub[0].='Trial not counted'; |
} else { |
} else { |
Line 3237 sub displaySubByDates {
|
Line 3262 sub displaySubByDates {
|
} |
} |
} |
} |
if (exists $$record{"$version:resource.$partid.award"}) { |
if (exists $$record{"$version:resource.$partid.award"}) { |
$displaySub[1].='<b>Part '.$partid.'</b> '. |
$displaySub[1].='<b>Part:</b> '.$display_part.' '. |
lc($$record{"$version:resource.$partid.award"}).' '. |
lc($$record{"$version:resource.$partid.award"}).' '. |
$mark{$$record{"$version:resource.$partid.solved"}}. |
$mark{$$record{"$version:resource.$partid.solved"}}. |
'<br />'; |
'<br />'; |
} |
} |
if (exists $$record{"$version:resource.$partid.regrader"}) { |
if (exists $$record{"$version:resource.$partid.regrader"}) { |
$displaySub[2].=$$record{"$version:resource.$partid.regrader"}. |
$displaySub[2].=$$record{"$version:resource.$partid.regrader"}. |
' (<b>'.&mt('Part').':</b> '.$partid.')'; |
' (<b>'.&mt('Part').':</b> '.$display_part.')'; |
} |
} |
} |
} |
# needed because old essay regrader has not parts info |
# needed because old essay regrader has not parts info |
Line 3341 sub updateGradeByPage {
|
Line 3366 sub updateGradeByPage {
|
$changeflag++; |
$changeflag++; |
$newpts = ''; |
$newpts = ''; |
} |
} |
|
my $display_part=&get_display_part($partid,undef, |
|
$curRes->symb()); |
my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid}; |
my $oldstatus = $ENV{'form.solved'.$question.'_'.$partid}; |
$displayPts[0].=' <b>Part</b> '.$partid.' = '. |
$displayPts[0].=' <b>Part:</b> '.$display_part.' = '. |
(($oldstatus eq 'excused') ? 'excused' : $oldpts). |
(($oldstatus eq 'excused') ? 'excused' : $oldpts). |
' <br>'; |
' <br>'; |
$displayPts[1].=' <b>Part</b> '.$partid.' = '. |
$displayPts[1].=' <b>Part:</b> '.$display_part.' = '. |
(($score eq 'excused') ? 'excused' : $newpts). |
(($score eq 'excused') ? 'excused' : $newpts). |
' <br>'; |
' <br>'; |
|
|
Line 3420 sub getSequenceDropDown {
|
Line 3446 sub getSequenceDropDown {
|
return $result; |
return $result; |
} |
} |
|
|
sub scantron_uploads { |
sub scantron_filenames { |
if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''}; |
|
my $result= '<select name="scantron_selectfile">'; |
|
my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname, |
&Apache::loncommon::propath($cdom,$cname)); |
&Apache::loncommon::propath($cdom,$cname)); |
$result.="<option></option>"; |
my @possiblenames; |
foreach my $filename (@files) { |
foreach my $filename (sort(@files)) { |
($filename)=split(/&/,$filename); |
($filename)=split(/&/,$filename); |
if ($filename!~/^scantron_orig_/) { next ; } |
if ($filename!~/^scantron_orig_/) { next ; } |
$filename=~s/^scantron_orig_//; |
$filename=~s/^scantron_orig_//; |
$result.="<option>$filename</option>\n"; |
push(@possiblenames,$filename); |
|
} |
|
return @possiblenames; |
|
} |
|
|
|
sub scantron_uploads { |
|
my ($file2grade) = @_; |
|
my $result= '<select name="scantron_selectfile">'; |
|
$result.="<option></option>"; |
|
foreach my $filename (sort(&scantron_filenames())) { |
|
$result.="<option".($filename eq $file2grade ? ' selected="on"':'').">$filename</option>\n"; |
} |
} |
$result.="</select>"; |
$result.="</select>"; |
return $result; |
return $result; |
Line 3457 sub scantron_CODElist {
|
Line 3491 sub scantron_CODElist {
|
my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum); |
my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum); |
my $namechoice='<option></option>'; |
my $namechoice='<option></option>'; |
foreach my $name (@names) { |
foreach my $name (sort(@names)) { |
if ($name =~ /^error: 2 /) { next; } |
if ($name =~ /^error: 2 /) { next; } |
$namechoice.='<option value="'.$name.'">'.$name.'</option>'; |
$namechoice.='<option value="'.$name.'">'.$name.'</option>'; |
} |
} |
Line 3478 sub scantron_CODEunique {
|
Line 3512 sub scantron_CODEunique {
|
} |
} |
|
|
sub scantron_selectphase { |
sub scantron_selectphase { |
my ($r) = @_; |
my ($r,$file2grade) = @_; |
my ($symb,$url)=&get_symb_and_url($r); |
my ($symb,$url)=&get_symb_and_url($r); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
my $sequence_selector=&getSequenceDropDown($r,$symb); |
my $sequence_selector=&getSequenceDropDown($r,$symb); |
my $default_form_data=&defaultFormData($symb,$url); |
my $default_form_data=&defaultFormData($symb,$url); |
my $grading_menu_button=&show_grading_menu_form($symb,$url); |
my $grading_menu_button=&show_grading_menu_form($symb,$url); |
my $file_selector=&scantron_uploads(); |
my $file_selector=&scantron_uploads($file2grade); |
my $format_selector=&scantron_scantab(); |
my $format_selector=&scantron_scantab(); |
my $CODE_selector=&scantron_CODElist(); |
my $CODE_selector=&scantron_CODElist(); |
my $CODE_unique=&scantron_CODEunique(); |
my $CODE_unique=&scantron_CODEunique(); |
Line 3496 sub scantron_selectphase {
|
Line 3530 sub scantron_selectphase {
|
<tr> |
<tr> |
<td bgcolor="#777777"> |
<td bgcolor="#777777"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantron_process"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantron_process"> |
<input type="hidden" name="command" value="scantron_validate" /> |
<input type="hidden" name="command" value="scantron_warning" /> |
$default_form_data |
$default_form_data |
<table width="100%" border="0"> |
<table width="100%" border="0"> |
<tr bgcolor="#e6ffff"> |
<tr bgcolor="#e6ffff"> |
Line 3602 SCANTRONFORM
|
Line 3636 SCANTRONFORM
|
<td> Filename of scoring office file: </td><td> $file_selector </td> |
<td> Filename of scoring office file: </td><td> $file_selector </td> |
</tr> |
</tr> |
<tr bgcolor="#ffffe6"> |
<tr bgcolor="#ffffe6"> |
<td> |
|
Records to download |
|
</td> |
|
<td> |
|
<input type="radio" name="scantron_options" value="download_skipped"/> Skipped Records <br /> |
|
<input type="radio" name="scantron_options" value="download_corrected"/> Corrected Records <br /> |
|
<input checked="on" type="radio" name="scantron_options" value="dowload_orig"/> Original Records |
|
</td> |
|
</tr> |
|
<tr bgcolor="#ffffe6"> |
|
<td colspan="2"> |
<td colspan="2"> |
<input type="submit" value="Validate Scantron Records" /> |
<input type="submit" value="Show List of Files" /> |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
Line 3821 sub scantron_find_student {
|
Line 3845 sub scantron_find_student {
|
|
|
sub scantron_filter { |
sub scantron_filter { |
my ($curres)=@_; |
my ($curres)=@_; |
if (ref($curres) && $curres->is_problem() && !$curres->randomout) { |
# randomout is dysfunctional at best for this purpose |
|
if (ref($curres) && $curres->is_problem()) { #&& !$curres->randomout) { |
return 1; |
return 1; |
} |
} |
return 0; |
return 0; |
Line 3928 sub check_for_error {
|
Line 3953 sub check_for_error {
|
} |
} |
} |
} |
|
|
|
sub scantron_warning_screen { |
|
my ($button_text)=@_; |
|
my $title=&Apache::lonnet::gettitle($ENV{'form.selectpage'}); |
|
return (<<STUFF); |
|
<p> |
|
<font color="red">Please double check the information |
|
below before clicking on '$button_text'</font> |
|
</p> |
|
<table> |
|
<tr><td><b>Sequence To be Graded:</b></td><td>$title</td></tr> |
|
<tr><td><b>Data File that will be used:</b></td><td><tt>$ENV{'form.scantron_selectfile'}</tt></td></tr> |
|
</table> |
|
</font> |
|
<br /> |
|
<p> If this information is correct, please click on '$button_text'.</p> |
|
<p> If something is incorrect, please click the 'Grading Menu' button to start over.</p> |
|
|
|
<br /> |
|
STUFF |
|
} |
|
|
|
sub scantron_do_warning { |
|
my ($r)=@_; |
|
my ($symb,$url)=&get_symb_and_url($r); |
|
if (!$symb) {return '';} |
|
my $default_form_data=&defaultFormData($symb,$url); |
|
$r->print(&scantron_form_start().$default_form_data); |
|
my $warning=&scantron_warning_screen('Validate Records'); |
|
$r->print(<<STUFF); |
|
$warning |
|
<input type="submit" name="submit" value="Validate Records" /> |
|
<input type="hidden" name="command" value="scantron_validate" /> |
|
</form> |
|
STUFF |
|
$r->print("<br />".&show_grading_menu_form($symb,$url)."</body></html>"); |
|
return ''; |
|
} |
|
|
|
sub scantron_form_start { |
|
my ($max_bubble)=@_; |
|
my $result= <<SCANTRONFORM; |
|
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
|
<input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" /> |
|
<input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" /> |
|
<input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" /> |
|
<input type="hidden" name="scantron_maxbubble" value="$max_bubble'" /> |
|
<input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" /> |
|
<input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" /> |
|
<input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" /> |
|
<input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" /> |
|
SCANTRONFORM |
|
return $result; |
|
} |
|
|
sub scantron_validate_file { |
sub scantron_validate_file { |
my ($r) = @_; |
my ($r) = @_; |
my ($symb,$url)=&get_symb_and_url($r); |
my ($symb,$url)=&get_symb_and_url($r); |
Line 3956 sub scantron_validate_file {
|
Line 4035 sub scantron_validate_file {
|
&scantron_process_corrections($r); |
&scantron_process_corrections($r); |
} |
} |
$r->print("<p>Gathering neccessary info.</p>");$r->rflush(); |
$r->print("<p>Gathering neccessary info.</p>");$r->rflush(); |
my $max_bubble=&scantron_get_maxbubble($r); |
|
#get the student pick code ready |
#get the student pick code ready |
$r->print(&Apache::loncommon::studentbrowser_javascript()); |
$r->print(&Apache::loncommon::studentbrowser_javascript()); |
my $result= <<SCANTRONFORM; |
my $max_bubble=&scantron_get_maxbubble($r); |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
my $result=&scantron_form_start($max_bubble).$default_form_data; |
<input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" /> |
|
<input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" /> |
|
<input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" /> |
|
<input type="hidden" name="scantron_maxbubble" value="$max_bubble'" /> |
|
<input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" /> |
|
<input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" /> |
|
<input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_options_redo'}" /> |
|
<input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_options_ignore'}" /> |
|
$default_form_data |
|
SCANTRONFORM |
|
$r->print($result); |
$r->print($result); |
|
|
my @validate_phases=( 'ID', |
my @validate_phases=( 'ID', |
Line 3993 SCANTRONFORM
|
Line 4061 SCANTRONFORM
|
} |
} |
} |
} |
if (!$stop) { |
if (!$stop) { |
$r->print("Validation process complete.<br />"); |
my $warning=&scantron_warning_screen('Start Grading'); |
$r->print('<input type="submit" name="submit" value="Start Grading" />'); |
$r->print(<<STUFF); |
$r->print('<input type="hidden" name="command" value="scantron_process" />'); |
Validation process complete.<br /> |
|
$warning |
|
<input type="submit" name="submit" value="Start Grading" /> |
|
<input type="hidden" name="command" value="scantron_process" /> |
|
STUFF |
|
|
} else { |
} else { |
$r->print('<input type="hidden" name="command" value="scantron_validate" />'); |
$r->print('<input type="hidden" name="command" value="scantron_validate" />'); |
$r->print("<input type='hidden' name='validatepass' value='".$currentphase."' />"); |
$r->print("<input type='hidden' name='validatepass' value='".$currentphase."' />"); |
Line 4398 sub scantron_validate_CODE {
|
Line 4471 sub scantron_validate_CODE {
|
$line,'incorrectCODE',\%allcodes); |
$line,'incorrectCODE',\%allcodes); |
return(1,$currentphase); |
return(1,$currentphase); |
} |
} |
if (exists($usedCODEs{$CODE}) && $ENV{'form.scantron_CODEunique'} |
if (exists($usedCODEs{$CODE}) |
|
&& $ENV{'form.scantron_CODEunique'} eq 'yes' |
&& !$$scan_record{'scantron.CODE_ignore_dup'}) { |
&& !$$scan_record{'scantron.CODE_ignore_dup'}) { |
&scantron_get_correction($r,$i,$scan_record, |
&scantron_get_correction($r,$i,$scan_record, |
\%scantron_config, |
\%scantron_config, |
Line 4565 SCANTRONFORM
|
Line 4639 SCANTRONFORM
|
$form{'CODE'}=$scan_record->{'scantron.CODE'}; |
$form{'CODE'}=$scan_record->{'scantron.CODE'}; |
} |
} |
my $result=&Apache::lonnet::ssi($resource->src(),%form); |
my $result=&Apache::lonnet::ssi($resource->src(),%form); |
|
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} |
} |
$completedstudents{$uname}={'line'=>$line}; |
$completedstudents{$uname}={'line'=>$line}; |
|
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} continue { |
} continue { |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('scantron\.'); |
&Apache::lonnet::delenv('scantron\.'); |
Line 4637 sub scantron_upload_scantron_data_save {
|
Line 4712 sub scantron_upload_scantron_data_save {
|
} |
} |
return ''; |
return ''; |
} |
} |
$r->print("Doing upload to ".$ENV{'form.courseid'}." <br />"); |
my %coursedata=&Apache::lonnet::coursedescription($ENV{'form.domainid'}.'_'.$ENV{'form.courseid'}); |
|
$r->print("Doing upload to ".$coursedata{'description'}." <br />"); |
my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'}, |
my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'}, |
$ENV{'form.domainid'}); |
$ENV{'form.domainid'}); |
my $fname=$ENV{'form.upfile.filename'}; |
my $fname=$ENV{'form.upfile.filename'}; |
Line 4654 sub scantron_upload_scantron_data_save {
|
Line 4730 sub scantron_upload_scantron_data_save {
|
$fname=~s/[^\w\.\-]//g; |
$fname=~s/[^\w\.\-]//g; |
# See if there is anything left |
# See if there is anything left |
unless ($fname) { return 'error: no uploaded file'; } |
unless ($fname) { return 'error: no uploaded file'; } |
|
my $uploadedfile=$fname; |
$fname='scantron_orig_'.$fname; |
$fname='scantron_orig_'.$fname; |
if (length($ENV{'form.upfile'}) < 2) { |
if (length($ENV{'form.upfile'}) < 2) { |
$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename."); |
$r->print("<font color='red'>Error:</font> The file you attempted to upload, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>, contained no information. Please check that you entered the correct filename."); |
Line 4662 sub scantron_upload_scantron_data_save {
|
Line 4739 sub scantron_upload_scantron_data_save {
|
if ($result =~ m|^/uploaded/|) { |
if ($result =~ m|^/uploaded/|) { |
$r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>"); |
$r->print("<font color='green'>Success:</font> Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location <tt>".$result."</tt>"); |
} else { |
} else { |
$r->print("<font color='red'>Error:</font> An error (".$result.") occured when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>"); |
$r->print("<font color='red'>Error:</font> An error (".$result.") occurred when attempting to upload the file, <tt>".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."</tt>"); |
} |
} |
} |
} |
if ($symb) { |
if ($symb) { |
$r->print(&show_grading_menu_form($symb,$url)); |
$r->print(&scantron_selectphase($r,$uploadedfile)); |
} else { |
} else { |
$r->print($doanotherupload); |
$r->print($doanotherupload); |
} |
} |
return ''; |
return ''; |
} |
} |
|
|
|
sub valid_file { |
|
my ($requested_file)=@_; |
|
foreach my $filename (sort(&scantron_filenames())) { |
|
&Apache::lonnet::logthis("$requested_file $filename"); |
|
if ($requested_file eq $filename) { return 1; } |
|
} |
|
return 0; |
|
} |
|
|
|
sub scantron_download_scantron_data { |
|
my ($r)=@_; |
|
my $default_form_data=&defaultFormData(&get_symb_and_url($r,1)); |
|
my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
my $file=$ENV{'form.scantron_selectfile'}; |
|
if (! &valid_file($file)) { |
|
$r->print(<<ERROR); |
|
<p> |
|
The requested file name was invalid. |
|
</p> |
|
ERROR |
|
$r->print(&show_grading_menu_form(&get_symb_and_url($r,1))); |
|
return; |
|
} |
|
my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file; |
|
my $corrected='/uploaded/'.$cdom.'/'.$cname.'/scantron_corrected_'.$file; |
|
my $skipped='/uploaded/'.$cdom.'/'.$cname.'/scantron_skipped_'.$file; |
|
&Apache::lonnet::allowuploaded('/adm/grades',$orig); |
|
&Apache::lonnet::allowuploaded('/adm/grades',$corrected); |
|
&Apache::lonnet::allowuploaded('/adm/grades',$skipped); |
|
$r->print(<<DOWNLOAD); |
|
<p> |
|
<a href="$orig">Original</a> file as uploaded by the scantron office. |
|
</p> |
|
<p> |
|
<a href="$corrected">Corrections</a>, a file of corrected records that were used in grading. |
|
</p> |
|
<p> |
|
<a href="$skipped">Skipped</a>, a file of records that were skipped. |
|
</p> |
|
DOWNLOAD |
|
$r->print(&show_grading_menu_form(&get_symb_and_url($r,1))); |
|
return ''; |
|
} |
|
|
#-------- end of section for handling grading scantron forms ------- |
#-------- end of section for handling grading scantron forms ------- |
# |
# |
Line 4787 GRADINGMENUJS
|
Line 4908 GRADINGMENUJS
|
|
|
$result.=&mt('Student Status').':</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef); |
$result.=&mt('Student Status').':</b>'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef); |
|
|
if (ref($sections) && (grep /no/,@$sections)) { |
|
$result.=' (Section "no" implies the students were not assigned a section.)<br />'; |
|
} |
|
$result.='</td></tr>'; |
$result.='</td></tr>'; |
|
|
$result.='<tr bgcolor="#ffffe6"valign="top"><td>'. |
$result.='<tr bgcolor="#ffffe6"valign="top"><td>'. |
Line 4950 sub handler {
|
Line 5068 sub handler {
|
} |
} |
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { |
$request->print(&scantron_selectphase($request)); |
$request->print(&scantron_selectphase($request)); |
} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) { |
$request->print(&scantron_validate_file($request)); |
$request->print(&scantron_do_warning($request)); |
} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) { |
$request->print(&scantron_validate_file($request)); |
$request->print(&scantron_validate_file($request)); |
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) { |
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) { |
Line 4964 sub handler {
|
Line 5082 sub handler {
|
(&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})|| |
(&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})|| |
&Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) { |
&Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) { |
$request->print(&scantron_upload_scantron_data_save($request)); |
$request->print(&scantron_upload_scantron_data_save($request)); |
} elsif ($command eq 'scantrondownload' && |
} elsif ($command eq 'scantron_download' && |
&Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) { |
&Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) { |
$request->print(&scantron_download_scantron_data($request)); |
$request->print(&scantron_download_scantron_data($request)); |
} elsif ($command) { |
} elsif ($command) { |
Line 4989 sub send_header {
|
Line 5107 sub send_header {
|
|
|
sub send_footer { |
sub send_footer { |
my ($request)= @_; |
my ($request)= @_; |
$request->print('</body>'); |
$request->print('</body></html>'); |
$request->print(&Apache::lontexconvert::footer()); |
|
} |
} |
|
|
1; |
1; |