Diff for /loncom/homework/inputtags.pm between versions 1.248.4.2 and 1.254

version 1.248.4.2, 2009/09/14 17:03:42 version 1.254, 2008/12/15 20:24:53
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # 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;  package Apache::inputtags;
 use HTML::Entities();  use HTML::Entities();
 use strict;  use strict;
Line 38  BEGIN { Line 62  BEGIN {
     &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));      &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
 }  }
   
 #   Initializes a set of global variables used during the parse of the problem.  =pod
 #  
 #  @Apache::inputtags::input        - List of current input ids.  =item initialize_inputtags()
 #  @Apache::inputtags::inputlist    - List of all input ids seen this problem.  
 #  @Apache::inputtags::response     - List of all current resopnse ids.  Initializes a set of global variables used during the parse of the problem.
 #  @Apache::inputtags::responselist - List of all response ids seen this   
 #                                       problem.  @Apache::inputtags::input        - List of current input ids.
 #  @Apache::inputtags::hint         - List of all hint ids.  @Apache::inputtags::inputlist    - List of all input ids seen this problem.
 #  @Apache::inputtags::hintlist     - List of all hint ids seen this problem.  @Apache::inputtags::response     - List of all current resopnse ids.
 #  @Apache::inputtags::previous     - List describing if specific responseds  @Apache::inputtags::responselist - List of all response ids seen this 
 #                                       have been used                                       problem.
 #  @Apache::inputtags::previous_version - Submission responses were used in.  @Apache::inputtags::hint         - List of all hint ids.
 #  $Apache::inputtags::part         - Current part id (valid only in   @Apache::inputtags::hintlist     - List of all hint ids seen this problem.
 #                                       <problem>)  @Apache::inputtags::previous     - List describing if specific responseds
 #                                     0 if not in a part.                                       have been used
 #  @Apache::inputtags::partlist     - List of part ids seen in the current  @Apache::inputtags::previous_version - Submission responses were used in.
 #                                       <problem>  $Apache::inputtags::part         - Current part id (valid only in 
 #  @Apache::inputtags::status       - List of problem  statuses. First                                        <problem>)
 #                                     element is the status of the <problem>                                     0 if not in a part.
 #                                     the remainder are for individual <part>s.  @Apache::inputtags::partlist     - List of part ids seen in the current
 #  %Apache::inputtags::params       - Hash of defined parameters for the                                       <problem>
 #                                     current response.  @Apache::inputtags::status       - List of problem  statuses. First 
 #  @Apache::inputtags::import       - List of all ids for <import> thes get                                     element is the status of the <problem>
 #                                     join()ed and prepended.                                     the remainder are for individual <part>s.
 #  @Apache::inputtags::importlist   - List of all import ids seen.  %Apache::inputtags::params       - Hash of defined parameters for the
 #  $Apache::inputtags::response_with_no_part                                     current response.
 #                                   - Flag set true if we have seen a response  @Apache::inputtags::import       - List of all ids for <import> thes get
 #                                     that is not inside a <part>                                     join()ed and prepended.
 #  %Apache::inputtags::answertxt    - <*response> tags store correct  @Apache::inputtags::importlist   - List of all import ids seen.
 #                                     answer strings for display by <textline/>  $Apache::inputtags::response_with_no_part
 #                                     in this hash.                                   - Flag set true if we have seen a response
 #  %Apache::inputtags::submission_display                                     that is not inside a <part>
 #                                   - <*response> tags store improved display  %Apache::inputtags::answertxt    - <*response> tags store correct
 #                                     of submission strings for display by part                                     answer strings for display by <textline/>
 #                                     end.                                     in this hash.
   %Apache::inputtags::submission_display
                                    - <*response> tags store improved display
                                      of submission strings for display by part
                                      end.
   
   =cut
   
 sub initialize_inputtags {  sub initialize_inputtags {
     @Apache::inputtags::input=();      @Apache::inputtags::input=();
Line 424  sub end_hiddenline { Line 454  sub end_hiddenline {
     return "";      return "";
 }  }
   
 # $part -> partid  =pod
 # $id -> responseid  
 # $uploadefiletypes -> comma seperated list of extensions allowed or * for any  =item file_selector()
 # $which -> 'uploadonly'  -> only newly uploaded files  
 #           'portfolioonly' -> only allow files from portfolio  $part -> partid
 #           'both' -> allow files from either location  $id -> responseid
 # $extratext -> additional text to go between the link and the input box  $uploadefiletypes -> comma seperated list of extensions allowed or * for any
 # $maxfilesize -> maximum cumulative filesize for submitted files (in MB).  $which -> 'uploadonly'  -> only newly uploaded files
 # returns a table row <tr>             '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 <tr> 
   
   =cut
   
 sub file_selector {  sub file_selector {
     my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;      my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;
     if (!$uploadedfiletypes) { return ''; }      if (!$uploadedfiletypes) { return ''; }
Line 445  sub file_selector { Line 482  sub file_selector {
     $result.='<tr><td>';      $result.='<tr><td>';
     if (($uploadedfiletypes ne '*') || ($maxfilesize)) {      if (($uploadedfiletypes ne '*') || ($maxfilesize)) {
         if ($uploadedfiletypes ne '*') {          if ($uploadedfiletypes ne '*') {
             $result.=      $result.=
                 &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';          &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';
         }          }
         if ($maxfilesize) {          if ($maxfilesize) {
             $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',              $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',
Line 486  sub show_past_file_submission { Line 523  sub show_past_file_submission {
     my $icon=&Apache::loncommon::icon($url);      my $icon=&Apache::loncommon::icon($url);
     my $curfile='<a href="'.$url.'"><img src="'.$icon.      my $curfile='<a href="'.$url.'"><img src="'.$icon.
  '" border="0" />'.$uploadedfile.'</a>';   '" border="0" />'.$uploadedfile.'</a>';
     return &mt('Currently submitted: <tt>[_1]</tt>',$curfile);      return &mt('Currently submitted: [_1]','<tt>'.$curfile.'</tt>');
   
 }  }
   
Line 516  sub show_past_portfile_submission { Line 553  sub show_past_portfile_submission {
  my $bad_files = '<span class="LC_filename">'.   my $bad_files = '<span class="LC_filename">'.
     join('</span>, <span class="LC_filename">',@bad_file_list).      join('</span>, <span class="LC_filename">',@bad_file_list).
     '</span>';      '</span>';
  $result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);   $result.='<p><span class="LC_error">'
                   .&mt("These file(s) don't exist: [_1]",$bad_files)
                   .'</span></p>';
     }      }
     return $result;      return $result;
   
Line 642  sub finalizeawards { Line 681  sub finalizeawards {
   
 sub decideoutput {  sub decideoutput {
     my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;      my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
   
     my $message='';      my $message='';
     my $button=0;      my $button=0;
     my $previousmsg;      my $previousmsg;
Line 783  sub decideoutput { Line 823  sub decideoutput {
     } elsif ($award eq 'SIG_FAIL') {      } elsif ($award eq 'SIG_FAIL') {
  my ($used,$min,$max)=split(':',$awardmsg);   my ($used,$min,$max)=split(':',$awardmsg);
  my $word = ($used < $min) ? 'more' : 'fewer';   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'};   $css_class=$possible_class{'not_charged_try'};
  $button=1;   $button=1;
     } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {      } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {
Line 829  sub decideoutput { Line 869  sub decideoutput {
  $button=1;   $button=1;
     } elsif ($award eq 'SUBMITTED') {      } elsif ($award eq 'SUBMITTED') {
  $message = &mt("Your submission has been recorded.");   $message = &mt("Your submission has been recorded.");
         if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') {  
             if ($target eq 'web') {  
                 $message .= '<br />'.&mt('Thank you for making a submission to the Geosciences Concept Inventory via the GCI Web Center.');  
             }  
         }  
  $css_class=$possible_class{'no_grade'};   $css_class=$possible_class{'no_grade'};
  $button=1;   $button=1;
     } elsif ($award eq 'DRAFT') {      } elsif ($award eq 'DRAFT') {
Line 886  sub decideoutput { Line 921  sub decideoutput {
     if (&Apache::lonhomework::hide_problem_status()      if (&Apache::lonhomework::hide_problem_status()
  && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER'   && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER'
  && &hide_award($award)) {   && &hide_award($award)) {
         if ($env{'request.uri'} eq '/res/gci/gci/internal/submission.problem') {   $message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
             if ($target eq 'web') {  
                 $message = &mt("Your submission has been recorded.").'<br />'.  
                            &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.");  
         }  
  $css_class=$possible_class{'no_grade'};   $css_class=$possible_class{'no_grade'};
  $button=1;   $button=1;
     }      }
Line 1208  sub get_grade_messages { Line 1236  sub get_grade_messages {
  $trystr = '\vskip 0 mm ';   $trystr = '\vskip 0 mm ';
     }      }
  } else {   } else {
             $trystr = '<td><span class="LC_nobreak">';      $trystr = '<td><span class="LC_nobreak">'.$tries_text." $tries";
             my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});      if ($Apache::lonhomework::parsing_a_task) {
             if ($parmhash{'suppress_tries'} ne 'yes') {      } elsif($env{'request.state'} ne 'construct') {
                 $trystr .= "$tries_text $tries";   $trystr.="/$maxtries";
         if ($Apache::lonhomework::parsing_a_task) {      } else {
         } elsif($env{'request.state'} ne 'construct') {   if (defined($Apache::inputtags::params{'maxtries'})) {
     $trystr.="/$maxtries";      $trystr.="/".$Apache::inputtags::params{'maxtries'};
         } else {   }
     if (defined($Apache::inputtags::params{'maxtries'})) {      }
         $trystr.="/".$Apache::inputtags::params{'maxtries'};  
     }  
         }  
             }  
     $trystr.="</span></td>";      $trystr.="</span></td>";
  }   }
     }      }
Line 1261  sub gradestatus { Line 1285  sub gradestatus {
  if ( $status eq 'SHOW_ANSWER') {   if ( $status eq 'SHOW_ANSWER') {
     undef($previousmsg);      undef($previousmsg);
  }   }
  if ( $showbutton ) {   if ( $showbutton ) { 
             if ($target ne 'tex') {      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 =    $button = 
     '<input       '<input 
                           onmouseup="javascript:setSubmittedPart(\''.$id.'\')"                            onmouseup="javascript:setSubmittedPart(\''.$id.'\')"
                            onsubmit="javascript:setSubmittedPart(\''.$id.'\')"                             onsubmit="javascript:setSubmittedPart(\''.$id.'\')"
                         type="submit" name="submit_'.$id.'"                          type="submit" name="submit_'.$id.'"
                          value="'.$submit_text.'" />';                           value="'.&mt('Submit Answer').'" />';
     }      }
  }   }
   
Line 1380  sub previous_tries { Line 1400  sub previous_tries {
     $prefix =~ tr{.}{_};      $prefix =~ tr{.}{_};
     my $function_name = "LONCAPA_previous_tries_".$prefix.      my $function_name = "LONCAPA_previous_tries_".$prefix.
  $Apache::lonxml::curdepth.'_'.$env{'form.counter'};   $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 ="<script type=\"text/javascript\">      my $result ="<script type=\"text/javascript\">
 // <![CDATA[  // <![CDATA[
     function $function_name() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('$start_page $output $end_page');newWindow.document.close();newWindow.focus()}      function $function_name() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('$start_page $output $end_page');newWindow.document.close();newWindow.focus()}
 // ]]>  // ]]>
 </script><a href=\"javascript:$function_name();void(0);\">".$triestext."</a><br />";  </script><a href=\"javascript:$function_name();void(0);\">".&mt("Previous Tries")."</a><br />";
     #use Data::Dumper;      #use Data::Dumper;
     #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display));      #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display));
     return $result;      return $result;
Line 1396  sub previous_tries { Line 1412  sub previous_tries {
   
 1;  1;
 __END__  __END__
   
   =pod
   
   =back
   
   =cut
     

Removed from v.1.248.4.2  
changed lines
  Added in v.1.254


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>