Diff for /loncom/homework/optionresponse.pm between versions 1.110 and 1.121

version 1.110, 2004/05/27 04:25:13 version 1.121, 2004/10/21 06:33:37
Line 38  sub start_optionresponse { Line 38  sub start_optionresponse {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   my $result='';    my $result='';
   #when in a option response use these    #when in a option response use these
   &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup'));    &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup','drawoptionlist'));
   push (@Apache::lonxml::namespace,'optionresponse');    push (@Apache::lonxml::namespace,'optionresponse');
   my $id = &Apache::response::start_response($parstack,$safeeval);    my $id = &Apache::response::start_response($parstack,$safeeval);
   %Apache::hint::option=();    %Apache::hint::option=();
Line 78  sub end_optionresponse { Line 78  sub end_optionresponse {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   &Apache::response::end_response;    &Apache::response::end_response;
   pop @Apache::lonxml::namespace;    pop @Apache::lonxml::namespace;
   &Apache::lonxml::deregister('Apache::optionresponse',('foilgroup','foil','conceptgroup'));    &Apache::lonxml::deregister('Apache::optionresponse',('foilgroup','foil','conceptgroup','drawoptionlist'));
   my $result;    my $result;
   if ($target eq 'edit') { $result=&Apache::edit::end_table(); }    if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
   undef(%Apache::response::foilnames);    undef(%Apache::response::foilnames);
Line 192  sub end_foilgroup { Line 192  sub end_foilgroup {
  my $ignored=0;   my $ignored=0;
  foreach $name (@whichopt) {   foreach $name (@whichopt) {
   my $response=&Apache::response::getresponse($temp);    my $response=&Apache::response::getresponse($temp);
   if ($ENV{'form.submitted'} eq 'scantron') {    if ($ENV{'form.submitted'} eq 'scantron' && $response=~/\S/) {
       $response = $opt[$response];        $response = $opt[$response];
   }    }
   if ( $response =~ /[^\s]/) {    if ( $response =~ /[^\s]/) {
Line 220  sub end_foilgroup { Line 220  sub end_foilgroup {
     $responsestr;      $responsestr;
  $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr;   $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr;
   
  if (!$Apache::lonhomework::scantronmode) {   if ($Apache::lonhomework::type eq 'survey') {
       if ($ignored == 0) {
    my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED';
    &Apache::response::handle_previous(\%previous,$ad);
       } elsif ($wrong==0 && $right==0) {
       } else {
    my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='MISSING_ANSWER';
    &Apache::response::handle_previous(\%previous,$ad);
       }
    } elsif (!$Apache::lonhomework::scantronmode) {
     my $ad;      my $ad;
     if ($wrong==0 && $ignored==0) {      if ($wrong==0 && $ignored==0) {
  $ad='EXACT_ANS';   $ad='EXACT_ANS';
Line 238  sub end_foilgroup { Line 247  sub end_foilgroup {
  } else {   } else {
     my $ad;      my $ad;
     if ($wrong==0 && $right==0) {      if ($wrong==0 && $right==0) {
  #nothing submitted   #nothing submitted only assign a score if we 
    #need to override a previous grade
    if (defined($Apache::lonhomework::history{"resource.$part.$id.awarddetail"})) {
       $ad='ASSIGNED_SCORE';
    }
     } else {      } else {
  $ad='ASSIGNED_SCORE';   $ad='ASSIGNED_SCORE';
     }      }
Line 350  sub displayfoils { Line 363  sub displayfoils {
  $text='•'.$text;   $text='•'.$text;
     }      }
     $result.=$text."\n";      $result.=$text."\n";
       }   }
       if ($Apache::lonhomework::type eq 'exam') {        if ($Apache::lonhomework::type eq 'exam') {
   $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);    $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
       }        }
Line 453  sub optionlist_correction { Line 466  sub optionlist_correction {
     if ($TeXlayout eq 'vertical') {      if ($TeXlayout eq 'vertical') {
  $texoptionlist.=' \vskip 0 mm ',   $texoptionlist.=' \vskip 0 mm ',
     } else {      } else {
  $texoptionlist.=',';   $texoptionlist.=', ';
     }      }
  }   }
  chop($texoptionlist);   $texoptionlist=~s/, $//;
  if ($TeXlayout ne 'vertical') {$texoptionlist.='.';}   if ($TeXlayout ne 'vertical') {$texoptionlist.='.';}
     } else {      } else {
  if ($TeXlayout ne 'vertical') {$texoptionlist='\\item [] \\vskip -5 mm';}   if ($TeXlayout ne 'vertical') {$texoptionlist='\\item [] \\vskip -5 mm';}
Line 479  sub webbubbles { Line 492  sub webbubbles {
  }   }
  $result.='<td><input type="radio" name="HWVAL_'.   $result.='<td><input type="radio" name="HWVAL_'.
     $Apache::inputtags::response['-1'].':'.$temp.      $Apache::inputtags::response['-1'].':'.$temp.
     '" value="'.$opt[$ind].'" '.$checked.' />'.$alphabet[$ind].': '.      '" value="'.$opt[$ind].'" '.$checked.' />';
     $opt[$ind].'</td>';   if ($alphabet[$ind]) {
       $result.=$alphabet[$ind].': ';
    }
    $result.=$opt[$ind].'</td>';
     }      }
     $result.='</tr></table>';      $result.='</tr></table>';
     return $result;      return $result;
Line 488  sub webbubbles { Line 504  sub webbubbles {
   
   
 sub bubbles {  sub bubbles {
     my ($ralphabit,$ropt) = @_;      my ($ralphabet,$ropt,$response) = @_;
     my @alphabet = @$ralphabit;      my @alphabet = @$ralphabet;
     my @opt = @$ropt;      my @opt = @$ropt;
     my ($result,$head,$line) =('','','');      my ($result,$head,$line) =('','','');
     my $number_of_bubbles = $#opt + 1;      my $number_of_bubbles = $#opt + 1;
Line 505  sub bubbles { Line 521  sub bubbles {
     for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {      for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {
  my $leftmargin;   my $leftmargin;
  $opt[$ind]=&Apache::lonxml::latex_special_symbols($opt[$ind]);   $opt[$ind]=&Apache::lonxml::latex_special_symbols($opt[$ind]);
    if ($response eq 'rankresponse') {$opt[$ind]='Rank '.$opt[$ind];}
  if ($ind==0) {$leftmargin=6;} else {$leftmargin=10;}   if ($ind==0) {$leftmargin=6;} else {$leftmargin=10;}
  $current_length += (length($opt[$ind])+length($alphabet[$ind])+4)*2;   $current_length += (length($opt[$ind])+length($alphabet[$ind])+4)*2;
  if ($current_length<($textwidth-$leftmargin) and $ind!=$number_of_bubbles) {   if ($current_length<($textwidth-$leftmargin) and $ind!=$number_of_bubbles) {
Line 600  sub end_foil { Line 617  sub end_foil {
   my $result = '';    my $result = '';
   if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { 
       $text=&Apache::lonxml::endredirection;        $text=&Apache::lonxml::endredirection;
       $text=~/(\w)/;        if ($target eq 'tex') {$text=~s/\\strut\s*\\\\\s*\\strut/\\vskip 0 mm/;}
       if (($target eq 'tex') and ($Apache::lonhomework::type ne 'exam') and ($text=~/\S/)) {$text = '\vspace*{-2 mm}\item '.$text;}         if (($target eq 'tex') and ($Apache::lonhomework::type ne 'exam') and ($text=~/\S/)) {$text = '\vspace*{-2 mm}\item '.$text;} 
   }    }
   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' 
Line 644  sub end_foil { Line 661  sub end_foil {
   return $result;    return $result;
 }  }
   
   sub start_drawoptionlist {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
       if ($target ne 'meta') {
    return $token->[4];
       }
   }
   
   sub end_drawoptionlist {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
       if ($target ne 'meta') {
    return $token->[2];
       }
   }
   
 sub insert_foil {  sub insert_foil {
   return '    return '
 <foil name="" value="unused">  <foil name="" value="unused">

Removed from v.1.110  
changed lines
  Added in v.1.121


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