--- loncom/homework/inputtags.pm 2003/09/22 20:49:01 1.117 +++ 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.117 2003/09/22 20:49:01 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); @@ -414,7 +435,7 @@ sub decideoutput { $bgcolor=$possiblecolors{'not_charged_try'}; $button=1; } elsif ($award eq 'SIG_FAIL') { - $message = &mt("Please adjust significant figures.");# you provided %s significant figures"; + $message = &mt("Significant figures are incorrect, submission was not graded.");# you provided %s significant figures"; $bgcolor=$possiblecolors{'not_charged_try'}; $button=1; } elsif ($award eq 'UNIT_FAIL') { @@ -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; } @@ -518,6 +539,9 @@ sub setgradedata { } elsif ( $award eq 'INCORRECT' ) { $Apache::lonhomework::results{"resource.$id.tries"} = $Apache::lonhomework::history{"resource.$id.tries"} + 1; + if (lc($Apache::lonhomework::problemstatus) eq 'no') { + $Apache::lonhomework::results{"resource.$id.awarded"} = 0; + } $Apache::lonhomework::results{"resource.$id.solved"} = 'incorrect_attempted' } elsif ( $award eq 'SUBMITTED' ) { @@ -537,6 +561,7 @@ sub setgradedata { if (lc($Apache::lonhomework::problemstatus) eq 'no') { $Apache::lonhomework::results{"resource.$id.tries"} = $Apache::lonhomework::history{"resource.$id.tries"} + 1; + $Apache::lonhomework::results{"resource.$id.awarded"} = 0; } } @@ -617,7 +642,8 @@ sub gradestatus { my $status = $Apache::inputtags::status['-1']; &Apache::lonxml::debug("gradestatus has :$status:"); - if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE') { + if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE' && + $status ne 'INVALID_ACCESS') { my $award = $Apache::lonhomework::history{"resource.$id.award"}; my $solved = $Apache::lonhomework::history{"resource.$id.solved"}; my $previous = $Apache::lonhomework::history{"resource.$id.previous"}; @@ -638,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'; } @@ -649,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"}) { @@ -674,7 +710,7 @@ sub gradestatus { if ($target eq 'tex') { return $button.' \vskip 0 mm '.$output.' '; } else { - return $button.''.$output.''; + return ''.$button.''.$output.''; } } }