version 1.197, 2006/06/29 22:57:39
|
version 1.206, 2006/09/29 20:55:33
|
Line 140 sub start_textfield {
|
Line 140 sub start_textfield {
|
my $resid=$Apache::inputtags::response[-1]; |
my $resid=$Apache::inputtags::response[-1]; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$Apache::lonxml::evaluate--; |
$Apache::lonxml::evaluate--; |
|
my $partid=$Apache::inputtags::part; |
|
my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
my $partid=$Apache::inputtags::part; |
|
my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); |
|
my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval); |
my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval); |
if ( $cols eq '') { $cols = 80; } |
if ( $cols eq '') { $cols = 80; } |
my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval); |
my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval); |
Line 161 sub start_textfield {
|
Line 161 sub start_textfield {
|
&Apache::lonxml::get_all_text("/textfield",$parser,$style); |
&Apache::lonxml::get_all_text("/textfield",$parser,$style); |
} |
} |
} else { |
} else { |
#right or wrong don't show it |
#show past answer in the essayresponse case |
#$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>'; |
if ($oldresponse =~ /\S/ |
$result=''; |
&& &Apache::londefdef::is_inside_of($tagstack, |
|
'essayresponse') ) { |
|
$result='<table class="LC_pastsubmission"><tr><td>'. |
|
$oldresponse.'</td></tr></table>'; |
|
} |
#get rid of any startup text |
#get rid of any startup text |
&Apache::lonxml::get_all_text("/textfield",$parser,$style); |
&Apache::lonxml::get_all_text("/textfield",$parser,$style); |
} |
} |
Line 283 sub start_textline {
|
Line 287 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::response::show_answer()) { |
|| ($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 417 sub file_selector {
|
Line 419 sub file_selector {
|
$result.=&mt('Submit a file: (only one file can be uploaded)'). |
$result.=&mt('Submit a file: (only one file can be uploaded)'). |
' <br /><input type="file" size="50" name="HWFILE'. |
' <br /><input type="file" size="50" name="HWFILE'. |
$jspart.'_'.$id.'" /><br />'; |
$jspart.'_'.$id.'" /><br />'; |
my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"'); |
$result .= &show_past_file_submission($part,$id); |
|
|
if ($uploadedfile) { |
|
my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}; |
|
&Apache::lonxml::extlink($url); |
|
&Apache::lonnet::allowuploaded('/adm/essayresponse',$url); |
|
my $icon=&Apache::loncommon::icon($url); |
|
my $curfile='<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$uploadedfile.'</a>'; |
|
$result.=&mt('Currently submitted: <tt>[_1]</tt>',$curfile); |
|
} else { |
|
#$result.=&mt('(Hand in a file you have prepared on your computer)'); |
|
} |
|
} |
} |
if ( $which eq 'both') { |
if ( $which eq 'both') { |
$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />'; |
$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />'; |
Line 439 sub file_selector {
|
Line 429 sub file_selector {
|
&mt('Select Portfolio Files').'</a><br />'. |
&mt('Select Portfolio Files').'</a><br />'. |
'<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]/){ |
$result .= &show_past_portfile_submission($part,$id); |
my (@filelist,@bad_file_list); |
|
foreach my $file (split(',',&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,'<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$file.'</a>'); |
|
if (! &Apache::lonnet::stat_file($url)) { |
|
&Apache::lonnet::logthis("bad file is $url"); |
|
push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$file.'</a>'); |
|
} |
|
} |
|
$result.=&mt("Portfolio files previously selected: <strong>[_1]</strong>",join(', ',@filelist)); |
|
if (@bad_file_list) { |
|
$result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> <span class="LC_filename">[_1]</span>',join(', ',@bad_file_list)); |
|
} |
|
} |
|
} |
} |
$result.='</td></tr>'; |
$result.='</td></tr>'; |
return $result; |
return $result; |
} |
} |
|
|
|
sub show_past_file_submission { |
|
my ($part,$id) = @_; |
|
my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"'); |
|
|
|
return if (!$uploadedfile); |
|
|
|
my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}; |
|
&Apache::lonxml::extlink($url); |
|
&Apache::lonnet::allowuploaded('/adm/essayresponse',$url); |
|
my $icon=&Apache::loncommon::icon($url); |
|
my $curfile='<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$uploadedfile.'</a>'; |
|
return &mt('Currently submitted: <tt>[_1]</tt>',$curfile); |
|
|
|
} |
|
|
|
sub show_past_portfile_submission { |
|
my ($part,$id) = @_; |
|
if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}!~/[^\s]/){ |
|
return; |
|
} |
|
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(@file_list,'<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$file.'</a>'); |
|
if (! &Apache::lonnet::stat_file($url)) { |
|
&Apache::lonnet::logthis("bad file is $url"); |
|
push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon. |
|
'" border="0" />'.$file.'</a>'); |
|
} |
|
} |
|
my $files = '<span class="LC_filename">'. |
|
join('</span>, <span class="LC_filename">',@file_list). |
|
'</span>'; |
|
my $result = &mt("Portfolio files previously selected: [_1]",$files); |
|
if (@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); |
|
} |
|
return $result; |
|
|
|
} |
|
|
sub checkstatus { |
sub checkstatus { |
my ($value,$awardref,$msgref)=@_; |
my ($value,$awardref,$msgref,$nameref)=@_; |
for (my $i=0;$i<=$#$awardref;$i++) { |
for (my $i=0;$i<=$#$awardref;$i++) { |
if ($$awardref[$i] eq $value) { |
if ($$awardref[$i] eq $value) { |
return ($$awardref[$i],$$msgref[$i]); |
if (ref($nameref)) { |
|
return ($$awardref[$i],$$msgref[$i],$$nameref[$i]); |
|
} else { |
|
return ($$awardref[$i],$$msgref[$i]); |
|
} |
} |
} |
} |
} |
return(undef,undef); |
return(undef,undef); |
Line 492 sub valid_award {
|
Line 517 sub valid_award {
|
|
|
sub finalizeawards { |
sub finalizeawards { |
my ($awardref,$msgref,$nameref,$reverse)=@_; |
my ($awardref,$msgref,$nameref,$reverse)=@_; |
my $result=undef; |
my ($result,$award,$msg,$name); |
my $award; |
|
my $msg; |
|
if ($#$awardref == -1) { $result = "NO_RESPONSE"; } |
if ($#$awardref == -1) { $result = "NO_RESPONSE"; } |
if ($result eq '' ) { |
if ($result eq '' ) { |
my $blankcount; |
my $blankcount; |
Line 520 sub finalizeawards {
|
Line 543 sub finalizeawards {
|
'APPROX_ANS', 'EXACT_ANS'); |
'APPROX_ANS', 'EXACT_ANS'); |
if ($reverse) { @awards=reverse(@awards); } |
if ($reverse) { @awards=reverse(@awards); } |
foreach my $possibleaward (@awards) { |
foreach my $possibleaward (@awards) { |
($result,$msg)=&checkstatus($possibleaward,$awardref,$msgref); |
($result,$msg,$name)=&checkstatus($possibleaward,$awardref,$msgref, |
if (defined($result)) { return ($result,$msg); } |
$nameref); |
|
if (defined($result)) { return ($result,$msg,$name); } |
} |
} |
return ('ERROR',undef); |
return ('ERROR',undef); |
} |
} |
Line 534 sub decideoutput {
|
Line 558 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 696 sub decideoutput {
|
Line 721 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 720 sub decideoutput {
|
Line 745 sub decideoutput {
|
} |
} |
my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser(); |
my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser(); |
foreach my $resid(@Apache::inputtags::response){ |
foreach my $resid(@Apache::inputtags::response){ |
&Apache::lonnet::logthis("handback is ".$Apache::lonhomework::history{"resource.$part.$resid.handback"}); |
|
if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) { |
if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) { |
$message.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$Apache::lonhomework::history{"resource.$part.$resid.handback"}.'">Returned File</a>'; |
$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' && |