--- loncom/homework/inputtags.pm 2010/12/21 14:56:03 1.271.2.3
+++ loncom/homework/inputtags.pm 2011/03/07 19:42:21 1.282
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.271.2.3 2010/12/21 14:56:03 raeburn Exp $
+# $Id: inputtags.pm,v 1.282 2011/03/07 19:42:21 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -354,7 +354,6 @@ sub start_textline {
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];
}
@@ -596,9 +595,9 @@ sub current_file_submissions {
}
}
}
+ my $num = 0;
foreach my $name (sort(keys(%okfiles))) {
if (ref($okfiles{$name}) eq 'ARRAY') {
- my $num = 0;
foreach my $url (@{$okfiles{$name}}) {
if (ref($rows{$url}) eq 'HASH') {
my $link = $rows{$url}{link};
@@ -624,7 +623,7 @@ sub current_file_submissions {
}
$result .=
'
'.$showname.' | '."\n".
+ '" border="0" alt="" />'.$showname.''."\n".
''.$rows{$url}{size}.' | '."\n".
''.$rows{$url}{lastmodified}.' | '."\n".
&Apache::loncommon::end_data_table_row();
@@ -636,7 +635,7 @@ sub current_file_submissions {
if ($header_shown) {
$result .= &Apache::loncommon::end_data_table().
'
'.
- &mt('Items checked for deletion will not be included amongst the files evaluated when your submission is graded.').'';
+ &mt('Exclude existing file(s) from grading by checking the "Delete?" checkbox(es) and clicking "Submit Answer"').'';
}
if (@bad_file_list) {
my $bad_files = ''.
@@ -685,7 +684,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 +702,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',
@@ -800,7 +801,7 @@ sub finalizeawards {
}
sub decideoutput {
- my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
+ my ($award,$awarded,$awardmsg,$solved,$previous,$target,$nocorrect)=@_;
my $message='';
my $button=0;
@@ -818,8 +819,14 @@ sub decideoutput {
my $part = $Apache::inputtags::part;
my $tohandgrade = &Apache::lonnet::EXT("resource.$part.handgrade");
my $handgrade = ('yes' eq lc($tohandgrade));
+#
+# Should "Computer's Answer" be displayed?
+# Should not be displayed if still answerable,
+# if the problem is handgraded,
+# or if the problem does not give a correct answer
+#
- my $computer = ($handgrade)? ''
+ my $computer = ($handgrade || $nocorrect)? ''
: " ".&mt("Computer's answer now shown above.");
&Apache::lonxml::debug("handgrade has :$handgrade:");
@@ -989,7 +996,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,7 +1281,7 @@ sub setgradedata {
&Apache::response::add_to_gradingqueue();
}
if (($Apache::lonhomework::type eq 'anonsurvey') ||
- ($Apache::lonhomework::type eq 'anonsurveycred') ||
+ ($Apache::lonhomework::type eq 'anonsurveycred') ||
($Apache::lonhomework::type eq 'randomizetry')) {
$Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type;
}
@@ -1352,8 +1367,8 @@ sub grade {
}
sub get_grade_messages {
- my ($id,$prefix,$target,$status) = @_;
-
+ my ($id,$prefix,$target,$status,$nocorrect) = @_;
+# nocorrect suppresses "Computer's answer now shown above"
my ($message,$latemessage,$trystr,$previousmsg);
my $showbutton = 1;
@@ -1367,7 +1382,7 @@ sub get_grade_messages {
&Apache::lonxml::debug('Getting message');
($showbutton,my $css_class,$message,$previousmsg) =
&decideoutput($award,$awarded,$awardmsg,$solved,$previous,
- $target);
+ $target,(($status eq 'CAN_ANSWER') || $nocorrect));
if ($target eq 'tex') {
$message='\vskip 2 mm '.$message.' ';
} else {
@@ -1400,7 +1415,7 @@ sub get_grade_messages {
$trystr = ''.&mt($tries_text)." $tries";
if ($Apache::lonhomework::parsing_a_task) {
} elsif($env{'request.state'} ne 'construct') {
- $trystr.="/$maxtries";
+ $trystr.="/".&Apache::lonhtmlcommon::direct_parm_link($maxtries,$env{'request.symb'},'maxtries',$id,$target);
} else {
if (defined($Apache::inputtags::params{'maxtries'})) {
$trystr.="/".$Apache::inputtags::params{'maxtries'};
@@ -1496,7 +1511,6 @@ sub previous_tries {
$count++;
$count_lookup{$i} = $count;
my $curr_rndseed = $Apache::lonhomework::history{"$prefix.rndseed"};
-
my ($previousmsg,$latemessage,$message,$trystr);
($previousmsg,$latemessage,$message,$trystr) =
@@ -1514,6 +1528,16 @@ sub previous_tries {
) {
my $txt_correct = &mt('Correct');
+ my $awarded = $Apache::lonhomework::history{"$prefix.awarded"};
+ if ($awarded < 1 && $awarded > 0) {
+ $txt_correct=&mt('Partially Correct');
+ } elsif ($awarded < 1) {
+ if ($awarded eq '') {
+ $txt_correct='';
+ } else {
+ $txt_correct=&mt('Incorrect');
+ }
+ }
$message =~ s{( | )(.*?)()}
{$1 $txt_correct. $3}s;
}
@@ -1522,7 +1546,7 @@ sub previous_tries {
if ($curr_rndseed ne $lastrndseed) {
$trystr .= '
'.&mt('New problem variation this try.').'';
}
- }
+ }
$message =~ s{()}{ $trystr $1};
}
my ($class) = ($message =~ m{