version 1.77, 2003/03/27 20:36:01
|
version 1.84, 2003/04/11 17:57:37
|
Line 343 LISTJAVASCRIPT
|
Line 343 LISTJAVASCRIPT
|
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; |
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; |
|
|
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n". |
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n". |
' <b>View Problem: </b><input type="radio" name="vProb" value="no" /> no '."\n". |
' <b>View Problem: </b><input type="radio" name="vProb" value="no" checked /> no '."\n". |
'<input type="radio" name="vProb" value="yes" checked /> one student '."\n". |
'<input type="radio" name="vProb" value="yes" /> one student '."\n". |
'<input type="radio" name="vProb" value="all" /> all students <br />'."\n". |
'<input type="radio" name="vProb" value="all" /> all students <br />'."\n". |
' <b>Submissions: </b>'."\n"; |
' <b>Submissions: </b>'."\n"; |
if ($ENV{'form.handgrade'} eq 'yes') { |
if ($ENV{'form.handgrade'} eq 'yes') { |
Line 628 SUBJAVASCRIPT
|
Line 628 SUBJAVASCRIPT
|
#--- javascript for essay type problem -- |
#--- javascript for essay type problem -- |
sub sub_page_kw_js { |
sub sub_page_kw_js { |
my $request = shift; |
my $request = shift; |
|
my $iconpath = $request->dir_config('lonIconsURL'); |
$request->print(<<SUBJAVASCRIPT); |
$request->print(<<SUBJAVASCRIPT); |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
|
|
Line 675 sub sub_page_kw_js {
|
Line 676 sub sub_page_kw_js {
|
} |
} |
|
|
//====================== Script for composing message ============== |
//====================== Script for composing message ============== |
|
// preload images |
|
img1 = new Image(); |
|
img1.src = "$iconpath/mailbkgrd.gif"; |
|
img2 = new Image(); |
|
img2.src = "$iconpath/mailto.gif"; |
|
|
function msgCenter(msgform,usrctr,fullname) { |
function msgCenter(msgform,usrctr,fullname) { |
var Nmsg = msgform.savemsgN.value; |
var Nmsg = msgform.savemsgN.value; |
savedMsgHeader(Nmsg,usrctr,fullname); |
savedMsgHeader(Nmsg,usrctr,fullname); |
Line 710 sub sub_page_kw_js {
|
Line 717 sub sub_page_kw_js {
|
height = 600; |
height = 600; |
scrollbar = "yes"; |
scrollbar = "yes"; |
} |
} |
// if (window.pWin) window.pWin.close(); |
// if (window.pWin) {window.pWin.close(); window.pWin=null} |
pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height); |
pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height); |
pWin.focus(); |
pWin.focus(); |
pDoc = pWin.document; |
pDoc = pWin.document; |
Line 729 sub sub_page_kw_js {
|
Line 736 sub sub_page_kw_js {
|
pDoc.write(" if (document.msgcenter.subchk.checked) {"); |
pDoc.write(" if (document.msgcenter.subchk.checked) {"); |
pDoc.write(" msgchk = \\"msgsub,\\";"); |
pDoc.write(" msgchk = \\"msgsub,\\";"); |
pDoc.write(" }"); |
pDoc.write(" }"); |
pDoc.write( "for (var i=1; i<=nmsg; i++) {"); |
pDoc.write(" var includemsg = 0;"); |
|
pDoc.write(" for (var i=1; i<=nmsg; i++) {"); |
pDoc.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);"); |
pDoc.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);"); |
pDoc.write(" var frmmsg = eval(\\"document.msgcenter.msg\\"+i);"); |
pDoc.write(" var frmmsg = eval(\\"document.msgcenter.msg\\"+i);"); |
pDoc.write(" opnmsg.value = frmmsg.value;"); |
pDoc.write(" opnmsg.value = frmmsg.value;"); |
pDoc.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);"); |
pDoc.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);"); |
pDoc.write(" if (chkbox.checked) {"); |
pDoc.write(" if (chkbox.checked) {"); |
pDoc.write(" msgchk += \\"savemsg\\"+i+\\",\\";"); |
pDoc.write(" msgchk += \\"savemsg\\"+i+\\",\\";"); |
|
pDoc.write(" includemsg = 1;"); |
pDoc.write(" }"); |
pDoc.write(" }"); |
pDoc.write(" }"); |
pDoc.write(" }"); |
pDoc.write(" if (document.msgcenter.newmsgchk.checked) {"); |
pDoc.write(" if (document.msgcenter.newmsgchk.checked) {"); |
pDoc.write(" msgchk += \\"newmsg\\"+usrctr;"); |
pDoc.write(" msgchk += \\"newmsg\\"+usrctr;"); |
|
pDoc.write(" includemsg = 1;"); |
pDoc.write(" }"); |
pDoc.write(" }"); |
|
pDoc.write(" imgformname = eval(\\"opener.document.SCORE.mailicon\\"+usrctr);"); |
|
pDoc.write(" imgformname.src = \\"$iconpath/\\"+((includemsg) ? \\"mailto.gif\\" : \\"mailbkgrd.gif\\");"); |
pDoc.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);"); |
pDoc.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);"); |
pDoc.write(" includemsg.value = msgchk;"); |
pDoc.write(" includemsg.value = msgchk;"); |
|
|
Line 1030 sub submission {
|
Line 1042 sub submission {
|
|
|
$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n". |
$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n". |
'<input type="hidden" name="command" value="handgrade" />'."\n". |
'<input type="hidden" name="command" value="handgrade" />'."\n". |
'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". |
'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". |
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". |
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n". |
'<input type="hidden" name="refresh" value="off" />'."\n". |
'<input type="hidden" name="refresh" value="off" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
Line 1054 sub submission {
|
Line 1066 sub submission {
|
my ($cts,$prnmsg) = (1,''); |
my ($cts,$prnmsg) = (1,''); |
while ($cts <= $ENV{'form.savemsgN'}) { |
while ($cts <= $ENV{'form.savemsgN'}) { |
$prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'. |
$prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'. |
($keyhash{$symb.'_savemsg'.$cts} eq '' ? $ENV{'form.savemsg'.$cts} : $keyhash{$symb.'_savemsg'.$cts}). |
($keyhash{$symb.'_savemsg'.$cts} eq '' ? |
|
&Apache::lonfeedback::clear_out_html($ENV{'form.savemsg'.$cts}) : |
|
&Apache::lonfeedback::clear_out_html($keyhash{$symb.'_savemsg'.$cts})). |
'" />'."\n"; |
'" />'."\n"; |
$cts++; |
$cts++; |
} |
} |
Line 1095 KEYWORDS
|
Line 1109 KEYWORDS
|
my ($classlist,$fullname); |
my ($classlist,$fullname); |
if ($ENV{'form.handgrade'} eq 'yes') { |
if ($ENV{'form.handgrade'} eq 'yes') { |
my @col_list; |
my @col_list; |
($classlist,undef,$fullname) = &getclasslist('all',$ENV{'form.showgrading'} eq 'yes' ? '1' : '0'); |
($classlist,undef,$fullname) = &getclasslist('all','0'); |
for (keys (%$handgrade)) { |
for (keys (%$handgrade)) { |
my $ncol = &Apache::lonnet::EXT('resource.'.$_. |
my $ncol = &Apache::lonnet::EXT('resource.'.$_. |
'.maxcollaborators', |
'.maxcollaborators', |
Line 1103 KEYWORDS
|
Line 1117 KEYWORDS
|
next if ($ncol <= 0); |
next if ($ncol <= 0); |
s/\_/\./g; |
s/\_/\./g; |
next if ($record{'resource.'.$_.'.collaborators'} eq ''); |
next if ($record{'resource.'.$_.'.collaborators'} eq ''); |
my (@collaborators) = split(/,?\s+/, |
my (@colList) = split(/,?\s+/, |
$record{'resource.'.$_.'.collaborators'}); |
$record{'resource.'.$_.'.collaborators'}); |
|
my @collaborators = (); |
|
foreach (@colList) { #pre-filter list - throw out submitter |
|
my ($co_name,$co_dom) = split /\@|:/,$_; |
|
$co_dom = $udom if (! defined($co_dom)); |
|
next if ($co_name eq $uname && $co_dom eq $udom); |
|
push @collaborators, $_; |
|
} |
my (@badcollaborators); |
my (@badcollaborators); |
if (scalar(@collaborators) != 0) { |
if (scalar(@collaborators) != 0) { |
$result.='<b>Collaborators: </b>'; |
$result.='<b>Collaborators: </b>'; |
foreach my $collaborator (@collaborators) { |
foreach my $collaborator (@collaborators) { |
my ($co_name,$co_dom) = split /\@|:/,$collaborator; |
my ($co_name,$co_dom) = split /\@|:/,$collaborator; |
$co_dom = $udom if (! defined($co_dom)); |
$co_dom = $udom if (! defined($co_dom)); |
next if ($co_name eq $uname && $co_dom eq $udom); |
|
# Doing this grep allows 'fuzzy' specification |
# Doing this grep allows 'fuzzy' specification |
my @Matches = grep /^$co_name:$co_dom/i, |
my @Matches = grep /^$co_name:$co_dom$/i, |
keys %$classlist; |
keys %$classlist; |
if (! scalar(@Matches)) { |
if (! scalar(@Matches)) { |
push @badcollaborators,$collaborator; |
push @badcollaborators,':'.$collaborator.':'; |
next; |
next; |
} |
} |
push @col_list, @Matches; |
push @col_list, @Matches; |
Line 1226 KEYWORDS
|
Line 1246 KEYWORDS
|
my $lastone = pop @col_fullnames; |
my $lastone = pop @col_fullnames; |
$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.'; |
$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.'; |
} |
} |
|
$msgfor =~ s/\'/\\'/g; |
$result.='<tr><td bgcolor="#ffffff">'."\n". |
$result.='<tr><td bgcolor="#ffffff">'."\n". |
' <a href="javascript:msgCenter(document.SCORE,'.$counter. |
' <a href="javascript:msgCenter(document.SCORE,'.$counter. |
',\''.$msgfor.'\')"; TARGET=_self>'. |
',\''.$msgfor.'\')"; TARGET=_self>'. |
'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'. |
'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a> '. |
|
'<img src="'.$request->dir_config('lonIconsURL'). |
|
'/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n". |
'<br /> (Message will be sent when you click on Save & Next below.)'."\n" |
'<br /> (Message will be sent when you click on Save & Next below.)'."\n" |
if ($ENV{'form.handgrade'} eq 'yes'); |
if ($ENV{'form.handgrade'} eq 'yes'); |
$request->print($result); |
$request->print($result); |
Line 1348 sub processHandGrade {
|
Line 1371 sub processHandGrade {
|
$ctr++; |
$ctr++; |
next; |
next; |
} |
} |
|
|
my $includemsg = $ENV{'form.includemsg'.$ctr}; |
my $includemsg = $ENV{'form.includemsg'.$ctr}; |
my ($subject,$message,$msgstatus) = ('','',''); |
my ($subject,$message,$msgstatus) = ('','',''); |
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { |
if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { |
Line 1357 sub processHandGrade {
|
Line 1379 sub processHandGrade {
|
foreach (@msgnum) { |
foreach (@msgnum) { |
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
$message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); |
} |
} |
$message =~ s/<([^>]|\n)*>//g; # removes html codes Or should this be lonnet::escape ?? |
$message =&Apache::lonfeedback::clear_out_html($message); |
$message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt; |
$message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt; |
$message.=" for <a href=\"/res/$url\">$ENV{'form.probTitle'}</a>"; |
$message.=" for <a href=\"". |
|
&Apache::lonnet::clutter($url). |
|
"?symb=$symb\">$ENV{'form.probTitle'}</a>"; |
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, |
$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, |
$ENV{'form.msgsub'},$message); |
$ENV{'form.msgsub'},$message); |
} |
} |
Line 2343 LISTJAVASCRIPT
|
Line 2367 LISTJAVASCRIPT
|
my $result='<h3><font color="#339933"> '. |
my $result='<h3><font color="#339933"> '. |
'Manual Grading by Page or Sequence</font></h3>'; |
'Manual Grading by Page or Sequence</font></h3>'; |
|
|
$result.='<form action="/adm/grades" method="post" name="displayPage">'."<br>\n"; |
$result.='<form action="/adm/grades" method="post" name="displayPage">'."\n"; |
$result.=' <b>Problems from:</b> <select name="selectpage">'."\n"; |
$result.=' <b>Problems from:</b> <select name="selectpage">'."\n"; |
my ($titles,$symbx) = &getSymbMap($request); |
my ($titles,$symbx) = &getSymbMap($request); |
my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); |
my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); |
Line 2377 LISTJAVASCRIPT
|
Line 2401 LISTJAVASCRIPT
|
$result.='<input type="hidden" name="section" value="'.$getsec.'" />'."\n". |
$result.='<input type="hidden" name="section" value="'.$getsec.'" />'."\n". |
'<input type="hidden" name="command" value="displayPage" />'."\n". |
'<input type="hidden" name="command" value="displayPage" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."<br><br>\n". |
'<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n"; |
'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."<br />\n"; |
|
|
$result.='<br /> <input type="button" '. |
$result.=' <input type="button" '. |
'onClick="javascript:checkPickOne(this.form);"value="Submit" /><br />'."\n"; |
'onClick="javascript:checkPickOne(this.form);"value="Submit" /><br />'."\n"; |
|
|
$request->print($result); |
$request->print($result); |
Line 2418 LISTJAVASCRIPT
|
Line 2442 LISTJAVASCRIPT
|
|
|
sub getSymbMap { |
sub getSymbMap { |
my ($request) = @_; |
my ($request) = @_; |
my $navmap = Apache::lonnavmaps::navmap-> new($request, |
my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', |
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
|
|
my $res = $navmap->firstResource(); # temp resource to access constants |
my $res = $navmap->firstResource(); # temp resource to access constants |
Line 2494 sub displayPage {
|
Line 2517 sub displayPage {
|
&sub_page_js($request); |
&sub_page_js($request); |
$request->print($result); |
$request->print($result); |
|
|
my $navmap = Apache::lonnavmaps::navmap-> new($request, |
my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', |
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
Line 2542 sub displayPage {
|
Line 2564 sub displayPage {
|
} else { |
} else { |
my $companswer = &Apache::loncommon::get_student_answers( |
my $companswer = &Apache::loncommon::get_student_answers( |
$symbx,$uname,$udom,$ENV{'request.course.id'}); |
$symbx,$uname,$udom,$ENV{'request.course.id'}); |
$companswer=~s|<form(.*?)>||g; |
$companswer =~ s|<form(.*?)>||g; |
$companswer=~s|</form>||g; |
$companswer =~ s|</form>||g; |
|
|
# while ($companswer =~ /(<a href\=\"javascript:newWindow.*?Script Vars<\/a>)/s) { #<a href="javascript:newWindow</a> |
# while ($companswer =~ /(<a href\=\"javascript:newWindow.*?Script Vars<\/a>)/s) { #<a href="javascript:newWindow</a> |
# $request->print('match='.$1.'<br>'); |
# $request->print('match='.$1.'<br>'); |
Line 2576 sub displayPage {
|
Line 2598 sub displayPage {
|
# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && |
# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && |
# $record{"$version:resource.$partid.solved"} eq ''); |
# $record{"$version:resource.$partid.solved"} eq ''); |
$displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? |
$displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? |
'<b>Trial '.$version.' Part '.$partid.'</b> ' |
'<b>Part '.$partid.' '. |
.$record{$version.':'.$matchKey[0]}.'<br />' : ''; |
($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' : |
|
'Trial '.$record{"$version:resource.$partid.tries"}).'</b> '. |
|
$record{$version.':'.$matchKey[0]}.'<br />' : ''; |
$displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? |
$displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? |
'<b>Part '.$partid.'</b> '. |
'<b>Part '.$partid.'</b> '. |
$record{"$version:resource.$partid.award"}.'/'. |
$record{"$version:resource.$partid.award"}.'/'. |
Line 2650 sub updateGradeByPage {
|
Line 2674 sub updateGradeByPage {
|
|
|
$request->print($result); |
$request->print($result); |
|
|
my $navmap = Apache::lonnavmaps::navmap-> new($request, |
my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', |
$ENV{'request.course.fn'}.'.db', |
|
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
$ENV{'request.course.fn'}.'_parms.db',1, 1); |
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); |
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps |
Line 2753 sub updateGradeByPage {
|
Line 2776 sub updateGradeByPage {
|
# |
# |
#------ start of section for handling grading by page/sequence --------- |
#------ start of section for handling grading by page/sequence --------- |
|
|
|
sub defaultFormData { |
|
my ($symb,$url)=@_; |
|
return ' |
|
<input type="hidden" name="symb" value="'.$symb.'" />'."\n". |
|
'<input type="hidden" name="url" value="'.$url.'" />'."\n". |
|
'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n". |
|
'<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n"; |
|
} |
|
|
sub getSequenceDropDown { |
sub getSequenceDropDown { |
my ($request,$symb)=@_; |
my ($request,$symb)=@_; |
my $result='<select name="selectpage">'."\n"; |
my $result='<select name="selectpage">'."\n"; |
Line 2770 sub getSequenceDropDown {
|
Line 2802 sub getSequenceDropDown {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub scantron_uploads { |
|
if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''}; |
|
my $result= '<select name="scantron_selectfile">'; |
|
opendir(DIR,$Apache::lonnet::perlvar{'lonScansDir'}); |
|
my @files=sort(readdir(DIR)); |
|
foreach my $filename (@files) { |
|
if ($filename eq '.' or $filename eq '..') { next; } |
|
$result.="<option>$filename</option>\n"; |
|
} |
|
closedir(DIR); |
|
$result.="</select>"; |
|
return $result; |
|
} |
|
|
|
sub scantron_scantab { |
|
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
|
my $result='<select name="scantron_format">'."\n"; |
|
foreach my $line (<$fh>) { |
|
my ($name,$descrip)=split(/:/,$line); |
|
if ($name =~ /^\#/) { next; } |
|
$result.='<option value="'.$name.'">'.$descrip.'</option>'."\n"; |
|
} |
|
$result.='</select>'."\n"; |
|
|
|
return $result; |
|
} |
|
|
sub scantron_selectphase { |
sub scantron_selectphase { |
my ($r) = @_; |
my ($r) = @_; |
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 $grading_menu_button=&show_grading_menu_form($symb,$url); |
|
my $file_selector=&scantron_uploads(); |
|
my $format_selector=&scantron_scantab(); |
my $result; |
my $result; |
$result.= <<SCANTRONFORM; |
$result.= <<SCANTRONFORM; |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process"> |
<input type="hidden" name="symb" value="$symb" /> |
<input type="hidden" name="command" value="scantron_process" /> |
<input type="hidden" name="url" value="$url" /> |
$default_form_data |
<input type="hidden" name="command" value="scantron_configphase" /> |
|
<table width="100%" border="0"> |
<table width="100%" border="0"> |
<tr> |
<tr> |
<td bgcolor="#777777"> |
<td bgcolor="#777777"> |
Line 2797 sub scantron_selectphase {
|
Line 2859 sub scantron_selectphase {
|
</tr> |
</tr> |
<tr bgcolor="#ffffe6"> |
<tr bgcolor="#ffffe6"> |
<td> |
<td> |
<!-- FIXME I need to present a list of files from a specfic directory that has been configured, or any existing delay queues --> |
Filename of scoring office file: $file_selector |
Filename of scoring office file: |
</td> |
<select name="selectfile"> |
</tr> |
<option value="filname1">filename1</option> |
<tr bgcolor="#ffffe6"> |
<option value="filname2">filename2</option> |
<td> |
</select> |
Format of data file: $format_selector |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
Line 2811 sub scantron_selectphase {
|
Line 2873 sub scantron_selectphase {
|
</table> |
</table> |
<input type="submit" value="Submit" /> |
<input type="submit" value="Submit" /> |
</form> |
</form> |
|
$grading_menu_button |
SCANTRONFORM |
SCANTRONFORM |
|
|
return $result; |
return $result; |
} |
} |
|
|
sub scantron_configphase { |
sub get_scantron_config { |
|
my ($which) = @_; |
|
my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); |
|
my %config; |
|
foreach my $line (<$fh>) { |
|
my ($name,$descrip)=split(/:/,$line); |
|
if ($name ne $which ) { next; } |
|
chomp($line); |
|
my @config=split(/:/,$line); |
|
$config{'name'}=$config[0]; |
|
$config{'description'}=$config[1]; |
|
$config{'CODElocation'}=$config[2]; |
|
$config{'CODEstart'}=$config[3]; |
|
$config{'CODElength'}=$config[4]; |
|
$config{'IDstart'}=$config[5]; |
|
$config{'IDlength'}=$config[6]; |
|
$config{'Qstart'}=$config[7]; |
|
$config{'Qlength'}=$config[8]; |
|
$config{'Qoff'}=$config[9]; |
|
$config{'Qon'}=$config[10]; |
|
last; |
|
} |
|
return %config; |
|
} |
|
|
|
sub username_to_idmap { |
|
my ($classlist)= @_; |
|
my %idmap; |
|
foreach my $student (keys(%$classlist)) { |
|
$idmap{$classlist->{$student}->[&Apache::loncoursedata::CL_ID]}= |
|
$student; |
|
} |
|
return %idmap; |
|
} |
|
|
|
sub scantron_parse_scanline { |
|
my ($line,$scantron_config)=@_; |
|
my %record; |
|
my $questions=substr($line,$$scantron_config{'Qstart'}-1); |
|
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); |
|
if ($$scantron_config{'CODElocation'} ne 0) { |
|
if ($$scantron_config{'CODElocation'} < 0) { |
|
$record{'scantron.CODE'}=substr($data,$$scantron_config{'CODEstart'}-1, |
|
$$scantron_config{'CODElength'}); |
|
} else { |
|
#FIXME interpret first N questions |
|
} |
|
} |
|
$record{'scantron.ID'}=substr($data,$$scantron_config{'IDstart'}-1, |
|
$$scantron_config{'IDlength'}); |
|
my @alphabet=('A'..'Z'); |
|
my $questnum=0; |
|
while ($questions) { |
|
$questnum++; |
|
my $currentquest=substr($questions,0,$$scantron_config{'Qlength'}); |
|
substr($questions,0,$$scantron_config{'Qlength'})=''; |
|
if (length($currentquest) < $$scantron_config{'Qlength'}) { next; } |
|
my (@array)=split(/$$scantron_config{'Qon'}/,$currentquest); |
|
if (scalar(@array) gt 2) { |
|
#FIXME do something intelligent with double bubbles |
|
Apache->request->print("<br ><b>Wha!!!</b> <pre>".scalar(@array). |
|
'-'.$currentquest.'-'.$questnum.'</pre><br />'); |
|
} |
|
if (length($array[0]) eq $$scantron_config{'Qlength'}) { |
|
$record{"scantron.$questnum.answer"}=''; |
|
} else { |
|
$record{"scantron.$questnum.answer"}=$alphabet[length($array[0])]; |
|
} |
|
} |
|
$record{'scantron.maxquest'}=$questnum; |
|
return \%record; |
|
} |
|
|
|
sub scantron_add_delay { |
|
} |
|
|
|
sub scantron_find_student { |
|
my ($scantron_record,$idmap)=@_; |
|
my $scanID=$$scantron_record{'scantron.ID'}; |
|
foreach my $id (keys(%$idmap)) { |
|
Apache->request->print('<pre>checking studnet -'.$id.'- againt -'.$scanID.'- </pre>'); |
|
if (lc($id) eq lc($scanID)) { Apache->request->print('success');return $$idmap{$id}; } |
|
} |
|
return undef; |
|
} |
|
|
|
sub scantron_filter { |
|
my ($curres)=@_; |
|
if (ref($curres) && $curres->is_problem() && !$curres->randomout) { |
|
return 1; |
|
} |
|
return 0; |
|
} |
|
|
|
sub scantron_process_students { |
my ($r) = @_; |
my ($r) = @_; |
my $sequence=$ENV{'form.selectpage'}; |
my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'}); |
my $result; |
my ($symb,$url)=&get_symb_and_url($r); |
$result.="got page $sequence"; |
if (!$symb) {return '';} |
|
my $default_form_data=&defaultFormData($symb,$url); |
|
|
|
my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'}); |
|
my $scanlines=Apache::File->new($Apache::lonnet::perlvar{'lonScansDir'}."/$ENV{'form.scantron_selectfile'}"); |
|
my $classlist=&Apache::loncoursedata::get_classlist(); |
|
my %idmap=&username_to_idmap($classlist); |
|
my $navmap=Apache::lonnavmaps::navmap->new($ENV{'request.course.fn'}.'.db',$ENV{'request.course.fn'}.'_parms.db',1, 1); |
|
my $map=$navmap->getResourceByUrl($sequence); |
|
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
|
$r->print("geto ".scalar(@resources)."<br />"); |
|
my $result= <<SCANTRONFORM; |
|
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload"> |
|
<input type="hidden" name="command" value="scantron_configphase" /> |
|
$default_form_data |
|
SCANTRONFORM |
|
$r->print($result); |
|
|
|
my @delayqueue; |
|
|
|
foreach my $line (<$scanlines>) { |
|
chomp($line); |
|
my $scan_record=&scantron_parse_scanline($line,\%scantron_config); |
|
my ($uname,$udom); |
|
if ($uname=&scantron_find_student($scan_record,\%idmap)) { |
|
&scantron_add_delay(\@delayqueue,$line, |
|
'Unable to find a student that matches'); |
|
} |
|
$r->print('<pre>doing studnet'.$uname.'</pre>'); |
|
($uname,$udom)=split(/:/,$uname); |
|
&Apache::lonnet::delenv('form\.counter$'); #') stupid emacs |
|
&Apache::lonnet::appenv(%$scan_record); |
$Apache::lonxml::debug=1; |
$Apache::lonxml::debug=1; |
&Apache::lonhomework::showhash(%ENV); |
&Apache::lonhomework::showhash(%ENV); |
$Apache::lonxml::debug=0; |
$Apache::lonxml::debug=0; |
#FIXME Needs to present some lines from the file and allow the instructor to specify which columns represent what data, possibly have some nice defaults setup, probably should do a pass through all problems for a student to get an idea of how many questions there are, and homw many lines we'll have, |
|
return $result; |
foreach my $resource (@resources) { |
} |
my $result=&Apache::lonnet::ssi($resource->src(), |
|
('submitted' =>'scantron', |
sub scantron_process_students { |
'grade_target' =>'grade', |
|
'grade_username'=>$uname, |
|
'grade_domain' =>$udom, |
|
'grade_courseid'=>$ENV{'request.course.id'}, |
|
'grade_symb' =>$resource->symb())); |
|
$r->print('<pre>'. |
|
$resource->symb().'-'. |
|
$resource->src().'-'.'</pre>result is'.$result); |
|
last; |
|
} |
|
&Apache::lonnet::delenv('form\.counter$'); #') stupid emacs |
|
&Apache::lonnet::delenv('scantron\.'); |
|
last; |
|
#FIXME |
|
#get iterator for $sequence |
|
#foreach question 'submit' the students answer to the server |
|
# through grade target { |
|
# generate data to pass back that includes grade recevied |
|
#} |
|
} |
|
foreach my $delay (@delayqueue) { |
|
#FIXME |
|
#print out each delayed student with interface to select how |
|
# to repair student provided info |
|
#Expected errors include |
|
# 1 bad/no stuid/username |
|
# 2 invalid bubblings |
|
|
|
} |
#FIXME |
#FIXME |
# loop through students, { |
|
# Check if studnet info valid, if not add line to delay queue |
|
# foreach question 'submit' the students answer to the server |
|
# through grade target { |
|
# generate data to pass back that includes grade recevied |
|
# } |
|
# } |
|
# loop through delay queue { |
|
# print out each delayed student with interface to select how |
|
# to repair student provided info |
|
# Expected errors include |
|
# 1 bad/no stuid/username |
|
# 2 invalid bubblings |
|
# } |
|
# if delay queue exists 2 submits one to process delayed students one |
# if delay queue exists 2 submits one to process delayed students one |
# to ignore delayed students, possibly saving the delay queue for later |
# to ignore delayed students, possibly saving the delay queue for later |
|
|
Line 3062 GRADINGMENUJS
|
Line 3264 GRADINGMENUJS
|
'Upload scores from file</td></tr>'."\n"; |
'Upload scores from file</td></tr>'."\n"; |
|
|
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
$result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'. |
'<input type="radio" name="command" value="scantron_selectphase" /> '. |
'<input type="radio" name="command" value="scantron_selectphase" '. |
|
($saveCmd eq 'scantron_selectphase' ? 'checked="on"' : '').' /> '. |
'Grade scantron forms</td></tr>'."\n"; |
'Grade scantron forms</td></tr>'."\n"; |
|
|
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) { |
if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) { |
Line 3195 sub handler {
|
Line 3398 sub handler {
|
} |
} |
} elsif ($command eq 'scantron_selectphase') { |
} elsif ($command eq 'scantron_selectphase') { |
$request->print(&scantron_selectphase($request)); |
$request->print(&scantron_selectphase($request)); |
} elsif ($command eq 'scantron_configphase') { |
} elsif ($command eq 'scantron_process') { |
$request->print(&scantron_configphase($request)); |
$request->print(&scantron_process_students($request)); |
} else { |
} else { |
$request->print("Unknown action: $command:"); |
$request->print("Unknown action: $command:"); |
} |
} |