Diff for /loncom/homework/rankresponse.pm between versions 1.1 and 1.4

version 1.1, 2003/01/19 08:13:04 version 1.4, 2003/03/19 14:23:38
Line 2 Line 2
 # rank style response  # rank style response
 #  #
 # $Id$  # $Id$
 #  
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 30 Line 29
 package Apache::rankresponse;  package Apache::rankresponse;
 use strict;  use strict;
 use HTML::Entities();  use HTML::Entities();
   use Apache::optionresponse;
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::rankresponse',('rankresponse'));      &Apache::lonxml::register('Apache::rankresponse',('rankresponse'));
Line 91  sub start_foilgroup { Line 91  sub start_foilgroup {
 sub end_foilgroup {  sub end_foilgroup {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;      my $result;
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer') {      if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') {
  my $style = $Apache::lonhomework::type;  
  my $name;  
  my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');   my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
  my $randomize = &Apache::lonxml::get_param('randomize',$parstack,   my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
    $safeeval,'-2');     $safeeval,'-2');
  my $tol = &Apache::lonxml::get_param('tol',$parstack,$safeeval,'-2');   my $tol = &Apache::lonxml::get_param('tol',$parstack,$safeeval,'-2');
  if (!defined($tol)) { $tol=0; }   if (!defined($tol)) { $tol=0; }
  if ($target eq 'web') {   if ($target eq 'web' || $target eq 'tex') {
     $result=&displayfoils($target,$max,$randomize,$tol);      $result=&displayfoils($target,$max,$randomize,$tol);
  } elsif ($target eq 'answer' ) {   } elsif ($target eq 'answer' ) {
     $result=&displayanswers($max,$randomize,$tol);      $result=&displayanswers($max,$randomize,$tol);
Line 233  sub grade_response { Line 231  sub grade_response {
 sub displayfoils {  sub displayfoils {
     my ($target,$max,$randomize,$tol)=@_;      my ($target,$max,$randomize,$tol)=@_;
     my $result;      my $result;
       my @alphabet=('A'..'Z');
     my (@whichfoils)=&whichfoils($max,$randomize);      my (@whichfoils)=&whichfoils($max,$randomize);
     my $part=$Apache::inputtags::part;      my $part=$Apache::inputtags::part;
     my $solved=$Apache::lonhomework::history{"resource.$part.solved"};      my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
Line 254  sub displayfoils { Line 253  sub displayfoils {
  my %lastresponse=&Apache::lonnet::str2hash($lastresponse);   my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
  foreach my $name (@whichfoils) {   foreach my $name (@whichfoils) {
     my $lastopt=$lastresponse{$name};      my $lastopt=$lastresponse{$name};
     my $optionlist="<option></option>\n";      my $optionlist='';
       if ($target ne 'tex') {$optionlist="<option></option>\n";}
     my $option;      my $option;
     foreach $option (@whichopt) {      foreach $option (@whichopt) {
  if ($option eq $lastopt) {   if ($option eq $lastopt) {
     $optionlist.="<option selected=\"on\">$option</option>\n";      if ($target ne 'tex') {$optionlist.="<option selected=\"on\">$option</option>\n";}
  } else {   } else {
     $optionlist.="<option>$option</option>\n";      if ($target ne 'tex') {$optionlist.="<option>$option</option>\n";}
  }   }
     }      }
     $optionlist='<select name="HWVAL_'.      if ($target ne 'tex') {
  $Apache::inputtags::response[-1].':'.$temp.'">'.   $optionlist='<select name="HWVAL_'.
     $optionlist."</select>\n";      $Apache::inputtags::response[-1].':'.$temp.'">'.
           $optionlist."</select>\n";
       } else {
    $optionlist=' '.$temp.' '.$optionlist.' ';
       }
     my $text=$Apache::response::foilgroup{$name.'.text'};      my $text=$Apache::response::foilgroup{$name.'.text'};
     $result.='<br />'.$optionlist.$text."\n";      if ($target ne 'tex') {
    $result.='<br />'.$optionlist.$text."\n";
    if ($Apache::lonhomework::type eq 'exam') {
       $result.=&Apache::optionresponse::webbubbles(\@alphabet,\@whichopt);
    }
       } else {
    if ($Apache::lonhomework::type eq 'exam') {
       $result.=' \framebox[5 mm][s]{\tiny\strut} '.$text."\n";
       $result.='\begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]'.&Apache::optionresponse::bubbles(\@alphabet,\@whichopt).'\end{enumerate}\strut ';
       &Apache::lonxml::increment_counter();
    } else {
    $result.=' \\\\ \framebox[5 mm][s]{\tiny\strut} '.$text."\n";
    }
       }
     $temp++;      $temp++;
  }   }
     }      }
     $result.="<br />";      if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';}
     return $result;      return $result;
 }  }
   
Line 397  sub insert_conceptgroup { Line 414  sub insert_conceptgroup {
 sub start_foil {  sub start_foil {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result='';      my $result='';
     if ($target eq 'web' ) {      if ($target eq 'web' || $target eq 'tex') {
  &Apache::lonxml::startredirection;   &Apache::lonxml::startredirection;
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result=&Apache::edit::tag_start($target,$token,"Foil");   $result=&Apache::edit::tag_start($target,$token,"Foil");
Line 425  sub end_foil { Line 442  sub end_foil {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $text ='';      my $text ='';
     my $result = '';      my $result = '';
     if ($target eq 'web') {      if ($target eq 'web' || $target eq 'tex') {
  $text=&Apache::lonxml::endredirection;   $text=&Apache::lonxml::endredirection;
     }      }
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
  my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);   my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
  if ($value ne 'unused') {   if ($value ne 'unused') {
     my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);      my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);

Removed from v.1.1  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>