--- loncom/homework/inputtags.pm 2006/09/21 21:23:19 1.205
+++ loncom/homework/inputtags.pm 2006/12/14 04:31:32 1.211
@@ -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.211 2006/12/14 04:31:32 albertel 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;
@@ -293,7 +294,14 @@ 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 = $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];
+ }
+ $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"');
+
if ($Apache::lonhomework::type ne 'exam') {
my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
$result='';
@@ -321,7 +329,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 +365,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 +406,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 +476,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)=@_;
@@ -740,7 +767,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.='
';