Diff for /loncom/homework/inputtags.pm between versions 1.121 and 1.126

version 1.121, 2003/10/13 21:09:47 version 1.126, 2004/01/15 00:15:12
Line 24 Line 24
 # /home/httpd/html/adm/gpl.txt  # /home/httpd/html/adm/gpl.txt
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  
 # 2/19 Guy   
   
 package Apache::inputtags;  package Apache::inputtags;
 use HTML::Entities();  use HTML::Entities();
Line 98  sub end_input { Line 96  sub end_input {
   return '';    return '';
 }  }
   
   sub addchars {
       my ($fieldid,$addchars)=@_;
       my $output='';
       foreach (split(/\,/,$addchars)) {
    $output.='<a href="javascript:void(document.forms.lonhomework.'.
       $fieldid.'.value+=\''.$_.'\')">'.$_.'</a> ';
       }
       return $output;
   }
   
 sub start_textfield {  sub start_textfield {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   my $result = "";    my $result = "";
Line 112  sub start_textfield { Line 120  sub start_textfield {
  if ( $cols eq '') { $cols = 80; }   if ( $cols eq '') { $cols = 80; }
  my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);   my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
  if ( $rows eq '') { $rows = 10; }   if ( $rows eq '') { $rows = 10; }
  $result= '<textarea wrap="hard" name="HWVAL_'.$resid.'" '.   my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
    $result='';
           if ($addchars) {
       $result.=&addchars('HWVAL_'.$resid,$addchars);
    }
    $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" '.
     "rows=\"$rows\" cols=\"$cols\">".$oldresponse;      "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
  if ($oldresponse ne '') {   if ($oldresponse ne '') {
     #get rid of any startup text if the user has already responded      #get rid of any startup text if the user has already responded
Line 135  sub start_textfield { Line 148  sub start_textfield {
     $result.=&Apache::edit::tag_start($target,$token);      $result.=&Apache::edit::tag_start($target,$token);
     $result.=&Apache::edit::text_arg('Rows:','rows',$token,4);      $result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
     $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);      $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
       $result.=&Apache::edit::text_arg
    ('Click-On Texts (comma sep):','addchars',$token,10);
     my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);      my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);
     $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);      $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
   } elsif ($target eq 'modified') {    } elsif ($target eq 'modified') {
     my $constructtag=&Apache::edit::get_new_args($token,$parstack,      my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  $safeeval,'rows','cols');     $safeeval,'rows','cols','addchars');
     if ($constructtag) {      if ($constructtag) {
       $result = &Apache::edit::rebuild_tag($token);        $result = &Apache::edit::rebuild_tag($token);
     } else {      } else {
       $result=$token->[4];        $result=$token->[4];
     }      }
     my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);      $result.=&Apache::edit::modifiedfield("/textfield",$parser);
     $result.=&Apache::edit::modifiedfield();  
   } elsif ($target eq 'tex') {    } elsif ($target eq 'tex') {
       my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);        my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
       my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);        my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
Line 194  sub start_textline { Line 208  sub start_textline {
       }        }
       my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});        my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
       if ($Apache::lonhomework::type ne 'exam') {        if ($Apache::lonhomework::type ne 'exam') {
         $result= '<input type="text" name="HWVAL_'.$id.'" value="'.   my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
    $result='';
           if ($addchars) {
       $result.=&addchars('HWVAL_'.$id,$addchars);
    }
           $result.= '<input type="text" name="HWVAL_'.$id.'" value="'.
     $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';      $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
       }        }
     } else {      } else {
Line 204  sub start_textline { Line 223  sub start_textline {
     }      }
   } elsif ($target eq 'edit') {    } elsif ($target eq 'edit') {
     $result=&Apache::edit::tag_start($target,$token);      $result=&Apache::edit::tag_start($target,$token);
     $result.=&Apache::edit::text_arg('Size:','size',$token,'5')."</td></tr>";      $result.=&Apache::edit::text_arg('Size:','size',$token,'5').
    &Apache::edit::text_arg
    ('Click-On Texts (comma sep):','addchars',$token,10)."</td></tr>";
     $result.=&Apache::edit::end_table;      $result.=&Apache::edit::end_table;
   } 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','addchars');
     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }      if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {    } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
       my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);        my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
Line 457  sub decideoutput { Line 478  sub decideoutput {
   }    }
   if (lc($Apache::lonhomework::problemstatus) eq 'no'  &&     if (lc($Apache::lonhomework::problemstatus) eq 'no'  && 
       $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {        $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {
       $message = &mt("Answer Submitted");        $message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
       $bgcolor=$possiblecolors{'correct'};        $bgcolor=$possiblecolors{'correct'};
       $button=1;        $button=1;
   }    }
Line 643  sub gradestatus { Line 664  sub gradestatus {
     my $tries = $Apache::lonhomework::history{"resource.$id.tries"};      my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");      my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
     &Apache::lonxml::debug("got maxtries of :$maxtries:");      &Apache::lonxml::debug("got maxtries of :$maxtries:");
       #if tries are set to negative turn off the Tries/Button and messages
       if (defined($maxtries) && $maxtries < 0) { return ''; }
     if ( $tries eq '' ) { $tries = '0'; }      if ( $tries eq '' ) { $tries = '0'; }
     if ( $maxtries eq '' ) { $maxtries = '2'; }       if ( $maxtries eq '' ) { $maxtries = '2'; } 
     if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; }       if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
Line 654  sub gradestatus { Line 677  sub gradestatus {
       $trystr = '\vskip 0 mm ';        $trystr = '\vskip 0 mm ';
   }    }
       } else {        } else {
          $trystr = "<td>".&mt('Tries')." $tries/$maxtries</td>";    $trystr = "<td>".&mt('Tries')." $tries";
     if($ENV{'request.state'} ne 'construct') { $trystr.="/$maxtries"; }
     $trystr.="</td>";
       }        }
     }      }
     if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}      if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}

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


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