--- loncom/homework/inputtags.pm 2003/10/13 21:09:47 1.121 +++ loncom/homework/inputtags.pm 2004/01/29 21:31:07 1.128 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.121 2003/10/13 21:09:47 albertel Exp $ +# $Id: inputtags.pm,v 1.128 2004/01/29 21:31:07 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -24,8 +24,6 @@ # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ -# -# 2/19 Guy package Apache::inputtags; use HTML::Entities(); @@ -98,6 +96,16 @@ sub end_input { return ''; } +sub addchars { + my ($fieldid,$addchars)=@_; + my $output=''; + foreach (split(/\,/,$addchars)) { + $output.=''.$_.' '; + } + return $output; +} + sub start_textfield { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result = ""; @@ -112,7 +120,12 @@ sub start_textfield { if ( $cols eq '') { $cols = 80; } my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval); if ( $rows eq '') { $rows = 10; } - $result= '".$oldresponse; if ($oldresponse ne '') { #get rid of any startup text if the user has already responded @@ -135,18 +148,19 @@ sub start_textfield { $result.=&Apache::edit::tag_start($target,$token); $result.=&Apache::edit::text_arg('Rows:','rows',$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); $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, - $safeeval,'rows','cols'); + $safeeval,'rows','cols','addchars'); if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } else { $result=$token->[4]; } - my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser); - $result.=&Apache::edit::modifiedfield(); + $result.=&Apache::edit::modifiedfield("/textfield",$parser); } elsif ($target eq 'tex') { my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval); my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval); @@ -194,7 +208,12 @@ sub start_textline { } my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"}); if ($Apache::lonhomework::type ne 'exam') { - $result= ''; } } else { @@ -204,10 +223,12 @@ sub start_textline { } } elsif ($target eq 'edit') { $result=&Apache::edit::tag_start($target,$token); - $result.=&Apache::edit::text_arg('Size:','size',$token,'5').""; + $result.=&Apache::edit::text_arg('Size:','size',$token,'5'). + &Apache::edit::text_arg + ('Click-On Texts (comma sep):','addchars',$token,10).""; $result.=&Apache::edit::end_table; } 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); } } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') { my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval); @@ -457,7 +478,7 @@ sub decideoutput { } if (lc($Apache::lonhomework::problemstatus) eq 'no' && $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'}; $button=1; } @@ -643,6 +664,8 @@ sub gradestatus { my $tries = $Apache::lonhomework::history{"resource.$id.tries"}; my $maxtries = &Apache::lonnet::EXT("resource.$id.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 ( $maxtries eq '' ) { $maxtries = '2'; } if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } @@ -654,13 +677,21 @@ sub gradestatus { $trystr = '\vskip 0 mm '; } } else { - $trystr = "".&mt('Tries')." $tries/$maxtries"; + $trystr = "".&mt('Tries')." $tries"; + if($ENV{'request.state'} ne 'construct') { + $trystr.="/$maxtries"; + } else { + if (defined($Apache::inputtags::params{'maxtries'})) { + $trystr.="/".$Apache::inputtags::params{'maxtries'}; + } + } + $trystr.=""; } } if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;} if ( $showbutton ) { if ($target ne 'tex') { - $button = ''; + $button = ''; } } if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) { @@ -679,7 +710,7 @@ sub gradestatus { if ($target eq 'tex') { return $button.' \vskip 0 mm '.$output.' '; } else { - return $button.''.$output.''; + return ''.$button.''.$output.''; } } }