--- loncom/homework/inputtags.pm 2003/04/08 15:18:45 1.91
+++ 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.91 2003/04/08 15:18:45 sakharuk 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,12 +304,15 @@ 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;
+ if ($award eq 'ASSIGNED_SCORE') {
+ $message = "A score has been assigned.";
} else {
- $message = "You are correct. Your receipt is ".
- &Apache::lonnet::receipt;
+ if ($target eq 'tex') {
+ $message = '\textbf{You are correct}.';
+ } else {
+ $message = "You are correct.";
+ }
+ $message=' Your receipt is '.&Apache::lonnet::receipt;
}
$button=0;
$previousmsg='';
@@ -332,11 +372,14 @@ sub decideoutput {
} elsif ($award eq 'DRAFT') {
$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;
- }
- if (lc($Apache::lonhomework::problemstatus) ne 'yes') {
+ }
+ if (lc($Apache::lonhomework::problemstatus) eq 'no') {
$message = "Answer Submitted";
$button=1;
}
@@ -361,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"} =
@@ -493,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 ';
}