--- loncom/homework/inputtags.pm 2009/09/14 17:03:42 1.248.4.2 +++ loncom/homework/inputtags.pm 2009/04/16 14:45:47 1.257 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.248.4.2 2009/09/14 17:03:42 raeburn Exp $ +# $Id: inputtags.pm,v 1.257 2009/04/16 14:45:47 onken Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,6 +25,30 @@ # # http://www.lon-capa.org/ +=pod + +=head1 NAME + +Apache::inputtags + +=head1 SYNOPSIS + + + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + + +=head1 NOTABLE SUBROUTINES + +=over + +=item + +=back + +=cut + package Apache::inputtags; use HTML::Entities(); use strict; @@ -38,41 +62,47 @@ BEGIN { &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline')); } -# Initializes a set of global variables used during the parse of the problem. -# -# @Apache::inputtags::input - List of current input ids. -# @Apache::inputtags::inputlist - List of all input ids seen this problem. -# @Apache::inputtags::response - List of all current resopnse ids. -# @Apache::inputtags::responselist - List of all response ids seen this -# problem. -# @Apache::inputtags::hint - List of all hint ids. -# @Apache::inputtags::hintlist - List of all hint ids seen this problem. -# @Apache::inputtags::previous - List describing if specific responseds -# have been used -# @Apache::inputtags::previous_version - Submission responses were used in. -# $Apache::inputtags::part - Current part id (valid only in -# ) -# 0 if not in a part. -# @Apache::inputtags::partlist - List of part ids seen in the current -# -# @Apache::inputtags::status - List of problem statuses. First -# element is the status of the -# the remainder are for individual s. -# %Apache::inputtags::params - Hash of defined parameters for the -# current response. -# @Apache::inputtags::import - List of all ids for thes get -# join()ed and prepended. -# @Apache::inputtags::importlist - List of all import ids seen. -# $Apache::inputtags::response_with_no_part -# - Flag set true if we have seen a response -# that is not inside a -# %Apache::inputtags::answertxt - <*response> tags store correct -# answer strings for display by -# in this hash. -# %Apache::inputtags::submission_display -# - <*response> tags store improved display -# of submission strings for display by part -# end. +=pod + +=item initialize_inputtags() + +Initializes a set of global variables used during the parse of the problem. + +@Apache::inputtags::input - List of current input ids. +@Apache::inputtags::inputlist - List of all input ids seen this problem. +@Apache::inputtags::response - List of all current resopnse ids. +@Apache::inputtags::responselist - List of all response ids seen this + problem. +@Apache::inputtags::hint - List of all hint ids. +@Apache::inputtags::hintlist - List of all hint ids seen this problem. +@Apache::inputtags::previous - List describing if specific responseds + have been used +@Apache::inputtags::previous_version - Submission responses were used in. +$Apache::inputtags::part - Current part id (valid only in + ) + 0 if not in a part. +@Apache::inputtags::partlist - List of part ids seen in the current + +@Apache::inputtags::status - List of problem statuses. First + element is the status of the + the remainder are for individual s. +%Apache::inputtags::params - Hash of defined parameters for the + current response. +@Apache::inputtags::import - List of all ids for thes get + join()ed and prepended. +@Apache::inputtags::importlist - List of all import ids seen. +$Apache::inputtags::response_with_no_part + - Flag set true if we have seen a response + that is not inside a +%Apache::inputtags::answertxt - <*response> tags store correct + answer strings for display by + in this hash. +%Apache::inputtags::submission_display + - <*response> tags store improved display + of submission strings for display by part + end. + +=cut sub initialize_inputtags { @Apache::inputtags::input=(); @@ -358,7 +388,8 @@ sub start_textline { && $Apache::lonhomework::type ne 'exam') { my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval); if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';} - if ($env{'form.pdfFormFields'} eq 'yes') { + if ($env{'form.pdfFormFields'} eq 'yes' + && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') { my $fieldname = $env{'request.symb'}. '&part_'. $Apache::inputtags::part. '&textresponse'. @@ -424,15 +455,22 @@ sub end_hiddenline { return ""; } -# $part -> partid -# $id -> responseid -# $uploadefiletypes -> comma seperated list of extensions allowed or * for any -# $which -> 'uploadonly' -> only newly uploaded files -# 'portfolioonly' -> only allow files from portfolio -# 'both' -> allow files from either location -# $extratext -> additional text to go between the link and the input box -# $maxfilesize -> maximum cumulative filesize for submitted files (in MB). -# returns a table row +=pod + +=item file_selector() + +$part -> partid +$id -> responseid +$uploadefiletypes -> comma seperated list of extensions allowed or * for any +$which -> 'uploadonly' -> only newly uploaded files + 'portfolioonly' -> only allow files from portfolio + 'both' -> allow files from either location +$extratext -> additional text to go between the link and the input box +$maxfilesize -> maximum cumulative filesize for submitted files (in MB). +returns a table row + +=cut + sub file_selector { my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_; if (!$uploadedfiletypes) { return ''; } @@ -445,8 +483,8 @@ sub file_selector { $result.=''; if (($uploadedfiletypes ne '*') || ($maxfilesize)) { if ($uploadedfiletypes ne '*') { - $result.= - &mt('Allowed filetypes: [_1]',''.$uploadedfiletypes.'').'
'; + $result.= + &mt('Allowed filetypes: [_1]',''.$uploadedfiletypes.'').'
'; } if ($maxfilesize) { $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].', @@ -486,7 +524,7 @@ sub show_past_file_submission { my $icon=&Apache::loncommon::icon($url); my $curfile=''.$uploadedfile.''; - return &mt('Currently submitted: [_1]',$curfile); + return &mt('Currently submitted: [_1]',''.$curfile.''); } @@ -516,7 +554,9 @@ sub show_past_portfile_submission { my $bad_files = ''. join(', ',@bad_file_list). ''; - $result.='
'.&mt('These file(s) don\'t exist: [_1]',$bad_files); + $result.='

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

