--- loncom/homework/inputtags.pm 2004/03/13 00:36:11 1.136
+++ loncom/homework/inputtags.pm 2004/05/20 23:11:12 1.142
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.136 2004/03/13 00:36:11 albertel Exp $
+# $Id: inputtags.pm,v 1.142 2004/05/20 23:11:12 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -118,7 +118,7 @@ sub start_textfield {
$Apache::lonxml::evaluate--;
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $partid=$Apache::inputtags::part;
- my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"});
+ my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"');
my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
if ( $cols eq '') { $cols = 80; }
my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
@@ -210,7 +210,7 @@ sub start_textline {
if ($size eq '') { $size=20; } else {
if ($size < 20) { $maxlength=$size; }
}
- my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
+ my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"},'<>&"');
if ($Apache::lonhomework::type ne 'exam') {
my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
$result='';
@@ -257,7 +257,7 @@ sub start_hiddenline {
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $partid=$Apache::inputtags::part;
my $id=$Apache::inputtags::response[-1];
- my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
+ my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"},'<>&"');
if ($Apache::lonhomework::type ne 'exam') {
$result= '';
@@ -305,7 +305,9 @@ sub finalizeawards {
}
if (defined($result)) { return ($result,$msg); }
foreach my $possibleaward ('MISSING_ANSWER', 'ERROR', 'NO_RESPONSE',
- 'TOO_LONG', 'UNIT_FAIL', 'NO_UNIT',
+ 'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR',
+ 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',
+ 'UNIT_FAIL', 'NO_UNIT',
'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT',
'MISORDERED_RANK', 'INVALID_FILETYPE',
@@ -413,14 +415,23 @@ sub decideoutput {
$message = &mt("Significant figures are incorrect, you provided [_1] significant figures while [_2] to [_3] were expected. Submission not graded.",(split(/:/,$awardmsg)));
$bgcolor=$possiblecolors{'not_charged_try'};
$button=1;
- } elsif ($award eq 'UNIT_FAIL') {
- $message = &mt('Units incorrect. Computer reads units as "[_1]"',
- $awardmsg);
+ } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {
+ $message = &mt('Error in instructor specifed unit. This error has been reported to the instructor.', $awardmsg);
+ if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
+ $bgcolor=$possiblecolors{'not_charged_try'};
+ $button=1;
+ } elsif ($award eq 'UNIT_INVALID_STUDENT') {
+ $message = &mt('Unable to interpret units. Computer reads units as "[_1]"',''.$awardmsg.'');
+ if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
+ $bgcolor=$possiblecolors{'not_charged_try'};
+ $button=1;
+ } elsif ($award eq 'UNIT_FAIL' || $award eq 'UNIT_IRRECONCIBLE') {
+ $message = &mt('Incompatible units. No conversion found between "[_1]" and the required units.',''.$awardmsg.'');
if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');}
$bgcolor=$possiblecolors{'not_charged_try'};
$button=1;
} elsif ($award eq 'UNIT_NOTNEEDED') {
- $message = &mt('Only a number required. Computer reads units of "[_1]"',$awardmsg);
+ $message = &mt('Only a number required. Computer reads units of "[_1]"',''.$awardmsg.'');
$bgcolor=$possiblecolors{'not_charged_try'};
$button=1;
} elsif ($award eq 'NO_UNIT') {
@@ -471,9 +482,26 @@ sub removealldata {
}
}
+sub hidealldata {
+ my ($id)=@_;
+ foreach my $key (keys(%Apache::lonhomework::results)) {
+ if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
+ &Apache::lonxml::debug("Hidding $key");
+ my $newkey=$key;
+ $newkey=~s/^(resource\.\Q$id\E\.[^\.]+\.)(.*)$/${1}hidden${2}/;
+ $Apache::lonhomework::results{$newkey}=
+ $Apache::lonhomework::results{$key};
+ delete($Apache::lonhomework::results{$key});
+ }
+ }
+}
+
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'})) {
+ $Apache::lonhomework::results{"resource.CODE"}=$ENV{'form.CODE'};
+ }
if (!$Apache::lonhomework::scantronmode &&
$Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {