[LON-CAPA-cvs] cvs: loncom(version_1_0_2_scantron) /homework grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 14 Oct 2003 22:52:25 -0000
This is a MIME encoded message
--albertel1066171945
Content-Type: text/plain
albertel Tue Oct 14 18:52:25 2003 EDT
Modified files: (Branch: version_1_0_2_scantron)
/loncom/homework grades.pm
Log:
- same functionality but much prettier
--albertel1066171945
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20031014185225.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.130.2.1.2.9 loncom/homework/grades.pm:1.130.2.1.2.10
--- loncom/homework/grades.pm:1.130.2.1.2.9 Mon Oct 13 20:05:16 2003
+++ loncom/homework/grades.pm Tue Oct 14 18:52:24 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.130.2.1.2.9 2003/10/14 00:05:16 albertel Exp $
+# $Id: grades.pm,v 1.130.2.1.2.10 2003/10/14 22:52:24 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3362,7 +3362,6 @@
$record{"scantron.$questnum.answer"}=$alphabet[length($array[0])];
}
if (scalar(@array) gt 2) {
- Apache->request->print("snippet is <pre>$currentquest</pre>");
push(@{$record{'scantron.doubleerror'}},$questnum);
my @ans=@array;
my $i=length($ans[0]);shift(@ans);
@@ -3379,7 +3378,6 @@
sub scantron_add_delay {
my ($delayqueue,$scanline,$errormessage,$errorcode)=@_;
- Apache->request->print('add_delay_error '.$_[2] );
push(@$delayqueue,
{'line' => $scanline, 'emsg' => $errormessage,
'ecode' => $errorcode }
@@ -3393,9 +3391,7 @@
return &scan_data($scan_data,"$line.user");
}
foreach my $id (keys(%$idmap)) {
- #Apache->request->print('<pre>checking studnet -'.$id.'- againt -'.$scanID.'- </pre>');
if (lc($id) eq lc($scanID)) {
- #Apache->request->print('success');
return $$idmap{$id};
}
}
@@ -3493,13 +3489,21 @@
}
}
if (!$stop) {
- $r->print("Validation process complete, click 'Submit' to start proccssing");
+ $r->print("Validation process complete.<br />");
+ $r->print('<input type="submit" name="submit" value="Start Grading" />');
$r->print('<input type="hidden" name="command" value="scantron_process" />');
} else {
$r->print('<input type="hidden" name="command" value="scantron_validate" />');
$r->print("<input type='hidden' name='validatepass' value='".$currentphase."' />");
}
- $r->print('<input type="submit" name="submit" /></form></body></html>');
+ if ($stop) {
+ $r->print('<input type="submit" name="submit" value="Continue ->" />');
+ $r->print(' using corrected info <br />');
+ $r->print("<input type='submit' value='Skip' name='scantron_skip_record' />");
+ $r->print(" this scanline saving it for later.");
+ }
+ $r->print(" </form><br />".&show_grading_menu_form($symb,$url).
+ "</body></html>");
return '';
}
@@ -3599,20 +3603,13 @@
my %found=('ids'=>{},'usernames'=>{});
for (my $i=0;$i<=$scanlines->{'count'};$i++) {
my $line=&scantron_get_line($scanlines,$i);
- if (!$line) { next; }
+ if ($line=~/^[\s\cz]*$/) { next; }
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
$scan_data);
my $id=$$scan_record{'scantron.ID'};
-# $r->print("<p>Checking ID ".$$scan_record{'scantron.ID'}.
-# " on paper ID ".$$scan_record{'scantron.PaperID'}."</p>\n");
my $found;
foreach my $checkid (keys(%idmap)) {
- if (lc($checkid) eq lc($id)) {
- if ($checkid ne $id) {
- #$r->print("<p>Using $checkid for encoded $id</p>\n");
- }
- $found=$checkid;last;
- }
+ if (lc($checkid) eq lc($id)) { $found=$checkid;last; }
}
if ($found) {
my $username=$idmap{$found};
@@ -3661,12 +3658,12 @@
#to show both the current line and the previous one and allow skipping
#the previous one or the current one
- $r->print("<p>This scantron record has an error ($error). ");
+ $r->print("<p>An error was detected ($error) ");
if ( defined($$scan_record{'scantron.PaperID'}) ) {
- $r->print("The current PaperID is <tt>".
+ $r->print(" for PaperID <tt>".
$$scan_record{'scantron.PaperID'}."</tt> \n");
} else {
- $r->print("The current scanline is <pre>".
+ $r->print(" in scanline $i <pre>".
$line."</pre> \n");
}
$r->print('<input type="hidden" name="scantron_corrections" value="'.$error.'" />'."\n");
@@ -3677,61 +3674,68 @@
} elsif ($error eq 'duplicateID') {
$r->print("The encoded ID has also been used by a previous paper $arg</p>\n");
}
- $r->print("<p>Original ID is <tt>".$$scan_record{'scantron.ID'}.
- "</tt><br />\n");
- $r->print("Name on paper is ".$$scan_record{'scantron.LastName'}.",".
+ $r->print("<p>The ID on the form is <tt>".
+ $$scan_record{'scantron.ID'}."</tt><br />\n");
+ $r->print("The name on the paper is ".
+ $$scan_record{'scantron.LastName'}.",".
$$scan_record{'scantron.FirstName'}."</p>");
- $r->print("<p>Please correct <br /> \n");
- $r->print("\n<ul><li> Pick a specific user -- username:<input type='text' name='scantron_username' value='' />");
- $r->print("\ndomain:".
- &Apache::loncommon::select_dom_form(undef,'scantron_domain'));
+ $r->print("<p>How should I handle this? <br /> \n");
+ $r->print("\n<ul><li> ");
#FIXME it would be nice if this sent back the user ID and
#could do partial userID matches
$r->print(&Apache::loncommon::selectstudent_link('scantronupload',
- 'scantron_username','scantron_domain'));
+ 'scantron_username','scantron_domain'));
+ $r->print(": <input type='text' name='scantron_username' value='' />");
+ $r->print("\n@".
+ &Apache::loncommon::select_dom_form(undef,'scantron_domain'));
+
$r->print('</li>');
} elsif ($error eq 'doublebubble') {
- $r->print("<pre>$line</pre>");
- $Apache::lonxml::debug=1;
- &Apache::lonhomework::showhashsubset($scan_record,'.');
- $Apache::lonxml::debug=0;
- $r->print("There have been multiple bubbles scanned for a single question\n");
+#FIXME Need to print out who this is along with the paper info
+ $r->print("<p>There have been multiple bubbles scanned for a some question(s)</p>\n");
$r->print('<input type="hidden" name="scantron_questions" value="'.
join(',',@{$arg}).'" />');
+ $r->print("<p>Please indicate which bubble should be used for grading</p>");
foreach my $question (@{$arg}) {
my $selected=$$scan_record{"scantron.$question.answer"};
- $r->print("<p> For question $question, selected bubbles were ".
- join(" ",split('',$selected,-1)).
- " <br />Please pick which one should be used for grading<br />");
- &scantron_bubble_selector($r,$scan_config,$question);
+ &scantron_bubble_selector($r,$scan_config,$question,split('',$selected));
}
} elsif ($error eq 'missingbubble') {
+ $r->print("<p>There have been <b>no</b> bubbles scanned for some question(s)</p>\n");
+ $r->print("<p>Please indicate which bubble should be used for grading</p>");
$r->print("Some questions have no scanned bubbles\n");
$r->print('<input type="hidden" name="scantron_questions" value="'.
join(',',@{$arg}).'" />');
foreach my $question (@{$arg}) {
my $selected=$$scan_record{"scantron.$question.answer"};
- $r->print("<p>Question $question, Please select a bubble to use ");
&scantron_bubble_selector($r,$scan_config,$question);
}
} else {
$r->print("\n<ul>");
}
- $r->print("<li>Skip this scanline saving it for later ");
- $r->print("\n<input type='checkbox' name='scantron_skip_record' /> </li></ul>");
+ $r->print("\n</li></ul>");
+
}
sub scantron_bubble_selector {
- my ($r,$scan_config,$quest)=@_;
+ my ($r,$scan_config,$quest,@selected)=@_;
my $max=$$scan_config{'Qlength'};
my @alphabet=('A'..'Z');
+ $r->print("<table border='1'><tr><td rowspan='2'>$quest</td>");
+ for (my $i=0;$i<$max+1;$i++) {
+ $r->print('<td align="center">');
+ if ($selected[0] eq $alphabet[$i]) { $r->print('X'); shift(@selected) }
+ else { $r->print(' '); }
+ $r->print('</td>');
+ }
+ $r->print('<td></td></tr><tr>');
for (my $i=0;$i<$max;$i++) {
- $r->print('<input type="radio" name="scantron_correct_Q_'.$quest.
- '" value="'.$i.'" />'.$alphabet[$i]);
+ $r->print('<td><input type="radio" name="scantron_correct_Q_'.$quest.
+ '" value="'.$i.'" />'.$alphabet[$i]."</td>");
}
- $r->print('<input type="radio" name="scantron_correct_Q_'.$quest.
- '" value="none" /> Nothing');
- $r->print('<br />');
+ $r->print('<td><input type="radio" name="scantron_correct_Q_'.$quest.
+ '" value="none" /> No bubble </td>');
+ $r->print('</tr></table>');
}
sub scantron_validate_CODE {
@@ -3751,7 +3755,7 @@
my ($scanlines,$scan_data)=&scantron_getfile();
for (my $i=0;$i<=$scanlines->{'count'};$i++) {
my $line=&scantron_get_line($scanlines,$i);
- if (!$line) { next; }
+ if ($line=~/^[\s\cz]*$/) { next; }
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
$scan_data);
if (!defined($$scan_record{'scantron.doubleerror'})) { next; }
@@ -3776,7 +3780,7 @@
if (!$max_bubble) { $max_bubble=2**31; }
for (my $i=0;$i<=$scanlines->{'count'};$i++) {
my $line=&scantron_get_line($scanlines,$i);
- if (!$line) { next; }
+ if ($line=~/^[\s\cz]*$/) { next; }
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
$scan_data);
if (!defined($$scan_record{'scantron.missingerror'})) { next; }
@@ -3826,17 +3830,15 @@
'Processing first student');
my $start=&Time::HiRes::time();
my $i=-1;
+ my ($uname,$udom);
while ($i<$scanlines->{'count'}) {
+ ($uname,$udom)=('','');
$i++;
my $line=&scantron_get_line($scanlines,$i);
- $r->print('<pre>line is'.$line.'</pre>');
- if (!defined($line)) {
- $r->print('skipping');
- next;
- }
+# $r->print('<pre>line is'.$line.'</pre>');
+ if ($line=~/^[\s\cz]*$/) { next; }
my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
$scan_data);
- my ($uname,$udom);
unless ($uname=&scantron_find_student($scan_record,$scan_data,
\%idmap,$i)) {
&scantron_add_delay(\@delayqueue,$line,
@@ -3848,7 +3850,7 @@
'Student '.$uname.' has multiple sheets',2);
next;
}
- $r->print('<pre>doing studnet'.$uname.'</pre>');
+# $r->print('<pre>doing studnet'.$uname.'</pre>');
($uname,$udom)=split(/:/,$uname);
&Apache::lonnet::delenv('form.counter');
&Apache::lonnet::appenv(%$scan_record);
@@ -3888,8 +3890,7 @@
} continue {
&Apache::lonnet::delenv('form.counter');
&Apache::lonnet::delenv('scantron\.');
- &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- 'last student');
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,$uname);
#last;
#FIXME
#get iterator for $sequence
@@ -3900,7 +3901,7 @@
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
my $lasttime = &Time::HiRes::time()-$start;
- $r->print("<p>took $lasttime</p>");
+ #$r->print("<p>took $lasttime</p>");
#$Apache::lonxml::debug=0;
foreach my $delay (@delayqueue) {
@@ -3917,6 +3918,9 @@
# to ignore delayed students, possibly saving the delay queue for later
$navmap->untieHashes();
+ $r->print("<p>Done</p>");
+ $r->print(&show_grading_menu_form($symb,$url));
+ return '';
}
sub scantron_upload_scantron_data {
@@ -4241,7 +4245,7 @@
&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) {
$request->print(&scantron_upload_scantron_data_save($request));
} elsif ($command) {
- $request->print("Access Denied");
+ $request->print("$command ".join(':',%perm)."Access Denied");
}
}
&send_footer($request);
--albertel1066171945--