--- loncom/homework/inputtags.pm 2006/09/21 21:23:19 1.205
+++ loncom/homework/inputtags.pm 2007/02/27 17:52:16 1.215
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.205 2006/09/21 21:23:19 albertel Exp $
+# $Id: inputtags.pm,v 1.215 2007/02/27 17:52:16 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -283,6 +283,7 @@ sub needs_exam_box {
sub start_textline {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result = "";
+ my $input_id = &start_input($parstack,$safeeval);
if ($target eq 'web') {
$Apache::lonxml::evaluate--;
my $partid=$Apache::inputtags::part;
@@ -291,9 +292,18 @@ sub start_textline {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
my $maxlength;
if ($size eq '') { $size=20; } else {
- if ($size < 20) { $maxlength=$size; }
+ if ($size < 20) {
+ $maxlength = ' maxlength="'.$size.'"';
+ }
+ }
+ my $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"};
+ &Apache::lonxml::debug("oldresponse $oldresponse is ".ref($oldresponse));
+
+ if (ref($oldresponse) eq 'ARRAY') {
+ $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist];
}
- my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"},'<>&"');
+ $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"');
+
if ($Apache::lonhomework::type ne 'exam') {
my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
$result='';
@@ -312,8 +322,8 @@ sub start_textline {
if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
$name = "none";
}
- $result.= '';
+ $result.= '';
}
if ($Apache::lonhomework::type eq 'exam'
&& &needs_exam_box($tagstack)) {
@@ -321,7 +331,8 @@ sub start_textline {
}
} else {
#right or wrong don't show what was last typed in.
- $result=''.$Apache::inputtags::answertxt{$id}.'';
+ my $count = scalar(@Apache::inputtags::inputlist)-1;
+ $result=''.$Apache::inputtags::answertxt{$id}[$count].'';
#$result='';
}
} elsif ($target eq 'edit') {
@@ -356,18 +367,25 @@ sub end_textline {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ($target eq 'web') { $Apache::lonxml::evaluate++; }
elsif ($target eq 'edit') { return ('','no'); }
+ &end_input();
return "";
}
sub start_hiddenline {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result = "";
+ my $input_id = &start_input($parstack,$safeeval);
if ($target eq 'web') {
$Apache::lonxml::evaluate--;
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 = $Apache::lonhomework::history{"resource.$partid.$id.submission"};
+ if (ref($oldresponse) eq 'ARRAY') {
+ $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist];
+ }
+ $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"');
+
if ($Apache::lonhomework::type ne 'exam') {
$result= '';
@@ -390,6 +408,7 @@ sub end_hiddenline {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
if ($target eq 'web') { $Apache::lonxml::evaluate++; }
elsif ($target eq 'edit') { return ('','no'); }
+ &end_input();
return "";
}
@@ -459,7 +478,7 @@ sub show_past_portfile_submission {
}
my (@file_list,@bad_file_list);
foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
- my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
+ my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
my $url="/uploaded/$domain/$user/portfolio$file";
my $icon=&Apache::loncommon::icon($url);
push(@file_list,'{$award} < $best) {
+ $best = $awards->{$award};
+ $which = $j;
+ }
+ $j++;
+ }
+ if (defined($which)) {
+ if (ref($nameref)) {
+ return ($$awardref[$which],$$msgref[$which],$$nameref[$which]);
+ } else {
+ return ($$awardref[$which],$$msgref[$which]);
+ }
}
return ('ERROR',undef);
}
+}
sub decideoutput {
my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
@@ -594,9 +623,10 @@ sub decideoutput {
$message.= $computer;
}
$added_computer_text=1;
- unless ($env{'course.'.
+ if ((!$env{'course.'.
$env{'request.course.id'}.
- '.disable_receipt_display'} eq 'yes') {
+ '.disable_receipt_display'} eq 'yes')&&
+ $env{'request.course.id'}) {
$message.=(($target eq 'web')?'
':' ').
&mt('Your receipt is').' '.&Apache::lonnet::receipt($Apache::inputtags::part).
(($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'');
@@ -674,10 +704,8 @@ sub decideoutput {
$button=1;
} elsif ($award eq 'SIG_FAIL') {
my ($used,$min,$max)=split(':',$awardmsg);
- my $word;
- if ($used < $min) { $word=&mt('more'); }
- if ($used > $max) { $word=&mt('fewer'); }
- $message = &mt("Submission not graded. Use [_2] digits.",$used,$word);
+ my $word = ($used < $min) ? 'more' : 'fewer';
+ $message = &mt("Submission not graded. Use $word digits.",$used);
$bgcolor=$possiblecolors{'not_charged_try'};
$button=1;
} elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {
@@ -740,7 +768,7 @@ sub decideoutput {
$message = &mt("Unknown message").": $award";
$button=1;
}
- my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
+ my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
foreach my $resid(@Apache::inputtags::response){
if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
$message.='
';
@@ -1038,7 +1066,7 @@ sub gradestatus {
if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}
if ( $showbutton ) {
if ($target ne 'tex') {
- $button = '';
+ $button = '';
}
}
if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {