--- loncom/homework/inputtags.pm 2002/10/24 19:30:39 1.69 +++ loncom/homework/inputtags.pm 2003/01/13 21:22:43 1.78 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.69 2002/10/24 19:30:39 sakharuk Exp $ +# $Id: inputtags.pm,v 1.78 2003/01/13 21:22:43 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,6 +47,8 @@ sub initialize_inputtags { @Apache::inputtags::responselist=(); # list of whether or not a specific response was previously used @Apache::inputtags::previous=(); + # submission it was used in + @Apache::inputtags::previous_version=(); # id of current part, 0 means that no part is current (inside only $Apache::inputtags::part=''; # list of problem date statuses, the first element is for @@ -120,6 +122,13 @@ sub start_textfield { $result=$token->[4]; } $result.=&Apache::edit::modifiedfield(); + } elsif ($target eq 'tex') { + if ($$tagstack[-2] eq 'essayresponse' and $Apache::lonhomework::type eq 'exam') { + my $number_of_lines= &Apache::lonxml::get_param('rows',$parstack,$safeeval); + $result = '\fbox{\fbox{\parbox{\textwidth-5mm}{'; + for (my $i=0;$i'; + if ($Apache::lonhomework::type ne 'exam') { + $result= ''; + } } else { #right or wrong don't show what was last typed in. #$result=''.$oldresponse.''; @@ -164,6 +178,10 @@ sub start_textline { } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size'); if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } + } elsif ($target eq 'tex' and $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}'; } return $result; } @@ -308,7 +326,8 @@ sub decideoutput { sub setgradedata { my ($award,$id,$previously_used) = @_; # 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; return ''; } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ @@ -380,13 +399,23 @@ sub grade { my $finalaward = &finalizeawards(@awards); my $previously_used; if ( $#Apache::inputtags::previous eq $#awards ) { - $previously_used = 'PREVIOUSLY_LAST'; - foreach my $value (@Apache::inputtags::previous) { - if ($value eq 'PREVIOUSLY_USED' ) { - $previously_used = $value; - last; + my $match=0; + my @matches; + foreach my $versionar (@Apache::inputtags::previous_version) { + foreach my $version (@$versionar) { + $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"); &setgradedata($finalaward,$id,$previously_used); @@ -405,7 +434,7 @@ sub gradestatus { my $status = $Apache::inputtags::status['-1']; &Apache::lonxml::debug("gradestatus has :$status:"); - if ( $status ne 'CLOSED' ) { + if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE') { my $award = $Apache::lonhomework::history{"resource.$id.award"}; my $solved = $Apache::lonhomework::history{"resource.$id.solved"}; my $previous = $Apache::lonhomework::history{"resource.$id.previous"}; @@ -432,7 +461,7 @@ sub gradestatus { if ( $showbutton ) { if ($target eq 'tex') { if ($ENV{'request.state'} ne "construct") { - $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} '; + $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 0 mm '; } } else { $trystr = "Tries $tries/$maxtries";