--- loncom/homework/inputtags.pm 2011/10/10 17:47:58 1.271.2.9
+++ loncom/homework/inputtags.pm 2010/11/03 17:06:28 1.273
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.271.2.9 2011/10/10 17:47:58 raeburn Exp $
+# $Id: inputtags.pm,v 1.273 2010/11/03 17:06:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ use LONCAPA;
BEGIN {
- &Apache::lonxml::register('Apache::inputtags',('hiddensubmission','hiddenline','textfield','textline'));
+ &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
}
=pod
@@ -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='';
@@ -479,48 +457,6 @@ sub end_hiddenline {
return "";
}
-sub start_hiddensubmission {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- my $result = "";
- my $input_id = &start_input($parstack,$safeeval);
- if ($target eq 'web') {
- $Apache::lonxml::evaluate--;
- if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
- my $partid=$Apache::inputtags::part;
- my $id=$Apache::inputtags::response[-1];
- if ($Apache::lonhomework::type ne 'exam') {
- my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
- $value = &HTML::Entities::encode($value,'<>&"');
- $result= '';
- }
- }
- } elsif ($target eq 'edit') {
- $result=&Apache::edit::tag_start($target,$token);
- $result.=&Apache::edit::text_arg('Value:','value',$token,'15');
- $result.=&Apache::edit::end_row();
- $result.=&Apache::edit::end_table();
- } elsif ($target eq 'modified') {
- my $constructtag=&Apache::edit::get_new_args($token,$parstack,
- $safeeval,'value');
- if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
- }
-
- if ( ($target eq 'web' || $target eq 'tex')
- && $Apache::lonhomework::type eq 'exam'
- && &needs_exam_box($tagstack)) {
- $result.=&exam_box($target);
- }
- return $result;
-}
-
-sub end_hiddensubmission {
- my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- if ($target eq 'web') { $Apache::lonxml::evaluate++; }
- elsif ($target eq 'edit') { return ('','no'); }
- &end_input();
- return "";
-}
-
=pod
=item file_selector()
@@ -638,9 +574,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};
@@ -666,7 +602,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();
@@ -678,7 +614,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"').'';
+ &mt('Items checked for deletion will not be included amongst the files evaluated when your submission is graded.').'';
}
if (@bad_file_list) {
my $bad_files = ''.
@@ -728,7 +664,7 @@ sub valid_award {
'UNIT_FAIL', 'NO_UNIT',
'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
'BAD_FORMULA', 'NOT_FUNCTION', 'WRONG_FORMAT',
- 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT',
+ 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT',
'MISORDERED_RANK', 'INVALID_FILETYPE',
'EXCESS_FILESIZE', 'FILENAME_INUSE',
'DRAFT', 'SUBMITTED', 'SUBMITTED_CREDIT',
@@ -746,7 +682,7 @@ sub valid_award {
'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT',
'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT',
'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'NOT_FUNCTION',
- 'WRONG_FORMAT', 'INTERNAL_ERROR',
+ 'WRONG_FORMAT', 'INTERNAL_ERROR',
'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK',
'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE',
'DRAFT', 'SUBMITTED',
@@ -844,7 +780,7 @@ sub finalizeawards {
}
sub decideoutput {
- my ($award,$awarded,$awardmsg,$solved,$previous,$target,$nocorrect)=@_;
+ my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
my $message='';
my $button=0;
@@ -862,14 +798,8 @@ 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 || $nocorrect)? ''
+
+ my $computer = ($handgrade)? ''
: " ".&mt("Computer's answer now shown above.");
&Apache::lonxml::debug("handgrade has :$handgrade:");
@@ -885,8 +815,8 @@ sub decideoutput {
$message=&mt('Incorrect.');
$css_class=$possible_class{'charged_try'};
}
- if ($handgrade ||
- ($env{'request.filename'}=~ m{/res/lib/templates/(examupload|DropBox)\.problem$})) {
+ if ($env{'request.filename'} =~
+ m|/res/lib/templates/examupload.problem$|) {
$message = &mt("A score has been assigned.");
$added_computer_text=1;
} else {
@@ -1047,7 +977,7 @@ sub decideoutput {
$message = &mt("Wrong format").'.';
$css_class=$possible_class{'not_charged_try'};
$button=1;
- } elsif ($award eq 'INTERNAL_ERROR') {
+ } 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;
@@ -1324,13 +1254,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 {
@@ -1410,8 +1336,8 @@ sub grade {
}
sub get_grade_messages {
- my ($id,$prefix,$target,$status,$nocorrect) = @_;
-# nocorrect suppresses "Computer's answer now shown above"
+ my ($id,$prefix,$target,$status) = @_;
+
my ($message,$latemessage,$trystr,$previousmsg);
my $showbutton = 1;
@@ -1425,7 +1351,7 @@ sub get_grade_messages {
&Apache::lonxml::debug('Getting message');
($showbutton,my $css_class,$message,$previousmsg) =
&decideoutput($award,$awarded,$awardmsg,$solved,$previous,
- $target,(($status eq 'CAN_ANSWER') || $nocorrect));
+ $target);
if ($target eq 'tex') {
$message='\vskip 2 mm '.$message.' ';
} else {
@@ -1443,30 +1369,28 @@ sub get_grade_messages {
if ( $tries eq '' ) { $tries = '0'; }
if ( $maxtries eq '' ) { $maxtries = '2'; }
if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; }
- my $tries_text= &get_tries_text();
+ my $tries_text= &get_tries_text();;
if ($showbutton) {
if ($target eq 'tex') {
if ($env{'request.state'} ne "construct"
&& $Apache::lonhomework::type ne 'exam'
&& $env{'form.suppress_tries'} ne 'yes') {
- $trystr ='{\vskip 1 mm \small '
- .&mt('[_1]'.$tries_text.'[_2] [_3]'
- ,'\textit{','}',$tries.'/'.$maxtries )
- .'} \vskip 2 mm';
+ $trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.
+ $tries.'/'.$maxtries.'} \vskip 2 mm ';
} else {
$trystr = '\vskip 0 mm ';
}
} else {
- my $trial = $tries;
+ $trystr = ''.&mt($tries_text)." $tries";
if ($Apache::lonhomework::parsing_a_task) {
} elsif($env{'request.state'} ne 'construct') {
- $trial.="/$maxtries";
+ $trystr.="/$maxtries";
} else {
if (defined($Apache::inputtags::params{'maxtries'})) {
- $trial.="/".$Apache::inputtags::params{'maxtries'};
+ $trystr.="/".$Apache::inputtags::params{'maxtries'};
}
}
- $trystr.=' | '.&mt("$tries_text [_1]",$trial).' | ';
+ $trystr.="";
}
}
@@ -1541,7 +1465,6 @@ sub previous_tries {
my $count;
my %count_lookup;
- my $lastrndseed;
foreach my $i (1..$Apache::lonhomework::history{'version'}) {
my $prefix = $i.":resource.$id";
@@ -1555,8 +1478,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) =
@@ -1574,25 +1496,10 @@ 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;
}
my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")";
- if (($curr_rndseed || $lastrndseed) && ($i > 1)) {
- if ($curr_rndseed ne $lastrndseed) {
- $trystr .= '
'.&mt('New problem variation this try.').'';
- }
- }
$message =~ s{()}{ $trystr $1};
}
my ($class) = ($message =~ m{