[system] / trunk / pg / lib / AnswerIO.pm Repository:
ViewVC logotype

View of /trunk/pg/lib/AnswerIO.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4766 - (download) (as text) (annotate)
Sat Feb 3 15:25:18 2007 UTC (12 years, 10 months ago) by gage
File size: 1309 byte(s)
Added new permissable log files.
that can be written to.

    1 
    2 
    3 =head1 NAME
    4 
    5   AnswerIO.pm
    6 
    7 =head1 SYNPOSIS
    8 
    9 This is not really an object, but it gives us a place to IO used by answer
   10 macros.
   11 
   12 
   13 
   14 =head1 DESCRIPTION
   15 
   16 
   17 =head2 Examples:
   18 
   19 
   20 
   21 =cut
   22 
   23 
   24 BEGIN {
   25   be_strict(); # an alias for use strict.  This means that all global variable must contain main:: as a prefix.
   26 }
   27 
   28 package AnswerIO;
   29 
   30 
   31 
   32 # Code for saving Answers to a file
   33 # function, not a method
   34 # Code in .pm files can access the disk.
   35 
   36 
   37 sub saveAnswerToFile {
   38     my $logFileID = shift;
   39       my $string = shift;
   40       # We want to allow acces only to predetermined files
   41       # We accomplish this by translating legal IDs into a file name
   42 
   43       my $rh_allowableFiles = {
   44          preflight => 'preflight.log',
   45          questionnaire => 'questionnaire.txt',
   46 
   47         };
   48       my $error=undef;
   49       my $logFileName = $rh_allowableFiles->{$logFileID};
   50       if ( defined($logFileName) ) {
   51         my $accessLog = Global::getCourseLogsDirectory().$logFileName;
   52         #$error = "access Log is $accessLog";
   53         #$error .="string is $string";
   54         open(LOG, ">>$accessLog") or $error.= "Can't open course access log $accessLog";
   55         print LOG $string;  #no format is forced on data.
   56         close(LOG);
   57       } else {
   58         $error = "Error: The file ID $logFileID is not recognized.";
   59       }
   60   return $error ;
   61 }
   62 
   63 
   64 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9