--- loncom/homework/inputtags.pm 2003/04/08 02:37:58 1.89
+++ loncom/homework/inputtags.pm 2003/05/06 15:31:45 1.98
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.89 2003/04/08 02:37:58 albertel Exp $
+# $Id: inputtags.pm,v 1.98 2003/05/06 15:31:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,7 @@ use strict;
use Apache::loncommon;
BEGIN {
- &Apache::lonxml::register('Apache::inputtags',('textfield','textline'));
+ &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
}
@@ -124,11 +124,17 @@ sub start_textfield {
}
$result.=&Apache::edit::modifiedfield();
} elsif ($target eq 'tex') {
+ my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
+ my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
if ($$tagstack[-2] eq 'essayresponse' and $Apache::lonhomework::type eq 'exam') {
- my $number_of_lines= &Apache::lonxml::get_param('rows',$parstack,$safeeval);
$result = '\fbox{\fbox{\parbox{\textwidth-5mm}{';
- for (my $i=0;$i';
+ }
+ }
+ } elsif ($target eq 'edit') {
+ $result=&Apache::edit::tag_start($target,$token);
+ $result.=&Apache::edit::end_table;
+ }
+ return $result;
+}
+
+sub end_hiddenline {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ if ($target eq 'web') { $Apache::lonxml::evaluate++; }
+ elsif ($target eq 'edit') { return ('','no'); }
+ return "";
+}
+
sub finalizeawards {
my $result='';
my $award;
@@ -252,6 +286,9 @@ sub finalizeawards {
foreach $award (@_) { if ($award eq 'SUBMITTED') {$result=$award; last;} }
}
if ($result eq '' ) {
+ foreach $award (@_) { if ($award eq 'ASSIGNED_SCORE') {$result=$award; last;} }
+ }
+ if ($result eq '' ) {
foreach $award (@_) { if ($award eq 'APPROX_ANS') {$result=$award; last;} }
}
if ($result eq '' ) { $result='EXACT_ANS'; }
@@ -267,76 +304,85 @@ sub decideoutput {
if ($previous) { $previousmsg='You have entered that answer before'; }
if ($solved =~ /^correct/) {
- if ($target eq 'tex') {
- $message = '\textbf{You are correct}. Your receipt is '.
- &Apache::lonnet::receipt;
- } else {
- $message = "You are correct. Your receipt is ".
- &Apache::lonnet::receipt;
- }
- $button=0;
- $previousmsg='';
+ if ($award eq 'ASSIGNED_SCORE') {
+ $message = "A score has been assigned.";
+ } else {
+ if ($target eq 'tex') {
+ $message = '\textbf{You are correct}.';
+ } else {
+ $message = "You are correct.";
+ }
+ $message=' Your receipt is '.&Apache::lonnet::receipt;
+ }
+ $button=0;
+ $previousmsg='';
} elsif ($solved =~ /^excused/) {
- $message = "You are excused from the problem.";
- $button=0;
- $previousmsg='';
- } elsif ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS' ) {
- if ($solved =~ /^incorrect/ || $solved eq '') {
- $message = "Incorrect";
- $button=1;
- } else {
- $message = "You are correct. Your receipt is ".
- &Apache::lonnet::receipt;
+ $message = "You are excused from the problem.";
$button=0;
$previousmsg='';
- }
+ } elsif ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS' ) {
+ if ($solved =~ /^incorrect/ || $solved eq '') {
+ $message = "Incorrect";
+ $button=1;
+ } else {
+ $message = "You are correct. Your receipt is ".
+ &Apache::lonnet::receipt;
+ $button=0;
+ $previousmsg='';
+ }
} elsif ($award eq 'NO_RESPONSE') {
- $message = '';
- $button=1;
+ $message = '';
+ $button=1;
} elsif ($award eq 'MISSING_ANSWER') {
- $message = 'Some parts were not submitted';
- $button = 1;
+ $message = 'Some parts were not submitted';
+ $button = 1;
} elsif ($award eq 'WANTED_NUMERIC') {
- $message = "This question expects a numeric answer";
- $button=1;
+ $message = "This question expects a numeric answer";
+ $button=1;
} elsif ($award eq 'MISORDERED_RANK') {
- $message = 'You have provided an invalid ranking, please refer to '.
- &Apache::loncommon::help_open_topic('Ranking_Problems','help on ranking problems').'.';
- $button=1;
+ $message = 'You have provided an invalid ranking, please refer to '.
+ &Apache::loncommon::help_open_topic('Ranking_Problems','help on ranking problems').'.';
+ $button=1;
} elsif ($award eq 'INVALID_FILETYPE') {
- $message = 'The filetype extension of the file you uploaded is not allowed.';
- $button=1;
+ $message = 'The filetype extension of the file you uploaded is not allowed.';
+ $button=1;
} elsif ($award eq 'SIG_FAIL') {
- $message = "Please adjust significant figures.";# you provided %s significant figures";
- $button=1;
+ $message = "Please adjust significant figures.";# you provided %s significant figures";
+ $button=1;
} elsif ($award eq 'UNIT_FAIL') {
- $message = "Units incorrect. ".
+ $message = "Units incorrect. ".
&Apache::loncommon::help_open_topic('Physical_Units'); #Computer reads units as %s";
- $button=1;
+ $button=1;
} elsif ($award eq 'UNIT_NOTNEEDED') {
- $message = "Only a number required.";# Computer reads units of %s";
- $button=1;
+ $message = "Only a number required.";# Computer reads units of %s";
+ $button=1;
} elsif ($award eq 'NO_UNIT') {
- $message = "Units required".
+ $message = "Units required".
&Apache::loncommon::help_open_topic('Physical_Units');
- $button=1;
+ $button=1;
} elsif ($award eq 'BAD_FORMULA') {
- $message = "Unable to understand formula";
- $button=1;
+ $message = "Unable to understand formula";
+ $button=1;
} elsif ($award eq 'INCORRECT') {
- $message = "Incorrect";
- $button=1;
+ $message = "Incorrect";
+ $button=1;
} elsif ($award eq 'SUBMITTED') {
- $message = "Your submission has been recorded.";
- $button=1;
+ $message = "Your submission has been recorded.";
+ $button=1;
} elsif ($award eq 'DRAFT') {
- $message = "A draft copy has been saved.";
- $button=1;
+ $message = "A draft copy has been saved.";
+ $button=1;
+ } elsif ($award eq 'ASSIGNED_SCORE') {
+ $message = "A score has been assigned.";
+ $button=0;
} else {
- $message = "Unknown message: $award";
- $button=1;
+ $message = "Unknown message: $award";
+ $button=1;
+ }
+ if (lc($Apache::lonhomework::problemstatus) eq 'no') {
+ $message = "Answer Submitted";
+ $button=1;
}
- if ($Apache::lonhomework::type eq 'exam') {$message='';$previousmsg='';}
return ($button,$message,$previousmsg);
}
@@ -358,16 +404,38 @@ sub setgradedata {
$Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
return '';
} elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
- /^correct/ ) {
+ /^correct/ || $Apache::lonhomework::scantronmode) {
#handle assignment of tries and solved status
+ my $solvemsg;
+ if ($Apache::lonhomework::scantronmode) {
+ $solvemsg='correct_by_scantron';
+ } else {
+ $solvemsg='correct_by_student';
+ }
if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
$Apache::lonhomework::results{"resource.$id.afterduedate"}='';
}
- if ( $award eq 'APPROX_ANS' || $award eq 'EXACT_ANS' ) {
+ if ( $award eq 'ASSIGNED_SCORE') {
+ $Apache::lonhomework::results{"resource.$id.tries"} =
+ $Apache::lonhomework::history{"resource.$id.tries"} + 1;
+ $Apache::lonhomework::results{"resource.$id.solved"} =
+ $solvemsg;
+ my $numawards=scalar(@Apache::inputtags::responselist);
+ &Apache::lonxml::debug("Whaaa!");
+ $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
+ foreach my $res (@Apache::inputtags::responselist) {
+ $Apache::lonhomework::results{"resource.$id.awarded"}+=
+ $Apache::lonhomework::results{"resource.$id.$res.awarded"};
+ }
+ if ($numawards > 0) {
+ $Apache::lonhomework::results{"resource.$id.awarded"}/=
+ $numawards;
+ }
+ } elsif ( $award eq 'APPROX_ANS' || $award eq 'EXACT_ANS' ) {
$Apache::lonhomework::results{"resource.$id.tries"} =
$Apache::lonhomework::history{"resource.$id.tries"} + 1;
$Apache::lonhomework::results{"resource.$id.solved"} =
- 'correct_by_student';
+ $solvemsg;
$Apache::lonhomework::results{"resource.$id.awarded"} = '1';
} elsif ( $award eq 'INCORRECT' ) {
$Apache::lonhomework::results{"resource.$id.tries"} =
@@ -490,8 +558,8 @@ sub gradestatus {
if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; }
if ( $showbutton ) {
if ($target eq 'tex') {
- if ($ENV{'request.state'} ne "construct") {
- $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 0 mm ';
+ if ($ENV{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam') {
+ $trystr = ' {\vskip 1 mm \small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 2 mm ';
} else {
$trystr = '\vskip 0 mm ';
}