[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 24 Jun 2002 19:06:05 -0000


This is a MIME encoded message

--albertel1024945565
Content-Type: text/plain

albertel		Mon Jun 24 15:06:05 2002 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - Doumentation updates
  
  
--albertel1024945565
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20020624150605.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.37 loncom/interface/loncommon.pm:1.38
--- loncom/interface/loncommon.pm:1.37	Thu May  9 11:56:02 2002
+++ loncom/interface/loncommon.pm	Mon Jun 24 15:06:05 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.37 2002/05/09 15:56:02 matthew Exp $
+# $Id: loncommon.pm,v 1.38 2002/06/24 19:06:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,7 +65,7 @@
 This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.
 
-=head2 Subroutines
+=head2 General Subroutines
 
 =over 4
 
@@ -79,7 +79,6 @@
 use POSIX qw(strftime);
 use Apache::Constants qw(:common);
 use Apache::lonmsg();
-
 my $readit;
 
 # ----------------------------------------------- Filetypes/Languages/Copyright
@@ -99,6 +98,9 @@
 my $theavecount;
 
 # ----------------------------------------------------------------------- BEGIN
+
+=pod
+
 =item BEGIN() 
 
 Initialize values from language.tab, copyright.tab, filetypes.tab,
@@ -785,12 +787,16 @@
       $prevattempts='<table border=2></tr><th>History</th>';
       foreach (sort(keys %lasthash)) {
 	my ($ign,@parts) = split(/\./,$_);
-	if (@parts) {
+	if ($#parts > 0) {
 	  my $data=$parts[-1];
 	  pop(@parts);
 	  $prevattempts.='<th>Part '.join('.',@parts).'<br />'.$data.'</th>';
 	} else {
-	  $prevattempts.='<th>'.$ign.'</th>';
+	  if ($#parts == 0) {
+	    $prevattempts.='<th>'.$parts[0].'</th>';
+	  } else {
+	    $prevattempts.='<th>'.$ign.'</th>';
+	  }
 	}
       }
       for ($version=1;$version<=$returnhash{'version'};$version++) {
@@ -865,31 +871,11 @@
   foreach my $element (@elements) {
     $ENV{'form.grade_'.$element}=$old{$element};
   }
-  $userview=~s/\<body[^\>]*\>//gi;
-  $userview=~s/\<\/body\>//gi;
-  $userview=~s/\<html\>//gi;
-  $userview=~s/\<\/html\>//gi;
-  $userview=~s/\<head\>//gi;
-  $userview=~s/\<\/head\>//gi;
-  $userview=~s/action\s*\=/would_be_action\=/gi;
   return $userview;
 }
 
 ###############################################
 
-=item get_unprocessed_cgi($query,$possible_names)
-
-Modify the %ENV hash to contain unprocessed CGI form parameters held in
-$query.  The parameters listed in $possible_names (an array reference),
-will be set in $ENV{'form.name'} if they do not already exist.
-
-Typically called with $ENV{'QUERY_STRING'} as the first parameter.  
-$possible_names is an ref to an array of form element names.  As an example:
-get_unprocessed_cgi($ENV{'QUERY_STRING'},['uname','udom']);
-will result in $ENV{'form.uname'} and $ENV{'form.udom'} being set.
-
-=cut
-
 ###############################################
 
 sub get_unprocessed_cgi {
@@ -942,11 +928,21 @@
   }
 }
 
-#---CSV Upload/Handling functions
+=pod
+
+=back
+
+=head2 CSV Upload/Handling functions
 
-# ========================================================= Store uploaded file
-# needs $ENV{'form.upfile'}
-# return $datatoken to be put into hidden field
+=over 4
+
+=item  upfile_store($r)
+
+Store uploaded file, $r should be the HTTP Request object,
+needs $ENV{'form.upfile'}
+returns $datatoken to be put into hidden field
+
+=cut
 
 sub upfile_store {
     my $r=shift;
@@ -965,9 +961,13 @@
     return $datatoken;
 }
 
-# ================================================= Load uploaded file from tmp
-# needs $ENV{'form.datatoken'}
-# sets $ENV{'form.upfile'} to the contents of the file
+=item load_tmp_file($r)
+
+Load uploaded file from tmp, $r should be the HTTP Request object,
+needs $ENV{'form.datatoken'},
+sets $ENV{'form.upfile'} to the contents of the file
+
+=cut
 
 sub load_tmp_file {
     my $r=shift;
@@ -982,10 +982,13 @@
     $ENV{'form.upfile'}=join('',@studentdata);
 }
 
-# ========================================= Separate uploaded file into records
-# returns array of records
-# needs $ENV{'form.upfile'}
-# needs $ENV{'form.upfiletype'}
+=item upfile_record_sep()
+
+Separate uploaded file into records
+returns array of records,
+needs $ENV{'form.upfile'} and $ENV{'form.upfiletype'}
+
+=cut
 
 sub upfile_record_sep {
     if ($ENV{'form.upfiletype'} eq 'xml') {
@@ -994,9 +997,12 @@
     }
 }
 
-# =============================================== Separate a record into fields
-# needs $ENV{'form.upfiletype'}
-# takes $record as arg
+=item record_sep($record)
+
+Separate a record into fields $record should be an item from the upfile_record_sep(), needs $ENV{'form.upfiletype'}
+
+=cut
+
 sub record_sep {
     my $record=shift;
     my %components=();
@@ -1041,7 +1047,12 @@
     return %components;
 }
 
-# =============================== HTML code to select file and specify its type
+=item upfile_select_html()
+
+return HTML code to select file and specify its type
+
+=cut
+
 sub upfile_select_html {
     return (<<'ENDUPFORM');
 <input type="file" name="upfile" size="50">
@@ -1054,9 +1065,14 @@
 ENDUPFORM
 }
 
-# ===================Prints a table of sample values from each column uploaded
-# $r is an Apache Request ref
-# $records is an arrayref from &Apache::loncommon::upfile_record_sep
+=item csv_print_samples($r,$records)
+
+Prints a table of sample values from each column uploaded $r is an
+Apache Request ref, $records is an arrayref from
+&Apache::loncommon::upfile_record_sep
+
+=cut
+
 sub csv_print_samples {
     my ($r,$records) = @_;
     my (%sone,%stwo,%sthree);
@@ -1079,10 +1095,15 @@
     $r->print('</tr></table><br />'."\n");
 }
 
-# ======Prints a table to create associations between values and table columns
-# $r is an Apache Request ref
-# $records is an arrayref from &Apache::loncommon::upfile_record_sep
-# $d is an array of 2 element arrays (internal name, displayed name)
+=item csv_print_select_table($r,$records,$d)
+
+Prints a table to create associations between values and table columns.
+$r is an Apache Request ref,
+$records is an arrayref from &Apache::loncommon::upfile_record_sep,
+$d is an array of 2 element arrays (internal name, displayed name)
+
+=cut
+
 sub csv_print_select_table {
     my ($r,$records,$d) = @_;
     my $i=0;my %sone;
@@ -1106,11 +1127,16 @@
     return $i;
 }
 
-# ===================Prints a table of sample values from the upload and
-#                      can make associate samples to internal names
-# $r is an Apache Request ref
-# $records is an arrayref from &Apache::loncommon::upfile_record_sep
-# $d is an array of 2 element arrays (internal name, displayed name)
+=item csv_samples_select_table($r,$records,$d)
+
+Prints a table of sample values from the upload and can make associate samples to internal names.
+
+$r is an Apache Request ref,
+$records is an arrayref from &Apache::loncommon::upfile_record_sep,
+$d is an array of 2 element arrays (internal name, displayed name)
+
+=cut
+
 sub csv_samples_select_table {
     my ($r,$records,$d) = @_;
     my %sone; my %stwo; my %sthree;
@@ -1141,6 +1167,14 @@
 1;
 __END__;
 
+=pod
+
+=back
+
+=head2 Access .tab File Data
+
+=over 4
+
 =item languageids() 
 
 returns list of all language ids
@@ -1179,6 +1213,12 @@
 returns description for a specified file type with
 extra formatting
 
+=back
+
+=head2 Alternate Problem Views
+
+=over 4
+
 =item get_previous_attempt() 
 
 return string with previous attempt on problem
@@ -1191,9 +1231,22 @@
 
 show a snapshot of how student was answering problem
 
-=item get_unprocessed_cgi() 
+=back
+
+=head2 HTTP Helper
+
+=over 4
 
-get unparsed CGI parameters
+=item get_unprocessed_cgi($query,$possible_names)
+
+Modify the %ENV hash to contain unprocessed CGI form parameters held in
+$query.  The parameters listed in $possible_names (an array reference),
+will be set in $ENV{'form.name'} if they do not already exist.
+
+Typically called with $ENV{'QUERY_STRING'} as the first parameter.  
+$possible_names is an ref to an array of form element names.  As an example:
+get_unprocessed_cgi($ENV{'QUERY_STRING'},['uname','udom']);
+will result in $ENV{'form.uname'} and $ENV{'form.udom'} being set.
 
 =item cacheheader() 
 

--albertel1024945565--