--- loncom/homework/inputtags.pm 2006/06/09 16:31:00 1.186.2.1
+++ loncom/homework/inputtags.pm 2006/03/09 01:11:12 1.190
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.186.2.1 2006/06/09 16:31:00 albertel Exp $
+# $Id: inputtags.pm,v 1.190 2006/03/09 01:11:12 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -222,6 +222,57 @@ sub end_textfield {
return $result;
}
+sub exam_score_line {
+ my ($target) = @_;
+
+ my $result;
+ if ($target eq 'tex') {
+ my $repetition = &Apache::response::repetition();
+ $result.='\begin{enumerate}';
+ if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
+ foreach my $i (0..$repetition-1) {
+ $result.='\item[\textbf{'.
+ ($Apache::lonxml::counter+$i).
+ '}.]\textit{Leave blank on scoring form}\vskip 0 mm';
+ }
+ $result.= '\end{enumerate}';
+ }
+
+ return $result;
+}
+
+sub exam_box {
+ my ($target) = @_;
+ my $result;
+
+ if ($target eq 'tex') {
+ $result .= '\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
+ $result .= &exam_score_line($target);
+ } elsif ($target eq 'web') {
+ my $id=$Apache::inputtags::response[-1];
+ $result.= '
+
';
+ }
+ return $result;
+}
+
+sub needs_exam_box {
+ my ($tagstack) = @_;
+ my @tags = ('formularesponse',
+ 'stringresponse',
+ 'reactionresponse',
+ 'organicresponse',
+ );
+
+ foreach my $tag (@tags) {
+ if (grep(/\Q$tag\E/,@$tagstack)) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
sub start_textline {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result = "";
@@ -229,9 +280,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'
- || ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER' &&
- $Apache::lonhomework::history{"resource.$partid.solved"} !~ /^correct/ )) {
+ if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
my $maxlength;
if ($size eq '') { $size=20; } else {
@@ -246,19 +295,18 @@ sub start_textline {
}
my $readonly=&Apache::lonxml::get_param('readonly',$parstack,
$safeeval);
- if (lc($readonly) eq 'yes'
- || $Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
+ if (lc($readonly) eq 'yes') {
$readonly=' readonly="readonly" ';
} else {
$readonly='';
}
- my $name = 'HWVAL_'.$id;
- if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
- $name = "none";
- }
- $result.= '';
}
+ if ($Apache::lonhomework::type eq 'exam'
+ && &needs_exam_box($tagstack)) {
+ $result.=&exam_box($target);
+ }
} else {
#right or wrong don't show what was last typed in.
$result=''.$Apache::inputtags::answertxt{$id}.'';
@@ -278,10 +326,16 @@ sub start_textline {
$safeeval,'size',
'addchars','readonly');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
- } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
+ } elsif ($target eq 'tex'
+ && $Apache::lonhomework::type ne 'exam') {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
$result='\framebox['.$size.'][s]{\tiny\strut}';
+
+ } elsif ($target eq 'tex'
+ && $Apache::lonhomework::type eq 'exam'
+ && &needs_exam_box($tagstack)) {
+ $result.=&exam_box($target);
}
return $result;
}
@@ -311,6 +365,12 @@ sub start_hiddenline {
$result=&Apache::edit::tag_start($target,$token);
$result.=&Apache::edit::end_table;
}
+
+ if ( ($target eq 'web' || $target eq 'tex')
+ && $Apache::lonhomework::type eq 'exam'
+ && &needs_exam_box($tagstack)) {
+ $result.=&exam_box($target);
+ }
return $result;
}
@@ -370,15 +430,22 @@ sub file_selector {
''.
'
';
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
- my @filelist;
+ my (@filelist,@bad_file_list);
foreach my $file (split(',',&Apache::lonnet::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)) {
+ push(@bad_file_list,''.$file.'');
+ }
}
$result.=&mt("Portfolio files previously selected: [_1]",join(', ',@filelist));
+ if (@bad_file_list) {
+ $result.='
'.&mt('These file(s) don\'t exist: [_1]',join(', ',@bad_file_list));
+ }
}
}
$result.='';