Diff for /loncom/interface/loncommon.pm between versions 1.42 and 1.45

version 1.42, 2002/07/01 15:24:44 version 1.45, 2002/07/09 17:15:58
Line 33 Line 33
 # 12/25,12/28 Gerd Kortemeyer  # 12/25,12/28 Gerd Kortemeyer
 # YEAR=2002  # YEAR=2002
 # 1/4 Gerd Kortemeyer  # 1/4 Gerd Kortemeyer
   # 6/24,7/2 H. K. Ng
   
 # Makes a table out of the previous attempts  # Makes a table out of the previous attempts
 # Inputs result_from_symbread, user, domain, course_id  # Inputs result_from_symbread, user, domain, course_id
Line 40 Line 41
   
 # POD header:  # POD header:
   
   =pod
   
 =head1 NAME  =head1 NAME
   
 Apache::loncommon - pile of common routines  Apache::loncommon - pile of common routines
Line 104  my $theavecount; Line 107  my $theavecount;
 =item BEGIN()   =item BEGIN() 
   
 Initialize values from language.tab, copyright.tab, filetypes.tab,  Initialize values from language.tab, copyright.tab, filetypes.tab,
 and filecategories.tab.  thesaurus.tab, and filecategories.tab.
   
 =cut  =cut
   
 # ----------------------------------------------------------------------- BEGIN  # ----------------------------------------------------------------------- BEGIN
   
 BEGIN {  BEGIN {
Line 341  my %menu = ( A1 => { text =>"Choice A1" Line 345  my %menu = ( A1 => { text =>"Choice A1"
                   }                    }
               );                );
   
 =back  
   
 =cut  =cut
   
 # ------------------------------------------------  # ------------------------------------------------
Line 427  END Line 429  END
   
 ###############################################################  ###############################################################
   
   =pod
   
   =item help_open_topic($topic, $stayOnPage, $width, $height)
   
   Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in /home/httpd/html/adm/help/tex, with underscores replaced by spaces.
   
   $stayOnPage is a value that will be interpreted as a boolean. If true, the link will not open a new window. If false, the link will open a new window using Javascript. (Default is false.)
   
   $width and $height are optional numerical parameters that will override the width and height of the popped up window, which may be useful for certain help topics with big pictures included.
   
   =cut
   
   sub help_open_topic {
       my ($topic, $stayOnPage, $width, $height) = @_;
       $stayOnPage = 0 if (not defined $stayOnPage);
       $width = 350 if (not defined $width);
       $height = 400 if (not defined $height);
       my $filename = $topic;
       $filename =~ s/ /_/g;
   
       my $template;
   
       if (!$stayOnPage)
       {
           $template = <<"ENDTEMPLATE";
   <a href="javascript:void(open('/adm/help/${filename}.hlp', 'Help for $topic', 'menubar=0,s
   crollbars=1,width=$width,height=$height'))"><image
     src="/adm/help/gif/smallHelp.gif"
     border="0" alt="(Help: $topic)"></a>
   ENDTEMPLATE
       }
       else
       {
           $template = <<"ENDTEMPLATE";
   <a href="/adm/help/${filename}.hlp"><image
     src="/adm/help/gif/smallHelp.gif"
     border="0" alt="(Help: $topic)"></a>
   ENDTEMPLATE
       }
   
       return $template;
   
   }
   
   =pod
   
 =item csv_translate($text)   =item csv_translate($text) 
   
 Translate $text to allow it to be output as a 'comma seperated values'   Translate $text to allow it to be output as a 'comma seperated values' 
Line 448  sub csv_translate { Line 496  sub csv_translate {
 ###############################################################  ###############################################################
 #-------------------------------------------  #-------------------------------------------
   
   =pod
   
 =item get_domains()  =item get_domains()
   
 Returns an array containing each of the domains listed in the hosts.tab  Returns an array containing each of the domains listed in the hosts.tab
Line 468  sub get_domains { Line 518  sub get_domains {
   
 #-------------------------------------------  #-------------------------------------------
   
   =pod
   
 =item select_dom_form($defdom,$name)  =item select_dom_form($defdom,$name)
   
 Returns a string containing a <select name='$name' size='1'> form to   Returns a string containing a <select name='$name' size='1'> form to 
Line 492  sub select_dom_form { Line 544  sub select_dom_form {
   
 #-------------------------------------------  #-------------------------------------------
   
   =pod
   
 =item get_home_servers($domain)  =item get_home_servers($domain)
   
 Returns a hash which contains keys like '103l3' and values like   Returns a hash which contains keys like '103l3' and values like 
Line 514  sub get_home_servers { Line 568  sub get_home_servers {
   
 #-------------------------------------------  #-------------------------------------------
   
   =pod
   
 =item home_server_option_list($domain)  =item home_server_option_list($domain)
   
 returns a string which contains an <option> list to be used in a   returns a string which contains an <option> list to be used in a 
Line 546  sub home_server_option_list { Line 602  sub home_server_option_list {
 ##    formname = the name given in the <form> tag.  ##    formname = the name given in the <form> tag.
 #-------------------------------------------  #-------------------------------------------
   
   =pod
   
 =item authform_xxxxxx  =item authform_xxxxxx
   
 The authform_xxxxxx subroutines provide javascript and html forms which   The authform_xxxxxx subroutines provide javascript and html forms which 
Line 864  sub filedescriptionex { Line 922  sub filedescriptionex {
 # $username,$domain - that of the student  # $username,$domain - that of the student
 # $course           - course name  # $course           - course name
 # $getattempt       - leave blank if want all attempts, else put something.  # $getattempt       - leave blank if want all attempts, else put something.
   # $regexp           - regular expression. If string matches regexp send to
   # $gradesub         - routine that process the string if it matches regexp
 #   # 
 # output  # output
 # formatted as a table all the attempts, if any.  # formatted as a table all the attempts, if any.
 #  #
 sub get_previous_attempt {  sub get_previous_attempt {
   my ($symb,$username,$domain,$course,$getattempt)=@_;    my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_;
   my $prevattempts='';    my $prevattempts='';
     no strict 'refs';
   if ($symb) {    if ($symb) {
     my (%returnhash)=      my (%returnhash)=
       &Apache::lonnet::restore($symb,$course,$domain,$username);        &Apache::lonnet::restore($symb,$course,$domain,$username);
Line 882  sub get_previous_attempt { Line 943  sub get_previous_attempt {
   $lasthash{$_}=$returnhash{$version.':'.$_};    $lasthash{$_}=$returnhash{$version.':'.$_};
         }          }
       }        }
       $prevattempts='<table border="0" width="100%"><tr><td bgcolor="#000000">';        $prevattempts='<table border="0" width="100%"><tr><td bgcolor="#777777">';
       $prevattempts.='<table border="0" width="100%"><tr bgcolor="#e6ffff"><td>History</td>';        $prevattempts.='<table border="0" width="100%"><tr bgcolor="#e6ffff"><td>History</td>';
       foreach (sort(keys %lasthash)) {        foreach (sort(keys %lasthash)) {
  my ($ign,@parts) = split(/\./,$_);   my ($ign,@parts) = split(/\./,$_);
Line 920  sub get_previous_attempt { Line 981  sub get_previous_attempt {
  } else {   } else {
   $value=$lasthash{$_};    $value=$lasthash{$_};
  }   }
    if ($_ =~/$regexp$/) {$value = &$gradesub($value)}
  $prevattempts.='<td>'.$value.'&nbsp;</td>';   $prevattempts.='<td>'.$value.'&nbsp;</td>';
       }        }
       $prevattempts.='</tr></table></td></tr></table>';        $prevattempts.='</tr></table></td></tr></table>';
Line 1031  sub add_to_env { Line 1093  sub add_to_env {
   
 =pod  =pod
   
   =back 
   
 =head2 CSV Upload/Handling functions  =head2 CSV Upload/Handling functions
   
 =over 4  =over 4

Removed from v.1.42  
changed lines
  Added in v.1.45


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