Diff for /loncom/homework/matchresponse.pm between versions 1.3 and 1.4

version 1.3, 2003/02/20 09:30:42 version 1.4, 2003/02/20 09:55:07
Line 85  sub start_itemgroup { Line 85  sub start_itemgroup {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;      my $result;
     %Apache::response::itemgroup=();      %Apache::response::itemgroup=();
       %Apache::matchresponse::itemtable=();
     if ($target eq 'edit') {      if ($target eq 'edit') {
  $result=&Apache::edit::tag_start($target,$token);   $result=&Apache::edit::tag_start($target,$token);
  $result.=&Apache::edit::select_arg('Randomize Order:','randomize',   $result.=&Apache::edit::select_arg('Randomize Order:','randomize',
    ['yes','no'],$token);     ['yes','no'],$token);
    $result.=&Apache::edit::select_arg('Items Display Location:',
      'location',
      ['top','bottom','left','right'],
      $token);
  $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();   $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
       } elsif ($target eq 'modified') {
    my $constructtag=&Apache::edit::get_new_args($token,$parstack,
        $safeeval,'randomize',
        'location');
    if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
       } elsif ($target eq 'web') {
    $Apache::matchresponse::itemtable{'location'}=
       &Apache::lonxml::get_param('location',$parstack,$safeeval);
     }      }
     return $result;      return $result;
 }  }
Line 117  sub end_itemgroup { Line 130  sub end_itemgroup {
     $Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;      $Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;
     $Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map;      $Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map;
     if ($target eq 'web') {      if ($target eq 'web') {
  $result.='<table>';   my $table='<table>';
  my $i=0;   my $i=0;
  foreach my $name (@names) {   foreach my $name (@names) {
     $result.='<tr><td>'.$alphabet[$i].'</td><td>'.      $table.='<tr><td>'.$alphabet[$i].'</td><td>'.
  $Apache::response::itemgroup{$name.'.text'}.   $Apache::response::itemgroup{$name.'.text'}.
     '</td></tr>';      '</td></tr>';
     $i++;      $i++;
  }   }
  $result.='</table>';   $table.='</table>';
    $Apache::matchresponse::itemtable{'display'}=$table;
     } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); }      } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); }
     return $result;      return $result;
 }  }
Line 306  sub grade_response { Line 320  sub grade_response {
     &Apache::response::handle_previous(\%previous,$ad);      &Apache::response::handle_previous(\%previous,$ad);
 }  }
   
   sub itemdisplay {
       my ($location)=@_;
       if ($location eq 'top' &&
    !defined($Apache::matchresponse::itemtable{'location'})) {
    return $Apache::matchresponse::itemtable{'display'};
       }
       if ($Apache::matchresponse::itemtable{'location'} eq $location) {
    return $Apache::matchresponse::itemtable{'display'};
       }
       return undef;
   }
 sub displayfoils {  sub displayfoils {
     my ($target,$max,$randomize)=@_;      my ($target,$max,$randomize)=@_;
     my $result;      my $result;
       my $question;
     my (@whichfoils)=&whichorder(&getfoilcounts($max),$randomize,      my (@whichfoils)=&whichorder(&getfoilcounts($max),$randomize,
  &Apache::response::showallfoils(),   &Apache::response::showallfoils(),
  \%Apache::response::foilgroup);   \%Apache::response::foilgroup);
Line 330  sub displayfoils { Line 356  sub displayfoils {
     my $text=$Apache::response::foilgroup{$name.'.text'};      my $text=$Apache::response::foilgroup{$name.'.text'};
     my $value=$Apache::response::foilgroup{$name.'.value'};      my $value=$Apache::response::foilgroup{$name.'.value'};
     my $letter=$name_letter_map{$value};      my $letter=$name_letter_map{$value};
     $result.='<br />'.$letter.':'.$text;      $question.='<br />'.$letter.':'.$text;
  }   }
     } else {      } else {
  my $i = 0;   my $i = 0;
Line 355  sub displayfoils { Line 381  sub displayfoils {
  $Apache::inputtags::response[-1].':'.$temp.'">'.   $Apache::inputtags::response[-1].':'.$temp.'">'.
     $optionlist."</select>\n";      $optionlist."</select>\n";
     my $text=$Apache::response::foilgroup{$name.'.text'};      my $text=$Apache::response::foilgroup{$name.'.text'};
     $result.='<br />'.$optionlist.$text."\n";      $question.='<br />'.$optionlist.$text."\n";
     $temp++;      $temp++;
  }   }
     }      }
       if ($result=&itemdisplay('top')) {
    $result.=$question;
       } elsif ($result=&itemdisplay('bottom')) {
    $result=$question.$result;
       } elsif ($result=&itemdisplay('right')) {
    $result='<table><tr><td>'.$question.'</td><td>'.$result.
       '</td></tr></table>';
       } elsif ($result=&itemdisplay('left')) {
    $result='<table><tr><td>'.$result.'</td><td>'.$question.
       '</td></tr></table>';
       }
     $result.="<br />";      $result.="<br />";
     return $result;      return $result;
 }  }

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


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