version 1.662, 2011/10/17 12:41:34
|
version 1.678, 2012/12/10 05:47:21
|
Line 54 use POSIX qw(floor);
|
Line 54 use POSIX qw(floor);
|
|
|
|
|
my %perm=(); |
my %perm=(); |
|
my %old_essays=(); |
|
|
# These variables are used to recover from ssi errors |
# These variables are used to recover from ssi errors |
|
|
Line 202 sub get_display_part {
|
Line 203 sub get_display_part {
|
sub reset_caches { |
sub reset_caches { |
&reset_analyze_cache(); |
&reset_analyze_cache(); |
&reset_perm(); |
&reset_perm(); |
|
&reset_old_essays(); |
} |
} |
|
|
{ |
{ |
Line 681 sub compute_points {
|
Line 683 sub compute_points {
|
# |
# |
|
|
sub most_similar { |
sub most_similar { |
my ($uname,$udom,$uessay,$old_essays)=@_; |
my ($uname,$udom,$symb,$uessay)=@_; |
|
|
|
unless ($symb) { return ''; } |
|
|
|
unless (ref($old_essays{$symb}) eq 'HASH') { return ''; } |
|
|
# ignore spaces and punctuation |
# ignore spaces and punctuation |
|
|
Line 698 sub most_similar {
|
Line 704 sub most_similar {
|
my $scrsid=''; |
my $scrsid=''; |
my $sessay=''; |
my $sessay=''; |
# go through all essays ... |
# go through all essays ... |
foreach my $tkey (keys(%$old_essays)) { |
foreach my $tkey (keys(%{$old_essays{$symb}})) { |
my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey)); |
my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey)); |
# ... except the same student |
# ... except the same student |
next if (($tname eq $uname) && ($tdom eq $udom)); |
next if (($tname eq $uname) && ($tdom eq $udom)); |
my $tessay=$old_essays->{$tkey}; |
my $tessay=$old_essays{$symb}{$tkey}; |
$tessay=~s/\W+/ /gs; |
$tessay=~s/\W+/ /gs; |
# String similarity gives up if not even limit |
# String similarity gives up if not even limit |
my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit); |
my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit); |
Line 712 sub most_similar {
|
Line 718 sub most_similar {
|
$sname=$tname; |
$sname=$tname; |
$sdom=$tdom; |
$sdom=$tdom; |
$scrsid=$tcrsid; |
$scrsid=$tcrsid; |
$sessay=$old_essays->{$tkey}; |
$sessay=$old_essays{$symb}{$tkey}; |
} |
} |
} |
} |
if ($limit>0.6) { |
if ($limit>0.6) { |
Line 1524 INNERJS
|
Line 1530 INNERJS
|
|
|
function savedMsgHeader(Nmsg,usrctr,fullname) { |
function savedMsgHeader(Nmsg,usrctr,fullname) { |
var height = 70*Nmsg+250; |
var height = 70*Nmsg+250; |
var scrollbar = "no"; |
|
if (height > 600) { |
if (height > 600) { |
height = 600; |
height = 600; |
scrollbar = "yes"; |
|
} |
} |
var xpos = (screen.width-600)/2; |
var xpos = (screen.width-600)/2; |
xpos = (xpos < 0) ? '0' : xpos; |
xpos = (xpos < 0) ? '0' : xpos; |
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', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=700,height='+height); |
pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars=yes,screenx='+xpos+',screeny='+ypos+',width=700,height='+height); |
pWin.focus(); |
pWin.focus(); |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.$docopen; |
pDoc.$docopen; |
Line 1542 INNERJS
|
Line 1546 INNERJS
|
|
|
pDoc.write("<form action=\\"inactive\\" name=\\"msgcenter\\">"); |
pDoc.write("<form action=\\"inactive\\" name=\\"msgcenter\\">"); |
pDoc.write("<input value=\\""+usrctr+"\\" name=\\"usrctr\\" type=\\"hidden\\">"); |
pDoc.write("<input value=\\""+usrctr+"\\" name=\\"usrctr\\" type=\\"hidden\\">"); |
pDoc.write("<h3><span class=\\"LC_info\\"> $lt{'comp'}\"+fullname+\"<\\/span><\\/h3><br /><br />"); |
pDoc.write("<h1> $lt{'comp'}\"+fullname+\"<\\/h1>"); |
|
|
pDoc.write('<table border="0" width="100%"><tr><td bgcolor="#777777">'); |
pDoc.write('<table style="border:1px solid black;"><tr>'); |
pDoc.write('<table border="0" width="100%"><tr bgcolor="#DDFFFF">'); |
pDoc.write("<td><b>$lt{'incl'}<\\/b><\\/td><td><b>$lt{'type'}<\\/b><\\/td><td><b>$lt{'mesa'}<\\/td><\\/tr>"); |
pDoc.write("<td><b>$lt{'type'}<\\/b><\\/td><td><b>$lt{'incl'}<\\/b><\\/td><td><b>$lt{'mesa'}<\\/td><\\/tr>"); |
|
} |
} |
function displaySubject(msg,shwsel) { |
function displaySubject(msg,shwsel) { |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.write("<tr bgcolor=\\"#ffffdd\\">"); |
pDoc.write("<tr>"); |
pDoc.write("<td>$lt{'subj'}<\\/td>"); |
|
pDoc.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
pDoc.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
pDoc.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"><\\/td><\\/tr>"); |
pDoc.write("<td>$lt{'subj'}<\\/td>"); |
|
pDoc.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"40\\" maxlength=\\"80\\"><\\/td><\\/tr>"); |
} |
} |
|
|
function displaySavedMsg(ctr,msg,shwsel) { |
function displaySavedMsg(ctr,msg,shwsel) { |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.write("<tr bgcolor=\\"#ffffdd\\">"); |
pDoc.write("<tr>"); |
pDoc.write("<td align=\\"center\\">"+ctr+"<\\/td>"); |
|
pDoc.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
pDoc.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
|
pDoc.write("<td align=\\"center\\">"+ctr+"<\\/td>"); |
pDoc.write("<td><textarea name=\\"msg"+ctr+"\\" cols=\\"60\\" rows=\\"3\\">"+msg+"<\\/textarea><\\/td><\\/tr>"); |
pDoc.write("<td><textarea name=\\"msg"+ctr+"\\" cols=\\"60\\" rows=\\"3\\">"+msg+"<\\/textarea><\\/td><\\/tr>"); |
} |
} |
|
|
function newMsg(newmsg,shwsel) { |
function newMsg(newmsg,shwsel) { |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.write("<tr bgcolor=\\"#ffffdd\\">"); |
pDoc.write("<tr>"); |
pDoc.write("<td align=\\"center\\">$lt{'new'}<\\/td>"); |
|
pDoc.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
pDoc.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>"); |
|
pDoc.write("<td align=\\"center\\">$lt{'new'}<\\/td>"); |
pDoc.write("<td><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"<\\/textarea><\\/td><\\/tr>"); |
pDoc.write("<td><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"<\\/textarea><\\/td><\\/tr>"); |
} |
} |
|
|
function msgTail() { |
function msgTail() { |
pDoc = pWin.document; |
pDoc = pWin.document; |
pDoc.write("<\\/table>"); |
//pDoc.write("<\\/table>"); |
pDoc.write("<\\/td><\\/tr><\\/table> "); |
pDoc.write("<\\/td><\\/tr><\\/table> "); |
pDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:checkInput()\\"> "); |
pDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:checkInput()\\"> "); |
pDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\"><br /><br />"); |
pDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\"><br /><br />"); |
Line 1829 sub show_problem {
|
Line 1832 sub show_problem {
|
$companswer=~s|</form>||g; |
$companswer=~s|</form>||g; |
$companswer=~s|name="submit"|name="would_have_been_submit"|g; |
$companswer=~s|name="submit"|name="would_have_been_submit"|g; |
} |
} |
|
my $renderheading = &mt('View of the problem'); |
|
my $answerheading = &mt('Correct answer'); |
|
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
|
my $stu_fullname = $env{'form.fullname'}; |
|
if ($stu_fullname eq '') { |
|
$stu_fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); |
|
} |
|
my $forwhom = &nameUserString(undef,$stu_fullname,$uname,$udom); |
|
if ($forwhom ne '') { |
|
$renderheading = &mt('View of the problem for[_1]',$forwhom); |
|
$answerheading = &mt('Correct answer for[_1]',$forwhom); |
|
} |
|
} |
$rendered= |
$rendered= |
'<div class="LC_Box">' |
'<div class="LC_Box">' |
.'<h3 class="LC_hcell">'.&mt('View of the problem').'</h3>' |
.'<h3 class="LC_hcell">'.$renderheading.'</h3>' |
.$rendered |
.$rendered |
.'</div>'; |
.'</div>'; |
$companswer= |
$companswer= |
'<div class="LC_Box">' |
'<div class="LC_Box">' |
.'<h3 class="LC_hcell">'.&mt('Correct answer').'</h3>' |
.'<h3 class="LC_hcell">'.$answerheading.'</h3>' |
.$companswer |
.$companswer |
.'</div>'; |
.'</div>'; |
my $result; |
my $result; |
Line 1938 sub submission {
|
Line 1954 sub submission {
|
'" src="'.$request->dir_config('lonIconsURL'). |
'" src="'.$request->dir_config('lonIconsURL'). |
'/check.gif" height="16" border="0" />'; |
'/check.gif" height="16" border="0" />'; |
|
|
my %old_essays; |
|
# header info |
# header info |
if ($counter == 0) { |
if ($counter == 0) { |
&sub_page_js($request); |
&sub_page_js($request); |
Line 2046 KEYWORDS
|
Line 2061 KEYWORDS
|
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); |
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/); |
$apath=&escape($apath); |
$apath=&escape($apath); |
$apath=~s/\W/\_/gs; |
$apath=~s/\W/\_/gs; |
%old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname); |
&init_old_essays($symb,$apath,$adom,$aname); |
} |
} |
} |
} |
|
|
Line 2185 KEYWORDS
|
Line 2200 KEYWORDS
|
} |
} |
if($env{'form.checkPlag'}){ |
if($env{'form.checkPlag'}){ |
my ($oname,$odom,$ocrsid,$oessay,$osim)= |
my ($oname,$odom,$ocrsid,$oessay,$osim)= |
&most_similar($uname,$udom,$subval,\%old_essays); |
&most_similar($uname,$udom,$symb,$subval); |
if ($osim) { |
if ($osim) { |
$osim=int($osim*100.0); |
$osim=int($osim*100.0); |
my %old_course_desc = |
my %old_course_desc = |
Line 2508 sub keywords_highlight {
|
Line 2523 sub keywords_highlight {
|
return $string; |
return $string; |
} |
} |
|
|
|
# For Tasks provide a mechanism to display previous version for one specific student |
|
|
|
sub show_previous_task_version { |
|
my ($request,$symb) = @_; |
|
if ($symb eq '') { |
|
$request->print("Unable to handle ambiguous references."); |
|
|
|
return ''; |
|
} |
|
my ($uname,$udom) = ($env{'form.student'},$env{'form.userdom'}); |
|
my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'}); |
|
if (!&canview($usec)) { |
|
$request->print('<span class="LC_warning">Unable to view previous version for requested student.('. |
|
$uname.':'.$udom.' in section '.$usec.' in course id '. |
|
$env{'request.course.id'}.')</span>'); |
|
return; |
|
} |
|
my $mode = 'both'; |
|
my $isTask = ($symb =~/\.task$/); |
|
if ($isTask) { |
|
if ($env{'form.previousversion'} =~ /^\d+$/) { |
|
if ($env{'form.fullname'} eq '') { |
|
$env{'form.fullname'} = |
|
&Apache::loncommon::plainname($uname,$udom,'lastname'); |
|
} |
|
my $probtitle=&Apache::lonnet::gettitle($symb); |
|
$request->print("\n\n". |
|
'<div class="LC_grade_show_user">'. |
|
'<h2>'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom). |
|
'</h2>'."\n"); |
|
&Apache::lonxml::clear_problem_counter(); |
|
$request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode, |
|
{'previousversion' => $env{'form.previousversion'} })); |
|
$request->print("\n</div>"); |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub choose_task_version_form { |
|
my ($symb,$uname,$udom,$nomenu) = @_; |
|
my $isTask = ($symb =~/\.task$/); |
|
my ($current,$version,$result,$js,$displayed,$rowtitle); |
|
if ($isTask) { |
|
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'}, |
|
$udom,$uname); |
|
if (($record{'resource.0.version'} eq '') || |
|
($record{'resource.0.version'} < 2)) { |
|
return ($record{'resource.0.version'}, |
|
$record{'resource.0.version'},$result,$js); |
|
} else { |
|
$current = $record{'resource.0.version'}; |
|
} |
|
if ($env{'form.previousversion'}) { |
|
$displayed = $env{'form.previousversion'}; |
|
$rowtitle = &mt('Choose another version:') |
|
} else { |
|
$displayed = $current; |
|
$rowtitle = &mt('Show earlier version:'); |
|
} |
|
$result = '<div class="LC_left_float">'; |
|
my $list; |
|
my $numversions = 0; |
|
for (my $i=1; $i<=$record{'resource.0.version'}; $i++) { |
|
if ($i == $current) { |
|
if (!$env{'form.previousversion'} || $nomenu) { |
|
next; |
|
} else { |
|
$list .= '<option value="'.$i.'">'.&mt('Current').'</option>'."\n"; |
|
$numversions ++; |
|
} |
|
} elsif (defined($record{'resource.'.$i.'.0.status'})) { |
|
unless ($i == $env{'form.previousversion'}) { |
|
$numversions ++; |
|
} |
|
$list .= '<option value="'.$i.'">'.$i.'</option>'."\n"; |
|
} |
|
} |
|
if ($numversions) { |
|
$symb = &HTML::Entities::encode($symb,'<>"&'); |
|
$result .= |
|
'<form name="getprev" method="post" action=""'. |
|
' onsubmit="return previousVersion('."'$uname','$udom','$symb','$displayed'".');">'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<th align="left">'.$rowtitle.'</th>'. |
|
'<td><select name="version">'. |
|
'<option>'.&mt('Select').'</option>'. |
|
$list. |
|
'</select></td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
unless ($nomenu) { |
|
$result .= &Apache::loncommon::start_data_table_row(). |
|
'<th align="left">'.&mt('Open in new window').'</th>'. |
|
'<td><span class="LC_nobreak">'. |
|
'<label><input type="radio" name="prevwin" value="1" />'. |
|
&mt('Yes').'</label>'. |
|
'<label><input type="radio" name="prevwin" value="0" checked="checked" />'.&mt('No').'</label>'. |
|
'</span></td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
|
$result .= |
|
&Apache::loncommon::start_data_table_row(). |
|
'<th align="left"> </th>'. |
|
'<td>'. |
|
'<input type="submit" name="prevsub" value="'.&mt('Display').'" />'. |
|
'</td>'. |
|
&Apache::loncommon::end_data_table_row(). |
|
&Apache::loncommon::end_data_table(). |
|
'</form>'; |
|
$js = &previous_display_javascript($nomenu,$current); |
|
} elsif ($displayed && $nomenu) { |
|
$result .= '<a href="javascript:window.close()">'.&mt('Close window').'</a>'; |
|
} else { |
|
$result .= &mt('No previous versions to show for this student'); |
|
} |
|
$result .= '</div>'; |
|
} |
|
return ($current,$displayed,$result,$js); |
|
} |
|
|
|
sub previous_display_javascript { |
|
my ($nomenu,$current) = @_; |
|
my $js = <<"JSONE"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function previousVersion(uname,udom,symb) { |
|
var current = '$current'; |
|
var version = document.getprev.version.options[document.getprev.version.selectedIndex].value; |
|
var prevstr = new RegExp("^\\\\d+\$"); |
|
if (!prevstr.test(version)) { |
|
return false; |
|
} |
|
var url = ''; |
|
if (version == current) { |
|
url = '/adm/grades?student='+uname+'&userdom='+udom+'&symb='+symb+'&command=submission'; |
|
} else { |
|
url = '/adm/grades?student='+uname+'&userdom='+udom+'&symb='+symb+'&command=versionsub&previousversion='+version; |
|
} |
|
JSONE |
|
if ($nomenu) { |
|
$js .= <<"JSTWO"; |
|
document.location.href = url; |
|
JSTWO |
|
} else { |
|
$js .= <<"JSTHREE"; |
|
var newwin = 0; |
|
for (var i=0; i<document.getprev.prevwin.length; i++) { |
|
if (document.getprev.prevwin[i].checked == true) { |
|
newwin = document.getprev.prevwin[i].value; |
|
} |
|
} |
|
if (newwin == 1) { |
|
var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; |
|
url = url+'&inhibitmenu=yes'; |
|
if (typeof(previousWin) == 'undefined' || previousWin.closed) { |
|
previousWin = window.open(url,'',options,1); |
|
} else { |
|
previousWin.location.href = url; |
|
} |
|
previousWin.focus(); |
|
return false; |
|
} else { |
|
document.location.href = url; |
|
return false; |
|
} |
|
JSTHREE |
|
} |
|
$js .= <<"ENDJS"; |
|
return false; |
|
} |
|
// ]]> |
|
</script> |
|
ENDJS |
|
|
|
} |
|
|
#--- Called from submission routine |
#--- Called from submission routine |
sub processHandGrade { |
sub processHandGrade { |
my ($request,$symb) = @_; |
my ($request,$symb) = @_; |
Line 4540 sub displaySubByDates {
|
Line 4732 sub displaySubByDates {
|
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('Date/Time').'</th>'. |
'<th>'.&mt('Date/Time').'</th>'. |
($isCODE?'<th>'.&mt('CODE').'</th>':''). |
($isCODE?'<th>'.&mt('CODE').'</th>':''). |
|
($isTask?'<th>'.&mt('Version').'</th>':''). |
'<th>'.&mt('Submission').'</th>'. |
'<th>'.&mt('Submission').'</th>'. |
'<th>'.&mt('Status').'</th>'. |
'<th>'.&mt('Status').'</th>'. |
&Apache::loncommon::end_data_table_header_row(); |
&Apache::loncommon::end_data_table_header_row(); |
Line 4560 sub displaySubByDates {
|
Line 4753 sub displaySubByDates {
|
if (exists($$record{$version.':resource.0.version'})) { |
if (exists($$record{$version.':resource.0.version'})) { |
$interaction = $$record{$version.':resource.0.version'}; |
$interaction = $$record{$version.':resource.0.version'}; |
} |
} |
|
if ($isTask && $env{'form.previousversion'}) { |
|
next unless ($interaction == $env{'form.previousversion'}); |
|
} |
my $where = ($isTask ? "$version:resource.$interaction" |
my $where = ($isTask ? "$version:resource.$interaction" |
: "$version:resource"); |
: "$version:resource"); |
$studentTable.=&Apache::loncommon::start_data_table_row(). |
$studentTable.=&Apache::loncommon::start_data_table_row(). |
Line 4568 sub displaySubByDates {
|
Line 4763 sub displaySubByDates {
|
if ($isCODE) { |
if ($isCODE) { |
$studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>'; |
$studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>'; |
} |
} |
|
if ($isTask) { |
|
$studentTable.='<td>'.$interaction.'</td>'; |
|
} |
my @versionKeys = split(/\:/,$$record{$version.':keys'}); |
my @versionKeys = split(/\:/,$$record{$version.':keys'}); |
my @displaySub = (); |
my @displaySub = (); |
foreach my $partid (@{$parts}) { |
foreach my $partid (@{$parts}) { |
Line 4587 sub displaySubByDates {
|
Line 4785 sub displaySubByDates {
|
|
|
my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) |
my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) |
: ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); |
: ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); |
$displaySub[0].='<span class="LC_nobreak"'; |
$displaySub[0].='<span class="LC_nobreak">'; |
$displaySub[0].='<b>'.&mt('Part: [_1]',$display_part).'</b>' |
$displaySub[0].='<b>'.&mt('Part: [_1]',$display_part).'</b>' |
.' <span class="LC_internal_info">' |
.' <span class="LC_internal_info">' |
.'('.&mt('Response ID: [_1]',$responseId).')' |
.'('.&mt('Response ID: [_1]',$responseId).')' |
Line 5412 sub scantron_selectphase {
|
Line 5610 sub scantron_selectphase {
|
LastNameLength - number of columns that the last name spans |
LastNameLength - number of columns that the last name spans |
BubblesPerRow - number of bubbles available in each row used to |
BubblesPerRow - number of bubbles available in each row used to |
bubble an answer. (If not specified, 10 assumed). |
bubble an answer. (If not specified, 10 assumed). |
|
|
=cut |
=cut |
|
|
sub get_scantron_config { |
sub get_scantron_config { |
Line 6226 sub scantron_warning_screen {
|
Line 6425 sub scantron_warning_screen {
|
'<tr><td><b>'.&mt('List of CODES to validate against:').'</b></td><td><tt>'. |
'<tr><td><b>'.&mt('List of CODES to validate against:').'</b></td><td><tt>'. |
$env{'form.scantron_CODElist'}.'</tt></td></tr>'; |
$env{'form.scantron_CODElist'}.'</tt></td></tr>'; |
} |
} |
|
my $lastbubblepoints; |
|
if ($env{'form.scantron_lastbubblepoints'} ne '') { |
|
$lastbubblepoints = |
|
'<tr><td><b>'.&mt('Hand-graded items: points from last bubble in row').'</b></td><td><tt>'. |
|
$env{'form.scantron_lastbubblepoints'}.'</tt></td></tr>'; |
|
} |
return (' |
return (' |
<p> |
<p> |
<span class="LC_warning"> |
<span class="LC_warning"> |
Line 6234 sub scantron_warning_screen {
|
Line 6439 sub scantron_warning_screen {
|
<table> |
<table> |
<tr><td><b>'.&mt('Sequence to be Graded:').'</b></td><td>'.$title.'</td></tr> |
<tr><td><b>'.&mt('Sequence to be Graded:').'</b></td><td>'.$title.'</td></tr> |
<tr><td><b>'.&mt('Data File that will be used:').'</b></td><td><tt>'.$env{'form.scantron_selectfile'}.'</tt></td></tr> |
<tr><td><b>'.&mt('Data File that will be used:').'</b></td><td><tt>'.$env{'form.scantron_selectfile'}.'</tt></td></tr> |
'.$CODElist.' |
'.$CODElist.$lastbubblepoints.' |
</table> |
</table> |
<p> '.&mt('If this information is correct, please click on \'[_1]\'.',&mt($button_text)).'<br /> |
<p> '.&mt('If this information is correct, please click on \'[_1]\'.',&mt($button_text)).'<br /> |
'.&mt('If something is incorrect, please return to [_1]Grade/Manage/Review Bubblesheets[_2] to start over.','<a href="/adm/grades?symb='.$symb.'&command=scantron_selectphase" class="LC_info">','</a>').'</p> |
'.&mt('If something is incorrect, please return to [_1]Grade/Manage/Review Bubblesheets[_2] to start over.','<a href="/adm/grades?symb='.$symb.'&command=scantron_selectphase" class="LC_info">','</a>').'</p> |
Line 6272 sub scantron_do_warning {
|
Line 6477 sub scantron_do_warning {
|
} |
} |
} else { |
} else { |
my $warning=&scantron_warning_screen('Grading: Validate Records',$symb); |
my $warning=&scantron_warning_screen('Grading: Validate Records',$symb); |
|
my $bubbledbyhand=&hand_bubble_option(); |
$r->print(' |
$r->print(' |
'.$warning.' |
'.$warning.$bubbledbyhand.' |
<input type="submit" name="submit" value="'.&mt('Grading: Validate Records').'" /> |
<input type="submit" name="submit" value="'.&mt('Grading: Validate Records').'" /> |
<input type="hidden" name="command" value="scantron_validate" /> |
<input type="hidden" name="command" value="scantron_validate" /> |
'); |
'); |
Line 6369 sub scantron_validate_file {
|
Line 6575 sub scantron_validate_file {
|
return ''; |
return ''; |
} |
} |
my $result=&scantron_form_start($max_bubble).$default_form_data; |
my $result=&scantron_form_start($max_bubble).$default_form_data; |
|
if ($env{'form.scantron_lastbubblepoints'} ne '') { |
|
$result .= '<input type="hidden" name="scantron_lastbubblepoints" value="'.$env{'form.scantron_lastbubblepoints'}.'" />'; |
|
} |
$r->print($result); |
$r->print($result); |
|
|
my @validate_phases=( 'sequence', |
my @validate_phases=( 'sequence', |
Line 6794 sub scantron_validate_sequence {
|
Line 7003 sub scantron_validate_sequence {
|
my @resources= |
my @resources= |
$navmap->retrieveResources($map,\&scantron_filter_not_exam,1,0); |
$navmap->retrieveResources($map,\&scantron_filter_not_exam,1,0); |
if (@resources) { |
if (@resources) { |
$r->print("<p>".&mt('Some resources in the sequence currently are not set to exam mode. Grading these resources currently may not work correctly.')."</p>"); |
$r->print( |
|
'<p class="LC_warning">' |
|
.&mt('Some resources in the sequence currently are not set to' |
|
.' exam mode. Grading these resources currently may not' |
|
.' work correctly.') |
|
.'</p>' |
|
); |
return (1,$currentphase); |
return (1,$currentphase); |
} |
} |
} |
} |
Line 6899 sub scantron_get_correction {
|
Line 7114 sub scantron_get_correction {
|
.&mt('The ID on the form is [_1]', |
.&mt('The ID on the form is [_1]', |
"<tt>$$scan_record{'scantron.ID'}</tt>") |
"<tt>$$scan_record{'scantron.ID'}</tt>") |
.'<br />' |
.'<br />' |
.&mt('The name on the paper is [_2], [_3]', |
.&mt('The name on the paper is [_1], [_2]', |
$$scan_record{'scantron.LastName'}, |
$$scan_record{'scantron.LastName'}, |
$$scan_record{'scantron.FirstName'}) |
$$scan_record{'scantron.FirstName'}) |
.'</p>'; |
.'</p>'; |
Line 7508 sub scantron_get_maxbubble {
|
Line 7723 sub scantron_get_maxbubble {
|
my $response_number = 0; |
my $response_number = 0; |
my $bubble_line = 0; |
my $bubble_line = 0; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
my ($analysis,$parts) = &scantron_partids_tograde($resource,$cid,$uname,$udom,undef,$bubbles_per_row); |
my ($analysis,$parts) = &scantron_partids_tograde($resource,$cid,$uname, |
|
$udom,undef,$bubbles_per_row); |
if ((ref($analysis) eq 'HASH') && (ref($parts) eq 'ARRAY')) { |
if ((ref($analysis) eq 'HASH') && (ref($parts) eq 'ARRAY')) { |
foreach my $part_id (@{$parts}) { |
foreach my $part_id (@{$parts}) { |
my $lines; |
my $lines; |
Line 7641 sub scantron_validate_missingbubbles {
|
Line 7857 sub scantron_validate_missingbubbles {
|
return (0,$currentphase+1); |
return (0,$currentphase+1); |
} |
} |
|
|
|
sub hand_bubble_option { |
|
my (undef, undef, $sequence) = |
|
&Apache::lonnet::decode_symb($env{'form.selectpage'}); |
|
return if ($sequence eq ''); |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
unless (ref($navmap)) { |
|
return; |
|
} |
|
my $needs_hand_bubbles; |
|
my $map=$navmap->getResourceByUrl($sequence); |
|
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
|
foreach my $res (@resources) { |
|
if (ref($res)) { |
|
if ($res->is_problem()) { |
|
my $partlist = $res->parts(); |
|
foreach my $part (@{ $partlist }) { |
|
my @types = $res->responseType($part); |
|
if (grep(/^(chem|essay|image|formula|math|string|functionplot)$/,@types)) { |
|
$needs_hand_bubbles = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($needs_hand_bubbles) { |
|
my %scantron_config=&get_scantron_config($env{'form.scantron_format'}); |
|
my $bubbles_per_row = &bubblesheet_bubbles_per_row(\%scantron_config); |
|
return &mt('The sequence to be graded contains response types which are handgraded.').'<p>'. |
|
&mt('If you have already graded these by bubbling sheets to indicate points awarded, [_1]what point value is assigned to a filled last bubble in each row?','<br />'). |
|
'<label><input type="radio" name="scantron_lastbubblepoints" value="'.$bubbles_per_row.'" checked="checked" />'.&mt('[quant,_1,point]',$bubbles_per_row).'</label> '.&mt('or').' '. |
|
'<label><input type="radio" name="scantron_lastbubblepoints" value="0"/>0 points</label></p>'; |
|
} |
|
return; |
|
} |
|
|
sub scantron_process_students { |
sub scantron_process_students { |
my ($r,$symb) = @_; |
my ($r,$symb) = @_; |
Line 7663 sub scantron_process_students {
|
Line 7914 sub scantron_process_students {
|
return ''; |
return ''; |
} |
} |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
|
my $randomorder; |
|
if (ref($map)) { |
|
$randomorder = $map->randomorder(); |
|
} |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
my (%grader_partids_by_symb,%grader_randomlists_by_symb); |
my (%grader_partids_by_symb,%grader_randomlists_by_symb,%ordered); |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, |
\%grader_randomlists_by_symb,$bubbles_per_row); |
\%grader_randomlists_by_symb,$bubbles_per_row); |
my $resource_error; |
my ($resource_error,%symb_to_resource,@master_seq); |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
my $ressymb; |
my $ressymb; |
if (ref($resource)) { |
if (ref($resource)) { |
$ressymb = $resource->symb(); |
$ressymb = $resource->symb(); |
|
push(@master_seq,$ressymb); |
|
$symb_to_resource{$ressymb} = $resource; |
} else { |
} else { |
$resource_error = 1; |
$resource_error = 1; |
last; |
last; |
} |
} |
my ($analysis,$parts) = |
my ($analysis,$parts) = |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
$env{'user.name'},$env{'user.domain'},1,$bubbles_per_row); |
$env{'user.name'},$env{'user.domain'}, |
|
1,$bubbles_per_row); |
$grader_partids_by_symb{$ressymb} = $parts; |
$grader_partids_by_symb{$ressymb} = $parts; |
if (ref($analysis) eq 'HASH') { |
if (ref($analysis) eq 'HASH') { |
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
Line 7705 SCANTRONFORM
|
Line 7963 SCANTRONFORM
|
|
|
my $lock=&Apache::lonnet::set_lock(&mt('Grading bubblesheet exam')); |
my $lock=&Apache::lonnet::set_lock(&mt('Grading bubblesheet exam')); |
my $count=&get_todo_count($scanlines,$scan_data); |
my $count=&get_todo_count($scanlines,$scan_data); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Bubblesheet Status', |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$count); |
'Bubblesheet Progress',$count, |
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,'Processing first student'); |
'inline',undef,'scantronupload'); |
|
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, |
|
'Processing first student'); |
|
$r->print('<br />'); |
$r->print('<br />'); |
my $start=&Time::HiRes::time(); |
my $start=&Time::HiRes::time(); |
my $i=-1; |
my $i=-1; |
Line 7741 SCANTRONFORM
|
Line 7996 SCANTRONFORM
|
my $line=&scantron_get_line($scanlines,$scan_data,$i); |
my $line=&scantron_get_line($scanlines,$scan_data,$i); |
if ($line=~/^[\s\cz]*$/) { next; } |
if ($line=~/^[\s\cz]*$/) { next; } |
if ($started) { |
if ($started) { |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student'); |
'last student'); |
|
} |
} |
$started=1; |
$started=1; |
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, |
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config, |
Line 7758 SCANTRONFORM
|
Line 8012 SCANTRONFORM
|
'Student '.$uname.' has multiple sheets',2); |
'Student '.$uname.' has multiple sheets',2); |
next; |
next; |
} |
} |
|
my $usec = $classlist->{$uname}->[&Apache::loncoursedata::CL_SECTION]; |
|
my $user = $uname.':'.$usec; |
($uname,$udom)=split(/:/,$uname); |
($uname,$udom)=split(/:/,$uname); |
|
|
|
my $scancode; |
|
if ((exists($scan_record->{'scantron.CODE'})) && |
|
(&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) { |
|
$scancode = $scan_record->{'scantron.CODE'}; |
|
} else { |
|
$scancode = ''; |
|
} |
|
|
|
my @mapresources = @resources; |
|
if ($randomorder) { |
|
@mapresources = |
|
&users_order($user,$scancode,$sequence,\@master_seq,\%ordered, |
|
\%symb_to_resource); |
|
} |
my (%partids_by_symb,$res_error); |
my (%partids_by_symb,$res_error); |
foreach my $resource (@resources) { |
foreach my $resource (@mapresources) { |
my $ressymb; |
my $ressymb; |
if (ref($resource)) { |
if (ref($resource)) { |
$ressymb = $resource->symb(); |
$ressymb = $resource->symb(); |
Line 7772 SCANTRONFORM
|
Line 8042 SCANTRONFORM
|
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
my ($analysis,$parts) = |
my ($analysis,$parts) = |
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom,undef,$bubbles_per_row); |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
|
$uname,$udom,undef,$bubbles_per_row); |
$partids_by_symb{$ressymb} = $parts; |
$partids_by_symb{$ressymb} = $parts; |
} else { |
} else { |
$partids_by_symb{$ressymb} = $grader_partids_by_symb{$ressymb}; |
$partids_by_symb{$ressymb} = $grader_partids_by_symb{$ressymb}; |
Line 7792 SCANTRONFORM
|
Line 8063 SCANTRONFORM
|
&scantron_putfile($scanlines,$scan_data); |
&scantron_putfile($scanlines,$scan_data); |
} |
} |
|
|
my $scancode; |
|
if ((exists($scan_record->{'scantron.CODE'})) && |
|
(&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) { |
|
$scancode = $scan_record->{'scantron.CODE'}; |
|
} else { |
|
$scancode = ''; |
|
} |
|
|
|
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
\@resources,\%partids_by_symb, |
\@mapresources,\%partids_by_symb, |
$bubbles_per_row) eq 'ssi_error') { |
$bubbles_per_row) eq 'ssi_error') { |
$ssi_error = 0; # So end of handler error message does not trigger. |
$ssi_error = 0; # So end of handler error message does not trigger. |
$r->print("</form>"); |
$r->print("</form>"); |
Line 7818 SCANTRONFORM
|
Line 8081 SCANTRONFORM
|
$studentdata =~ s/\r$//; |
$studentdata =~ s/\r$//; |
my $studentrecord = ''; |
my $studentrecord = ''; |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@mapresources) { |
my $ressymb = $resource->symb(); |
my $ressymb = $resource->symb(); |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
Line 7829 SCANTRONFORM
|
Line 8092 SCANTRONFORM
|
if ($studentrecord ne $studentdata) { |
if ($studentrecord ne $studentdata) { |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
\@resources,\%partids_by_symb, |
\@mapresources,\%partids_by_symb, |
$bubbles_per_row) eq 'ssi_error') { |
$bubbles_per_row) eq 'ssi_error') { |
$ssi_error = 0; # So end of handler error message does not trigger. |
$ssi_error = 0; # So end of handler error message does not trigger. |
$r->print("</form>"); |
$r->print("</form>"); |
Line 7840 SCANTRONFORM
|
Line 8103 SCANTRONFORM
|
} |
} |
$counter = -1; |
$counter = -1; |
$studentrecord = ''; |
$studentrecord = ''; |
foreach my $resource (@resources) { |
foreach my $resource (@mapresources) { |
my $ressymb = $resource->symb(); |
my $ressymb = $resource->symb(); |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
&verify_scantron_grading($resource,$udom,$uname,$env{'request.course.id'}, |
Line 7901 sub graders_resources_pass {
|
Line 8164 sub graders_resources_pass {
|
my $ressymb = $resource->symb(); |
my $ressymb = $resource->symb(); |
my ($analysis,$parts) = |
my ($analysis,$parts) = |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
$env{'user.name'},$env{'user.domain'},1,$bubbles_per_row); |
$env{'user.name'},$env{'user.domain'}, |
|
1,$bubbles_per_row); |
$grader_partids_by_symb->{$ressymb} = $parts; |
$grader_partids_by_symb->{$ressymb} = $parts; |
if (ref($analysis) eq 'HASH') { |
if (ref($analysis) eq 'HASH') { |
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
Line 7914 sub graders_resources_pass {
|
Line 8178 sub graders_resources_pass {
|
return; |
return; |
} |
} |
|
|
|
=pod |
|
|
|
=item users_order |
|
|
|
Returns array of resources in current map, ordered based on either CODE, |
|
if this is a CODEd exam, or based on student's identity if this is a |
|
"NAMEd" exam. |
|
|
|
Should be used when randomorder applied when the corresponding exam was |
|
printed, prior to students completing bubblesheets for the version of the |
|
exam the student received. |
|
|
|
=cut |
|
|
|
sub users_order { |
|
my ($user,$scancode,$mapurl,$master_seq,$ordered,$symb_to_resource) = @_; |
|
my @mapresources; |
|
unless ((ref($ordered) eq 'HASH') && (ref($symb_to_resource) eq 'HASH')) { |
|
return @mapresources; |
|
} |
|
if (($scancode) && (ref($ordered->{$scancode}) eq 'ARRAY')) { |
|
@mapresources = @{$ordered->{$scancode}}; |
|
} elsif ($scancode) { |
|
$env{'form.CODE'} = $scancode; |
|
my $actual_seq = |
|
&Apache::lonprintout::master_seq_to_person_seq($mapurl, |
|
$master_seq, |
|
$user,$scancode); |
|
if (ref($actual_seq) eq 'ARRAY') { |
|
@{$ordered->{$scancode}} = |
|
map { $symb_to_resource->{$_}; } @{$actual_seq}; |
|
@mapresources = @{$ordered->{$scancode}}; |
|
} |
|
delete($env{'form.CODE'}); |
|
} else { |
|
my $actual_seq = |
|
&Apache::lonprintout::master_seq_to_person_seq($mapurl, |
|
$master_seq, |
|
$user); |
|
if (ref($actual_seq) eq 'ARRAY') { |
|
@mapresources = |
|
map { $symb_to_resource->{$_}; } @{$actual_seq}; |
|
} |
|
} |
|
return @mapresources; |
|
} |
|
|
sub grade_student_bubbles { |
sub grade_student_bubbles { |
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row) = @_; |
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts,$bubbles_per_row) = @_; |
# Walk folder as student here to get resources in order student sees. |
|
if (ref($resources) eq 'ARRAY') { |
if (ref($resources) eq 'ARRAY') { |
my $count = 0; |
my $count = 0; |
foreach my $resource (@{$resources}) { |
foreach my $resource (@{$resources}) { |
Line 7932 sub grade_student_bubbles {
|
Line 8242 sub grade_student_bubbles {
|
if ($bubbles_per_row ne '') { |
if ($bubbles_per_row ne '') { |
$form{'bubbles_per_row'} = $bubbles_per_row; |
$form{'bubbles_per_row'} = $bubbles_per_row; |
} |
} |
|
if ($env{'form.scantron_lastbubblepoints'} ne '') { |
|
$form{'scantron_lastbubblepoints'} = $env{'form.scantron_lastbubblepoints'}; |
|
} |
if (ref($parts) eq 'HASH') { |
if (ref($parts) eq 'HASH') { |
if (ref($parts->{$ressymb}) eq 'ARRAY') { |
if (ref($parts->{$ressymb}) eq 'ARRAY') { |
foreach my $part (@{$parts->{$ressymb}}) { |
foreach my $part (@{$parts->{$ressymb}}) { |
Line 8217 sub checkscantron_results {
|
Line 8530 sub checkscantron_results {
|
return ''; |
return ''; |
} |
} |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
|
my ($randomorder,@master_seq,%symb_to_resource); |
|
if (ref($map)) { |
|
$randomorder=$map->randomorder(); |
|
} |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
|
foreach my $resource (@resources) { |
|
if (ref($resource)) { |
|
my $ressymb = $resource->symb(); |
|
push(@master_seq,$ressymb); |
|
$symb_to_resource{$ressymb} = $resource; |
|
} |
|
} |
my (%grader_partids_by_symb,%grader_randomlists_by_symb); |
my (%grader_partids_by_symb,%grader_randomlists_by_symb); |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, \%grader_randomlists_by_symb); |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, |
|
\%grader_randomlists_by_symb,$bubbles_per_row); |
my ($uname,$udom); |
my ($uname,$udom); |
my (%scandata,%lastname,%bylast); |
my (%scandata,%lastname,%bylast); |
$r->print(' |
$r->print(' |
Line 8230 sub checkscantron_results {
|
Line 8554 sub checkscantron_results {
|
my %completedstudents; |
my %completedstudents; |
|
|
my $count=&Apache::grades::get_todo_count($scanlines,$scan_data); |
my $count=&Apache::grades::get_todo_count($scanlines,$scan_data); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Bubblesheet/Submissions Comparison Status', |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$count); |
'Progress of Bubblesheet Data/Submission Records Comparison',$count, |
my ($username,$domain,$started,%ordered); |
'inline',undef,'checkscantron'); |
|
my ($username,$domain,$started); |
|
my $nav_error; |
my $nav_error; |
&scantron_get_maxbubble(\$nav_error,\%scantron_config); # Need the bubble lines array to parse. |
&scantron_get_maxbubble(\$nav_error,\%scantron_config); # Need the bubble lines array to parse. |
if ($nav_error) { |
if ($nav_error) { |
Line 8241 sub checkscantron_results {
|
Line 8563 sub checkscantron_results {
|
return ''; |
return ''; |
} |
} |
|
|
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,'Processing first student'); |
'Processing first student'); |
|
my $start=&Time::HiRes::time(); |
my $start=&Time::HiRes::time(); |
my $i=-1; |
my $i=-1; |
|
|
Line 8252 sub checkscantron_results {
|
Line 8573 sub checkscantron_results {
|
my $line=&Apache::grades::scantron_get_line($scanlines,$scan_data,$i); |
my $line=&Apache::grades::scantron_get_line($scanlines,$scan_data,$i); |
if ($line=~/^[\s\cz]*$/) { next; } |
if ($line=~/^[\s\cz]*$/) { next; } |
if ($started) { |
if ($started) { |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student'); |
'last student'); |
|
} |
} |
$started=1; |
$started=1; |
my $scan_record= |
my $scan_record= |
Line 8277 sub checkscantron_results {
|
Line 8597 sub checkscantron_results {
|
$scandata{$pid} = substr($line,$scantron_config{'Qstart'}-1,$lastpos); |
$scandata{$pid} = substr($line,$scantron_config{'Qstart'}-1,$lastpos); |
chomp($scandata{$pid}); |
chomp($scandata{$pid}); |
$scandata{$pid} =~ s/\r$//; |
$scandata{$pid} =~ s/\r$//; |
|
my $usec = $classlist->{$uname}->[&Apache::loncoursedata::CL_SECTION]; |
|
my $user = $uname.':'.$usec; |
($username,$domain)=split(/:/,$uname); |
($username,$domain)=split(/:/,$uname); |
|
|
|
my $scancode; |
|
if ((exists($scan_record->{'scantron.CODE'})) && |
|
(&Apache::lonnet::validCODE($scan_record->{'scantron.CODE'}))) { |
|
$scancode = $scan_record->{'scantron.CODE'}; |
|
} else { |
|
$scancode = ''; |
|
} |
|
|
|
my @mapresources = @resources; |
|
if ($randomorder) { |
|
@mapresources = |
|
&users_order($user,$scancode,$sequence,\@master_seq,\%ordered, |
|
\%symb_to_resource); |
|
} |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@mapresources) { |
my $parts; |
my $parts; |
my $ressymb = $resource->symb(); |
my $ressymb = $resource->symb(); |
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
(my $analysis,$parts) = |
(my $analysis,$parts) = |
&scantron_partids_tograde($resource,$env{'request.course.id'},$username,$domain,undef,$bubbles_per_row); |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
|
$username,$domain,undef, |
|
$bubbles_per_row); |
} else { |
} else { |
$parts = $grader_partids_by_symb{$ressymb}; |
$parts = $grader_partids_by_symb{$ressymb}; |
} |
} |
Line 8505 sub letter_to_digits {
|
Line 8844 sub letter_to_digits {
|
|
|
sub href_symb_cmd { |
sub href_symb_cmd { |
my ($symb,$cmd)=@_; |
my ($symb,$cmd)=@_; |
return '/adm/grades?symb='.&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb),'<>&"').'&command='.$cmd; |
return '/adm/grades?symb='.&HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb),'<>&"').'&command='.$cmd; |
} |
} |
|
|
sub grading_menu { |
sub grading_menu { |
Line 8768 sub init_perm {
|
Line 9107 sub init_perm {
|
} |
} |
} |
} |
|
|
|
sub init_old_essays { |
|
my ($symb,$apath,$adom,$aname) = @_; |
|
if ($symb ne '') { |
|
my %essays = &Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname); |
|
if (keys(%essays) > 0) { |
|
$old_essays{$symb} = \%essays; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub reset_old_essays { |
|
undef(%old_essays); |
|
} |
|
|
sub gather_clicker_ids { |
sub gather_clicker_ids { |
my %clicker_ids; |
my %clicker_ids; |
|
|
Line 8865 sub process_clicker {
|
Line 9219 sub process_clicker {
|
my $pincorrect=&mt("Percentage points for incorrect solution"); |
my $pincorrect=&mt("Percentage points for incorrect solution"); |
my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype', |
my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype', |
{'iclicker' => 'i>clicker', |
{'iclicker' => 'i>clicker', |
'interwrite' => 'interwrite PRS'}); |
'interwrite' => 'interwrite PRS', |
|
'turning' => 'Turning Technologies'}); |
$symb = &Apache::lonenc::check_encrypt($symb); |
$symb = &Apache::lonenc::check_encrypt($symb); |
$result.= &Apache::lonhtmlcommon::scripttag(<<ENDUPFORM); |
$result.= &Apache::lonhtmlcommon::scripttag(<<ENDUPFORM); |
function sanitycheck() { |
function sanitycheck() { |
Line 9039 ENDHEADER
|
Line 9394 ENDHEADER
|
if ($env{'form.upfiletype'} eq 'interwrite') { |
if ($env{'form.upfiletype'} eq 'interwrite') { |
($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses); |
($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses); |
} |
} |
|
if ($env{'form.upfiletype'} eq 'turning') { |
|
($errormsg,$number)=&turning_eval(\@questiontitles,\%responses); |
|
} |
$result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'. |
$result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'. |
'<input type="hidden" name="number" value="'.$number.'" />'. |
'<input type="hidden" name="number" value="'.$number.'" />'. |
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses', |
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses', |
Line 9175 sub interwrite_eval {
|
Line 9533 sub interwrite_eval {
|
return ($errormsg,$number); |
return ($errormsg,$number); |
} |
} |
|
|
|
sub turning_eval { |
|
my ($questiontitles,$responses)=@_; |
|
my $number=0; |
|
my $errormsg=''; |
|
foreach my $line (split(/[\n\r]/,$env{'form.upfile'})) { |
|
my %components=&Apache::loncommon::record_sep($line); |
|
my @entries=map {$components{$_}} (sort(keys(%components))); |
|
if ($#entries>$number) { $number=$#entries; } |
|
my $id=$entries[0]; |
|
my @idresponses; |
|
$id=~s/^[\#0]+//; |
|
unless ($id) { next; } |
|
for (my $idx=1;$idx<=$#entries;$idx++) { |
|
$entries[$idx]=~s/\,/\;/g; |
|
$entries[$idx]=~s/[^a-zA-Z0-9\.\*\-\+\;]+//g; |
|
push(@idresponses,$entries[$idx]); |
|
} |
|
$$responses{$id}=join(',',@idresponses); |
|
} |
|
for (my $i=1; $i<=$number; $i++) { |
|
$$questiontitles[$i]=&mt('Question [_1]',$i); |
|
} |
|
return ($errormsg,$number); |
|
} |
|
|
|
|
sub assign_clicker_grades { |
sub assign_clicker_grades { |
my ($r,$symb)=@_; |
my ($r,$symb)=@_; |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
Line 9312 sub navmap_errormsg {
|
Line 9696 sub navmap_errormsg {
|
} |
} |
|
|
sub startpage { |
sub startpage { |
my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag) = @_; |
my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag,$stuvcurrent,$stuvdisp,$nomenu,$js) = @_; |
unshift(@$crumbs,{href=>&href_symb_cmd($symb,'gradingmenu'),text=>"Grading"}); |
if ($nomenu) { |
$r->print(&Apache::loncommon::start_page('Grading',undef, |
$r->print(&Apache::loncommon::start_page("Student's Version",$js,{'only_body' => '1'})); |
{'bread_crumbs' => $crumbs})); |
} else { |
&Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); |
unshift(@$crumbs,{href=>&href_symb_cmd($symb,'gradingmenu'),text=>"Grading"}); |
|
$r->print(&Apache::loncommon::start_page('Grading',$js, |
|
{'bread_crumbs' => $crumbs})); |
|
&Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); |
|
} |
unless ($nodisplayflag) { |
unless ($nodisplayflag) { |
$r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag)); |
$r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)); |
} |
} |
} |
} |
|
|
Line 9340 sub handler {
|
Line 9728 sub handler {
|
} |
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
|
|
|
# see what command we need to execute |
|
|
|
my @commands=&Apache::loncommon::get_env_multiple('form.command'); |
|
my $command=$commands[0]; |
|
|
&init_perm(); |
&init_perm(); |
if (!$env{'request.course.id'}) { |
if (!$env{'request.course.id'}) { |
# Not in a course. |
unless ((&Apache::lonnet::allowed('usc',$env{'request.role.domain'})) && |
$env{'user.error.msg'}="/adm/grades::vgr:0:0:Cannot display grades page outside course context"; |
($command =~ /^scantronupload/)) { |
return HTTP_NOT_ACCEPTABLE; |
# Not in a course. |
|
$env{'user.error.msg'}="/adm/grades::vgr:0:0:Cannot display grades page outside course context"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
} elsif (!%perm) { |
} elsif (!%perm) { |
$request->internal_redirect('/adm/quickgrades'); |
$request->internal_redirect('/adm/quickgrades'); |
} |
} |
&Apache::loncommon::content_type($request,'text/html'); |
&Apache::loncommon::content_type($request,'text/html'); |
$request->send_http_header; |
$request->send_http_header; |
|
|
|
|
# see what command we need to execute |
|
|
|
my @commands=&Apache::loncommon::get_env_multiple('form.command'); |
|
my $command=$commands[0]; |
|
|
|
if ($#commands > 0) { |
if ($#commands > 0) { |
&Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands)); |
&Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands)); |
} |
} |
Line 9379 sub handler {
|
Line 9769 sub handler {
|
&select_problem($request); |
&select_problem($request); |
} else { |
} else { |
if ($command eq 'submission' && $perm{'vgr'}) { |
if ($command eq 'submission' && $perm{'vgr'}) { |
&startpage($request,$symb,[{href=>"", text=>"Student Submissions"}]); |
my ($stuvcurrent,$stuvdisp,$versionform,$js); |
|
if (($env{'form.student'} ne '') && ($env{'form.userdom'} ne '')) { |
|
($stuvcurrent,$stuvdisp,$versionform,$js) = |
|
&choose_task_version_form($symb,$env{'form.student'}, |
|
$env{'form.userdom'}); |
|
} |
|
&startpage($request,$symb,[{href=>"", text=>"Student Submissions"}],undef,undef,$stuvcurrent,$stuvdisp,undef,$js); |
|
if ($versionform) { |
|
$request->print($versionform); |
|
} |
|
$request->print('<br clear="all" />'); |
($env{'form.student'} eq '' ? &listStudents($request,$symb) : &submission($request,0,0,$symb)); |
($env{'form.student'} eq '' ? &listStudents($request,$symb) : &submission($request,0,0,$symb)); |
|
} elsif ($command eq 'versionsub' && $perm{'vgr'}) { |
|
my ($stuvcurrent,$stuvdisp,$versionform,$js) = |
|
&choose_task_version_form($symb,$env{'form.student'}, |
|
$env{'form.userdom'}, |
|
$env{'form.inhibitmenu'}); |
|
&startpage($request,$symb,[{href=>"", text=>"Previous Student Version"}],undef,undef,$stuvcurrent,$stuvdisp,$env{'form.inhibitmenu'},$js); |
|
if ($versionform) { |
|
$request->print($versionform); |
|
} |
|
$request->print('<br clear="all" />'); |
|
$request->print(&show_previous_task_version($request,$symb)); |
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) { |
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) { |
&startpage($request,$symb,[{href=>&href_symb_cmd($symb,'all_for_one'),text=>'Grade page/folder for one student'}, |
&startpage($request,$symb,[{href=>&href_symb_cmd($symb,'all_for_one'),text=>'Grade page/folder for one student'}, |
{href=>'',text=>'Select student'}],1,1); |
{href=>'',text=>'Select student'}],1,1); |
Line 9518 sub handler {
|
Line 9929 sub handler {
|
if ($ssi_error) { |
if ($ssi_error) { |
&ssi_print_error($request); |
&ssi_print_error($request); |
} |
} |
&Apache::lonquickgrades::endGradeScreen($request); |
if ($env{'form.inhibitmenu'}) { |
$request->print(&Apache::loncommon::end_page()); |
$request->print(&Apache::loncommon::end_page()); |
|
} else { |
|
&Apache::lonquickgrades::endGradeScreen($request); |
|
} |
&reset_caches(); |
&reset_caches(); |
return OK; |
return OK; |
} |
} |
Line 9590 ssi_with_retries()
|
Line 10004 ssi_with_retries()
|
|
|
=over |
=over |
|
|
|
=head1 Routines to display previous version of a Task for a specific student |
|
|
|
Tasks are graded pass/fail. Students who have yet to pass a particular Task |
|
can receive another opportunity. Access to tasks is slot-based. If a slot |
|
requires a proctor to check-in the student, a new version of the Task will |
|
be created when the student is checked in to the new opportunity. |
|
|
|
If a particular student has tried two or more versions of a particular task, |
|
the submission screen provides a user with vgr privileges (e.g., a Course |
|
Coordinator) the ability to display a previous version worked on by the |
|
student. By default, the current version is displayed. If a previous version |
|
has been selected for display, submission data are only shown that pertain |
|
to that particular version, and the interface to submit grades is not shown. |
|
|
|
=over 4 |
|
|
|
=item show_previous_task_version() |
|
|
|
Displays a specified version of a student's Task, as the student sees it. |
|
|
|
Inputs: 2 |
|
request - request object |
|
symb - unique symb for current instance of resource |
|
|
|
Output: None. |
|
|
|
Side Effects: calls &show_problem() to print version of Task, with |
|
version contained in form item: $env{'form.previousversion'} |
|
|
|
=item choose_task_version_form() |
|
|
|
Displays a web form used to select which version of a student's view of a |
|
Task should be displayed. Either launches a pop-up window, or replaces |
|
content in existing pop-up, or replaces page in main window. |
|
|
|
Inputs: 4 |
|
symb - unique symb for current instance of resource |
|
uname - username of student |
|
udom - domain of student |
|
nomenu - 1 if display is in a pop-up window, and hence no menu |
|
breadcrumbs etc., are displayed |
|
|
|
Output: 4 |
|
current - student's current version |
|
displayed - student's version being displayed |
|
result - scalar containing HTML for web form used to switch to |
|
a different version (or a link to close window, if pop-up). |
|
js - javascript for processing selection in versions web form |
|
|
|
Side Effects: None. |
|
|
|
=item previous_display_javascript() |
|
|
|
Inputs: 2 |
|
nomenu - 1 if display is in a pop-up window, and hence no menu |
|
breadcrumbs etc., are displayed. |
|
current - student's current version number. |
|
|
|
Output: 1 |
|
js - javascript for processing selection in versions web form. |
|
|
|
Side Effects: None. |
|
|
|
=back |
|
|
|
=head1 Routines to process bubblesheet data. |
|
|
|
=over 4 |
|
|
=item scantron_get_correction() : |
=item scantron_get_correction() : |
|
|
Builds the interface screen to interact with the operator to fix a |
Builds the interface screen to interact with the operator to fix a |
Line 9695 ssi_with_retries()
|
Line 10178 ssi_with_retries()
|
=item navmap_errormsg() : |
=item navmap_errormsg() : |
|
|
Returns HTML mark-up inside a <div></div> with a link to re-initialize the course. |
Returns HTML mark-up inside a <div></div> with a link to re-initialize the course. |
Should be called whenever the request to instantiate a navmap object fails. |
Should be called whenever the request to instantiate a navmap object fails. |
|
|
|
=back |
|
|
=back |
=back |
|
|