[system] / trunk / webwork / system / scripts / export_webwork-database.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/scripts/export_webwork-database.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (download) (as text) (annotate)
Mon Jun 25 18:20:05 2001 UTC (18 years, 5 months ago) by sam
File size: 1935 byte(s)
Removed unneeded scripts (as per discussion with gage, apizer). Added
BEGIN-block method for library inclusion to command-line scripts.

    1 #!/usr/local/bin/webwork-perl
    2 
    3 ####################################################################
    4 # Copyright @ 1995-1999 University of Rochester
    5 # All Rights Reserved
    6 ####################################################################
    7 
    8 BEGIN {
    9   my $useLibDir = '.';
   10   if    ($0 =~ m|^(/.*)/|)  { $useLibDir = $1; }
   11   elsif ($0 =~ m|^(\..*)/|) { $useLibDir = $1; }
   12   elsif ($0 =~ m|^(.+)/|)   { $useLibDir = "./$1"; }
   13   unshift @INC, $useLibDir;
   14 }
   15 
   16 use webworkInit; # WeBWorKInitLine
   17 
   18 # Called as
   19 # showDatabase.pl courseID
   20 
   21 use Global;
   22 use Auth;
   23 use strict;
   24 
   25 if (@ARGV != 2)
   26   {
   27    print "\nSyntax is export_webwork-database.pl courseID outputTextFile\n";
   28    print "      (e.g. export_webwork-database.pl  demoCourse textDatabase)\n\n";
   29    exit(0);
   30   }
   31 
   32 my $course = $ARGV[0];
   33 my $outFileName = $ARGV[1];
   34 
   35 # Give caller options
   36 
   37 
   38 # establish environment for this script
   39 
   40   &Global::getCourseEnvironment($course);
   41 
   42 # Directory paths
   43 
   44 my $databaseDirectory = getCourseDatabaseDirectory();
   45 my $courseScriptsDirectory = getWebworkScriptDirectory();
   46 
   47 # File names
   48 
   49   require "${courseScriptsDirectory}$Global::DBglue_pl";
   50   require "${courseScriptsDirectory}$Global::HTMLglue_pl";
   51   require "${courseScriptsDirectory}$Global::FILE_pl";
   52 
   53   my $databaseFile = $Global::database;
   54 
   55 # get all psvn's for set
   56 
   57 my %PROBSET;
   58 my $wwDbObj;      # Object for referencing the database
   59 
   60 &read_psvn_record(\$wwDbObj, \%PROBSET, "${databaseDirectory}${databaseFile}", 'R', $Global::standard_tie_permission);
   61 
   62 my ($key,$item);
   63 my @keys = sort keys %PROBSET;
   64 
   65 open(OUTFILE,">$outFileName") or wwerror("$0","can't open $outFileName for writing");
   66 
   67 foreach $key (@keys) {
   68     print OUTFILE "[$key]\n";
   69     my $string = $PROBSET{$key};
   70 #    print  OUTFILE "|$string|\n";
   71   my @probSetRecord = split(/[\&]/,$string);
   72   @probSetRecord = sort @probSetRecord;
   73   foreach $item (@probSetRecord) {
   74       print OUTFILE "\t$item\n";
   75   }
   76   print OUTFILE "\n";
   77 }
   78 
   79 close(OUTFILE);

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9