--- loncom/homework/inputtags.pm 2010/12/31 19:10:16 1.271.2.4 +++ loncom/homework/inputtags.pm 2010/10/31 12:33:02 1.272 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.271.2.4 2010/12/31 19:10:16 raeburn Exp $ +# $Id: inputtags.pm,v 1.272 2010/10/31 12:33:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -175,18 +175,7 @@ sub start_textfield { if ($target eq 'web') { $Apache::lonxml::evaluate--; my $partid=$Apache::inputtags::part; - my ($oldresponse,$newvariation); - if ((($Apache::lonhomework::history{"resource.$partid.type"} eq 'randomizetry') || - ($Apache::lonhomework::type eq 'randomizetry')) && - ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) { - if ($env{'form.'.$partid.'.rndseed'} ne - $Apache::lonhomework::history{"resource.$partid.rndseed"}) { - $newvariation = 1; - } - } - unless ($newvariation) { - $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); - } + my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"'); if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval); if ( $cols eq '') { $cols = 80; } @@ -342,27 +331,16 @@ sub start_textline { $maxlength = ' maxlength="'.$size.'"'; } } - my ($oldresponse,$newvariation); - if ((($Apache::lonhomework::history{"resource.$partid.type"} eq 'randomizetry') || - ($Apache::lonhomework::type eq 'randomizetry')) && - ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) { - if ($env{'form.'.$partid.'.rndseed'} ne - $Apache::lonhomework::history{"resource.$partid.rndseed"}) { - $newvariation = 1; - } - } - unless ($newvariation) { - $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"}; - &Apache::lonxml::debug("oldresponse $oldresponse is ".ref($oldresponse)); - - if (ref($oldresponse) eq 'ARRAY') { - $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist]; - } - $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"'); - $oldresponse =~ s/^\s+//; - $oldresponse =~ s/\s+$//; - $oldresponse =~ s/\s+/ /g; - } + my $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"}; + &Apache::lonxml::debug("oldresponse $oldresponse is ".ref($oldresponse)); + + if (ref($oldresponse) eq 'ARRAY') { + $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist]; + } + $oldresponse = &HTML::Entities::encode($oldresponse,'<>&"'); + $oldresponse =~ s/^\s+//; + $oldresponse =~ s/\s+$//; + $oldresponse =~ s/\s+/ /g; if ($Apache::lonhomework::type ne 'exam') { my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval); $result=''; @@ -596,7 +574,6 @@ sub current_file_submissions { } } } - my $num = 0; foreach my $name (sort(keys(%okfiles))) { if (ref($okfiles{$name}) eq 'ARRAY') { foreach my $url (@{$okfiles{$name}}) { @@ -615,8 +592,7 @@ sub current_file_submissions { if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { $result .= ''."\n"; - $num ++; + ' value="'.$portfile.'" />'."\n"; } my $showname = $rows{$url}{path}.$name; if ($legacy{$url}) { @@ -624,7 +600,7 @@ sub current_file_submissions { } $result .= ''.$showname.''."\n". + '" border="0" />'.$showname.''."\n". ''.$rows{$url}{size}.''."\n". ''.$rows{$url}{lastmodified}.''."\n". &Apache::loncommon::end_data_table_row(); @@ -634,9 +610,7 @@ sub current_file_submissions { } } if ($header_shown) { - $result .= &Apache::loncommon::end_data_table(). - '
'. - &mt('Exclude existing file(s) from grading by checking the "Delete?" checkbox(es) and clicking "Submit Answer"').''; + $result .= &Apache::loncommon::end_data_table(); } if (@bad_file_list) { my $bad_files = ''. @@ -685,7 +659,8 @@ sub valid_award { 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', - 'BAD_FORMULA', 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', + 'BAD_FORMULA', 'NOT_FUNCTION', 'WRONG_FORMAT', + 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', 'DRAFT', 'SUBMITTED', 'SUBMITTED_CREDIT', @@ -702,7 +677,8 @@ sub valid_award { 'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', - 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'INTERNAL_ERROR', + 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'NOT_FUNCTION', + 'WRONG_FORMAT', 'INTERNAL_ERROR', 'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', 'DRAFT', 'SUBMITTED', @@ -989,7 +965,15 @@ sub decideoutput { if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Formula_Answers')}; $css_class=$possible_class{'not_charged_try'}; $button=1; - } elsif ($award eq 'INTERNAL_ERROR') { + } elsif ($award eq 'NOT_FUNCTION') { + $message = &mt("Not a function").'.'; + $css_class=$possible_class{'not_charged_try'}; + $button=1; + } elsif ($award eq 'WRONG_FORMAT') { + $message = &mt("Wrong format").'.'; + $css_class=$possible_class{'not_charged_try'}; + $button=1; + } elsif ($award eq 'INTERNAL_ERROR') { $message = &mt("An internal error occurred while processing your answer. Please try again later."); $css_class=$possible_class{'not_charged_try'}; $button=1; @@ -1266,13 +1250,9 @@ sub setgradedata { &Apache::response::add_to_gradingqueue(); } if (($Apache::lonhomework::type eq 'anonsurvey') || - ($Apache::lonhomework::type eq 'anonsurveycred') || - ($Apache::lonhomework::type eq 'randomizetry')) { + ($Apache::lonhomework::type eq 'anonsurveycred')) { $Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type; } - if ($Apache::lonhomework::type eq 'randomizetry') { - $Apache::lonhomework::results{"resource.$id.rndseed"} = $env{'form.'.$id.'.rndseed'}; - } } sub find_which_previous { @@ -1481,7 +1461,6 @@ sub previous_tries { my $count; my %count_lookup; - my $lastrndseed; foreach my $i (1..$Apache::lonhomework::history{'version'}) { my $prefix = $i.":resource.$id"; @@ -1495,8 +1474,7 @@ sub previous_tries { next if (!exists($Apache::lonhomework::history{"$prefix.award"})); $count++; $count_lookup{$i} = $count; - my $curr_rndseed = $Apache::lonhomework::history{"$prefix.rndseed"}; - + my ($previousmsg,$latemessage,$message,$trystr); ($previousmsg,$latemessage,$message,$trystr) = @@ -1518,11 +1496,6 @@ sub previous_tries { {$1 $txt_correct. $3}s; } my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")"; - if ($curr_rndseed || $lastrndseed) { - if ($curr_rndseed ne $lastrndseed) { - $trystr .= '
'.&mt('New problem variation this try.').''; - } - } $message =~ s{()}{ $trystr $1}; } my ($class) = ($message =~ m{