--- loncom/homework/inputtags.pm 2009/12/06 21:00:15 1.260.4.1 +++ loncom/homework/inputtags.pm 2010/06/17 00:13:20 1.264 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.260.4.1 2009/12/06 21:00:15 raeburn Exp $ +# $Id: inputtags.pm,v 1.264 2010/06/17 00:13:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -572,9 +572,11 @@ sub valid_award { 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', - 'EXCESS_FILESIZE', 'DRAFT', - 'SUBMITTED', 'ASSIGNED_SCORE', - 'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') { + 'EXCESS_FILESIZE', 'FILENAME_INUSE', + 'DRAFT', 'SUBMITTED', 'SUBMITTED_CREDIT', + 'ANONYMOUS', 'ANONYMOUS_CREDIT', + 'ASSIGNED_SCORE', 'APPROX_ANS', + 'EXACT_ANS','COMMA_FAIL') { if ($award eq $possibleaward) { return 1; } } return 0; @@ -587,7 +589,9 @@ sub valid_award { 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'INTERNAL_ERROR', 'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', - 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'DRAFT', 'SUBMITTED', + 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', + 'DRAFT', 'SUBMITTED', + 'SUBMITTED_CREDIT', 'ANONYMOUS', 'ANONYMOUS_CREDIT', 'ASSIGNED_SCORE', 'APPROX_ANS', 'EXACT_ANS'); my $i=0; my %fwd_awards = map { ($_,$i++) } @awards; @@ -611,7 +615,7 @@ sub hide_award { return 1; } if ($award =~ - /^(?:EXACT_ANS|APPROX_ANS|SUBMITTED|ASSIGNED_SCORE|INCORRECT)/) { + /^(?:EXACT_ANS|APPROX_ANS|SUBMITTED|SUBMITTED_CREDIT|ANONYMOUS|ANONYMOUS_CREDIT|ASSIGNED_SCORE|INCORRECT)/) { return 1; } return 0; @@ -817,6 +821,16 @@ sub decideoutput { $message = &mt('Submission won\'t be graded. The combined size of submitted files exceeded the amount allowed.'); $css_class=$possible_class{'not_charged_try'}; $button=1; + } elsif ($award eq 'FILENAME_INUSE') { + $message = &mt('You have already uploaded a file with that filename.'); + if ($target eq 'tex') { + $message.= "\\\\\n"; + } else { + $message .= '
'; + } + $message .= &mt('Please use a different file name.'); + $css_class=$possible_class{'not_charged_try'}; + $button=1; } elsif ($award eq 'INVALID_FILETYPE') { $message = &mt("Submission won't be graded. The type of file submitted is not allowed."); $css_class=$possible_class{'not_charged_try'}; @@ -869,15 +883,20 @@ sub decideoutput { $css_class=$possible_class{'charged_try'}; $button=1; } elsif ($award eq 'SUBMITTED') { - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - if ($target eq 'web') { - $message .= '
'.&mt('Thank you for making a submission to the Geosciences Concept Inventory via the GCI Web Center.'); - } - } else { - $message = &mt("Your submission has been recorded."); - } + $message = &mt("Your submission has been recorded."); $css_class=$possible_class{'no_grade'}; $button=1; + } elsif ($award eq 'SUBMITTED_CREDIT') { + $message = &mt("Your submission has been recorded, and credit awarded."); + $css_class=$possible_class{'correct'}; + $button=1; + } elsif ($award eq 'ANONYMOUS') { + $message = &mt("Your anonymous submission has been recorded."); + $css_class=$possible_class{'no_grade'}; + $button=1; + } elsif ($award eq 'ANONYMOUS_CREDIT') { + $message = &mt("Your anonymous submission has been recorded, and credit awarded."); + $css_class=$possible_class{'correct'}; } elsif ($award eq 'DRAFT') { $message = &mt("Copy saved but not submitted."); $css_class=$possible_class{'not_charged_try'}; @@ -928,14 +947,7 @@ sub decideoutput { if (&Apache::lonhomework::hide_problem_status() && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER' && &hide_award($award)) { - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - if ($target eq 'web') { - $message = &mt("Your submission has been recorded.").'
'. - &mt('Thank you for making a submission to the Geosciences Concept Inventory via the GCI Web Center.'); - } - } else { - $message = &mt("Answer Submitted: Your final submission will be graded after the due date."); - } + $message = &mt("Answer Submitted: Your final submission will be graded after the due date."); $css_class=$possible_class{'no_grade'}; $button=1; } @@ -1048,6 +1060,18 @@ sub setgradedata { $Apache::lonhomework::results{"resource.$id.solved"} = $solvemsg; $Apache::lonhomework::results{"resource.$id.awarded"} = '1'; + } elsif ( $award eq 'SUBMITTED_CREDIT' ) { + $Apache::lonhomework::results{"resource.$id.tries"} = + $Apache::lonhomework::history{"resource.$id.tries"} + 1; + $Apache::lonhomework::results{"resource.$id.solved"} = + 'credit_attempted'; + $Apache::lonhomework::results{"resource.$id.awarded"} = '1'; + } elsif ( $award eq 'ANONYMOUS_CREDIT' ) { + $Apache::lonhomework::results{"resource.$id.tries"} = + $Apache::lonhomework::history{"resource.$id.tries"} + 1; + $Apache::lonhomework::results{"resource.$id.solved"} = + 'credit_attempted'; + $Apache::lonhomework::results{"resource.$id.awarded"} = '1'; } elsif ( $award eq 'INCORRECT' ) { $Apache::lonhomework::results{"resource.$id.tries"} = $Apache::lonhomework::history{"resource.$id.tries"} + 1; @@ -1062,6 +1086,11 @@ sub setgradedata { $Apache::lonhomework::history{"resource.$id.tries"} + 1; $Apache::lonhomework::results{"resource.$id.solved"} = 'ungraded_attempted'; + } elsif ( $award eq 'ANONYMOUS' ) { + $Apache::lonhomework::results{"resource.$id.tries"} = + $Apache::lonhomework::history{"resource.$id.tries"} + 1; + $Apache::lonhomework::results{"resource.$id.solved"} = + 'ungraded_attempted'; } elsif ( $award eq 'DRAFT' ) { $Apache::lonhomework::results{"resource.$id.solved"} = ''; } elsif ( $award eq 'NO_RESPONSE' ) { @@ -1121,6 +1150,10 @@ sub setgradedata { if ($award eq 'SUBMITTED') { &Apache::response::add_to_gradingqueue(); } + if (($Apache::lonhomework::type eq 'anonsurvey') || + ($Apache::lonhomework::type eq 'anonsurveycred')) { + $Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type; + } } sub find_which_previous { @@ -1233,12 +1266,7 @@ sub get_grade_messages { 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' || - $Apache::lonhomework::parsing_a_task) { - $tries_text=&mt('Submissions'); - } - + my $tries_text= &get_tries_text();; if ($showbutton) { if ($target eq 'tex') { if ($env{'request.state'} ne "construct" @@ -1250,19 +1278,15 @@ sub get_grade_messages { $trystr = '\vskip 0 mm '; } } else { - $trystr = ''; - my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'}); - if ($parmhash{'suppress_tries'} ne 'yes') { - $trystr .= "$tries_text $tries"; - if ($Apache::lonhomework::parsing_a_task) { - } elsif($env{'request.state'} ne 'construct') { - $trystr.="/$maxtries"; - } else { - if (defined($Apache::inputtags::params{'maxtries'})) { - $trystr.="/".$Apache::inputtags::params{'maxtries'}; - } - } - } + $trystr = ''.&mt($tries_text)." $tries"; + if ($Apache::lonhomework::parsing_a_task) { + } elsif($env{'request.state'} ne 'construct') { + $trystr.="/$maxtries"; + } else { + if (defined($Apache::inputtags::params{'maxtries'})) { + $trystr.="/".$Apache::inputtags::params{'maxtries'}; + } + } $trystr.=""; } } @@ -1305,14 +1329,10 @@ sub gradestatus { } if ( $showbutton ) { if ($target ne 'tex') { - my $submit_text = &mt('Submit Answer'); - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - $submit_text = &mt('Submit Questions'); - } $button = - ''; + value="'.&mt('Submit Answer').'" />'; } } @@ -1345,7 +1365,13 @@ sub previous_tries { foreach my $i (1..$Apache::lonhomework::history{'version'}) { my $prefix = $i.":resource.$id"; - + my $is_anon; + if (defined($env{'form.grade_symb'})) { + if (($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurvey') || + ($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurveycred')) { + $is_anon = 1; + } + } next if (!exists($Apache::lonhomework::history{"$prefix.award"})); $count++; $count_lookup{$i} = $count; @@ -1390,7 +1416,11 @@ sub previous_tries { $submission = $Apache::lonhomework::history{"$prefix.submission"}; } - $output.=''.$submission.''; + if ($is_anon) { + $output.=''.&mt('(only shown to submitter)').''; + } else { + $output.=''.$submission.''; + } } else { $output.=''; } @@ -1408,12 +1438,9 @@ sub previous_tries { $output.='
'; my $windowopen=&Apache::lonhtmlcommon::javascript_docopen(); - my $pagetitle = 'Previous Tries'; - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - $pagetitle = 'Submission History'; - } + my $tries_text = &get_tries_text('link'); my $start_page = - &Apache::loncommon::start_page($pagetitle, undef, + &Apache::loncommon::start_page($tries_text, undef, {'only_body' => 1, 'bgcolor' => '#FFFFFF', 'js_ready' => 1, @@ -1424,20 +1451,38 @@ sub previous_tries { $prefix =~ tr{.}{_}; my $function_name = "LONCAPA_previous_tries_".$prefix. $Apache::lonxml::curdepth.'_'.$env{'form.counter'}; - my $triestext = &mt('Previous Tries'); - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - $triestext = &mt('Submission History'); - } my $result ="".$triestext."
"; +".&mt($tries_text)."
"; #use Data::Dumper; #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display)); return $result; } +sub get_tries_text { + my ($context) = @_; + my $tries_text; + if ($context eq 'link') { + $tries_text = 'Previous Tries'; + } else { + $tries_text = 'Tries'; + } + if ( $Apache::lonhomework::type eq 'survey' || + $Apache::lonhomework::type eq 'surveycred' || + $Apache::lonhomework::type eq 'anonsurvey' || + $Apache::lonhomework::type eq 'anonsurveycred' || + $Apache::lonhomework::parsing_a_task) { + if ($context eq 'link') { + $tries_text = 'Previous Submissions'; + } else { + $tries_text = 'Submissions'; + } + } + return $tries_text; +} + 1; __END__