--- loncom/homework/inputtags.pm 2003/10/30 20:52:54 1.122 +++ loncom/homework/inputtags.pm 2004/02/27 17:18:32 1.133 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.122 2003/10/30 20:52:54 albertel Exp $ +# $Id: inputtags.pm,v 1.133 2004/02/27 17:18:32 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(); @@ -64,6 +62,8 @@ sub initialize_inputtags { @Apache::inputtags::import=(); # list of all import ids seen @Apache::inputtags::importlist=(); + # just used to note whether we have seen a response that isn't in a part + $Apache::inputtags::response_with_no_part=0; } sub check_for_duplicate_ids { @@ -98,6 +98,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 +122,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,11 +150,13 @@ 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 { @@ -193,7 +210,12 @@ sub start_textline { } my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"}); if ($Apache::lonhomework::type ne 'exam') { - $result= ''; } } else { @@ -203,10 +225,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); @@ -347,7 +371,7 @@ sub decideoutput { $ENV{'request.course.id'}. '.disable_receipt_display'} eq 'yes') { $message.=(($target eq 'web')?'':' '). - &mt('Your receipt is').' '.&Apache::lonnet::receipt(). + &mt('Your receipt is').' '.&Apache::lonnet::receipt($Apache::inputtags::part). (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''); } } @@ -374,7 +398,7 @@ sub decideoutput { $ENV{'request.course.id'}. '.disable_receipt_display'} eq 'yes') { $message.=(($target eq 'web')?'':' '). - 'Your receipt is '.&Apache::lonnet::receipt(). + 'Your receipt is '.&Apache::lonnet::receipt($Apache::inputtags::part). (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''); } $bgcolor=$possiblecolors{'correct'}; @@ -456,7 +480,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; } @@ -476,7 +500,8 @@ sub removealldata { sub setgradedata { my ($award,$id,$previously_used) = @_; # if the student already has it correct, don't modify the status - if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' && + if (!$Apache::lonhomework::scantronmode && + $Apache::inputtags::status['-1'] ne 'CAN_ANSWER' && $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') { $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; return ''; @@ -543,21 +568,28 @@ sub setgradedata { } } - # check if this was a previous submission if it was delete the - # unneeded data and update the previously_used attribute - if ( $previously_used eq 'PREVIOUSLY_USED') { - if (lc($Apache::lonhomework::problemstatus) ne 'no') { - delete($Apache::lonhomework::results{"resource.$id.tries"}); - $Apache::lonhomework::results{"resource.$id.previous"} = '1'; - } - } elsif ( $previously_used eq 'PREVIOUSLY_LAST') { - #delete all data as they student didn't do anything, but save - #the list of collaborators. - &removealldata($id); - #and since they didn't do anything we were never here - return ''; - } else { - $Apache::lonhomework::results{"resource.$id.previous"} = '0'; + # did either of the overall awards chage? If so ignore the + # previous check + if (($Apache::lonhomework::results{"resource.$id.awarded"} eq + $Apache::lonhomework::history{"resource.$id.awarded"}) && + ($Apache::lonhomework::results{"resource.$id.solved"} eq + $Apache::lonhomework::history{"resource.$id.solved"})) { + # check if this was a previous submission if it was delete the + # unneeded data and update the previously_used attribute + if ( $previously_used eq 'PREVIOUSLY_USED') { + if (lc($Apache::lonhomework::problemstatus) ne 'no') { + delete($Apache::lonhomework::results{"resource.$id.tries"}); + $Apache::lonhomework::results{"resource.$id.previous"} = '1'; + } + } elsif ( $previously_used eq 'PREVIOUSLY_LAST') { + #delete all data as they student didn't do anything, but save + #the list of collaborators. + &removealldata($id); + #and since they didn't do anything we were never here + return ''; + } else { + $Apache::lonhomework::results{"resource.$id.previous"} = '0'; + } } } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~ /^correct/ ) { @@ -631,7 +663,7 @@ sub gradestatus { ($showbutton,$bgcolor,$message,$previousmsg) = &decideoutput($award,$solved,$previous,$target); if ($target eq 'tex') { - $message=' '.$message.' '; + $message='\vskip 2 mm '.$message.' '; } else { $message="$message"; if ($previousmsg) { @@ -642,24 +674,36 @@ 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'; } + my $tries_text=&mt('Tries'); + if ( $Apache::lonhomework::type eq 'survey') { $tries_text=&mt('Submissions'); } if ( $showbutton ) { if ($target eq 'tex') { if ($ENV{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam') { - $trystr = ' {\vskip 1 mm \small \textit{'.&mt('Tries').'} '.$tries.'/'.$maxtries.'} \vskip 2 mm '; + $trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.$tries.'/'.$maxtries.'} \vskip 2 mm '; } else { $trystr = '\vskip 0 mm '; } } else { - $trystr = "".&mt('Tries')." $tries/$maxtries"; + $trystr = "".$tries_text." $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"}) { @@ -678,7 +722,7 @@ sub gradestatus { if ($target eq 'tex') { return $button.' \vskip 0 mm '.$output.' '; } else { - return $button.''.$output.''; + return ''.$button.''.$output.''; } } }