'; } return $result; @@ -642,6 +682,7 @@ sub finalizeawards { sub decideoutput { my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_; + my $message=''; my $button=0; my $previousmsg; @@ -695,7 +736,7 @@ sub decideoutput { '.disable_receipt_display'} ne 'yes') && ($Apache::lonhomework::type ne 'practice')) { $message.=(($target eq 'web')?'
':' '). - &mt('Your receipt is [_1]', + &mt('Your receipt no. is [_1]', (&Apache::lonnet::receipt($Apache::inputtags::part). (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''))); } @@ -777,13 +818,13 @@ sub decideoutput { $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.'); + $message = &mt("Submission won't be graded. The type of file submitted is not allowed."); $css_class=$possible_class{'not_charged_try'}; $button=1; } elsif ($award eq 'SIG_FAIL') { my ($used,$min,$max)=split(':',$awardmsg); my $word = ($used < $min) ? 'more' : 'fewer'; - $message = &mt("Submission not graded. Use $word digits.",$used); + $message = &mt("Submission not graded. Use $word digits.",$used); $css_class=$possible_class{'not_charged_try'}; $button=1; } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') { @@ -829,11 +870,6 @@ sub decideoutput { $button=1; } elsif ($award eq 'SUBMITTED') { $message = &mt("Your submission has been recorded."); - 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.'); - } - } $css_class=$possible_class{'no_grade'}; $button=1; } elsif ($award eq 'DRAFT') { @@ -886,14 +922,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; } @@ -1208,19 +1237,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 = ''.$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.=""; } } @@ -1261,18 +1286,14 @@ sub gradestatus { if ( $status eq 'SHOW_ANSWER') { undef($previousmsg); } - 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'); - } + if ( $showbutton ) { + if ($target ne 'tex') { $button = ''; + value="'.&mt('Submit Answer').'" />'; } } @@ -1380,15 +1401,11 @@ 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("Previous Tries")."
"; #use Data::Dumper; #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display)); return $result; @@ -1396,4 +1413,10 @@ sub previous_tries { 1; __END__ + +=pod + +=back + +=cut