[LON-CAPA-cvs] cvs: loncom /homework grades.pm inputtags.pm /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sat, 06 Nov 2004 01:11:39 -0000
albertel Fri Nov 5 20:11:39 2004 EDT
Modified files:
/loncom/homework inputtags.pm grades.pm
/loncom/lonnet/perl lonnet.pm
Log:
- implement it so that if you grade a students with a CODE, and then realize that you didn't want them to be graded with a CODE, things will work
- also rndseed ignores CODEs that are invalid (I.e. are '' or contain non word cahracters)
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.153 loncom/homework/inputtags.pm:1.154
--- loncom/homework/inputtags.pm:1.153 Wed Oct 20 22:43:34 2004
+++ loncom/homework/inputtags.pm Fri Nov 5 20:11:38 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.153 2004/10/21 02:43:34 albertel Exp $
+# $Id: inputtags.pm,v 1.154 2004/11/06 01:11:38 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -528,10 +528,15 @@
sub setgradedata {
my ($award,$msg,$id,$previously_used) = @_;
- # if the student already has it correct, don't modify the status
- if ($Apache::lonhomework::scantronmode && defined($ENV{'form.CODE'})) {
+ if ($Apache::lonhomework::scantronmode &&
+ &Apache::lonnet::validCODE($ENV{'form.CODE'})) {
$Apache::lonhomework::results{"resource.CODE"}=$ENV{'form.CODE'};
+ } elsif ($Apache::lonhomework::scantronmode &&
+ $ENV{'form.CODE'} eq '' &&
+ $Apache::lonhomework::history{"resource.CODE"} ne '') {
+ $Apache::lonhomework::results{"resource.CODE"}='';
}
+
if (!$Apache::lonhomework::scantronmode &&
$Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
@@ -540,7 +545,10 @@
} elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
/^correct/ || $Apache::lonhomework::scantronmode ||
lc($Apache::lonhomework::problemstatus) eq 'no') {
- #handle assignment of tries and solved status
+ # the student doesn't already have it correct,
+ # or we are in a mode (scantron orno problem status) where a correct
+ # can become incorrect
+ # handle assignment of tries and solved status
my $solvemsg;
if ($Apache::lonhomework::scantronmode) {
$solvemsg='correct_by_scantron';
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.223 loncom/homework/grades.pm:1.224
--- loncom/homework/grades.pm:1.223 Tue Nov 2 15:48:02 2004
+++ loncom/homework/grades.pm Fri Nov 5 20:11:38 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.223 2004/11/02 20:48:02 albertel Exp $
+# $Id: grades.pm,v 1.224 2004/11/06 01:11:38 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3196,9 +3196,12 @@
sub displaySubByDates {
my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_;
+ my $isCODE=0;
+ if (exists($record->{'resource.CODE'})) { $isCODE=1; }
my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.
'<table border="0" width="100%"><tr bgcolor="#e6ffff">'.
'<td><b>Date/Time</b></td>'.
+ ($isCODE?'<td><b>CODE</b></td>':'').
'<td><b>Submission</b></td>'.
'<td><b>Status </b></td></tr>';
my ($version);
@@ -3211,6 +3214,9 @@
for ($version=1;$version<=$$record{'version'};$version++) {
my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
$studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';
+ if ($isCODE) {
+ $studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>';
+ }
my @versionKeys = split(/\:/,$$record{$version.':keys'});
my @displaySub = ();
foreach my $partid (@{$parts}) {
@@ -4295,8 +4301,8 @@
} elsif ($error eq 'duplicateCODE') {
$r->print("</p><p>The encoded CODE has also been used by a previous paper ".join(', ',@{$arg}).", and CODEs are 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 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 ".
@@ -4442,6 +4448,12 @@
$scan_data);
my $CODE=$$scan_record{'scantron.CODE'};
my $error=0;
+ if (!&Apache::lonnet::validCODE($CODE)) {
+ &scantron_get_correction($r,$i,$scan_record,
+ \%scantron_config,
+ $line,'incorrectCODE',\%allcodes);
+ return(1,$currentphase);
+ }
if (%allcodes && !exists($allcodes{$CODE})
&& !$$scan_record{'scantron.useCODE'}) {
&scantron_get_correction($r,$i,$scan_record,
@@ -4615,6 +4627,8 @@
if (exists($scan_record->{'scantron.CODE'}) &&
$scan_record->{'scantron.CODE'}) {
$form{'CODE'}=$scan_record->{'scantron.CODE'};
+ } else {
+ $form{'CODE'}='';
}
my $result=&Apache::lonnet::ssi($resource->src(),%form);
if (&Apache::loncommon::connection_aborted($r)) { last; }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.561 loncom/lonnet/perl/lonnet.pm:1.562
--- loncom/lonnet/perl/lonnet.pm:1.561 Thu Nov 4 18:43:07 2004
+++ loncom/lonnet/perl/lonnet.pm Fri Nov 5 20:11:38 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.561 2004/11/04 23:43:07 banghart Exp $
+# $Id: lonnet.pm,v 1.562 2004/11/06 01:11:38 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4867,10 +4867,16 @@
return &latest_rnd_algorithm_id();
}
+sub validCODE {
+ my ($CODE)=@_;
+ if (defined($CODE) && $CODE ne '' && $CODE =~ /^\w+$/) { return 1; }
+ return 0;
+}
+
sub getCODE {
- if (defined($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
+ if (&validCODE($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
if (defined($Apache::lonhomework::parsing_a_problem) &&
- defined($Apache::lonhomework::history{'resource.CODE'})) {
+ &validCODE($Apache::lonhomework::history{'resource.CODE'})) {
return $Apache::lonhomework::history{'resource.CODE'};
}
return undef;