version 1.96, 2003/04/24 12:44:54
|
version 1.101, 2003/05/09 22:24:05
|
Line 33 use strict;
|
Line 33 use strict;
|
use Apache::loncommon; |
use Apache::loncommon; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::inputtags',('textfield','textline')); |
&Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); |
} |
} |
|
|
|
|
Line 160 sub start_textline {
|
Line 160 sub start_textline {
|
my $result = ""; |
my $result = ""; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$Apache::lonxml::evaluate--; |
$Apache::lonxml::evaluate--; |
|
my $partid=$Apache::inputtags::part; |
|
my $id=$Apache::inputtags::response[-1]; |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { |
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 { |
if ($size < 20) { $maxlength=$size; } |
if ($size < 20) { $maxlength=$size; } |
} |
} |
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 = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"}); |
if ($Apache::lonhomework::type ne 'exam') { |
if ($Apache::lonhomework::type ne 'exam') { |
$result= '<input type="text" name="HWVAL_'.$id.'" value="'. |
$result= '<input type="text" name="HWVAL_'.$id.'" value="'. |
Line 200 sub end_textline {
|
Line 200 sub end_textline {
|
return ""; |
return ""; |
} |
} |
|
|
|
sub start_hiddenline { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
my $result = ""; |
|
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"}); |
|
if ($Apache::lonhomework::type ne 'exam') { |
|
$result= '<input type="hidden" name="HWVAL_'.$id.'" value="'. |
|
$oldresponse.'" />'; |
|
} |
|
} |
|
} elsif ($target eq 'edit') { |
|
$result=&Apache::edit::tag_start($target,$token); |
|
$result.=&Apache::edit::end_table; |
|
} |
|
return $result; |
|
} |
|
|
|
sub end_hiddenline { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
|
if ($target eq 'web') { $Apache::lonxml::evaluate++; } |
|
elsif ($target eq 'edit') { return ('','no'); } |
|
return ""; |
|
} |
|
|
sub finalizeawards { |
sub finalizeawards { |
my $result=''; |
my $result=''; |
my $award; |
my $award; |
Line 350 sub decideoutput {
|
Line 378 sub decideoutput {
|
} else { |
} else { |
$message = "Unknown message: $award"; |
$message = "Unknown message: $award"; |
$button=1; |
$button=1; |
} |
} |
if (lc($Apache::lonhomework::problemstatus) ne 'yes') { |
if (lc($Apache::lonhomework::problemstatus) eq 'no') { |
$message = "Answer Submitted"; |
$message = "Answer Submitted"; |
$button=1; |
$button=1; |
} |
} |
Line 376 sub setgradedata {
|
Line 404 sub setgradedata {
|
$Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; |
$Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; |
return ''; |
return ''; |
} elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ |
} elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ |
/^correct/ || $Apache::lonhomework::scantronmode) { |
/^correct/ || $Apache::lonhomework::scantronmode || |
|
lc($Apache::lonhomework::problemstatus) eq 'no') { |
#handle assignment of tries and solved status |
#handle assignment of tries and solved status |
my $solvemsg; |
my $solvemsg; |
if ($Apache::lonhomework::scantronmode) { |
if ($Apache::lonhomework::scantronmode) { |
Line 428 sub setgradedata {
|
Line 457 sub setgradedata {
|
} else { |
} else { |
$Apache::lonhomework::results{"resource.$id.solved"} = |
$Apache::lonhomework::results{"resource.$id.solved"} = |
'incorrect_attempted'; |
'incorrect_attempted'; |
|
if (lc($Apache::lonhomework::problemstatus) eq 'no') { |
|
$Apache::lonhomework::results{"resource.$id.tries"} = |
|
$Apache::lonhomework::history{"resource.$id.tries"} + 1; |
|
} |
} |
} |
|
|
# check if this was a previous submission if it was delete the |
# check if this was a previous submission if it was delete the |
# unneeded data and update the previously_used attribute |
# unneeded data and update the previously_used attribute |
if ( $previously_used eq 'PREVIOUSLY_USED') { |
if ( $previously_used eq 'PREVIOUSLY_USED') { |
delete($Apache::lonhomework::results{"resource.$id.tries"}); |
if (lc($Apache::lonhomework::problemstatus) ne 'no') { |
$Apache::lonhomework::results{"resource.$id.previous"} = '1'; |
delete($Apache::lonhomework::results{"resource.$id.tries"}); |
|
$Apache::lonhomework::results{"resource.$id.previous"} = '1'; |
|
} |
} elsif ( $previously_used eq 'PREVIOUSLY_LAST') { |
} elsif ( $previously_used eq 'PREVIOUSLY_LAST') { |
#delete all data as they student didn't do anything, but save |
#delete all data as they student didn't do anything, but save |
#the list of collaborators. |
#the list of collaborators. |
Line 530 sub gradestatus {
|
Line 565 sub gradestatus {
|
if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } |
if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } |
if ( $showbutton ) { |
if ( $showbutton ) { |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
if ($ENV{'request.state'} ne "construct") { |
if ($ENV{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam') { |
$trystr = ' {\vskip -1 mm \small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 2 mm '; |
$trystr = ' {\vskip 1 mm \small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 2 mm '; |
} else { |
} else { |
$trystr = '\vskip 0 mm '; |
$trystr = '\vskip 0 mm '; |
} |
} |