--- loncom/homework/inputtags.pm 2010/09/13 04:26:26 1.260.4.2 +++ loncom/homework/inputtags.pm 2010/06/21 02:15:37 1.265 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.260.4.2 2010/09/13 04:26:26 raeburn Exp $ +# $Id: inputtags.pm,v 1.265 2010/06/21 02:15:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -483,7 +483,7 @@ sub file_selector { my $current_files_display = ¤t_file_submissions($part,$id); my $addfiles; if ($current_files_display) { - $result .= &Apache::lonhtmlcommon::row_title(&mt('Currently submitted files')). + $result .= &Apache::lonhtmlcommon::row_title(&mt('Currently submitted files:')). $current_files_display. &Apache::lonhtmlcommon::row_closure(); $addfiles = &mt('Submit other file(s)'); @@ -504,16 +504,16 @@ sub file_selector { $result .= $constraints.'
'; } if ($which eq 'uploadonly' || $which eq 'both') { - $result.=&mt('Submit a file: (only one file per submission)'). + $result.=&mt('Submit a file: (only one file per submission)'). '

'; } - if ( $which eq 'both') { + if ( $which eq 'both') { $result.='
'.''.&mt('OR:').'
'; } if ($which eq 'portfolioonly' || $which eq 'both') { $result.=$extratext.''. - &mt('Select Portfolio Files: (one or more files per submission)').'
'. + &mt('Select Portfolio Files: (one or more files per submission)').'
'. ''. '
'; @@ -526,31 +526,27 @@ sub current_file_submissions { my ($part,$id) = @_; my $jspart=$part; $jspart=~s/\./_/g; - my $uploadedfile=$Apache::lonhomework::history{"resource.$part.$id.uploadedfile"}; + my $uploadedfile=&HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"'); my $portfiles=$Apache::lonhomework::history{"resource.$part.$id.portfiles"}; return if (($uploadedfile eq '') && ($portfiles !~/[^\s]/)); my $header = &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(); - if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { - $header .= ''.&mt('Delete?').''; - } - $header .= ''.&mt('File').''. + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Delete?').''. + ''.&mt('Name').''. ''.&mt('Size (MB)').''. ''.&mt('Last Modified').''. &Apache::loncommon::end_data_table_header_row(); my (undef,$crsid,$udom,$uname)=&Apache::lonnet::whichuser(); my ($cdom,$cnum) = ($crsid =~ /^($LONCAPA::match_domain)_($LONCAPA::match_courseid)$/); - my ($result,$header_shown,%okfiles,%rows,%legacy,@bad_file_list); + my ($result,$header_shown,%okfiles,%rows,@bad_file_list); if ($uploadedfile) { my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"}; - my $link = &HTML::Entities::encode($url,'<>&"'); - my ($path,$name) = ($url =~ m{^(/uploaded/\Q$udom\E/\Q$uname\E/essayresponse.*/)([^/]+)$}); + my ($path,$name) = ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E/(essayresponse/.+/)([^/]+))}); my ($status,$hashref,$error) = - ¤t_file_info($url,$link,$name,$path); + ¤t_file_info($url,$uploadedfile,$name,$path); if ($status eq 'ok') { push(@{$okfiles{$name}},$url); $rows{$url} = $hashref; - $legacy{$url} = 1; &Apache::lonxml::extlink($url); &Apache::lonnet::allowuploaded('/adm/essayresponse',$url); } else { @@ -587,22 +583,11 @@ sub current_file_submissions { $header_shown = 1; } $result.= - &Apache::loncommon::start_data_table_row()."\n"; - if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') { - $result .= - ''."\n"; - } - my $showname = $rows{$url}{path}.$name; - if ($legacy{$url}) { - $showname = $name.' '.&mt('not in portfolio'); - } - if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') { - $showname = $name; - } - $result .= + &Apache::loncommon::start_data_table_row()."\n". + ''."\n". ''.$showname.''."\n". + '" border="0" />'.$name.''."\n". ''.$rows{$url}{size}.''."\n". ''.$rows{$url}{lastmodified}.''."\n". &Apache::loncommon::end_data_table_row(); @@ -615,12 +600,12 @@ sub current_file_submissions { $result .= &Apache::loncommon::end_data_table(); } if (@bad_file_list) { - my $bad_files = ''. - join(', ',@bad_file_list). - ''; - $result.='

'. - &mt("These file(s) don't exist: [_1]",$bad_files). - '

'; + my $bad_files = ''. + join(', ',@bad_file_list). + ''; + $result.='

'. + &mt("These file(s) don't exist: [_1]",$bad_files). + '

'; } return $result; } @@ -664,8 +649,10 @@ sub valid_award { 'BAD_FORMULA', 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', - 'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE', - 'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') { + 'DRAFT', 'SUBMITTED', 'SUBMITTED_CREDIT', + 'ANONYMOUS', 'ANONYMOUS_CREDIT', + 'ASSIGNED_SCORE', 'APPROX_ANS', + 'EXACT_ANS','COMMA_FAIL') { if ($award eq $possibleaward) { return 1; } } return 0; @@ -678,8 +665,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', 'FILENAME_INUSE', + '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; @@ -703,7 +691,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; @@ -971,15 +959,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'}; @@ -1030,14 +1023,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; } @@ -1150,6 +1136,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; @@ -1164,6 +1162,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' ) { @@ -1223,6 +1226,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 { @@ -1335,12 +1342,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" @@ -1352,19 +1354,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.=""; } } @@ -1407,14 +1405,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').'" />'; } } @@ -1447,7 +1441,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; @@ -1492,7 +1492,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.=''; } @@ -1510,12 +1514,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, @@ -1526,20 +1527,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__