version 1.548, 2009/01/16 10:59:52
|
version 1.571, 2009/05/07 17:55:25
|
Line 234 sub reset_caches {
|
Line 234 sub reset_caches {
|
|
|
{ |
{ |
my %analyze_cache; |
my %analyze_cache; |
|
my %analyze_cache_formkeys; |
|
|
sub reset_analyze_cache { |
sub reset_analyze_cache { |
undef(%analyze_cache); |
undef(%analyze_cache); |
|
undef(%analyze_cache_formkeys); |
} |
} |
|
|
sub get_analyze { |
sub get_analyze { |
my ($symb,$uname,$udom,$no_increment)=@_; |
my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_; |
my $key = "$symb\0$uname\0$udom"; |
my $key = "$symb\0$uname\0$udom"; |
return $analyze_cache{$key} if (exists($analyze_cache{$key})); |
if (exists($analyze_cache{$key})) { |
|
my $getupdate = 0; |
|
if (ref($add_to_hash) eq 'HASH') { |
|
foreach my $item (keys(%{$add_to_hash})) { |
|
if (ref($analyze_cache_formkeys{$key}) eq 'HASH') { |
|
if (!exists($analyze_cache_formkeys{$key}{$item})) { |
|
$getupdate = 1; |
|
last; |
|
} |
|
} else { |
|
$getupdate = 1; |
|
} |
|
} |
|
} |
|
if (!$getupdate) { |
|
return $analyze_cache{$key}; |
|
} |
|
} |
|
|
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
$url=&Apache::lonnet::clutter($url); |
$url=&Apache::lonnet::clutter($url); |
my $subresult=&ssi_with_retries($url, $ssi_retries, |
my %form = ('grade_target' => 'analyze', |
('grade_target' => 'analyze', |
'grade_domain' => $udom, |
'grade_domain' => $udom, |
'grade_symb' => $symb, |
'grade_symb' => $symb, |
'grade_courseid' => $env{'request.course.id'}, |
'grade_courseid' => |
'grade_username' => $uname, |
$env{'request.course.id'}, |
'grade_noincrement' => $no_increment); |
'grade_username' => $uname, |
if (ref($add_to_hash)) { |
'grade_noincrement' => $no_increment)); |
%form = (%form,%{$add_to_hash}); |
|
} |
|
my $subresult=&ssi_with_retries($url, $ssi_retries,%form); |
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
|
if (ref($add_to_hash) eq 'HASH') { |
|
$analyze_cache_formkeys{$key} = $add_to_hash; |
|
} else { |
|
$analyze_cache_formkeys{$key} = {}; |
|
} |
return $analyze_cache{$key} = \%analyze; |
return $analyze_cache{$key} = \%analyze; |
} |
} |
|
|
Line 268 sub reset_caches {
|
Line 294 sub reset_caches {
|
sub get_radiobutton_correct_foil { |
sub get_radiobutton_correct_foil { |
my ($partid,$respid,$symb,$uname,$udom)=@_; |
my ($partid,$respid,$symb,$uname,$udom)=@_; |
my $analyze = &get_analyze($symb,$uname,$udom); |
my $analyze = &get_analyze($symb,$uname,$udom); |
foreach my $foil (@{&get_order($partid,$respid,$symb,$uname,$udom)}) { |
my $foils = &get_order($partid,$respid,$symb,$uname,$udom); |
if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { |
if (ref($foils) eq 'ARRAY') { |
return $foil; |
foreach my $foil (@{$foils}) { |
|
if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { |
|
return $foil; |
|
} |
} |
} |
} |
} |
} |
} |
|
|
|
sub scantron_partids_tograde { |
|
my ($resource,$cid,$uname,$udom,$check_for_randomlist) = @_; |
|
my (%analysis,@parts); |
|
if (ref($resource)) { |
|
my $symb = $resource->symb(); |
|
my $add_to_form; |
|
if ($check_for_randomlist) { |
|
$add_to_form = { 'check_parts_withrandomlist' => 1,}; |
|
} |
|
my $analyze = &get_analyze($symb,$uname,$udom,undef,$add_to_form); |
|
if (ref($analyze) eq 'HASH') { |
|
%analysis = %{$analyze}; |
|
} |
|
if (ref($analysis{'parts'}) eq 'ARRAY') { |
|
foreach my $part (@{$analysis{'parts'}}) { |
|
my ($id,$respid) = split(/\./,$part); |
|
if (!&Apache::loncommon::check_if_partid_hidden($id,$symb,$udom,$uname)) { |
|
push(@parts,$part); |
|
} |
|
} |
|
} |
|
} |
|
return (\%analysis,\@parts); |
|
} |
|
|
} |
} |
|
|
#--- Clean response type for display |
#--- Clean response type for display |
Line 699 sub verifyreceipt {
|
Line 754 sub verifyreceipt {
|
|
|
my $title.= |
my $title.= |
'<h3><span class="LC_info">'. |
'<h3><span class="LC_info">'. |
&mt('Verifying Submission Receipt [_1]',$receipt). |
&mt('Verifying Receipt No. [_1]',$receipt). |
'</span></h3>'."\n". |
'</span></h3>'."\n". |
'<h4>'.&mt('<b>Resource: </b>[_1]',$env{'form.probTitle'}). |
'<h4>'.&mt('<b>Resource: </b>[_1]',$env{'form.probTitle'}). |
'</h4>'."\n"; |
'</h4>'."\n"; |
Line 789 sub listStudents {
|
Line 844 sub listStudents {
|
|
|
my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); |
my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); |
|
|
my %lt = ( 'multiple' => |
my %lt = &Apache::lonlocal::texthash ( |
&mt("Please select a student or group of students before clicking on the Next button."), |
'multiple' => 'Please select a student or group of students before clicking on the Next button.', |
'single' => |
'single' => 'Please select the student before clicking on the Next button.', |
&mt("Please select the student before clicking on the Next button."), |
); |
); |
|
%lt = &Apache::lonlocal::texthash(%lt); |
|
$request->print(<<LISTJAVASCRIPT); |
$request->print(<<LISTJAVASCRIPT); |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
function checkSelect(checkBox) { |
function checkSelect(checkBox) { |
Line 836 LISTJAVASCRIPT
|
Line 889 LISTJAVASCRIPT
|
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'. |
my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'. |
"\n".$table; |
"\n".$table; |
|
|
$gradeTable .= |
$gradeTable .= &Apache::lonhtmlcommon::start_pick_box(); |
' <b>'.&mt('View Problem Text').': </b>'. |
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text')) |
'<label><input type="radio" name="vProb" value="no" checked="checked" /> '.&mt('no').' </label>'."\n". |
.'<label><input type="radio" name="vProb" value="no" checked="checked" /> '.&mt('no').' </label>'."\n" |
'<label><input type="radio" name="vProb" value="yes" /> '.&mt('one student').' </label>'."\n". |
.'<label><input type="radio" name="vProb" value="yes" /> '.&mt('one student').' </label>'."\n" |
'<label><input type="radio" name="vProb" value="all" /> '.&mt('all students').' </label><br />'."\n"; |
.'<label><input type="radio" name="vProb" value="all" /> '.&mt('all students').' </label><br />'."\n" |
$gradeTable .= |
.&Apache::lonhtmlcommon::row_closure(); |
' <b>'.&mt('View Answer').': </b>'. |
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Answer')) |
'<label><input type="radio" name="vAns" value="no" /> '.&mt('no').' </label>'."\n". |
.'<label><input type="radio" name="vAns" value="no" /> '.&mt('no').' </label>'."\n" |
'<label><input type="radio" name="vAns" value="yes" /> '.&mt('one student').' </label>'."\n". |
.'<label><input type="radio" name="vAns" value="yes" /> '.&mt('one student').' </label>'."\n" |
'<label><input type="radio" name="vAns" value="all" checked="checked" /> '.&mt('all students').' </label><br />'."\n"; |
.'<label><input type="radio" name="vAns" value="all" checked="checked" /> '.&mt('all students').' </label><br />'."\n" |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
|
my $submission_options; |
my $submission_options; |
if ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) { |
if ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) { |
Line 860 LISTJAVASCRIPT
|
Line 914 LISTJAVASCRIPT
|
'<label><input type="radio" name="lastSub" value="last" /> '.&mt('last submission & parts info').' </label>'."\n". |
'<label><input type="radio" name="lastSub" value="last" /> '.&mt('last submission & parts info').' </label>'."\n". |
'<label><input type="radio" name="lastSub" value="datesub" /> '.&mt('by dates and submissions').' </label>'."\n". |
'<label><input type="radio" name="lastSub" value="datesub" /> '.&mt('by dates and submissions').' </label>'."\n". |
'<label><input type="radio" name="lastSub" value="all" /> '.&mt('all details').'</label>'; |
'<label><input type="radio" name="lastSub" value="all" /> '.&mt('all details').'</label>'; |
$gradeTable .= |
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Submissions')) |
' <b>'.&mt('Submissions').': </b>'.$submission_options.'<br />'."\n"; |
.$submission_options |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
|
|
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Grading Increments')) |
|
.'<select name="increment">' |
|
.'<option value="1">'.&mt('Whole Points').'</option>' |
|
.'<option value=".5">'.&mt('Half Points').'</option>' |
|
.'<option value=".25">'.&mt('Quarter Points').'</option>' |
|
.'<option value=".1">'.&mt('Tenths of a Point').'</option>' |
|
.'</select>' |
|
.&Apache::lonhtmlcommon::row_closure(); |
|
|
$gradeTable .= |
$gradeTable .= |
' <b>'.&mt('Grading Increments').': </b>'. |
|
'<select name="increment">'. |
|
'<option value="1">'.&mt('Whole Points').'</option>'. |
|
'<option value=".5">'.&mt('Half Points').'</option>'. |
|
'<option value=".25">'.&mt('Quarter Points').'</option>'. |
|
'<option value=".1">'.&mt('Tenths of a Point').'</option>'. |
|
'</select>'; |
|
|
|
$gradeTable .= |
|
&build_section_inputs(). |
&build_section_inputs(). |
'<input type="hidden" name="submitonly" value="'.$submitonly.'" />'."\n". |
'<input type="hidden" name="submitonly" value="'.$submitonly.'" />'."\n". |
'<input type="hidden" name="handgrade" value="'.$env{'form.handgrade'}.'" /><br />'."\n". |
'<input type="hidden" name="handgrade" value="'.$env{'form.handgrade'}.'" /><br />'."\n". |
Line 883 LISTJAVASCRIPT
|
Line 938 LISTJAVASCRIPT
|
'<input type="hidden" name="saveStatusOld" value="'.$saveStatus.'" />'."\n"; |
'<input type="hidden" name="saveStatusOld" value="'.$saveStatus.'" />'."\n"; |
|
|
if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) { |
if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) { |
$gradeTable.='<input type="hidden" name="Status" value="'.$stu_status.'" />'."\n"; |
$gradeTable .= '<input type="hidden" name="Status" value="'.$stu_status.'" />'."\n"; |
} else { |
} else { |
$gradeTable.=&mt('<b>Student Status:</b> [_1]', |
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Student Status')) |
&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);')).'<br />'; |
.&Apache::lonhtmlcommon::StatusOptions( |
|
$saveStatus,undef,1,'javascript:reLoadList(this.form);') |
|
.&Apache::lonhtmlcommon::row_closure(); |
} |
} |
|
|
$gradeTable.=&mt('To '.lc($viewgrade)." a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.").'<br />'."\n". |
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Check For Plagiarism')) |
'<input type="hidden" name="command" value="processGroup" />'."\n"; |
.'<input type="checkbox" name="checkPlag" checked="checked" />' |
|
.&Apache::lonhtmlcommon::row_closure(1) |
|
.&Apache::lonhtmlcommon::end_pick_box(); |
|
|
|
$gradeTable .= '<p>' |
|
.&mt('To '.lc($viewgrade)." a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n" |
|
.'<input type="hidden" name="command" value="processGroup" />' |
|
.'</p>'; |
|
|
# checkall buttons |
# checkall buttons |
$gradeTable.=&check_script('gradesub', 'stuinfo'); |
$gradeTable.=&check_script('gradesub', 'stuinfo'); |
Line 898 LISTJAVASCRIPT
|
Line 962 LISTJAVASCRIPT
|
'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n". |
'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n". |
'value="'.&mt('Next').' →" /> <br />'."\n"; |
'value="'.&mt('Next').' →" /> <br />'."\n"; |
$gradeTable.=&check_buttons(); |
$gradeTable.=&check_buttons(); |
$gradeTable.='<label><input type="checkbox" name="checkPlag" checked="checked" />'.&mt('Check For Plagiarism').'</label>'; |
|
my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); |
my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); |
$gradeTable.= &Apache::loncommon::start_data_table(). |
$gradeTable.= &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(); |
&Apache::loncommon::start_data_table_header_row(); |
Line 981 LISTJAVASCRIPT
|
Line 1044 LISTJAVASCRIPT
|
$gradeTable.= &Apache::loncommon::start_data_table_row(); |
$gradeTable.= &Apache::loncommon::start_data_table_row(); |
} |
} |
$gradeTable.='<td align="right">'.$ctr.' </td>'. |
$gradeTable.='<td align="right">'.$ctr.' </td>'. |
'<td align="center"><label><input type=checkbox name="stuinfo" value="'. |
'<td align="center"><label><input type="checkbox" name="stuinfo" value="'. |
$student.':'.$$fullname{$student}.':::SECTION'.$section. |
$student.':'.$$fullname{$student}.':::SECTION'.$section. |
') " /> </label></td>'."\n".'<td>'. |
') " /> </label></td>'."\n".'<td>'. |
&nameUserString(undef,$$fullname{$student},$uname,$udom). |
&nameUserString(undef,$$fullname{$student},$uname,$udom). |
Line 1488 INNERJS
|
Line 1551 INNERJS
|
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\\"> Compose Message for \"+fullname+\"<\\/span><\\/h3><br /><br />"); |
pDoc.write("<h3><span class=\\"LC_info\\"> Compose Message for \"+fullname+\"<\\/span><\\/h3><br /><br />"); |
|
|
pDoc.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">"); |
pDoc.write('<table border="0" width="100%"><tr><td bgcolor="#777777">'); |
pDoc.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">"); |
pDoc.write('<table border="0" width="100%"><tr bgcolor="#DDFFFF">'); |
pDoc.write("<td><b>Type<\\/b><\\/td><td><b>Include<\\/b><\\/td><td><b>Message<\\/td><\\/tr>"); |
pDoc.write("<td><b>Type<\\/b><\\/td><td><b>Include<\\/b><\\/td><td><b>Message<\\/td><\\/tr>"); |
} |
} |
function displaySubject(msg,shwsel) { |
function displaySubject(msg,shwsel) { |
Line 1573 INNERJS
|
Line 1636 INNERJS
|
hDoc.write("<form action=\\"inactive\\" name=\\"hlCenter\\">"); |
hDoc.write("<form action=\\"inactive\\" name=\\"hlCenter\\">"); |
hDoc.write("<h3><span class=\\"LC_info\\"> Keyword Highlight Options<\\/span><\\/h3><br /><br />"); |
hDoc.write("<h3><span class=\\"LC_info\\"> Keyword Highlight Options<\\/span><\\/h3><br /><br />"); |
|
|
hDoc.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">"); |
hDoc.write('<table border="0" width="100%"><tr><td bgcolor="#777777">'); |
hDoc.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">"); |
hDoc.write('<table border="0" width="100%"><tr bgcolor="#DDFFFF">'); |
hDoc.write("<td><b>Text Color<\\/b><\\/td><td><b>Font Size<\\/b><\\/td><td><b>Font Style<\\/td><\\/tr>"); |
hDoc.write("<td><b>Text Color<\\/b><\\/td><td><b>Font Size<\\/b><\\/td><td><b>Font Style<\\/td><\\/tr>"); |
} |
} |
|
|
Line 2099 KEYWORDS
|
Line 2162 KEYWORDS
|
foreach my $file (@$files) { |
foreach my $file (@$files) { |
$file_counter++; |
$file_counter++; |
&Apache::lonnet::allowuploaded('/adm/grades',$file); |
&Apache::lonnet::allowuploaded('/adm/grades',$file); |
$lastsubonly.='<br /><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border=0"> '.$file.'</a>'; |
$lastsubonly.='<br /><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.&Apache::loncommon::icon($file).'" border="0" /> '.$file.'</a>'; |
} |
} |
$lastsubonly.='<br />'; |
$lastsubonly.='<br />'; |
} |
} |
$lastsubonly.='<b>'.&mt('Submitted Answer:').' </b>'. |
$lastsubonly.='<b>'.&mt('Submitted Answer:').' </b>'. |
&cleanRecord($subval,$responsetype,$symb,$partid, |
&cleanRecord($subval,$responsetype,$symb,$partid, |
$respid,\%record,$order); |
$respid,\%record,$order,undef,$uname,$udom); |
if ($similar) {$lastsubonly.="<br /><br />$similar\n";} |
if ($similar) {$lastsubonly.="<br /><br />$similar\n";} |
$lastsubonly.='</div>'; |
$lastsubonly.='</div>'; |
} |
} |
Line 2234 KEYWORDS
|
Line 2297 KEYWORDS
|
'<option>7</option><option>10</option></select>'."\n"; |
'<option>7</option><option>10</option></select>'."\n"; |
my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1'); |
my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1'); |
$ntstu =~ s/<option>$nsel</<option selected="selected">$nsel</; |
$ntstu =~ s/<option>$nsel</<option selected="selected">$nsel</; |
$endform.=&mt('[_1]student(s)',$ntstu); |
$endform.=&mt('[quant,_1,student]',$ntstu); |
$endform.=' <input type="button" value="'.&mt('Previous').'" '. |
$endform.=' <input type="button" value="'.&mt('Previous').'" '. |
'onClick="javascript:checksubmit(this.form,\'Previous\');" target="_self" /> '."\n". |
'onClick="javascript:checksubmit(this.form,\'Previous\');" target="_self" /> '."\n". |
'<input type="button" value="'.&mt('Next').'" '. |
'<input type="button" value="'.&mt('Next').'" '. |
Line 3173 sub viewgrades {
|
Line 3236 sub viewgrades {
|
'<input type="hidden" name="Status" value="'.$env{'stu_status'}.'" />'."\n". |
'<input type="hidden" name="Status" value="'.$env{'stu_status'}.'" />'."\n". |
'<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n"; |
'<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n"; |
|
|
my $sectionClass; |
my ($common_header,$specific_header); |
my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); |
|
if ($env{'form.section'} eq 'all') { |
if ($env{'form.section'} eq 'all') { |
$sectionClass=&mt('Class'); |
$common_header = &mt('Assign Common Grade to Class'); |
|
$specific_header = &mt('Assign Grade to Specific Students in Class'); |
} elsif ($env{'form.section'} eq 'none') { |
} elsif ($env{'form.section'} eq 'none') { |
$sectionClass=&mt('Students in no Section'); |
$common_header = &mt('Assign Common Grade to Students in no Section'); |
|
$specific_header = &mt('Assign Grade to Specific Students in no Section'); |
} else { |
} else { |
$sectionClass=&mt('Students in Section(s) [_1]'); |
my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); |
|
$common_header = &mt('Assign Common Grade to Students in Section(s) [_1]',$section_display); |
|
$specific_header = &mt('Assign Grade to Specific Students in Section(s) [_1]',$section_display); |
} |
} |
$result.= |
$result.= '<h3>'.$common_header.'</h3>'.&Apache::loncommon::start_data_table(); |
'<h3>'. |
|
&mt("Assign Common Grade to [_1]",$sectionClass,$section_display).'</h3>'; |
|
$result.= &Apache::loncommon::start_data_table(); |
|
#radio buttons/text box for assigning points for a section or class. |
#radio buttons/text box for assigning points for a section or class. |
#handles different parts of a problem |
#handles different parts of a problem |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
Line 3243 sub viewgrades {
|
Line 3306 sub viewgrades {
|
|
|
#table listing all the students in a section/class |
#table listing all the students in a section/class |
#header of table |
#header of table |
$result.= '<h3>'.&mt('Assign Grade to Specific Students in ').$sectionClass, |
$result.= '<h3>'.$specific_header.'</h3>'. |
$section_display.'</h3>'; |
&Apache::loncommon::start_data_table(). |
$result.= &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
'<th>'.&mt('No.').'</th>'. |
'<th>'.&mt('No.').'</th>'. |
'<th>'.&nameUserString('header')."</th>\n"; |
'<th>'.&nameUserString('header')."</th>\n"; |
|
my (@parts) = sort(&getpartlist($symb)); |
my (@parts) = sort(&getpartlist($symb)); |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
my @partids = (); |
my @partids = (); |
Line 3426 sub editgrades {
|
Line 3488 sub editgrades {
|
if ($part !~ m/^\Q$partid\E/) { next;} |
if ($part !~ m/^\Q$partid\E/) { next;} |
if ($type eq 'awarded' || $type eq 'solved') { next; } |
if ($type eq 'awarded' || $type eq 'solved') { next; } |
my $display=&Apache::lonnet::metadata($url,$stores.'.display'); |
my $display=&Apache::lonnet::metadata($url,$stores.'.display'); |
$display =~ s/\[Part: (\w)+\]//; |
$display =~ s/\[Part: \Q$part\E\]//; |
my $narrowtext = &mt('Tries'); |
my $narrowtext = &mt('Tries'); |
$display =~ s/Number of Attempts/$narrowtext/; |
$display =~ s/Number of Attempts/$narrowtext/; |
$header .= '<th align="center">'.&mt('Old').' '.$display.'</th>'. |
$header .= '<th align="center">'.&mt('Old').' '.$display.'</th>'. |
Line 3742 ENDPICK
|
Line 3804 ENDPICK
|
sub csvupload_fields { |
sub csvupload_fields { |
my ($symb) = @_; |
my ($symb) = @_; |
my (@parts) = &getpartlist($symb); |
my (@parts) = &getpartlist($symb); |
my @fields=(['ID','Student ID'], |
my @fields=(['ID','Student/Employee ID'], |
['username','Student Username'], |
['username','Student Username'], |
['domain','Student Domain']); |
['domain','Student Domain']); |
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); |
my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); |
Line 4028 sub csvuploadassign {
|
Line 4090 sub csvuploadassign {
|
$countdone++; |
$countdone++; |
} |
} |
} |
} |
$request->print('<br /><span class="LC_info">'.&mt("Saved [_1] students",$countdone)."</span>\n"); |
$request->print('<br />'.&Apache::lonhtmlcommon::confirm_success(&mt("Saved scores for [quant,_1,student]",$countdone),$countdone==0)); |
if (@skipped) { |
if (@skipped) { |
$request->print('<p><span class="LC_warning">'.&mt('Skipped Students').'</span></p>'); |
$request->print('<br />'.&Apache::lonhtmlcommon::confirm_success(&mt('No scores stored for the following username(s):'),1).'<br />'); |
foreach my $student (@skipped) { $request->print("$student<br />\n"); } |
$request->print(join(', ',@skipped)); |
} |
} |
if (@notallowed) { |
if (@notallowed) { |
$request->print('<p><span class="LC_error">'.&mt('Students Not Allowed to Modify').'</span></p>'); |
$request->print('<br />'.&Apache::lonhtmlcommon::confirm_success(&mt('Modification of scores not allowed for the following username(s):'),1).'<br />'); |
foreach my $student (@notallowed) { $request->print("$student<br />\n"); } |
$request->print(join(', ',@notallowed)); |
} |
} |
$request->print("<br />\n"); |
$request->print("<br />\n"); |
$request->print(&show_grading_menu_form($symb)); |
$request->print(&show_grading_menu_form($symb)); |
Line 4655 Next each scanline is checked for any er
|
Line 4717 Next each scanline is checked for any er
|
bubbles' (it's an error because it may have been mis-scanned |
bubbles' (it's an error because it may have been mis-scanned |
because too light bubbling), 'double bubble' (each bubble line should |
because too light bubbling), 'double bubble' (each bubble line should |
have no more that one letter picked), invalid or duplicated CODE, |
have no more that one letter picked), invalid or duplicated CODE, |
invalid student ID |
invalid student/employee ID |
|
|
If the CODE option is used that determines the randomization of the |
If the CODE option is used that determines the randomization of the |
homework problems, either way the student ID is looked up into a |
homework problems, either way the student/employee ID is looked up into a |
username:domain. |
username:domain. |
|
|
During the validation phase the instructor can choose to skip scanlines. |
During the validation phase the instructor can choose to skip scanlines. |
Line 4728 sub getSequenceDropDown {
|
Line 4790 sub getSequenceDropDown {
|
} |
} |
|
|
my %bubble_lines_per_response; # no. bubble lines for each response. |
my %bubble_lines_per_response; # no. bubble lines for each response. |
# index is "symb.part_id" |
# key is zero-based index - 0, 1, 2 ... |
|
|
my %first_bubble_line; # First bubble line no. for each bubble. |
my %first_bubble_line; # First bubble line no. for each bubble. |
|
|
Line 4769 sub restore_bubble_lines {
|
Line 4831 sub restore_bubble_lines {
|
$env{"form.scantron.responsetype.$line"}; |
$env{"form.scantron.responsetype.$line"}; |
$line++; |
$line++; |
} |
} |
|
|
} |
} |
|
|
# Given the parsed scanline, get the response for |
# Given the parsed scanline, get the response for |
Line 4778 sub restore_bubble_lines {
|
Line 4839 sub restore_bubble_lines {
|
sub get_response_bubbles { |
sub get_response_bubbles { |
my ($parsed_line, $response) = @_; |
my ($parsed_line, $response) = @_; |
|
|
|
|
my $bubble_line = $first_bubble_line{$response-1} +1; |
my $bubble_line = $first_bubble_line{$response-1} +1; |
my $bubble_lines= $bubble_lines_per_response{$response-1}; |
my $bubble_lines= $bubble_lines_per_response{$response-1}; |
|
|
Line 5134 sub scantron_selectphase {
|
Line 5194 sub scantron_selectphase {
|
'<td> '.$format_selector.' </td>'."\n". |
'<td> '.$format_selector.' </td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::start_data_table_row()."\n". |
&Apache::loncommon::start_data_table_row()."\n". |
|
'<td> '.&mt('Options').' </td>'."\n". |
|
'<td> <label><input type="checkbox" name="scantron_options_hidden" value="ignore_hidden"/> '.&mt('Skip hidden resources').'</label></td>'. |
|
&Apache::loncommon::end_data_table_row()."\n". |
|
&Apache::loncommon::start_data_table_row()."\n". |
'<td colspan="2">'."\n". |
'<td colspan="2">'."\n". |
'<input type="hidden" name="command" value="checksubmissions" />'."\n". |
'<input type="hidden" name="command" value="checksubmissions" />'."\n". |
'<input type="submit" value="'.&mt('Review Scantron Data and Submission Records').'" />'."\n". |
'<input type="submit" value="'.&mt('Review Scantron Data and Submission Records').'" />'."\n". |
Line 5177 sub scantron_selectphase {
|
Line 5241 sub scantron_selectphase {
|
CODEstart - (only matter if a CODE exists) column in the line where |
CODEstart - (only matter if a CODE exists) column in the line where |
the CODE starts |
the CODE starts |
CODElength - length of the CODE |
CODElength - length of the CODE |
IDstart - column where the student ID number starts |
IDstart - column where the student/employee ID number starts |
IDlength - length of the student ID info |
IDlength - length of the student/employee ID info |
Qstart - column where the information from the bubbled |
Qstart - column where the information from the bubbled |
'questions' start |
'questions' start |
Qlength - number of columns comprising a single bubble line from |
Qlength - number of columns comprising a single bubble line from |
Line 5238 sub get_scantron_config {
|
Line 5302 sub get_scantron_config {
|
|
|
=item username_to_idmap |
=item username_to_idmap |
|
|
creates a hash keyed by student id with values of the corresponding |
creates a hash keyed by student/employee ID with values of the corresponding |
student username:domain. |
student username:domain. |
|
|
Arguments: |
Arguments: |
Line 5277 sub username_to_idmap {
|
Line 5341 sub username_to_idmap {
|
$whichline - line number of the passed in scanline |
$whichline - line number of the passed in scanline |
$field - type of change to process |
$field - type of change to process |
(either |
(either |
'ID' -> correct the student ID number |
'ID' -> correct the student/employee ID number |
'CODE' -> correct the CODE |
'CODE' -> correct the CODE |
'answer' -> fixup the submitted answers) |
'answer' -> fixup the submitted answers) |
|
|
Line 5451 sub digits_to_letters {
|
Line 5515 sub digits_to_letters {
|
CODE_ignore_dup - 1 if the CODE is a duplicated use when unique |
CODE_ignore_dup - 1 if the CODE is a duplicated use when unique |
CODEs were selected, but the usage has been |
CODEs were selected, but the usage has been |
forced by the operator |
forced by the operator |
ID - student ID |
ID - student/employee ID |
PaperID - if used, the ID number printed on the sheet when the |
PaperID - if used, the ID number printed on the sheet when the |
paper was scanned |
paper was scanned |
FirstName - first name from the sheet |
FirstName - first name from the sheet |
Line 5487 sub scantron_parse_scanline {
|
Line 5551 sub scantron_parse_scanline {
|
my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_; |
my ($line,$whichline,$scantron_config,$scan_data,$just_header)=@_; |
|
|
my %record; |
my %record; |
my $questions=substr($line,$$scantron_config{'Qstart'}-1); # Answers |
my $lastpos = $env{'form.scantron_maxbubble'}*$$scantron_config{'Qlength'}; |
|
my $questions=substr($line,$$scantron_config{'Qstart'}-1,$lastpos); # Answers |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff |
my $data=substr($line,0,$$scantron_config{'Qstart'}-1); # earlier stuff |
if (!($$scantron_config{'CODElocation'} eq 0 || |
if (!($$scantron_config{'CODElocation'} eq 0 || |
$$scantron_config{'CODElocation'} eq 'none')) { |
$$scantron_config{'CODElocation'} eq 'none')) { |
Line 6712 sub scantron_get_correction {
|
Line 6777 sub scantron_get_correction {
|
if ($closest > 0) { |
if ($closest > 0) { |
foreach my $testcode (@{$closest}) { |
foreach my $testcode (@{$closest}) { |
my $checked=''; |
my $checked=''; |
if (!$i) { $checked=' checked="checked" '; } |
if (!$i) { $checked=' checked="checked"'; } |
$r->print(" |
$r->print(" |
<label> |
<label> |
<input type='radio' name='scantron_CODE_resolution' value='use_closest_$i' $checked /> |
<input type='radio' name='scantron_CODE_resolution' value='use_closest_$i'$checked /> |
".&mt("Use the similar CODE [_1] instead.", |
".&mt("Use the similar CODE [_1] instead.", |
"<b><tt>".$testcode."</tt></b>")." |
"<b><tt>".$testcode."</tt></b>")." |
</label> |
</label> |
Line 6726 sub scantron_get_correction {
|
Line 6791 sub scantron_get_correction {
|
} |
} |
} |
} |
if ($$scan_record{'scantron.CODE'}=~/\S/ ) { |
if ($$scan_record{'scantron.CODE'}=~/\S/ ) { |
my $checked; if (!$i) { $checked=' checked="checked" '; } |
my $checked; if (!$i) { $checked=' checked="checked"'; } |
$r->print(" |
$r->print(" |
<label> |
<label> |
<input type='radio' name='scantron_CODE_resolution' value='use_unfound' $checked /> |
<input type='radio' name='scantron_CODE_resolution' value='use_unfound'$checked /> |
".&mt("Use the CODE [_1] that is was on the paper, ignoring the error.", |
".&mt("Use the CODE [_1] that is was on the paper, ignoring the error.", |
"<b><tt>".$$scan_record{'scantron.CODE'}."</tt></b>")." |
"<b><tt>".$$scan_record{'scantron.CODE'}."</tt></b>")." |
</label>"); |
</label>"); |
Line 6760 ENDSCRIPT
|
Line 6825 ENDSCRIPT
|
".&mt("[_1]Select[_2] a CODE from the list of all CODEs and use it.", |
".&mt("[_1]Select[_2] a CODE from the list of all CODEs and use it.", |
"<a target='_blank' href='$href'>","</a>")." |
"<a target='_blank' href='$href'>","</a>")." |
</label> |
</label> |
".&mt("Selected CODE is [_1]","<input readonly='true' type='text' size='8' name='scantron_CODE_selectedvalue' onfocus=\"javascript:change_radio('use_found')\" onchange=\"javascript:change_radio('use_found')\" />")); |
".&mt("Selected CODE is [_1]",'<input readonly="readonly" type="text" size="8" name="scantron_CODE_selectedvalue" onfocus="javascript:change_radio(\'use_found\')" onchange="javascript:change_radio(\'use_found\')" />')); |
$r->print("\n<br />"); |
$r->print("\n<br />"); |
} |
} |
$r->print(" |
$r->print(" |
Line 7234 sub scantron_get_maxbubble {
|
Line 7299 sub scantron_get_maxbubble {
|
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
|
|
my $uname = $env{'form.student'}; |
my $uname = $env{'user.name'}; |
my $udom = $env{'form.userdom'}; |
my $udom = $env{'user.domain'}; |
my $cid = $env{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
my $total_lines = 0; |
my $total_lines = 0; |
%bubble_lines_per_response = (); |
%bubble_lines_per_response = (); |
%first_bubble_line = (); |
%first_bubble_line = (); |
%subdivided_bubble_lines = (); |
%subdivided_bubble_lines = (); |
%responsetype_per_response = (); |
%responsetype_per_response = (); |
|
|
my $response_number = 0; |
my $response_number = 0; |
my $bubble_line = 0; |
my $bubble_line = 0; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
Line 7301 sub scantron_get_maxbubble {
|
Line 7366 sub scantron_get_maxbubble {
|
} |
} |
} |
} |
} |
} |
&Apache::lonnet::delenv('scantron\.'); |
&Apache::lonnet::delenv('scantron.'); |
|
|
&save_bubble_lines(); |
&save_bubble_lines(); |
$env{'form.scantron_maxbubble'} = |
$env{'form.scantron_maxbubble'} = |
Line 7309 sub scantron_get_maxbubble {
|
Line 7374 sub scantron_get_maxbubble {
|
return $env{'form.scantron_maxbubble'}; |
return $env{'form.scantron_maxbubble'}; |
} |
} |
|
|
sub scantron_partids_tograde { |
|
my ($resource,$cid,$uname,$udom) = @_; |
|
my (%analysis,@parts); |
|
|
|
if (ref($resource)) { |
|
my $symb = $resource->symb(); |
|
my $result=&ssi_with_retries($resource->src(), $ssi_retries, |
|
('symb' => $symb, |
|
'grade_target' => 'analyze', |
|
'grade_courseid' => $cid, |
|
'grade_domain' => $udom, |
|
'grade_username' => $uname)); |
|
my (undef, $an) = split(/_HASH_REF__/,$result, 2); |
|
%analysis = &Apache::lonnet::str2hash($an); |
|
|
|
if (ref($analysis{'parts'}) eq 'ARRAY') { |
|
foreach my $part (@{$analysis{'parts'}}) { |
|
my ($id,$respid) = split(/\./,$part); |
|
if (!&Apache::loncommon::check_if_partid_hidden($id,$symb,$udom,$uname)) { |
|
push(@parts,$part); |
|
} |
|
} |
|
} |
|
} |
|
return (\%analysis,\@parts); |
|
} |
|
|
|
sub scantron_validate_missingbubbles { |
sub scantron_validate_missingbubbles { |
my ($r,$currentphase) = @_; |
my ($r,$currentphase) = @_; |
#get student info |
#get student info |
Line 7407 sub scantron_process_students {
|
Line 7445 sub scantron_process_students {
|
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
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 ($uname,$udom,%partids_by_symb); |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, |
|
\%grader_randomlists_by_symb); |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
my $ressymb = $resource->symb(); |
my $ressymb = $resource->symb(); |
my ($analysis,$parts) = |
my ($analysis,$parts) = |
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); |
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
$partids_by_symb{$ressymb} = $parts; |
$env{'user.name'},$env{'user.domain'},1); |
|
$grader_partids_by_symb{$ressymb} = $parts; |
|
if (ref($analysis) eq 'HASH') { |
|
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
|
$grader_randomlists_by_symb{$ressymb} = |
|
$analysis->{'parts_withrandomlist'}; |
|
} |
|
} |
} |
} |
# $r->print("geto ".scalar(@resources)."<br />"); |
|
|
my ($uname,$udom); |
my $result= <<SCANTRONFORM; |
my $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="scantronupload"> |
<input type="hidden" name="command" value="scantron_configphase" /> |
<input type="hidden" name="command" value="scantron_configphase" /> |
Line 7439 SCANTRONFORM
|
Line 7486 SCANTRONFORM
|
my $started; |
my $started; |
|
|
&scantron_get_maxbubble(); # Need the bubble lines array to parse. |
&scantron_get_maxbubble(); # Need the bubble lines array to parse. |
|
|
|
|
# If an ssi failed in scantron_get_maxbubble, put an error message out to |
# If an ssi failed in scantron_get_maxbubble, put an error message out to |
# the user and return. |
# the user and return. |
Line 7480 SCANTRONFORM
|
Line 7526 SCANTRONFORM
|
} |
} |
($uname,$udom)=split(/:/,$uname); |
($uname,$udom)=split(/:/,$uname); |
|
|
|
my %partids_by_symb; |
|
foreach my $resource (@resources) { |
|
my $ressymb = $resource->symb(); |
|
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
|
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); |
|
$partids_by_symb{$ressymb} = $parts; |
|
} else { |
|
$partids_by_symb{$ressymb} = $grader_partids_by_symb{$ressymb}; |
|
} |
|
} |
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonnet::appenv($scan_record); |
&Apache::lonnet::appenv($scan_record); |
|
|
Line 7496 SCANTRONFORM
|
Line 7555 SCANTRONFORM
|
} |
} |
|
|
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
@resources) eq 'ssi_error') { |
\@resources,\%partids_by_symb) 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>"); |
&ssi_print_error($r); |
&ssi_print_error($r); |
Line 7514 SCANTRONFORM
|
Line 7573 SCANTRONFORM
|
my $studentrecord = ''; |
my $studentrecord = ''; |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
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'}, |
$counter,$studentdata,\%partids_by_symb, |
$counter,$studentdata,$partids_by_symb{$ressymb}, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$studentrecord .= $recording; |
$studentrecord .= $recording; |
} |
} |
if ($studentrecord ne $studentdata) { |
if ($studentrecord ne $studentdata) { |
|
&Apache::lonxml::clear_problem_counter(); |
|
if (&grade_student_bubbles($r,$uname,$udom,$scan_record,$scancode, |
|
\@resources,\%partids_by_symb) eq 'ssi_error') { |
|
$ssi_error = 0; # So end of handler error message does not trigger. |
|
$r->print("</form>"); |
|
&ssi_print_error($r); |
|
$r->print(&show_grading_menu_form($symb)); |
|
&Apache::lonnet::remove_lock($lock); |
|
delete($completedstudents{$uname}); |
|
return ''; |
|
} |
$counter = -1; |
$counter = -1; |
$studentrecord = ''; |
$studentrecord = ''; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
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'}, |
$counter,$studentdata,\%partids_by_symb, |
$counter,$studentdata,$partids_by_symb{$ressymb}, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$studentrecord .= $recording; |
$studentrecord .= $recording; |
} |
} |
Line 7563 SCANTRONFORM
|
Line 7635 SCANTRONFORM
|
if (&Apache::loncommon::connection_aborted($r)) { last; } |
if (&Apache::loncommon::connection_aborted($r)) { last; } |
} continue { |
} continue { |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonnet::delenv('scantron\.'); |
&Apache::lonnet::delenv('scantron.'); |
} |
} |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonnet::remove_lock($lock); |
&Apache::lonnet::remove_lock($lock); |
Line 7575 SCANTRONFORM
|
Line 7647 SCANTRONFORM
|
return ''; |
return ''; |
} |
} |
|
|
|
sub graders_resources_pass { |
|
my ($resources,$grader_partids_by_symb,$grader_randomlists_by_symb) = @_; |
|
if ((ref($resources) eq 'ARRAY') && (ref($grader_partids_by_symb)) && |
|
(ref($grader_randomlists_by_symb) eq 'HASH')) { |
|
foreach my $resource (@{$resources}) { |
|
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'}, |
|
$env{'user.name'},$env{'user.domain'},1); |
|
$grader_partids_by_symb->{$ressymb} = $parts; |
|
if (ref($analysis) eq 'HASH') { |
|
if (ref($analysis->{'parts_withrandomlist'}) eq 'ARRAY') { |
|
$grader_randomlists_by_symb->{$ressymb} = |
|
$analysis->{'parts_withrandomlist'}; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub grade_student_bubbles { |
sub grade_student_bubbles { |
my ($r,$uname,$udom,$scan_record,$scancode,@resources) = @_; |
my ($r,$uname,$udom,$scan_record,$scancode,$resources,$parts) = @_; |
foreach my $resource (@resources) { |
if (ref($resources) eq 'ARRAY') { |
my %form = ('submitted' => 'scantron', |
my $count = 0; |
'grade_target' => 'grade', |
foreach my $resource (@{$resources}) { |
'grade_username'=> $uname, |
my $ressymb = $resource->symb(); |
'grade_domain' => $udom, |
my %form = ('submitted' => 'scantron', |
'grade_courseid'=> $env{'request.course.id'}, |
'grade_target' => 'grade', |
'grade_symb' => $resource->symb(), |
'grade_username' => $uname, |
'CODE' => $scancode); |
'grade_domain' => $udom, |
my $result=&ssi_with_retries($resource->src(),$ssi_retries,%form); |
'grade_courseid' => $env{'request.course.id'}, |
return 'ssi_error' if ($ssi_error); |
'grade_symb' => $ressymb, |
last if (&Apache::loncommon::connection_aborted($r)); |
'CODE' => $scancode |
|
); |
|
if (ref($parts) eq 'HASH') { |
|
if (ref($parts->{$ressymb}) eq 'ARRAY') { |
|
foreach my $part (@{$parts->{$ressymb}}) { |
|
$form{'scantron_questnum_start.'.$part} = |
|
1+$env{'form.scantron.first_bubble_line.'.$count}; |
|
$count++; |
|
} |
|
} |
|
} |
|
my $result=&ssi_with_retries($resource->src(),$ssi_retries,%form); |
|
return 'ssi_error' if ($ssi_error); |
|
last if (&Apache::loncommon::connection_aborted($r)); |
|
} |
} |
} |
return; |
return; |
} |
} |
|
|
sub scantron_upload_scantron_data { |
sub scantron_upload_scantron_data { |
my ($r)=@_; |
my ($r)=@_; |
$r->print(&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'})); |
my $dom = $env{'request.role.domain'}; |
|
my $domdesc = &Apache::lonnet::domain($dom,'description'); |
|
$r->print(&Apache::loncommon::coursebrowser_javascript($dom)); |
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid', |
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid', |
'domainid', |
'domainid', |
'coursename'); |
'coursename',$dom); |
my $domsel=&Apache::loncommon::select_dom_form($env{'request.role.domain'}, |
my $syllabuslink = '<a href="javascript:ToSyllabus();">'.&mt('Syllabus').'</a>'. |
'domainid'); |
(' 'x2).&mt('(shows course personnel)'); |
my $default_form_data=&defaultFormData(&get_symb($r,1)); |
my $default_form_data=&defaultFormData(&get_symb($r,1)); |
$r->print(' |
$r->print(' |
<script type="text/javascript" language="javascript"> |
<script type="text/javascript" language="javascript"> |
Line 7608 sub scantron_upload_scantron_data {
|
Line 7717 sub scantron_upload_scantron_data {
|
alert("'.&mt('Please use the browse button to select a file from your local directory.').'"); |
alert("'.&mt('Please use the browse button to select a file from your local directory.').'"); |
return false; |
return false; |
} |
} |
|
if (formname.courseid.value == "") { |
|
alert("'.&mt('Please use the \"Select Course\" link to open a separate window where you can search for a course to which a file can be uploaded.').'"); |
|
return false; |
|
} |
formname.submit(); |
formname.submit(); |
} |
} |
|
|
|
function ToSyllabus() { |
|
var cdom = '."'$dom'".'; |
|
var cnum = document.rules.courseid.value; |
|
if (cdom == "" || cdom == null) { |
|
return; |
|
} |
|
if (cnum == "" || cnum == null) { |
|
return; |
|
} |
|
syllwin=window.open("/public/"+cdom+"/"+cnum+"/syllabus","LONCAPASyllabus", |
|
"height=350,width=350,scrollbars=yes,menubar=no"); |
|
return; |
|
} |
|
|
</script> |
</script> |
|
|
|
<h3>'.&mt('Send scanned bubblesheet data to a course').'</h3> |
|
|
<form enctype="multipart/form-data" action="/adm/grades" name="rules" method="post"> |
<form enctype="multipart/form-data" action="/adm/grades" name="rules" method="post"> |
'.$default_form_data.' |
'.$default_form_data. |
<table> |
&Apache::lonhtmlcommon::start_pick_box(). |
<tr><td>'.$select_link.' </td></tr> |
&Apache::lonhtmlcommon::row_title(&mt('Course ID')). |
<tr><td>'.&mt('Course ID:').' </td> |
'<input name="courseid" type="text" size="30" />'.$select_link. |
<td><input name="courseid" type="text" /> </td></tr> |
&Apache::lonhtmlcommon::row_closure(). |
<tr><td>'.&mt('Course Name:').' </td> |
&Apache::lonhtmlcommon::row_title(&mt('Course Name')). |
<td><input name="coursename" type="text" /> </td></tr> |
'<input name="coursename" type="text" size="30" />'.$syllabuslink. |
<tr><td>'.&mt('Domain:').' </td> |
&Apache::lonhtmlcommon::row_closure(). |
<td>'.$domsel.' </td></tr> |
&Apache::lonhtmlcommon::row_title(&mt('Domain')). |
<tr><td>'.&mt('File to upload:').'</td> |
'<input name="domainid" type="hidden" />'.$domdesc. |
<td><input type="file" name="upfile" size="50" /></td></tr> |
&Apache::lonhtmlcommon::row_closure(). |
</table> |
&Apache::lonhtmlcommon::row_title(&mt('File to upload')). |
|
'<input type="file" name="upfile" size="50" />'. |
|
&Apache::lonhtmlcommon::row_closure(1). |
|
&Apache::lonhtmlcommon::end_pick_box().'<br /> |
|
|
<input name="command" value="scantronupload_save" type="hidden" /> |
<input name="command" value="scantronupload_save" type="hidden" /> |
<input type="button" onClick="javascript:checkUpload(this.form);" value="'.&mt('Upload Scantron Data').'" /> |
<input type="button" onClick="javascript:checkUpload(this.form);" value="'.&mt('Upload Scantron Data').'" /> |
</form> |
</form> |
Line 7653 sub scantron_upload_scantron_data_save {
|
Line 7787 sub scantron_upload_scantron_data_save {
|
return ''; |
return ''; |
} |
} |
my %coursedata=&Apache::lonnet::coursedescription($env{'form.domainid'}.'_'.$env{'form.courseid'}); |
my %coursedata=&Apache::lonnet::coursedescription($env{'form.domainid'}.'_'.$env{'form.courseid'}); |
$r->print(&mt("Doing upload to [_1]",$coursedata{'description'})." <br />"); |
my $uploadedfile; |
my $fname=$env{'form.upfile.filename'}; |
$r->print('<h3>'.&mt("Uploading file to [_1]",$coursedata{'description'}).'</h3>'); |
#FIXME |
|
#copied from lonnet::userfileupload() |
|
#make that function able to target a specified course |
|
# Replace Windows backslashes by forward slashes |
|
$fname=~s/\\/\//g; |
|
# Get rid of everything but the actual filename |
|
$fname=~s/^.*\/([^\/]+)$/$1/; |
|
# Replace spaces by underscores |
|
$fname=~s/\s+/\_/g; |
|
# Replace all other weird characters by nothing |
|
$fname=~s/[^\w\.\-]//g; |
|
# See if there is anything left |
|
unless ($fname) { return 'error: no uploaded file'; } |
|
my $uploadedfile=$fname; |
|
$fname='scantron_orig_'.$fname; |
|
if (length($env{'form.upfile'}) < 2) { |
if (length($env{'form.upfile'}) < 2) { |
$r->print(&mt("<span class=\"LC_error\">Error:</span> The file you attempted to upload, [_1] contained no information. Please check that you entered the correct filename.",'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</span>")); |
$r->print(&mt('[_1]Error:[_2] The file you attempted to upload, [_3] contained no information. Please check that you entered the correct filename.','<span class="LC_error">','</span>','<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'</span>')); |
} else { |
} else { |
my $result=&Apache::lonnet::finishuserfileupload($env{'form.courseid'},$env{'form.domainid'},'upfile',$fname); |
my $result = |
if ($result =~ m|^/uploaded/|) { |
&Apache::lonnet::userfileupload('upfile','','scantron','','','', |
$r->print(&mt("<span class=\"LC_success\">Success:</span> Successfully uploaded [_1] bytes of data into location [_2]", |
$env{'form.courseid'},$env{'form.domainid'}); |
(length($env{'form.upfile'})-1), |
if ($result =~ m{^/uploaded/}) { |
'<span class="LC_filename">'.$result."</span>")); |
$r->print(&mt('[_1]Success:[_2] Successfully uploaded [_3] bytes of data into location: [_4]', |
|
'<span class="LC_success">','</span>',(length($env{'form.upfile'})-1), |
|
'<span class="LC_filename">'.$result.'</span>')); |
|
($uploadedfile) = ($result =~ m{/([^/]+)$}); |
|
$r->print(&validate_uploaded_scantron_file($env{'form.domainid'}, |
|
$env{'form.courseid'},$uploadedfile)); |
} else { |
} else { |
$r->print(&mt("<span class=\"LC_error\">Error:</span> An error ([_1]) occurred when attempting to upload the file, [_2]", |
$r->print(&mt('[_1]Error:[_2] An error ([_3]) occurred when attempting to upload the file, [_4]', |
$result, |
'<span class="LC_error">','</span>',$result, |
'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"')."</span>")); |
'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'</span>')); |
|
|
} |
} |
} |
} |
if ($symb) { |
if ($symb) { |
Line 7693 sub scantron_upload_scantron_data_save {
|
Line 7816 sub scantron_upload_scantron_data_save {
|
return ''; |
return ''; |
} |
} |
|
|
|
sub validate_uploaded_scantron_file { |
|
my ($cdom,$cname,$fname) = @_; |
|
my $scanlines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.$fname); |
|
my @lines; |
|
if ($scanlines ne '-1') { |
|
@lines=split("\n",$scanlines,-1); |
|
} |
|
my $output; |
|
if (@lines) { |
|
my (%counts,$max_match_format); |
|
my ($max_match_count,$max_match_pct) = (0,0); |
|
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cname); |
|
my %idmap = &username_to_idmap($classlist); |
|
foreach my $key (keys(%idmap)) { |
|
my $lckey = lc($key); |
|
$idmap{$lckey} = $idmap{$key}; |
|
} |
|
my %unique_formats; |
|
my @formatlines = &get_scantronformat_file(); |
|
foreach my $line (@formatlines) { |
|
chomp($line); |
|
my @config = split(/:/,$line); |
|
my $idstart = $config[5]; |
|
my $idlength = $config[6]; |
|
if (($idstart ne '') && ($idlength > 0)) { |
|
if (ref($unique_formats{$idstart.':'.$idlength}) eq 'ARRAY') { |
|
push(@{$unique_formats{$idstart.':'.$idlength}},$config[0].':'.$config[1]); |
|
} else { |
|
$unique_formats{$idstart.':'.$idlength} = [$config[0].':'.$config[1]]; |
|
} |
|
} |
|
} |
|
foreach my $key (keys(%unique_formats)) { |
|
my ($idstart,$idlength) = split(':',$key); |
|
%{$counts{$key}} = ( |
|
'found' => 0, |
|
'total' => 0, |
|
); |
|
foreach my $line (@lines) { |
|
next if ($line =~ /^#/); |
|
next if ($line =~ /^[\s\cz]*$/); |
|
my $id = substr($line,$idstart-1,$idlength); |
|
$id = lc($id); |
|
if (exists($idmap{$id})) { |
|
$counts{$key}{'found'} ++; |
|
} |
|
$counts{$key}{'total'} ++; |
|
} |
|
if ($counts{$key}{'total'}) { |
|
my $percent_match = (100*$counts{$key}{'found'})/($counts{$key}{'total'}); |
|
if (($max_match_format eq '') || ($percent_match > $max_match_pct)) { |
|
$max_match_pct = $percent_match; |
|
$max_match_format = $key; |
|
$max_match_count = $counts{$key}{'total'}; |
|
} |
|
} |
|
} |
|
if (ref($unique_formats{$max_match_format}) eq 'ARRAY') { |
|
my $format_descs; |
|
my $numwithformat = @{$unique_formats{$max_match_format}}; |
|
for (my $i=0; $i<$numwithformat; $i++) { |
|
my ($name,$desc) = split(':',$unique_formats{$max_match_format}[$i]); |
|
if ($i<$numwithformat-2) { |
|
$format_descs .= '"<i>'.$desc.'</i>", '; |
|
} elsif ($i==$numwithformat-2) { |
|
$format_descs .= '"<i>'.$desc.'</i>" '.&mt('and').' '; |
|
} elsif ($i==$numwithformat-1) { |
|
$format_descs .= '"<i>'.$desc.'</i>"'; |
|
} |
|
} |
|
my $showpct = sprintf("%.0f",$max_match_pct).'%'; |
|
$output .= '<br />'.&mt('Comparison of student IDs in the uploaded file with the course roster found matches for [_1] of the [_2] entries in the file (for the format defined for [_3]).','<b>'.$showpct.'</b>','<b>'.$max_match_count.'</b>',$format_descs). |
|
'<br />'.&mt('A low percentage of matches results from one of the following:').'<ul>'. |
|
'<li>'.&mt('The file was uploaded to the wrong course').'</li>'. |
|
'<li>'.&mt('The data are not in the format expected for the domain: [_1]', |
|
'<i>'.$cdom.'</i>').'</li>'. |
|
'<li>'.&mt('Students did not bubble their IDs, or mis-bubbled them').'</li>'. |
|
'<li>'.&mt('The course roster is not up to date').'</li>'. |
|
'</ul>'; |
|
} |
|
} else { |
|
$output = '<span class="LC_warning">'.&mt('Uploaded file contained no data').'</span>'; |
|
} |
|
return $output; |
|
} |
|
|
sub valid_file { |
sub valid_file { |
my ($requested_file)=@_; |
my ($requested_file)=@_; |
foreach my $filename (sort(&scantron_filenames())) { |
foreach my $filename (sort(&scantron_filenames())) { |
Line 7759 sub checkscantron_results {
|
Line 7968 sub checkscantron_results {
|
my %idmap=&Apache::grades::username_to_idmap($classlist); |
my %idmap=&Apache::grades::username_to_idmap($classlist); |
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $navmap=Apache::lonnavmaps::navmap->new(); |
my $map=$navmap->getResourceByUrl($sequence); |
my $map=$navmap->getResourceByUrl($sequence); |
my @resources=$navmap->retrieveResources($map,undef,1,0); |
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); |
my ($uname,$udom,%partids_by_symb); |
my (%grader_partids_by_symb,%grader_randomlists_by_symb); |
foreach my $resource (@resources) { |
&graders_resources_pass(\@resources,\%grader_partids_by_symb, \%grader_randomlists_by_symb); |
my $ressymb = $resource->symb(); |
|
my ($analysis,$parts) = |
my ($uname,$udom); |
&scantron_partids_tograde($resource,$env{'request.course.id'},$uname,$udom); |
|
$partids_by_symb{$ressymb} = $parts; |
|
} |
|
my (%scandata,%lastname,%bylast); |
my (%scandata,%lastname,%bylast); |
$r->print(' |
$r->print(' |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="checkscantron">'."\n"); |
<form method="post" enctype="multipart/form-data" action="/adm/grades" name="checkscantron">'."\n"); |
Line 7780 sub checkscantron_results {
|
Line 7986 sub checkscantron_results {
|
'inline',undef,'checkscantron'); |
'inline',undef,'checkscantron'); |
my ($username,$domain,$started); |
my ($username,$domain,$started); |
|
|
&Apache::grades::scantron_get_maxbubble(); # Need the bubble lines array to parse. |
&scantron_get_maxbubble(); # Need the bubble lines array to parse. |
|
|
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state, |
'Processing first student'); |
'Processing first student'); |
Line 7821 sub checkscantron_results {
|
Line 8027 sub checkscantron_results {
|
($username,$domain)=split(/:/,$uname); |
($username,$domain)=split(/:/,$uname); |
my $counter = -1; |
my $counter = -1; |
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
|
my $parts; |
|
my $ressymb = $resource->symb(); |
|
if ((exists($grader_randomlists_by_symb{$ressymb})) || |
|
(ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { |
|
(my $analysis,$parts) = |
|
&scantron_partids_tograde($resource,$env{'request.course.id'},$username,$domain); |
|
} else { |
|
$parts = $grader_partids_by_symb{$ressymb}; |
|
} |
($counter,my $recording) = |
($counter,my $recording) = |
&verify_scantron_grading($resource,$domain,$username,$cid,$counter, |
&verify_scantron_grading($resource,$domain,$username,$cid,$counter, |
$scandata{$pid},\%partids_by_symb, |
$scandata{$pid},$parts, |
\%scantron_config,\%lettdig,$numletts); |
\%scantron_config,\%lettdig,$numletts); |
$record{$pid} .= $recording; |
$record{$pid} .= $recording; |
} |
} |
Line 7888 sub checkscantron_results {
|
Line 8103 sub checkscantron_results {
|
} |
} |
|
|
sub verify_scantron_grading { |
sub verify_scantron_grading { |
my ($resource,$domain,$username,$cid,$counter,$scandata,$partids_by_symb, |
my ($resource,$domain,$username,$cid,$counter,$scandata,$partids, |
$scantron_config,$lettdig,$numletts) = @_; |
$scantron_config,$lettdig,$numletts) = @_; |
my ($record,%expected,%startpos); |
my ($record,%expected,%startpos); |
return ($counter,$record) if (!ref($resource)); |
return ($counter,$record) if (!ref($resource)); |
return ($counter,$record) if (!$resource->is_problem()); |
return ($counter,$record) if (!$resource->is_problem()); |
my $symb = $resource->symb(); |
my $symb = $resource->symb(); |
return ($counter,$record) if (ref($partids_by_symb) ne 'HASH'); |
return ($counter,$record) if (ref($partids) ne 'ARRAY'); |
return ($counter,$record) if (ref($partids_by_symb->{$symb}) ne 'ARRAY'); |
foreach my $part_id (@{$partids}) { |
foreach my $part_id (@{$partids_by_symb->{$symb}}) { |
|
$counter ++; |
$counter ++; |
$expected{$part_id} = 0; |
$expected{$part_id} = 0; |
if ($env{"form.scantron.sub_bubblelines.$counter"}) { |
if ($env{"form.scantron.sub_bubblelines.$counter"}) { |
Line 7989 sub verify_scantron_grading {
|
Line 8203 sub verify_scantron_grading {
|
} |
} |
} |
} |
} |
} |
foreach my $part_id (@{$partids_by_symb->{$symb}}) { |
foreach my $part_id (@{$partids}) { |
if ($recorded{$part_id} eq '') { |
if ($recorded{$part_id} eq '') { |
for (my $i=0; $i<$expected{$part_id}; $i++) { |
for (my $i=0; $i<$expected{$part_id}; $i++) { |
for (my $j=0; $j<$scantron_config->{'Qlength'}; $j++) { |
for (my $j=0; $j<$scantron_config->{'Qlength'}; $j++) { |
Line 8443 sub process_clicker {
|
Line 8657 sub process_clicker {
|
my %checked; |
my %checked; |
foreach my $gradingmechanism ('attendance','personnel','specific','given') { |
foreach my $gradingmechanism ('attendance','personnel','specific','given') { |
if ($env{'form.gradingmechanism'} eq $gradingmechanism) { |
if ($env{'form.gradingmechanism'} eq $gradingmechanism) { |
$checked{$gradingmechanism}="checked='checked'"; |
$checked{$gradingmechanism}=' checked="checked"'; |
} |
} |
} |
} |
|
|
Line 8507 function sanitycheck() {
|
Line 8721 function sanitycheck() {
|
<input type="hidden" name="saveState" value="$env{'form.saveState'}" /> |
<input type="hidden" name="saveState" value="$env{'form.saveState'}" /> |
<input type="file" name="upfile" size="50" /> |
<input type="file" name="upfile" size="50" /> |
<br /><label>$type: $selectform</label> |
<br /><label>$type: $selectform</label> |
<br /><label><input type="radio" name="gradingmechanism" value="attendance" $checked{'attendance'} onClick="sanitycheck()" />$attendance </label> |
<br /><label><input type="radio" name="gradingmechanism" value="attendance"$checked{'attendance'} onClick="sanitycheck()" />$attendance </label> |
<br /><label><input type="radio" name="gradingmechanism" value="personnel" $checked{'personnel'} onClick="sanitycheck()" />$personnel</label> |
<br /><label><input type="radio" name="gradingmechanism" value="personnel"$checked{'personnel'} onClick="sanitycheck()" />$personnel</label> |
<br /><label><input type="radio" name="gradingmechanism" value="specific" $checked{'specific'} onClick="sanitycheck()" />$specific </label> |
<br /><label><input type="radio" name="gradingmechanism" value="specific"$checked{'specific'} onClick="sanitycheck()" />$specific </label> |
<input type="text" name="specificid" value="$env{'form.specificid'}" size="20" /> |
<input type="text" name="specificid" value="$env{'form.specificid'}" size="20" /> |
<br /><label><input type="radio" name="gradingmechanism" value="given" $checked{'given'} onClick="sanitycheck()" />$given </label> |
<br /><label><input type="radio" name="gradingmechanism" value="given"$checked{'given'} onClick="sanitycheck()" />$given </label> |
<br /> |
<br /> |
<input type="text" name="givenanswer" size="50" /> |
<input type="text" name="givenanswer" size="50" /> |
<input type="hidden" name="waschecked" value="$env{'form.gradingmechanism'}" /> |
<input type="hidden" name="waschecked" value="$env{'form.gradingmechanism'}" /> |
Line 8864 ENDHEADER
|
Line 9078 ENDHEADER
|
} |
} |
} |
} |
# We are done |
# We are done |
$result.='<br />'.&mt('Successfully stored grades for [_1] student(s).',$storecount). |
$result.='<br />'.&mt('Successfully stored grades for [quant,_1,student].',$storecount). |
'</td></tr></table>'."\n". |
'</td></tr></table>'."\n". |
'</td></tr></table><br /><br />'."\n"; |
'</td></tr></table><br /><br />'."\n"; |
return $result.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
Line 8990 sub handler {
|
Line 9204 sub handler {
|
} elsif ($command eq 'checksubmissions' && $perm{'vgr'}) { |
} elsif ($command eq 'checksubmissions' && $perm{'vgr'}) { |
$request->print(&checkscantron_results($request)); |
$request->print(&checkscantron_results($request)); |
} elsif ($command) { |
} elsif ($command) { |
$request->print("Access Denied ($command)"); |
$request->print('<p class="LC_error">'.&mt('Access Denied ([_1])',$command).'</p>'); |
} |
} |
} |
} |
if ($ssi_error) { |
if ($ssi_error) { |
Line 9158 ssi_with_retries()
|
Line 9372 ssi_with_retries()
|
=item scantron_validate_ID() : |
=item scantron_validate_ID() : |
|
|
Validates all scanlines in the selected file to not have any |
Validates all scanlines in the selected file to not have any |
invalid or underspecified student IDs |
invalid or underspecified student/employee IDs |
|
|
=back |
=back |
|
|