--- loncom/homework/inputtags.pm 2005/04/07 06:56:21 1.165 +++ loncom/homework/inputtags.pm 2005/09/09 18:45:56 1.175 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.165 2005/04/07 06:56:21 albertel Exp $ +# $Id: inputtags.pm,v 1.175 2005/09/09 18:45:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,10 @@ sub initialize_inputtags { @Apache::inputtags::response=(); # list of all response ids seen in this problem @Apache::inputtags::responselist=(); + # list of all current hint ids + @Apache::inputtags::hint=(); + # list of all hint ids seen in this problem + @Apache::inputtags::hintlist=(); # list of whether or not a specific response was previously used @Apache::inputtags::previous=(); # submission it was used in @@ -75,6 +79,7 @@ sub check_for_duplicate_ids { my %check; foreach my $id (@Apache::inputtags::partlist, @Apache::inputtags::responselist, + @Apache::inputtags::hintlist, @Apache::inputtags::importlist) { $check{$id}++; } @@ -235,7 +240,7 @@ sub start_textline { } } else { #right or wrong don't show what was last typed in. - $result=''.$Apache::inputtags::answertxt{$id}.''; + $result=''.$Apache::inputtags::answertxt{$id}.''; #$result=''; } } elsif ($target eq 'edit') { @@ -301,10 +306,15 @@ sub end_hiddenline { # $which -> 'uploadedonly' -> only newly uploaded files # 'portfolioonly' -> only allow files from portfolio # 'both' -> allow files from either location +# $extratext -> additional text to go between the link and the input box # returns a table row sub file_selector { - my ($part,$id,$uploadedfiletypes,$which)=@_; + my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_; if (!$uploadedfiletypes) { return ''; } + + my $jspart=$part; + $jspart=~s/\./_/g; + my $result; $result.=''; @@ -315,7 +325,7 @@ sub file_selector { if ($which eq 'uploadonly' || $which eq 'both') { $result.=&mt('Submit a file: (only one file can be uploaded)'). '

'; + $jspart.'_'.$id.'" />
'; my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"'); if ($uploadedfile) { @@ -334,9 +344,9 @@ sub file_selector { $result.='
'.''.&mt('OR:').'
'; } if ($which eq 'portfolioonly' || $which eq 'both') { - $result.=''. + $result.=$extratext.''. &mt('Select Portfolio Files').'
'. - ''. + ''. '
'; if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){ my @filelist; @@ -397,7 +407,7 @@ sub finalizeawards { } sub decideoutput { - my ($award,$awardmsg,$solved,$previous,$target)=@_; + my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_; my $message=''; my $button=0; my $previousmsg; @@ -409,16 +419,28 @@ sub decideoutput { 'not_charged_try' => '#ffffaa', 'no_message' => '#fffff', ); + if ($previous) { $previousmsg=&mt('You have entered that answer before'); } if ($solved =~ /^correct/) { - if ($award eq 'ASSIGNED_SCORE') { + $bgcolor=$possiblecolors{'correct'}; + $message=&mt('You are correct.'); + if ($awarded < 1 && $awarded > 0) { + $message=&mt('You are partially correct.'); + $bgcolor=$possiblecolors{'not_charged_try'}; + } elsif ($awarded < 1) { + $message=&mt('Incorrect.'); + $bgcolor=$possiblecolors{'charged_try'}; + } + if ($env{'request.filename'} =~ + m|/res/lib/templates/examupload.problem$|) { $message = &mt("A score has been assigned."); + $added_computer_text=1; } else { if ($target eq 'tex') { - $message = '\textbf{'.&mt('You are correct.').'}'; + $message = '\textbf{'.$message.'}'; } else { - $message = "".&mt('You are correct.').""; + $message = "".$message.""; $message.=" ".&mt("Computer's answer now shown above."); } $added_computer_text=1; @@ -430,7 +452,6 @@ sub decideoutput { (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''); } } - $bgcolor=$possiblecolors{'correct'}; $button=0; $previousmsg=''; } elsif ($solved =~ /^excused/) { @@ -494,7 +515,7 @@ sub decideoutput { $bgcolor=$possiblecolors{'not_charged_try'}; $button=1; } elsif ($award eq 'INVALID_FILETYPE') { - $message = &mt('The filetype extension of the file you uploaded is not allowed.'); + $message = &mt('Submission won\'t be graded. The type of file submitted is not allowed.'); $bgcolor=$possiblecolors{'not_charged_try'}; $button=1; } elsif ($award eq 'SIG_FAIL') { @@ -783,6 +804,7 @@ sub gradestatus { if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE' && $status ne 'INVALID_ACCESS') { my $award = $Apache::lonhomework::history{"resource.$id.award"}; + my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"}; my $solved = $Apache::lonhomework::history{"resource.$id.solved"}; my $previous = $Apache::lonhomework::history{"resource.$id.previous"}; my $awardmsg = $Apache::lonhomework::history{"resource.$id.awardmsg"}; @@ -790,7 +812,8 @@ sub gradestatus { if ( $award ne '' || $solved ne '' || $status eq 'SHOW_ANSWER') { &Apache::lonxml::debug('Getting message'); ($showbutton,$bgcolor,$message,$previousmsg) = - &decideoutput($award,$awardmsg,$solved,$previous,$target); + &decideoutput($award,$awarded,$awardmsg,$solved,$previous, + $target); if ($target eq 'tex') { $message='\vskip 2 mm '.$message.' '; } else {