[system] / trunk / wwmoodle / wwquestion / bin / setup / setup.pl Repository:
ViewVC logotype

View of /trunk/wwmoodle/wwquestion/bin/setup/setup.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5502 - (download) (as text) (annotate)
Wed Sep 12 15:44:49 2007 UTC (12 years, 5 months ago) by mleventi
File size: 4393 byte(s)
Fixed linking Errors

    1 #!/usr/bin/env perl
    2 
    3 use Cwd;
    4 
    5 sub promptUser {
    6 
    7    #-------------------------------------------------------------------#
    8    #  two possible input arguments - $promptString, and $defaultValue  #
    9    #  make the input arguments local variables.                        #
   10    #-------------------------------------------------------------------#
   11 
   12    local($promptString,$defaultValue) = @_;
   13 
   14    #-------------------------------------------------------------------#
   15    #  if there is a default value, use the first print statement; if   #
   16    #  no default is provided, print the second string.                 #
   17    #-------------------------------------------------------------------#
   18 
   19    if ($defaultValue) {
   20       print $promptString, "[", $defaultValue, "]: ";
   21    } else {
   22       print $promptString, ": ";
   23    }
   24 
   25    $| = 1;               # force a flush after our print
   26    $_ = <STDIN>;         # get the input from STDIN (presumably the keyboard)
   27 
   28 
   29    #------------------------------------------------------------------#
   30    # remove the newline character from the end of the input the user  #
   31    # gave us.                                                         #
   32    #------------------------------------------------------------------#
   33 
   34    chomp;
   35 
   36    #-----------------------------------------------------------------#
   37    #  if we had a $default value, and the user gave us input, then   #
   38    #  return the input; if we had a default, and they gave us no     #
   39    #  no input, return the $defaultValue.                            #
   40    #                                                                 #
   41    #  if we did not have a default value, then just return whatever  #
   42    #  the user gave us.  if they just hit the <enter> key,           #
   43    #  the calling routine will have to deal with that.               #
   44    #-----------------------------------------------------------------#
   45 
   46    if ("$defaultValue") {
   47       return $_ ? $_ : $defaultValue;    # return $_ if it has a value
   48    } else {
   49       return $_;
   50    }
   51 }
   52 
   53 print "###################################\n";
   54 print "#WeBWorK Question Type in Moodle  #\n";
   55 print "###################################\n";
   56 
   57 #Continue?
   58 print "This script will setup the configuration of WeBWorK Question Server.\n";
   59 $continue = promptUser('Continue','y');
   60 if($continue ne "y") {
   61     exit;
   62 }
   63 
   64 #Program Root
   65 print "Please enter the root directory where wwquestion module is located. \n";
   66 print "Example: /tmp/wwmoodle/wwquestion\n";
   67 $wwquestionRoot = promptUser('');
   68 
   69 #Moodle Root
   70 print "Please enter the root directory where Moodle is installed. \n";
   71 print "Example: /var/www/moodle \n";
   72 $moodleRoot = promptUser('');
   73 
   74 #WSDL Root Directory
   75 print "Please enter the WSDL Path given in the server setup. \n";
   76 print "Example: http://myserver/problemserver_files/WSDL.wsdl\n";
   77 $wsdlPath = promptUser('');
   78 
   79 #Writing Configuration File
   80 open(INPUT2, "<config.php.base");
   81 $content = "";
   82 while(<INPUT2>)
   83 {
   84     my($line) = $_;
   85     $content .= $line;
   86 }
   87 close INPUT2;
   88 
   89 $content =~ s/MARKER_FOR_WSDL/$wsdlPath/;
   90 open(OUTP3, ">config.php") or die("Cannot open file 'config.php' for writing.\n");
   91 print OUTP3 $content;
   92 close OUTP3;
   93 
   94 system("mv config.php $wwquestionRoot/moodle/question/type/webwork/config.php");
   95 print "config.php file generated.\n";
   96 
   97 #File Moving/Linking
   98 $files = promptUser('Would you like me to place the files into proper directories (y,n)','y');
   99 if($files eq 'y') {
  100    $doWhat = promptUser('Would you like me to copy the files or soft link them.(copy,link)','link');
  101    if($doWhat eq 'link') {
  102       $action = 'ln -sf ';
  103    } elsif ($doWhat eq 'copy') {
  104       print "Remember to rerun setup when/if you update from the CVS\n";
  105       $action = 'cp -R ';
  106    } else {
  107       exit;
  108    }
  109    #wipe existing directories
  110    system("rm -rf $moodleRoot/question/type/webwork");
  111    system("rm -rf $moodleRoot/lang/en_utf8/help/webwork");
  112    system($action . "$wwquestionRoot/moodle/question/type/webwork " .$moodleRoot . '/question/type/');
  113    system($action . "$wwquestionRoot/moodle/lang/en_utf8/qtype_webwork.php " . $moodleRoot . '/lang/en_utf8/qtype_webwork.php');
  114    system($action . "$wwquestionRoot/moodle/lang/en_utf8/help/quiz/webwork.html " . $moodleRoot . '/lang/en_utf8/help/quiz/webwork.html');
  115    system($action . "$wwquestionRoot/moodle/lang/en_utf8/help/webwork " . $moodleRoot . '/lang/en_utf8/help/');
  116 
  117    print "Setup Successful!\n";
  118 
  119 
  120 }
  121 
  122 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9