version 1.67, 2002/10/24 19:13:53
|
version 1.75, 2002/11/27 19:25:56
|
Line 47 sub initialize_inputtags {
|
Line 47 sub initialize_inputtags {
|
@Apache::inputtags::responselist=(); |
@Apache::inputtags::responselist=(); |
# list of whether or not a specific response was previously used |
# list of whether or not a specific response was previously used |
@Apache::inputtags::previous=(); |
@Apache::inputtags::previous=(); |
|
# submission it was used in |
|
@Apache::inputtags::previous_version=(); |
# id of current part, 0 means that no part is current (inside <problem> only |
# id of current part, 0 means that no part is current (inside <problem> only |
$Apache::inputtags::part=''; |
$Apache::inputtags::part=''; |
# list of problem date statuses, the first element is for <problem> |
# list of problem date statuses, the first element is for <problem> |
Line 146 sub start_textline {
|
Line 148 sub start_textline {
|
$Apache::lonxml::evaluate--; |
$Apache::lonxml::evaluate--; |
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); |
if ($size eq '') { $size=20; } |
my $maxlength; |
|
if ($size eq '') { $size=20; } else { |
|
if ($size < 20) { $maxlength=$size; } |
|
} |
my $partid=$Apache::inputtags::part; |
my $partid=$Apache::inputtags::part; |
my $id=$Apache::inputtags::response[-1]; |
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"}); |
$result= '<input type="text" name="HWVAL'.$id.'" value="'. |
if ($Apache::lonhomework::type ne 'exam') { |
$oldresponse.'" size="'.$size.'" />'; |
$result= '<input type="text" name="HWVAL'.$id.'" value="'. |
|
$oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />'; |
|
} |
} else { |
} else { |
#right or wrong don't show what was last typed in. |
#right or wrong don't show what was last typed in. |
#$result='<i>'.$oldresponse.'</i>'; |
#$result='<i>'.$oldresponse.'</i>'; |
Line 164 sub start_textline {
|
Line 171 sub start_textline {
|
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size'); |
my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size'); |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } |
|
} elsif ($target eq 'tex') { |
|
$result='\framebox[1cm][s]{\hfill}'; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 234 sub finalizeawards {
|
Line 243 sub finalizeawards {
|
} |
} |
|
|
sub decideoutput { |
sub decideoutput { |
my ($award,$solved,$previous)=@_; |
my ($award,$solved,$previous,$target)=@_; |
my $message=''; |
my $message=''; |
my $button=0; |
my $button=0; |
my $previousmsg; |
my $previousmsg; |
Line 242 sub decideoutput {
|
Line 251 sub decideoutput {
|
if ($previous) { $previousmsg='You have entered that answer before'; } |
if ($previous) { $previousmsg='You have entered that answer before'; } |
|
|
if ($solved =~ /^correct/) { |
if ($solved =~ /^correct/) { |
$message = "<b>You are correct.</b> Your receipt is ". |
if ($target eq 'tex') { |
|
$message = '\textbf{You are correct}. Your receipt is '. |
|
&Apache::lonnet::receipt; |
|
} else { |
|
$message = "<b>You are correct.</b> Your receipt is ". |
&Apache::lonnet::receipt; |
&Apache::lonnet::receipt; |
|
} |
$button=0; |
$button=0; |
$previousmsg=''; |
$previousmsg=''; |
} elsif ($solved =~ /^excused/) { |
} elsif ($solved =~ /^excused/) { |
Line 303 sub decideoutput {
|
Line 317 sub decideoutput {
|
sub setgradedata { |
sub setgradedata { |
my ($award,$id,$previously_used) = @_; |
my ($award,$id,$previously_used) = @_; |
# if the student already has it correct, don't modify the status |
# if the student already has it correct, don't modify the status |
if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER') { |
if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' && |
|
$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') { |
$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"} !~ |
Line 375 sub grade {
|
Line 390 sub grade {
|
my $finalaward = &finalizeawards(@awards); |
my $finalaward = &finalizeawards(@awards); |
my $previously_used; |
my $previously_used; |
if ( $#Apache::inputtags::previous eq $#awards ) { |
if ( $#Apache::inputtags::previous eq $#awards ) { |
$previously_used = 'PREVIOUSLY_LAST'; |
my $match=0; |
foreach my $value (@Apache::inputtags::previous) { |
my @matches; |
if ($value eq 'PREVIOUSLY_USED' ) { |
foreach my $versionar (@Apache::inputtags::previous_version) { |
$previously_used = $value; |
foreach my $version (@$versionar) { |
last; |
$matches[$version]++; |
|
} |
|
} |
|
foreach my $elem (@matches) {if ($elem eq ($#awards+1)) {$match=1;}} |
|
if ($match) { |
|
$previously_used = 'PREVIOUSLY_LAST'; |
|
foreach my $value (@Apache::inputtags::previous) { |
|
if ($value eq 'PREVIOUSLY_USED' ) { |
|
$previously_used = $value; |
|
last; |
|
} |
|
} |
} |
} |
} |
|
} |
} |
&Apache::lonxml::debug("final award $finalaward, $previously_used"); |
&Apache::lonxml::debug("final award $finalaward, $previously_used"); |
&setgradedata($finalaward,$id,$previously_used); |
&setgradedata($finalaward,$id,$previously_used); |
Line 408 sub gradestatus {
|
Line 433 sub gradestatus {
|
if ( $award ne '' ) { |
if ( $award ne '' ) { |
&Apache::lonxml::debug('Getting message'); |
&Apache::lonxml::debug('Getting message'); |
($showbutton,$message,$previousmsg) = |
($showbutton,$message,$previousmsg) = |
&decideoutput($award,$solved,$previous); |
&decideoutput($award,$solved,$previous,$target); |
if ($target eq 'tex') { |
if ($target eq 'tex') { |
$message=' '.$message.' '; |
$message=' '.$message.' '; |
} else { |
} else { |
Line 426 sub gradestatus {
|
Line 451 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 ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) { |
if ($ENV{'request.state'} ne "construct") { |
$trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} '; |
$trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 0 mm '; |
} |
} |
} else { |
} else { |
$trystr = "<td>Tries $tries/$maxtries</td>"; |
$trystr = "<td>Tries $tries/$maxtries</td>"; |