--- loncom/homework/inputtags.pm 2006/04/18 22:36:23 1.191
+++ loncom/homework/inputtags.pm 2006/07/20 21:48:07 1.204
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.191 2006/04/18 22:36:23 albertel Exp $
+# $Id: inputtags.pm,v 1.204 2006/07/20 21:48:07 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -31,6 +31,9 @@ use strict;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::lonnet;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
BEGIN {
&Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
@@ -280,7 +283,7 @@ sub start_textline {
$Apache::lonxml::evaluate--;
my $partid=$Apache::inputtags::part;
my $id=$Apache::inputtags::response[-1];
- if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+ if (!&Apache::response::show_answer()) {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
my $maxlength;
if ($size eq '') { $size=20; } else {
@@ -295,12 +298,17 @@ sub start_textline {
}
my $readonly=&Apache::lonxml::get_param('readonly',$parstack,
$safeeval);
- if (lc($readonly) eq 'yes') {
+ if (lc($readonly) eq 'yes'
+ || $Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
$readonly=' readonly="readonly" ';
} else {
$readonly='';
}
- $result.= '';
}
if ($Apache::lonhomework::type eq 'exam'
@@ -430,21 +438,28 @@ sub file_selector {
''.
'
';
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
- my (@filelist,@bad_file_list);
- foreach my $file (split(',',&Apache::lonnet::unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
+ 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 $url="/uploaded/$domain/$user/portfolio$file";
my $icon=&Apache::loncommon::icon($url);
- push(@filelist,''.$file.'');
if (! &Apache::lonnet::stat_file($url)) {
+ &Apache::lonnet::logthis("bad file is $url");
push(@bad_file_list,''.$file.'');
}
}
- $result.=&mt("Portfolio files previously selected: [_1]",join(', ',@filelist));
+ my $files = ''.
+ join(', ',@file_list).
+ '';
+ $result.=&mt("Portfolio files previously selected: [_1]",$files);
if (@bad_file_list) {
- $result.='
'.&mt('These file(s) don\'t exist: [_1]',join(', ',@bad_file_list));
+ my $bad_files = ''.
+ join(', ',@bad_file_list).
+ '';
+ $result.='
'.&mt('These file(s) don\'t exist: [_1]',$bad_files);
}
}
}
@@ -523,10 +538,11 @@ sub decideoutput {
my $bgcolor='orange';
my $added_computer_text=0;
my %possiblecolors =
- ( 'correct' => '#aaffaa',
- 'charged_try' => '#ffaaaa',
+ ( 'correct' => '#aaffaa',
+ 'charged_try' => '#ffaaaa',
'not_charged_try' => '#ffffaa',
- 'no_message' => '#fffff',
+ 'no_grade' => '#ffffaa',
+ 'no_message' => '#ffffff',
);
my $part = $Apache::inputtags::part;
@@ -539,8 +555,8 @@ sub decideoutput {
if ($previous) { $previousmsg=&mt('You have entered that answer before'); }
- if ($solved =~ /^correct/) {
- $bgcolor=$possiblecolors{'correct'};
+ if ($solved =~ /^correct/) {
+ $bgcolor=$possiblecolors{'correct'};
$message=&mt('You are correct.');
if ($awarded < 1 && $awarded > 0) {
$message=&mt('You are partially correct.');
@@ -685,7 +701,7 @@ sub decideoutput {
$button=1;
} elsif ($award eq 'SUBMITTED') {
$message = &mt("Your submission has been recorded.");
- $bgcolor=$possiblecolors{'correct'};
+ $bgcolor=$possiblecolors{'no_grade'};
$button=1;
} elsif ($award eq 'DRAFT') {
$message = &mt("A draft copy has been saved.");
@@ -707,10 +723,24 @@ sub decideoutput {
$message = &mt("Unknown message").": $award";
$button=1;
}
+ my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
+ foreach my $resid(@Apache::inputtags::response){
+ if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
+ $message.='
';
+ my @files = split(/\s*,\s*/,
+ $Apache::lonhomework::history{"resource.$part.$resid.handback"});
+ my $file_msg;
+ foreach my $file (@files) {
+ $file_msg.= '
'.$file.'';
+ }
+ $message .= &mt('Returned file(s): [_1]',$file_msg);
+ }
+ }
+
if (lc($Apache::lonhomework::problemstatus) eq 'no' &&
$Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {
$message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
- $bgcolor=$possiblecolors{'correct'};
+ $bgcolor=$possiblecolors{'no_grade'};
$button=1;
}
if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' &&