version 1.188, 2006/03/09 00:41:24
|
version 1.201, 2006/07/14 18:17:58
|
Line 31 use strict;
|
Line 31 use strict;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); |
&Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); |
Line 149 sub start_textfield {
|
Line 152 sub start_textfield {
|
if ($addchars) { |
if ($addchars) { |
$result.=&addchars('HWVAL_'.$resid,$addchars); |
$result.=&addchars('HWVAL_'.$resid,$addchars); |
} |
} |
push @Apache::lonxml::htmlareafields,'HWVAL_'.$resid; |
&Apache::lonhtmlcommon::add_htmlareafields('HWVAL_'.$resid); |
$result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '. |
$result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '. |
"rows=\"$rows\" cols=\"$cols\">".$oldresponse; |
"rows=\"$rows\" cols=\"$cols\">".$oldresponse; |
if ($oldresponse ne '') { |
if ($oldresponse ne '') { |
Line 222 sub end_textfield {
|
Line 225 sub end_textfield {
|
return $result; |
return $result; |
} |
} |
|
|
sub exam_box { |
sub exam_score_line { |
my ($target) = @_; |
my ($target) = @_; |
my $result; |
|
|
|
|
my $result; |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
$result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}'; |
|
my $repetition = &Apache::response::repetition(); |
my $repetition = &Apache::response::repetition(); |
$result.='\begin{enumerate}'; |
$result.='\begin{enumerate}'; |
|
if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';} |
foreach my $i (0..$repetition-1) { |
foreach my $i (0..$repetition-1) { |
$result.='\item[\textbf{'. |
$result.='\item[\textbf{'. |
($Apache::lonxml::counter+$i). |
($Apache::lonxml::counter+$i). |
'}.]\textit{Leave blank on scoring form}\vskip 0 mm'; |
'}.]\textit{Leave blank on scoring form}\vskip 0 mm'; |
} |
} |
$result.= '\end{enumerate}'; |
$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') { |
} elsif ($target eq 'web') { |
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
$result.= '<br /><br /> |
$result.= '<br /><br /> |
Line 252 sub needs_exam_box {
|
Line 266 sub needs_exam_box {
|
'stringresponse', |
'stringresponse', |
'reactionresponse', |
'reactionresponse', |
'organicresponse', |
'organicresponse', |
'imageresponse', |
|
); |
); |
|
|
foreach my $tag (@tags) { |
foreach my $tag (@tags) { |
Line 270 sub start_textline {
|
Line 283 sub start_textline {
|
$Apache::lonxml::evaluate--; |
$Apache::lonxml::evaluate--; |
my $partid=$Apache::inputtags::part; |
my $partid=$Apache::inputtags::part; |
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER' |
|
|| lc($Apache::lonhomework::problemstatus) eq 'no' |
|
|| ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER' |
|
&& $Apache::lonhomework::history{"resource.$partid.solved"} !~ /^correct/ )) { |
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval); |
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval); |
my $maxlength; |
my $maxlength; |
if ($size eq '') { $size=20; } else { |
if ($size eq '') { $size=20; } else { |
Line 285 sub start_textline {
|
Line 301 sub start_textline {
|
} |
} |
my $readonly=&Apache::lonxml::get_param('readonly',$parstack, |
my $readonly=&Apache::lonxml::get_param('readonly',$parstack, |
$safeeval); |
$safeeval); |
if (lc($readonly) eq 'yes') { |
if (lc($readonly) eq 'yes' |
|
|| $Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') { |
$readonly=' readonly="readonly" '; |
$readonly=' readonly="readonly" '; |
} else { |
} else { |
$readonly=''; |
$readonly=''; |
} |
} |
$result.= '<input type="text" '.$readonly.' name="HWVAL_'.$id.'" value="'. |
my $name = 'HWVAL_'.$id; |
|
if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') { |
|
$name = "none"; |
|
} |
|
$result.= '<input type="text" '.$readonly.' name="'.$name.'" value="'. |
$oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />'; |
$oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />'; |
} |
} |
if ($Apache::lonhomework::type eq 'exam' |
if ($Apache::lonhomework::type eq 'exam' |
Line 355 sub start_hiddenline {
|
Line 376 sub start_hiddenline {
|
$result=&Apache::edit::tag_start($target,$token); |
$result=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::end_table; |
$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; |
return $result; |
} |
} |
|
|
Line 414 sub file_selector {
|
Line 441 sub file_selector {
|
'<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'. |
'<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'. |
'<br />'; |
'<br />'; |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){ |
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){ |
my (@filelist,@bad_file_list); |
my (@file_list,@bad_file_list); |
foreach my $file (split(',',&Apache::lonnet::unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) { |
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::lonxml::whichuser(); |
my $url="/uploaded/$domain/$user/portfolio$file"; |
my $url="/uploaded/$domain/$user/portfolio$file"; |
my $icon=&Apache::loncommon::icon($url); |
my $icon=&Apache::loncommon::icon($url); |
push(@filelist,'<a href="'.$url.'"><img src="'.$icon. |
push(@file_list,'<a href="'.$url.'"><img src="'.$icon. |
'" border="0" />'.$file.'</a>'); |
'" border="0" />'.$file.'</a>'); |
if (! &Apache::lonnet::stat_file($url)) { |
if (! &Apache::lonnet::stat_file($url)) { |
|
&Apache::lonnet::logthis("bad file is $url"); |
push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon. |
push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon. |
'" border="0" />'.$file.'</a>'); |
'" border="0" />'.$file.'</a>'); |
} |
} |
} |
} |
$result.=&mt("Portfolio files previously selected: <strong>[_1]</strong>",join(', ',@filelist)); |
my $files = '<span class="LC_filename">'. |
|
join('</span>, <span class="LC_filename">',@file_list). |
|
'</span>'; |
|
$result.=&mt("Portfolio files previously selected: [_1]",$files); |
if (@bad_file_list) { |
if (@bad_file_list) { |
$result.='<br />'.&mt('<font color="red">These file(s) don\'t exist:</font> <strong>[_1]</strong>',join(', ',@bad_file_list)); |
my $bad_files = '<span class="LC_filename">'. |
|
join('</span>, <span class="LC_filename">',@bad_file_list). |
|
'</span>'; |
|
$result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files); |
} |
} |
} |
} |
} |
} |
Line 507 sub decideoutput {
|
Line 541 sub decideoutput {
|
my $bgcolor='orange'; |
my $bgcolor='orange'; |
my $added_computer_text=0; |
my $added_computer_text=0; |
my %possiblecolors = |
my %possiblecolors = |
( 'correct' => '#aaffaa', |
( 'correct' => '#aaffaa', |
'charged_try' => '#ffaaaa', |
'charged_try' => '#ffaaaa', |
'not_charged_try' => '#ffffaa', |
'not_charged_try' => '#ffffaa', |
'no_message' => '#fffff', |
'no_grade' => '#ffffaa', |
|
'no_message' => '#ffffff', |
); |
); |
|
|
my $part = $Apache::inputtags::part; |
my $part = $Apache::inputtags::part; |
Line 523 sub decideoutput {
|
Line 558 sub decideoutput {
|
|
|
if ($previous) { $previousmsg=&mt('You have entered that answer before'); } |
if ($previous) { $previousmsg=&mt('You have entered that answer before'); } |
|
|
if ($solved =~ /^correct/) { |
if ($solved =~ /^correct/) { |
$bgcolor=$possiblecolors{'correct'}; |
$bgcolor=$possiblecolors{'correct'}; |
$message=&mt('You are correct.'); |
$message=&mt('You are correct.'); |
if ($awarded < 1 && $awarded > 0) { |
if ($awarded < 1 && $awarded > 0) { |
$message=&mt('You are partially correct.'); |
$message=&mt('You are partially correct.'); |
Line 669 sub decideoutput {
|
Line 704 sub decideoutput {
|
$button=1; |
$button=1; |
} elsif ($award eq 'SUBMITTED') { |
} elsif ($award eq 'SUBMITTED') { |
$message = &mt("Your submission has been recorded."); |
$message = &mt("Your submission has been recorded."); |
$bgcolor=$possiblecolors{'correct'}; |
$bgcolor=$possiblecolors{'no_grade'}; |
$button=1; |
$button=1; |
} elsif ($award eq 'DRAFT') { |
} elsif ($award eq 'DRAFT') { |
$message = &mt("A draft copy has been saved."); |
$message = &mt("A draft copy has been saved."); |
Line 691 sub decideoutput {
|
Line 726 sub decideoutput {
|
$message = &mt("Unknown message").": $award"; |
$message = &mt("Unknown message").": $award"; |
$button=1; |
$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.='<br />'; |
|
my @files = split(/\s*,\s*/, |
|
$Apache::lonhomework::history{"resource.$part.$resid.handback"}); |
|
my $file_msg; |
|
foreach my $file (@files) { |
|
$file_msg.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$file.'">'.$file.'</a>'; |
|
} |
|
$message .= &mt('Returned file(s): [_1]',$file_msg); |
|
} |
|
} |
|
|
if (lc($Apache::lonhomework::problemstatus) eq 'no' && |
if (lc($Apache::lonhomework::problemstatus) eq 'no' && |
$Apache::inputtags::status[-1] ne 'SHOW_ANSWER') { |
$Apache::inputtags::status[-1] ne 'SHOW_ANSWER') { |
$message = &mt("Answer Submitted: Your final submission will be graded after the due date."); |
$message = &mt("Answer Submitted: Your final submission will be graded after the due date."); |
$bgcolor=$possiblecolors{'correct'}; |
$bgcolor=$possiblecolors{'no_grade'}; |
$button=1; |
$button=1; |
} |
} |
if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' && |
if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' && |