[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /homework grades.pm /interface lonpickcode.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 22 Apr 2004 22:57:54 -0000
This is a MIME encoded message
--albertel1082674674
Content-Type: text/plain
albertel Thu Apr 22 18:57:54 2004 EDT
Added files:
/loncom/interface lonpickcode.pm
Modified files:
/loncom loncapa_apache.conf
/loncom/homework grades.pm
Log:
- most of the work for allowing a user to pcik a new code is doen
- also addin interface fore allwoing downloads of datafiles (not acutally workign yet)
- add in the possibility to 'redo skipped' or 'ignore previous corrections', not working yet but the interface is there
--albertel1082674674
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040422185754.txt"
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.76 loncom/loncapa_apache.conf:1.77
--- loncom/loncapa_apache.conf:1.76 Thu Apr 1 09:28:49 2004
+++ loncom/loncapa_apache.conf Thu Apr 22 18:57:53 2004
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.76 2004/04/01 14:28:49 albertel Exp $
+## $Id: loncapa_apache.conf,v 1.77 2004/04/22 22:57:53 albertel Exp $
##
#
@@ -324,6 +324,14 @@
PerlAccessHandler Apache::lonacc
SetHandler perl-script
PerlHandler Apache::lonpickcourse
+ErrorDocument 403 /adm/login
+ErrorDocument 500 /adm/errorhandler
+</Location>
+
+<Location /adm/pickcode>
+PerlAccessHandler Apache::lonacc
+SetHandler perl-script
+PerlHandler Apache::lonpickcode
ErrorDocument 403 /adm/login
ErrorDocument 500 /adm/errorhandler
</Location>
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.186 loncom/homework/grades.pm:1.187
--- loncom/homework/grades.pm:1.186 Tue Apr 20 02:11:49 2004
+++ loncom/homework/grades.pm Thu Apr 22 18:57:53 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.186 2004/04/20 06:11:49 albertel Exp $
+# $Id: grades.pm,v 1.187 2004/04/22 22:57:53 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3487,7 +3487,7 @@
<table width="100%" border="0">
<tr>
<td bgcolor="#777777">
- <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process">
+ <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantron_process">
<input type="hidden" name="command" value="scantron_validate" />
$default_form_data
<table width="100%" border="0">
@@ -3519,6 +3519,13 @@
</td>
</tr>
<tr bgcolor="#ffffe6">
+ <td> Options: </td>
+ <td>
+ <input type="checkbox" name="scantron_options" value="redo_skipped"/> Redo skipped records <br />
+ <input type="checkbox" name="scantron_options" value="ignore_corrections"/> Ignore Original Corrections
+ </td>
+ </tr>
+ <tr bgcolor="#ffffe6">
<td colspan="2">
<input type="submit" value="Validate Scantron Records" />
</td>
@@ -3579,6 +3586,40 @@
</tr>
SCANTRONFORM
}
+ $r->print(<<SCANTRONFORM);
+ <tr>
+ <td bgcolor="#777777">
+ <form action='/adm/grades' name='scantron_download'>
+ <input type="hidden" name="command" value="scantron_download" />
+ <table width="100%" border="0">
+ <tr bgcolor="#e6ffff">
+ <td colspan="2">
+ <b>Download a scoring office file</b>
+ </td>
+ </tr>
+ <tr bgcolor="#ffffe6">
+ <td> Filename of scoring office file: </td><td> $file_selector </td>
+ </tr>
+ <tr bgcolor="#ffffe6">
+ <td>
+ Records to download
+ </td>
+ <td>
+ <input type="radio" name="scantron_options" value="download_skipped"/> Skipped Records <br />
+ <input type="radio" name="scantron_options" value="download_corrected"/> Corrected Records <br />
+ <input checked="on" type="radio" name="scantron_options" value="dowload_orig"/> Original Records
+ </td>
+ </tr>
+ <tr bgcolor="#ffffe6">
+ <td colspan="2">
+ <input type="submit" value="Validate Scantron Records" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+SCANTRONFORM
$r->print(<<SCANTRONFORM);
</table>
@@ -3690,7 +3731,7 @@
}
sub scantron_parse_scanline {
- my ($line,$whichline,$scantron_config,$scan_data)=@_;
+ my ($line,$whichline,$scantron_config,$scan_data,$justCODE)=@_;
my %record;
my $questions=substr($line,$$scantron_config{'Qstart'}-1);
my $data=substr($line,0,$$scantron_config{'Qstart'}-1);
@@ -3702,6 +3743,7 @@
#FIXME interpret first N questions
}
}
+ if ($justCODE) { return \%record; }
$record{'scantron.ID'}=substr($data,$$scantron_config{'IDstart'}-1,
$$scantron_config{'IDlength'});
$record{'scantron.PaperID'}=
@@ -4061,18 +4103,31 @@
$r->print('</li>');
} elsif ($error =~ /CODE$/) {
if ($error eq 'incorrectCODE') {
- $r->print("The encoded CODE is not in the list of possible CODEs</p>\n");
+ $r->print("</p><p>The encoded CODE is not in the list of possible CODEs</p>\n");
} elsif ($error eq 'duplicateCODE') {
- $r->print("The encoded CODE has also been used by a previous paper $arg, and CODEs were supposed to be unique</p>\n");
+ $r->print("</p><p>The encoded CODE has also been used by a previous paper $arg, and CODEs were supposed to be unique</p>\n");
}
+ $r->print("<p>The CODE on the form is <tt>".
+ $$scan_record{'scantron.CODE'}."</tt><br />\n");
$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>How should I handle this? <br /> \n");
- $r->print("\n<ul><li> ");
- $r->print('</li>');
+ $r->print("\n<br /> ");
+ $r->print("<input type='radio' name='scan_CODE_resolution' value='use_unfound' checked='on' /> Use the CODE <b><tt>".$$scan_record{'scantron.CODE'}."</tt></b> that is was on the paper, ignoring the error.");
+ $r->print("\n<br />");
+ my $href="/adm/pickcode?".
+ "form=".&Apache::lonnet::escape("scantronupload").
+ "&scantron_format=".&Apache::lonnet::escape($ENV{'form.scantron_format'}).
+ "&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}).
+ "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).
+ "&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'});
+ $r->print("<input type='radio' name='scan_CODE_resolution' value='use_found' /> <a target='_blank' href='$href'>Select</a> a CODE from the list of all CODEs and use it. Selected CODE is <input type='text' size='8' name='scan_CODE_selectedvalue' />");
+ $r->print("\n<br />");
+ $r->print("<input type='radio' name='scan_CODE_resolution' value='use_typed' /> Use <input type='text' size='8' name='scan_CODE_newvalue' /> as the CODE.");
+ $r->print("\n<br /><br />");
} elsif ($error eq 'doublebubble') {
#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");
Index: loncom/interface/lonpickcode.pm
+++ loncom/interface/lonpickcode.pm
# The LearningOnline Network
# Pick a CODE from the list of possible CODEs
#
# $Id: lonpickcode.pm,v 1.1 2004/04/22 22:57:53 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package Apache::lonpickcode;
use strict;
use Apache::Constants qw(:common);
use Apache::loncommon();
use Apache::grades();
use Apache::lonlocal;
sub get_code_freq {
my ($r)=@_;
my %codes;
my %scantron_config=
&Apache::grades::get_scantron_config($ENV{'form.scantron_format'});
$r->rflush();
my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile();
for (my $i=0;$i<=$scanlines->{'count'};$i++) {
my $line=&Apache::grades::scantron_get_line($scanlines,$i);
if ($line=~/^[\s\cz]*$/) { next; }
my $scan_record=
&Apache::grades::scantron_parse_scanline($line,$i,
\%scantron_config,
$scan_data,1);
$codes{$$scan_record{'scantron.CODE'}}++;
}
return %codes;
}
sub get_codes {
my $old_name=$ENV{'form.scantron_CODElist'};
my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);
my %allcodes=map {(&Apache::lonprintout::num_to_letters($_),1)} split(',',$result{$old_name});
return %allcodes;
}
sub num_matches {
my ($code) = @_;
my $orig=$ENV{'form.curCODE'};
my @code=split(//,$code);
my @orig=split(//,$orig);
my $same=0;
for (my $i=0;$i<scalar(@code);$i++) {
if ($code[$i] eq $orig[$i]) { $same++; }
}
return $same;
}
sub handler {
my $r = shift;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print(<<ENDDOCUMENT);
<html>
<head>
<title>The LearningOnline Network with CAPA</title>
</head>
ENDDOCUMENT
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['curCODE','scantron_selectfile',
'form','scantron_format',
'scantron_CODElist']);
if (!
($ENV{'request.course.id'}) &&
(&Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
$r->print('<body>Access not allowed.</body>');
return OK;
}
$r->print(&Apache::loncommon::bodytag("Selecting a CODE"));
$r->print(<<ENDSCRIPT);
<script>
function gochoose(uname,udom) {
opener.document.$ENV{'form.form'}.$ENV{'form.unameelement'}.value=uname;
var slct=opener.document.$ENV{'form.form'}.$ENV{'form.udomelement'};
var i;
for (i=0;i<slct.length;i++) {
if (slct.options[i].value==udom) { slct.selectedIndex=i; }
}
self.close();
}
</script>
ENDSCRIPT
$r->print("<p>The CODE on the paper is <tt><b>".$ENV{'form.curCODE'}.
"</b></tt>. Please Select a new one.</p>\n".'<form>');
my %codes=&get_codes();
my %code_freq=&get_code_freq($r);
my $num_matches=&num_matches($ENV{'form.curCODE'});
for (my $i=$num_matches;$i>=0;$i--) {
my $to_print="<p> CODEs with $i matches</p>";
$to_print.='<table border="1"><tr><td></td><td>CODE</td><td># of exams using this CODE</td>';
my $print;
foreach my $code (sort(keys(%codes))) {
if (&num_matches($code) != $i) { next; }
$print=1;
my $count=$code_freq{$code};
if (!$count) { $count=0; }
$to_print.='<tr><td>'.
'<input type="button" value="'.&mt('Select').
'" onClick="gochoose(\''.$code.'\')" /></td>'.
'<td><tt>'.$code.'</tt></td><td> <tt>'.$count.
'</tt></td></tr>';
delete($codes{$code});
}
$to_print.='</table>';
if ($print) { $r->print($to_print); }
}
$r->print('</form></body></html>');
return OK;
}
1;
__END__
--albertel1082674674--