[system] / trunk / webwork / system / scripts / course_webwork_setup.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/scripts/course_webwork_setup.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 127 - (download) (as text) (annotate)
Mon Aug 13 20:29:42 2001 UTC (18 years, 6 months ago) by apizer
File size: 37839 byte(s)
removed all reference to courseScripts directory (which is no longer used
by individual courses).  Also the default now in setting up a course is to
have the macros directory implemented.  Added comments on the
webworkCourse.ph file explaining how the macros directory works.

    1 #!/usr/bin/perl
    2 use strict;
    3 
    4 
    5 ################################################################################
    6 ##
    7 ## File: course_webwork_setup.pl   (for WeBWorK course installation)
    8 ##
    9 ##   this file changes the permissions to the correct ones in each of the
   10 ##    subdirectories and the main course directory.  It also creates the
   11 ##    webworkCourse.ph file.
   12 ##   It prompts the user to enter the correct cgiURL and htmlURL
   13 ##    The default values for these variables and for the variables pointing
   14 ##    to the main directory can be set in the file defaults.cws.
   15 ##
   16 ###############################################################################
   17 
   18 sub getAns {
   19   my $ans = <STDIN>;
   20   $ans =~ s/^\s*//;
   21   $ans = substr($ans, 0, 1);
   22   return lc($ans);
   23 }
   24 
   25 ################# Prompt to run this script #########################
   26 print qq{
   27 This script is used to setup a WeBWorK course.
   28 
   29 A "demo" or "working" version of the course can be setup.
   30 
   31 This script will create initialization files, directories,
   32 and set groups and default permissions. It will make backups
   33 of files that are changed.  For a "working" version it will
   34 not make any changes without prompting. \n
   35 
   36 This script must be run from the base course directory, for
   37 example from /www/webwork-root/webwork/courses/mth140a
   38 
   39 You will need the following information:\n
   40 1) The course URL (e.g. http://webwork.math.rochester.edu/mth140a/)
   41 2) The cgi WeBWorK URL.  It is listed in the Global.pm file as \$cgiWebworkURL.
   42    Global.pm is a file in the main WeBWorK system directory.
   43 3) The symbolic link (e.g. mth140a) pointing to the course (we call this the CLASS_ID).
   44    It appears in the courses subdirectory of the main WeBWorK system directory.
   45 4) The group (e.g. MTH140A) containing the webserver, your loginID, and the loginID's
   46    of anyone else who will creating and editing WeBWorK problems for your course.
   47    YOU DO NOT NEED THIS WHEN SETTING UP A "DEMO" VERSION.
   48 
   49 Hit [Enter] to continue...
   50 };
   51 my $garbage;
   52 $garbage = <STDIN>;
   53 
   54 print qq{
   55 Items 3) and 4) should be set up by your system administrator before running this script.
   56 
   57 In our example the classID and the group name are different, but they can be the same.
   58 
   59 See the html document .../docs/techdescription/usingwebwork.html for detailed
   60 explainations.  The examples here are taken from those directions.  docs is a
   61 subdirectory of the main WeBWorK system directory.
   62 
   63 Do you wish to continue\? (y or n)
   64 };
   65 
   66 exit(0) if &getAns ne 'y';
   67 
   68 
   69 ################## Find out if setting up a demo or working course ##########################
   70 my $course_setup_mode = 'working';
   71 my $file_creation_mode = 'working';
   72 
   73 print qq{
   74 
   75 
   76 You can set up a "working" or a "demo" version of a course.  A "demo" version
   77 should only be used as a sample course, never for an actual course.  In a "demo"
   78 version all the system type files specific to the course (e.g. webworkCourse.ph)
   79 are world readable and many files are world writable.
   80 Other than that, "working" or  "demo" versions function the same.
   81 
   82 Do you wish to setup a "working" or a "demo" version? (w or d)
   83 };
   84 
   85 if (&getAns eq 'd') {
   86   $course_setup_mode = 'demo';
   87   $file_creation_mode = 'demo';
   88 }
   89 
   90 print qq{
   91 
   92 Setting up a $course_setup_mode version.
   93 
   94 };
   95 
   96 ################## read + process defaults file  ######################
   97 
   98 my ($htmlurldefault,$cgiurldefault,$courselinkdefault);
   99 open(DEFAULTS, "defaults.cws");
  100 while(<DEFAULTS>)
  101   {
  102   chomp($_);
  103   $_ =~ s/^ //g;
  104   if($_ =~ /^#/  ||  $_ eq "")  ## comment line or blank line
  105   {}
  106   else
  107   {
  108   $_ =~ /^\s*(\w+)\s*=\s*([-,\s\/\w\.:]*)/;  ## does this include everything that can be in a filename or a URL???
  109   if ($1 eq "htmlURL")
  110     {$htmlurldefault = $2;}
  111   if ($1 eq "cgiURL")
  112     {$cgiurldefault = $2;}
  113   if ($1 eq "courseLink")
  114     {$courselinkdefault = $2;}
  115   }
  116   }
  117 
  118 close(DEFAULTS);
  119 # done with defaults
  120 
  121 
  122 
  123 ################### Create directories if they don't exist. ###################
  124 my $ans;
  125 if ($course_setup_mode eq 'demo') {$ans = 'y';}
  126 else {
  127 print "\nDefault directory and file permissions are set assuming\n";
  128 print "the webserver is in the group.\n\n";
  129 print "Do you want to create missing directories (if any)\? (y or n)\n";
  130 $ans = &getAns;
  131 }
  132 if ($ans eq 'y')
  133   {
  134   print "\n";
  135   unless(-e 'scoring')
  136     {
  137     mkdir('scoring', 0770);
  138     chmod(0770, 'scoring') || die "Can't do chmod on scoring directory";
  139     print 'directory scoring'.", 0770 created.\n";
  140     }
  141   unless(-e 'scoring/scoring.log')
  142     {
  143     open(TEMPCREATEFILE, ">scoring/scoring.log") || die "Can't open scoring/scoring.log";
  144     close(TEMPCREATEFILE);
  145     chmod(0660,"scoring/scoring.log") || die "Can't do chmod(0660, scoring/scoring.log)";
  146     print 'file scoring/scoring.log'.", 0660 created.\n";
  147     }
  148   unless(-e 'DATA')
  149     {
  150     mkdir('DATA', 0770);
  151     chmod(0770, 'DATA') || die "Can't do chmod on DATA directory";
  152     print 'directory DATA'.", 0770 created.\n";
  153     }
  154   unless(-e 'DATA/.auth')
  155     {
  156     mkdir('DATA/.auth', 0770);
  157     chmod(0770, 'DATA/.auth') || die "Can't do chmod on DATA/.auth directory";
  158     print 'directory DATA/.auth'.", 0770 created.\n";
  159     }
  160   unless(-e 'html')
  161     {
  162     mkdir('html', 0770);
  163     chmod(0770, 'html') || die "Can't do chmod on html directory";
  164     print 'directory html'.", 0770 created.\n";
  165   }
  166   unless(-e 'html/images')
  167     {
  168     mkdir('html/images', 0770);
  169     chmod(0770, 'html/images') || die "Can't do chmod on html/images/ directory";
  170     print 'directory html/images'.", 0770 created.\n";
  171     }
  172   unless(-e 'html/tmp')
  173     {
  174     mkdir('html/tmp', 0770);
  175     chmod(0770, 'html/tmp') || die "Can't do chmod on html/tmp/ directory";
  176     print 'directory html/tmp'.", 0770 created.\n";
  177     }
  178   unless(-e 'html/tmp/l2h')
  179     {
  180     mkdir('html/tmp/l2h', 0770);
  181     chmod(0770, 'html/tmp/l2h') || die "Can't do chmod on html/tmp/l2h directory";
  182     print 'directory html/tmp/l2h'.", 0770 created.\n";
  183     }
  184   unless(-e 'html/tmp/eps')
  185     {
  186     mkdir('html/tmp/eps', 0770);
  187     chmod(0770, 'html/tmp/eps') || die "Can't do chmod on html/tmp/eps directory";
  188     print 'directory html/tmp/eps'.", 0770 created.\n";
  189     }
  190   unless(-e 'html/tmp/images')
  191     {
  192     mkdir('html/tmp/images', 0770);
  193     chmod(0770, 'html/tmp/images') || die "Can't do chmod on html/tmp/images directory";
  194     print 'directory html/tmp/images'.", 0770 created.\n";
  195   }
  196   unless(-e 'html/tmp/gif')
  197     {
  198     mkdir('html/tmp/gif', 0770);
  199     chmod(0770, 'html/tmp/gif') || die "Can't do chmod on html/tmp/gif directory";
  200     print 'directory html/tmp/gif'.", 0770 created.\n";
  201   }
  202   unless(-e 'html/tmp/html')
  203     {
  204     mkdir('html/tmp/html', 0770);
  205     chmod(0770, 'html/tmp/html') || die "Can't do chmod on html/tmp/html directory";
  206     print 'directory html/tmp/html'.", 0770 created.\n";
  207     }
  208   unless(-e 'templates')
  209     {
  210     mkdir('templates', 0770);
  211     chmod(0770, 'templates') || die "Can't do chmod on templates directory";
  212     print 'directory templates'.", 0770 created.\n";
  213   }
  214   unless(-e 'templates/email')
  215     {
  216     mkdir('templates/email', 0770);
  217     chmod(0770, 'templates/email') || die "Can't do chmod on templates/email directory";
  218     print 'directory templates/email'.", 0770 created.\n";
  219     }
  220   unless(-e 'templates/macros')
  221     {
  222     mkdir('templates/macros', 0750);
  223     chmod(0750, 'templates/macros') || die "Can't do chmod on templates/macros directory";
  224     print 'directory templates/macros'.", 0750 created.\n";
  225     }
  226   unless(-e 'logs')
  227     {
  228     mkdir('logs', 0770);
  229     chmod(0770, 'logs') || die "Can't do chmod on logs directory";
  230     print 'logs'.", 0770 created.\n";
  231     }
  232    unless(-e 'logs/login.log')
  233      {
  234      open(TEMPCREATEFILE, ">logs/login.log") || die "Can't open logs/login.log";
  235      close(TEMPCREATEFILE);
  236      chmod(0660,"logs/login.log") || die "Can't do chmod(0660, logs/login.log)";
  237      print 'file logs/login.log'.", 0660 created.\n";
  238      }
  239   }
  240 
  241 
  242 
  243 ##################### get base directory   ###############################
  244 
  245 use Cwd;   ## module for getting current wording directory
  246 
  247 my $current_dir = cwd();
  248 $current_dir .= '/' unless $current_dir =~ m|/$|;
  249 $current_dir =~ m|([^/]+/)$|;
  250 my $courseDirectory = $1;
  251 
  252 ####################### Prompt for htmlURL ###############################
  253 print "\n\n";
  254 
  255 print <<MSG1,"--------->";
  256 
  257 ------------> ENTER course URL <-------------
  258 
  259 This html-URL should be a link in the webserver's htdocs tree which points
  260 to the html subdirectory of the course you are creating. See documentation
  261 for help.
  262 
  263 (e.g. $htmlurldefault)
  264 
  265 default = $htmlurldefault
  266 MSG1
  267 
  268 my $HTML_URL=<STDIN>;
  269 chomp($HTML_URL);
  270 if ($HTML_URL eq '')
  271   {
  272   $HTML_URL = $htmlurldefault;
  273 }
  274 
  275 $HTML_URL = check_URL('html-URL',$HTML_URL);
  276 
  277 $HTML_URL .= "/" unless $HTML_URL =~ m"/$" ;
  278 print qq(\nhtmlURL set to: "$HTML_URL"\n);
  279 
  280 #################### Prompt for cgiURL ###################################
  281 print "\n\n\n\n";
  282 
  283 print <<MSG2,"--------->";
  284 
  285 ------------> ENTER cgi WeBWorK URL <-------------
  286 
  287 This cgi-URL should be point to the url of the main WeBWorK
  288 cgi subdirectory.  It is listed in the Global.pm file of the
  289 main WeBWorK system as \$cgiWebworkURL . If you use a relative
  290 path name (e.g. "/cgi-bin/system/"), don't forget the first "/".
  291 
  292 (e.g. $cgiurldefault)
  293 
  294 default = $cgiurldefault
  295 MSG2
  296 
  297 my $CGI_URL=<STDIN>;
  298 chomp($CGI_URL);
  299 if ($CGI_URL eq '')
  300   {
  301   $CGI_URL = $cgiurldefault;
  302 }
  303 
  304 $CGI_URL = check_URL('cgi-URL',$CGI_URL);
  305 
  306 $CGI_URL .= "/" unless $CGI_URL =~ m"/$" ;
  307 print qq(\ncgiURL set to: "$CGI_URL"\n);
  308 
  309 ################## Prompt for courseLink  ###############################
  310 print "\n\n\n\n";
  311 
  312 print <<MSG3,"--------->";
  313 
  314 ------------> ENTER course link (i.e. classID) name <-------------
  315 
  316 This symbolic link (i.e. the classID) points to the course directory. It
  317 appears in the courses subdirectory of the main WeBWorK system. (If
  318 instead of a link, you have put the actual course directory under
  319 .../system/courses/, enter the course directory name.)
  320 
  321 (e.g. mth140a)
  322 
  323 default = $courselinkdefault
  324 MSG3
  325 my $CLASS_ID=<STDIN>;
  326 chomp($CLASS_ID);
  327 if ($CLASS_ID eq "")
  328   {
  329   $CLASS_ID = $courselinkdefault;
  330   }
  331 print qq(\ncourse link (i.e. the classID) set to: "$CLASS_ID"\n);
  332 
  333 
  334 ################## Prompt for group  ###############################
  335 
  336 my ($name, $passwd, $gid, $members, @info,$groupName);
  337 
  338 if ($course_setup_mode eq 'demo')  {
  339   @info = getpwuid($<);
  340   $gid =$info[3];
  341   $groupName = (getgrgid($gid))[0];
  342 }
  343 
  344 else {
  345   print "\n\n\n\n";
  346 
  347 print <<MSG4,"--------->";
  348 
  349 ------------> ENTER group name <-------------
  350 
  351 
  352 This group should have been set up by your systen administrator
  353 and must contain at least your userID and (for a "working" version)
  354 the userID of the webserver.  All files and directories created will
  355 have this as their group.
  356 
  357 Enter the group name:
  358 MSG4
  359   $groupName = <STDIN>;
  360   chomp($groupName);
  361 
  362   unless ((defined($groupName)) and ($groupName =~ /\w+/)){
  363     my @info = getpwuid($<);
  364     $gid =$info[3];
  365     $groupName = (getgrgid($gid))[0];
  366   }
  367 
  368 print qq(\ngroup will be set to: "$groupName"\n);
  369 ($name, $passwd, $gid, $members) = getgrnam ($groupName);
  370 
  371 # check that the group name is valid
  372 # should probably check that the webserver is also a member of this group XXXXXXX
  373 
  374     $members = " ".$members." ";  ## put a spaces arround string
  375     my $username = getpwuid($<);
  376     if($members =~ /\s+$username\s+/)
  377       {
  378       print "\n\nGood.  $username is a member of the group $groupName.\n\n";
  379       }
  380     else
  381       {
  382       print "\n\nSorry.  $username is NOT a member of the group $groupName.\n";
  383       print "The group for all directories and files will not be changed.\n";
  384       print "Ask your system administrator to set up the group. Then you can\n";
  385       print "change the group by hand (see instructions) or run this script again.\n\n";
  386       die;
  387       }
  388 }
  389 
  390 ##################    BEGIN  new webworkCourse.ph #########################
  391 
  392 open(COURSETMP, ">webworkCourse.ph.tmp");
  393 print COURSETMP <<"ENDCOURSETMP";
  394 
  395 # file webworkCourse.ph
  396 # contains variables specific to a course
  397 
  398 #  The variables defined in Global.pm set defaults and
  399 #  parameters for the whole WeBWorK system.  These defaults can
  400 #  be over ridden for this individual course by redefining
  401 #  the variables in this webworkCourse.ph file.
  402 #  For example the default feedback address set in Global.pm as:
  403 #  \$feedbackAddress = 'webwork\@math.rochester.edu';
  404 #  can (and should) be over ridden by entering
  405 #  \$Global::feedbackAddress  = 'apizer\@math.rochester.edu,gage\@math.rochester.edu';
  406 #  below where of course you should substitute your own email address
  407 #  for that of Pizer and Gage (and uncomment the line).
  408 
  409 #  \$Global::feedbackAddress  = 'apizer\@math.rochester.edu,gage\@math.rochester.edu';
  410 
  411 
  412 
  413 ## In addition, you should customize the following three items for your course
  414 
  415 #  If you want to write essay type problems or questionnaires where the results are
  416 #  emailed back, you have to authorize the email addresses here by uncommenting and
  417 #  editing the next line.
  418 
  419 #  \$PG_environment{'ALLOW_MAIL_TO'} = ['apizer\@math.rochester.edu','gage\@math.rochester.edu'];
  420 
  421 
  422 #  On the Professor page, one can view statistical data on problem sets for
  423 #  the whole course and section by section or by recitation.  You may want to
  424 #  exclude certain sections or recitations (e.g. those containing practice users,
  425 #  TA's, or professors) from the overall statistics.  Statistics for excluded
  426 #  sections are reported separately.  List the names of all sections and
  427 #  recitations to be excluded in a coma separated list, e.g.
  428 #  \@excluse_these_sections_from_overall_statistics = ('', 'T.A.', 'Prof section');
  429 #  \@excluse_these_recitations_from_overall_statistics = ('');
  430 #  If this list is empty or commented out, no sections will be excluded.
  431 
  432 \@excluse_these_sections_from_overall_statistics = ('');
  433 \@excluse_these_recitations_from_overall_statistics = ('');
  434 
  435 
  436 
  437 #  If the following line is uncommented, when the user(s) listed view
  438 #  a problem or download a set, the file names of the source files will be
  439 #  listed.  Replace 'leeza', etc. by appropiate login names
  440 
  441 #\$PG_environment{'PRINT_FILE_NAMES_FOR'} = ['leeza','apizer','gage'];
  442 
  443 ######################################################################################
  444 ######################################################################################
  445 
  446 #  NORMALLY, THERE SHOULD BE NO NEED FOR CHANGES BELOW THIS LINE.  RUN THE SCRIPT
  447 #  course_webwork_setup.pl AND EVERYTHING SHOULD BE SETUP CORRECTLY. IF YOU DO
  448 #  EDIT THIS FILE BY HAND, WORK CAREFULLY.  REMEMBER THAT ALL DIRECTORY NAMES MUST
  449 #  END IN A TRALING DIRECTORY DELIMITER.
  450 
  451 
  452 
  453 #  To make it easier to edit and change these directories we define
  454 #  the classDirectory.  This variable is not used outside this file
  455 #  and while it is common for all of these directories to reside inside
  456 #  one directory, it is not necessary.
  457 
  458 \$classDirectory = "\${mainDirectory}courses/$courseDirectory";
  459 
  460 #  The database directory contains data describing the students in the course
  461 #  and their scores on homework.  The cgi scripts run by the webserver must
  462 #  be able to access the contents of this directory.
  463 
  464 \$databaseDirectory = "\${classDirectory}DATA/";
  465 
  466 #  The templates directory contains the class list, the problem set definition
  467 #  files and the problem templates.
  468 
  469 \$templateDirectory = "\${classDirectory}templates/";
  470 
  471 #  The email directory contains (templates of) emails which can be sent to everyone
  472 #  on the classlist.
  473 
  474 \$emailDirectory = "\${templateDirectory}email/";
  475 
  476 #  The macros directory contains macros for the problems files and the
  477 #  problem templates. These are usually macro files which are particular to the course.
  478 #  Macro files are searched for first in the \$macroDirectory and then
  479 #  in the system's courseScript directory.  If it is commented out, the macro files are
  480 #  only searched for in the system's courseScript directory.
  481 
  482 \$macroDirectory = "\${templateDirectory}macros/";
  483 
  484 #  The scoring directory contains files used by the scoring programs. These
  485 #  files contain scoring information for the whole class and are used for
  486 #  calculating semester grades, etc.
  487 
  488 \$scoringDirectory = "\${classDirectory}scoring/";
  489 
  490 #  The html directory contains the first page for the course (index.html),
  491 #  course documentation, and also subdirectories (e.g. tmp/)
  492 #  (e.g. tmp/) containing latex2html problems, gifs, etc.  The webserver has
  493 #  direct access to the html directory and the courseURL points to this
  494 #  directory.
  495 
  496 \$htmlDirectory = "\${classDirectory}html/";
  497 
  498 #  The logs directory contains log fies, e.g. login.log, backup psvn
  499 #  logs and logs of datamunger activity.
  500 
  501 \$logsDirectory = "\${classDirectory}logs/";
  502 
  503 
  504 #  This is the temp directory used by downloadPS, etc
  505 
  506 \$courseTempDirectory = "\${classDirectory}html/tmp/";
  507 
  508 #  This is the URL of the course html directory.  It points to the \$htmlDirectory
  509 #  above and it should have been set up correctly by the course_webwork_setup.pl
  510 #  script.  See the documentatiom (run the script or read
  511 #  .../docs/techdescription/settingupcourse.html).  Note that the URL depends on
  512 #  links in you webserver's htdocs directory and must end in a trailing directory
  513 #  delimiter (/ for unix).
  514 
  515 \$htmlURL = "$HTML_URL";
  516 
  517 #  This is the URL of the course tmp directory.  This is for temporary storage of
  518 #  html files, images, etc that have to accessible to the webserver.  This directory
  519 #  contains the subdirectories l2h, gif, eps, and html (not the \${classDirectory}html
  520 #  directory). All these subdirectories and their files will be recreated if deleted
  521 #  (althought recreating l2h files is time consuminmg).  The location of this directory
  522 #  may be changed fast disk which is not backed up.
  523 
  524 \$courseTempURL = "\${htmlURL}tmp/";
  525 
  526 #  This is the classID, i.e the symbolic link (or directory) that points to the base
  527 #  course directory. It appears in the courses subdirectory of the main WeBWorK system.
  528 
  529 \$classID = "$CLASS_ID";
  530 
  531 #  This is the name of the default classlist file which resides in the
  532 #  templateDirectory.  This default name is used when students change their
  533 #  own email addresses and also to  edit the classlist file over the web.
  534 
  535 \$classlistFilename  = "\${classID}.lst";
  536 
  537 # This is the name of the group and the numerical gid. (some) Files created by
  538 # the WeBWorK system will have their group set to "\$groupID". Normally this
  539 # group will contain the webserver, your loginID, and the loginID's of anyone
  540 # else who will creating and editing WeBWorK problems for your course. If you
  541 # are editing this file by hand and know the \$groupID but not the \$numericalGroupID,
  542 # ask your systems administrator or run course_webwork_setup.pl and look at the
  543 # webworkCourse.ph it produces.  You may also be able to get this information by
  544 # looking at the group file usually:  /etc/group
  545 # Finally, if you have set up a "demo" version, the "\$numericalGroupID" will be
  546 # set to -1 which means maintain the current (default) group.
  547 ENDCOURSETMP
  548 
  549 if ($file_creation_mode eq 'demo')
  550 {
  551 print COURSETMP <<"ENDCOURSETMP";
  552 
  553 \$groupID = "$groupName";
  554 \$numericalGroupID = -1;
  555 
  556 ## this sets the header file over riding the Global setting
  557 
  558 \$Global::SET_HEADER = "paperSetHeader.pg";
  559 
  560 ENDCOURSETMP
  561 }
  562 
  563 else
  564 {
  565 print COURSETMP <<"ENDCOURSETMP";
  566 
  567 \$groupID = "$groupName";
  568 \$numericalGroupID = $gid;
  569 
  570 ## this sets the header file over riding the Global setting
  571 \$Global::SET_HEADER = "paperSetHeader.pg";
  572 
  573 ## If uncommented, this sets the default mode for displayed problems
  574 ## over riding the Global setting.
  575 #\$htmlModeDefault = 'HTML_tth'; # The default mode for displayed problems
  576                  # (either 'HTML','Latex2HTML', or 'HTML_tth')
  577 
  578 # This sets the default for grading multipart problems.  The choices at present are
  579 # std_problem_grader or avg_problem_grader. The std_problem_grader gives credit for
  580 # a mutipart problem only if all parts are answers correctly. The avg_problem_grader
  581 # gives partial credit for a mutipart problems.
  582 
  583 \$PG_environment{PROBLEM_GRADER_TO_USE} = 'avg_problem_grader';
  584 #\$PG_environment{PROBLEM_GRADER_TO_USE} = 'std_problem_grader';
  585 
  586 
  587 # This allows or dissallows Destroy and Rebuild. Set to 0 or 1. If set to 1 a
  588 # professor can destroy and rebuild problems sets in one operation. This is very
  589 # convenient and powerful, but also very dangerous.  Usually  this is not allowed
  590 # in courses students are using.  It is often set to 1 in a private course being
  591 # used only for developing problem sets.
  592 
  593 \$allowDestroyRebuildProbSets = 0;
  594 
  595 ENDCOURSETMP
  596 }
  597 
  598 
  599 if ($file_creation_mode eq 'demo')
  600 {
  601 print COURSETMP <<"ENDCOURSETMP";
  602 
  603 ## File and Directory permissions
  604 
  605 ## These permissions over ride the permissions set in
  606 ## Global.pm
  607 
  608 ## e.g. S1-1521.sco in (base course directory)/DATA
  609 \$sco_files_permission = 0666;
  610 
  611 ## tie permissions (used in tie commands)
  612 ## The database, password, and permissions files
  613 ## always take their permissions from the Global
  614 ## vaiables below.  The important keys file
  615 ## takes its permission from \$restricted_tie_permission.
  616 \$restricted_tie_permission = 0666;
  617 \$standard_tie_permission = 0666;
  618 
  619 ## webwork-database in (base course directory)/DATA
  620 \$webwork_database_permission = 0666;
  621 
  622 ## password in (base course directory)/DATA/.auth
  623 \$password_permission = 0666;
  624 
  625 ## permissions in (base course directory)/DATA/.auth
  626 \$permissions_permission = 0666;
  627 
  628 ## e.g. s1ful.csv in (base course directory)/scoring
  629 \$scoring_files_permission = 0666;
  630 
  631 ## e.g. s1bak1.csv in (base course directory)/scoring
  632 \$scoring_bak_files_permission = 0666;
  633 
  634 ## e.g. 8587l2h.log  in (base course directory)/html/tmp/l2h
  635 \$l2h_logs_permission = 0666;
  636 
  637 ## e.g set1/ in (base course directory)/html/tmp/l2h
  638 \$l2h_set_directory_permission = 0777;
  639 
  640 ## e.g. 1-1082/ in (base course directory)/html/tmp/l2h/set1
  641 \$l2h_prob_directory_permission  = 0777;
  642 
  643 ## e.g. 1082output.html in (base course directory)/html/tmp/l2h/set1/1-1082
  644 \$l2h_data_permission = 0777;
  645 
  646 ENDCOURSETMP
  647 }
  648 
  649 print COURSETMP <<"ENDCOURSETMP";
  650 
  651 
  652 ## This (if uncommented) overrides the setting in Global.pm. Use 'db_tie.pl' for the
  653 ## DB database and 'gdbm_tie.pl' for the GDBM database. For a "new" database type,
  654 ## you will have to write a 'newdb_tie.pl' file. These reside in the scripts directory.
  655 
  656 #\$Global::DBtie_file = 'db_tie.pl';
  657 
  658 
  659 ## This tells WeBWorK where to find the file that connects it to a physical database.
  660 
  661 require "\${Global::scriptDirectory}\$Global::DBtie_file";
  662 
  663 ## These are the file names for the various databases associated with this course.
  664 ## These names override the generic names given in Global.pm
  665 
  666 \$CL_Database       = "\${classID}_classlist_DB";
  667 \$passwordFilename    = "\${classID}_password_DB";
  668 \$permissionsFilename   = "\${classID}_permissions_DB";
  669 \$database          = "\${classID}_webwork_DB";
  670 
  671 # The following line is required by perl
  672 1;
  673 
  674 ENDCOURSETMP
  675 close(COURSETMP);
  676 
  677 #############      END new webworkCourse.ph #########################
  678 
  679 ###################### BEGIN new index.html  #########################
  680 
  681 open(INDEXTMP, ">index.html.tmp");
  682 print INDEXTMP <<"ENDINDEXTMP";
  683 <HTML>
  684 <HEAD>
  685 <TITLE>Welcome to WeBWorK</TITLE>
  686 </HEAD>
  687 
  688 <BODY BGCOLOR="#FFFFFF">
  689 
  690 <P ALIGN=CENTER>
  691    <IMG SRC="/webwork_system_html/images/webwork.gif" ALIGN=CENTER BORDER=1 ALT="WeBWorK Logo">
  692 </P>
  693 
  694 <BLOCKQUOTE>
  695    <H1>WeBWorK Generic Course Login Page for $CLASS_ID</H1>
  696    <HR>
  697 
  698    <H2>Log in as &quot;practice&quot; user</H2>
  699 
  700    You may test out WeBWorK by logging in as a
  701    &quot;practice&quot; user.  To begin, choose the <B>login</B> button below;
  702    Use <B><KBD>practice1</KBD></B> as your login name and password.
  703 
  704    <FORM ACTION= "${CGI_URL}login.pl" METHOD="POST">
  705     <INPUT TYPE="HIDDEN" NAME="course" VALUE="$CLASS_ID">
  706     <B><INPUT TYPE=SUBMIT VALUE="Login"></B>
  707    </FORM>
  708 
  709 <P>
  710 <STRONG>For more information on WeBWorK: </STRONG>
  711 <A HREF="http://webwork.math.rochester.edu/docs/docs">Webwork docs</A>.
  712 
  713 <HR>
  714 
  715 
  716 <FORM ACTION="${CGI_URL}feedback.pl" METHOD="POST">
  717 <INPUT TYPE="image" SRC="/webwork_system_html/images/ww_feedback.gif" BORDER=1 ALT="[Feedback]"  VALUE="Feedback">
  718 
  719 Last updated: <STRONG>22 August 2000</STRONG><BR>
  720 <TT>${HTML_URL}index.html</TT>
  721 
  722 </BLOCKQUOTE>
  723 
  724 </BODY></HTML>
  725 
  726 ENDINDEXTMP
  727 close(INDEXTMP);
  728 #############      END new index.html #########################
  729 
  730 #################### prompt for creating webworkCourse.ph #################
  731 print "\n\n";
  732 if (-e 'webworkCourse.ph')
  733   {
  734   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  735   else {
  736   print "An old webworkCourse.ph exists.  Do you want to create a new\n";
  737   print "webworkCourse.ph and save the old file as webworkCourse.ph.bak1?\n";
  738   print "If you answer y, and webworkCourse.ph.bak1 already exits, it\n";
  739   print "will be saved as webworkCourse.ph.bak2. Only two backups are kept. (y or n)\n";
  740   $ans=&getAns;
  741   }
  742 
  743   if ($ans eq 'y')
  744     {
  745     rename('webworkCourse.ph.bak1',  'webworkCourse.ph.bak2');
  746     rename('webworkCourse.ph',  'webworkCourse.ph.bak1');
  747     rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp";
  748     chmod 0644, 'webworkCourse.ph';
  749     }
  750   else
  751     {
  752     print "\nThe old webworkCourse.ph has not been changed.  You can look\n";
  753     print "at webworkCourse.ph.tmp to see what the new version would have been.\n";
  754     }
  755   }
  756 else
  757   {
  758   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  759   else {
  760   print "Do you want to create a webworkCourse.ph file (we recommmend that\n";
  761   print "you do as it is required for WeBWorK to function)? (y or n)\n";
  762   $ans=&getAns;
  763   }
  764   if ($ans eq 'y')
  765     {
  766     rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp.
  767        Fix the problem and run the setup script again. Stopped ";
  768     chmod 0644, 'webworkCourse.ph';
  769     }
  770   else
  771     {
  772     print "\nA webworkCourse.ph file has not been created.  You will need to\n";
  773     print "create such a file.  You can look at webworkCourse.ph.tmp to see\n";
  774     print "what the file would have looked like.\n";
  775     }
  776   }
  777 
  778 #################### prompt for creating index.html #################
  779 
  780 print "\n\n";
  781 if (-e 'html/index.html')
  782   {
  783   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  784   else {
  785     print "An old index.html exists.  Do you want to create a new\n";
  786     print "index.html and save the old file as index.html.bak1\?\n";
  787     print "If you answer y, and index.html.bak1 already exits, it\n";
  788     print "will be saved as index.html.bak2. Only two backups are kept. (y or n)\n";
  789     $ans= &getAns;
  790   }
  791 
  792   if ($ans eq 'y')
  793     {
  794     rename('html/index.html.bak1',  'html/index.html.bak2');
  795     rename('html/index.html',  'html/index.html.bak1');
  796     rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped ";
  797     chmod 0664, 'html/index.html';
  798     }
  799   else
  800     {
  801     print "\nThe old index.html has not been changed.  You can look\n";
  802     print "at index.html.tmp to see what the new version would have been.\n";
  803     }
  804   }
  805 else
  806   {
  807   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  808   else {
  809     print "Do you want to create an index.html file (we recommmend that\n";
  810     print "you do as it is required for WeBWorK to function)? (y or n)\n";
  811 
  812   $ans= &getAns;
  813   }
  814   if ($ans eq 'y')
  815     {
  816     rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped ";
  817     chmod 0664, 'html/index.html';
  818     }
  819   else
  820     {
  821     print "\nA index.html file has not been created.  You will need to\n";
  822     print "create such a file.  You can look at index.html.tmp to see\n";
  823     print "what the file would have looked like.\n";
  824     }
  825   }
  826 
  827 
  828 ################### Prompt to change the group ##########################
  829 if ($course_setup_mode eq 'demo') {$ans = 'y';}
  830 else {
  831 print qq{
  832 Do you want to set the group for all directories and files\?
  833 It is highly recommended that you do so.  Note that the default
  834 permissions for "working" version assumes the webserver is in
  835 the group. (y or n)
  836 };
  837 
  838 
  839 $ans= &getAns;
  840 }
  841   {               ## bare block to make breaking out easy
  842   if ($ans eq 'y')
  843     {
  844 
  845 
  846     chown(-1, $gid, '.');
  847     chown(-1, $gid,  <*>);
  848     chown(-1, $gid,  <logs/*>);
  849     chown(-1, $gid,  <DATA/*>);
  850     chown(-1, $gid,  <DATA/.auth>);
  851     chown(-1, $gid,  <DATA/.auth/*>);
  852     chown(-1, $gid,  <html/*>);
  853     chown(-1, $gid, <html/tmp/*>);
  854     chown(-1, $gid, <html/tmp/l2h/*>);
  855     chown(-1, $gid, <html/tmp/l2h/*/*>);
  856     chown(-1, $gid, <html/tmp/l2h/*/*/*>);
  857     chown(-1, $gid,  <scoring/*>);
  858     chown(-1, $gid,  <templates/*>);
  859     chown(-1, $gid,  <templates/*/*>);
  860     chown(-1, $gid,  <templates/*/*/*>);
  861     print qq(\n The group has been set to "$groupName"\n\n);
  862     }
  863   }   ##end of bare block
  864 
  865 
  866 ######################### Prompt file permission changes ######################
  867 if ($course_setup_mode eq 'demo') {$ans = 'y';}
  868 else {
  869 print "\n\n\n\n";
  870 print qq(
  871 Do you want to set default "$course_setup_mode" permissions for
  872 all directories and files\? It is highly recommended that you do so.
  873 The default permissions for a "working" version assume the webserver
  874 is in the group.
  875 Set permissions\?  (y or n)
  876 );
  877   $ans= &getAns;
  878 
  879 }
  880 if ($ans eq 'y')
  881 {if ($course_setup_mode eq "demo")
  882   {      ####demo  mode
  883   chmod(0755, '.') || die "Can't set permissions correctly for  base directory. Fix the problem and run the setup script again. Stopped ";
  884   chmod(0755, <*.pl>); ## perl files
  885   chmod(0644, <*.ph>); ## ph files
  886   chmod(0777, 'scoring') || die "Can't set permissions correctly for  scoring directory. Fix the problem and run the setup script again. Stopped ";
  887   chmod(0666, <scoring/*>) ;        # files in scoring - 600, there may be no files
  888   chmod(0777, 'logs') || die "Can't set permissions correctly for  logs directory. Fix the problem and run the setup script again. Stopped ";
  889   chmod(0666, <logs/*>) ;        # files in logs - 660, there may be no files
  890   chmod(0777, 'DATA') || die "Can't set permissions correctly for  DATA directory. Fix the problem and run the setup script again. Stopped ";
  891   chmod(0666, <DATA/*>) ;        # files in DATA - 660, there may be no files
  892   chmod(0777, 'DATA/.auth') || die "Can't set permissions correctly for  DATA/.auth directory. Fix the problem and run the setup script again. Stopped ";
  893   chmod(0666, <DATA/.auth/*>) ;        # files in DATA/.auth - 660, there may be no files
  894   chmod(0755, 'html')  || die "Can't set permissions correctly for  html directory. Fix the problem and run the setup script again. Stopped ";         # html subdir - 750
  895   chmod(0644, <html/*>)  ;
  896   chmod(0777, 'html/images') || die "Can't set permissions correctly for  html/images/ directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/ subdir - 775
  897   chmod(0777, 'html/tmp') || die "Can't set permissions correctly for  html/tmp/ directory. Fix the problem and run the setup script again. Stopped ";     # html/tmp/ subdir - 775
  898   chmod(0777, 'html/tmp/l2h') || die "Can't set permissions correctly for  html/tmp/l2h directory. Fix the problem and run the setup script again. Stopped ";   # html/tmp/l2h/ subdir - 775
  899   chmod(0777, <html/tmp/l2h/*>);   # html/tmp/l2h/ subdir - 775
  900   chmod(0777, <html/tmp/l2h/*/*>) ;    # html/tmp/l2h/ subdir - 775
  901   chmod(0777, <html/tmp/l2h/*/*/*>) ;    # html/tmp/l2h/ subdir - 775
  902   chmod(0777, 'html/tmp/eps') || die "Can't set permissions correctly for  html/tmp/eps directory. Fix the problem and run the setup script again. Stopped ";   # html/tmp/l2h/ subdir - 775
  903   chmod(0777, 'html/tmp/images') || die "Can't set permissions correctly for  html/tmp/images directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  904   chmod(0777, 'html/tmp/gif') || die "Can't set permissions correctly for  html/tmp/gif directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  905   chmod(0777, 'html/tmp/html') || die "Can't set permissions correctly for  html/tmp/html directory. Fix the problem and run the setup script again. Stopped ";   # html/tmp/l2h/ subdir - 775
  906   chmod(0755, 'courseScripts') || die "Can't set permissions correctly for  courseScripts directory. Fix the problem and run the setup script again. Stopped ";    # courseScripts subdir - 750
  907   chmod(0755, <courseScripts/*>)   ;
  908   chmod(0777, 'templates') || die "Can't set permissions correctly for templates directory. Fix the problem and run the setup script again. Stopped ";   # templates subdir - 750
  909   chmod(0777, <templates/*>) ;  # files and directories in templates - 777, there may be no files
  910   chmod(0777, <templates/*/*>) ;  # files and directories in templates - 777, there may be no files
  911   chmod(0777, <templates/*/*/*>) ;  # files and directories in templates - 777, there may be no files
  912   chmod(0755, 'templates/macros') || die "Can't set permissions correctly for  templates/macros directory. Fix the problem and run the setup script again. Stopped ";   # templates/macros subdir - 750
  913   chmod(0755, <templates/macros/*>) ;  # files in templates/macros - 640, there may be no files
  914   print "\n Permissions set to default values.\n";
  915   }
  916 else      #####working mode
  917   {
  918   chmod(0750, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped ";
  919   chmod(0750, <*.pl>); ## perl files
  920   chmod(0640, <*.ph>); ## ph files
  921   chmod(0770, 'scoring') || die "Can't set permissions correctly for  scoring directory. Fix the problem and run the setup script again. Stopped ";
  922   chmod(0660, <scoring/*>) ;        # files in scoring - 600, there may be no files
  923   chmod(0770, 'logs') || die "Can't set permissions correctly for  logs directory. Fix the problem and run the setup script again. Stopped ";
  924   chmod(0660, <logs/*>) ;        # files in logs - 660, there may be no files
  925   chmod(0770, 'DATA') || die "Can't set permissions correctly for  DATA directory. Fix the problem and run the setup script again. Stopped ";
  926   chmod(0660, <DATA/*>) ;        # files in DATA - 660, there may be no files
  927   chmod(0770, 'DATA/.auth') || die "Can't set permissions correctly for  DATA/.auth directory. Fix the problem and run the setup script again. Stopped ";
  928   chmod(0660, <DATA/.auth/*>) ;        # files in DATA/.auth - 660, there may be no files
  929   chmod(0750, 'html')  || die "Can't set permissions correctly for  html directory. Fix the problem and run the setup script again. Stopped ";        # html subdir - 750
  930   chmod(0640, <html/*>)  ;
  931   chmod(0770, 'html/images') || die "Can't set permissions correctly for  html/images/ directory. Fix the problem and run the setup script again. Stopped ";     # html/tmp/ subdir - 775
  932   chmod(0770, 'html/tmp') || die "Can't set permissions correctly for  html/tmp/ directory. Fix the problem and run the setup script again. Stopped ";     # html/tmp/ subdir - 775
  933   chmod(0770, 'html/tmp/l2h') || die "Can't set permissions correctly for  html/tmp/l2h directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  934   chmod(0770, <html/tmp/l2h/*>);   # html/tmp/l2h/ subdir - 775
  935   chmod(0770, <html/tmp/l2h/*/*>) ;    # html/tmp/l2h/ subdir - 775
  936   chmod(0770, <html/tmp/l2h/*/*/*>) ;    # html/tmp/l2h/ subdir - 775
  937   chmod(0770, 'html/tmp/eps') || die "Can't set permissions correctly for  html/tmp/eps directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  938   chmod(0770, 'html/tmp/images') || die "Can't set permissions correctly for  html/tmp/images directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  939   chmod(0770, 'html/tmp/gif') || die "Can't set permissions correctly for  html/tmp/gif directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  940   chmod(0770, 'html/tmp/html') || die "Can't set permissions correctly for  html/tmp/html directory. Fix the problem and run the setup script again. Stopped ";    # html/tmp/l2h/ subdir - 775
  941   chmod(0750, 'courseScripts') || die "Can't set permissions correctly for  courseScripts directory. Fix the problem and run the setup script again. Stopped ";    # courseScripts subdir - 750
  942   chmod(0750, <courseScripts/*>)   ;
  943   chmod(0770, 'templates') || die "Can't set permissions correctly for  templates directory. Fix the problem and run the setup script again. Stopped ";  # templates subdir - 750
  944   chmod(0770, <templates/*>) ;  # files and directories in templates - 770, there may be no files
  945   chmod(0770, <templates/*/*>) ;  # files and directories in templates - 770, there may be no files
  946   chmod(0770, <templates/*/*/*>) ;  # files and directories in templates - 770, there may be no files
  947   chmod(0750, 'templates/macros') || die "Can't set permissions correctly for  templates/macros directory. Fix the problem and run the setup script again. Stopped ";    # templates/macros subdir - 750
  948   chmod(0750, <templates/macros/*>) ;  # files in templates/macros - 640, there may be no files
  949   print "\n Permissions set to default values.\n";
  950   }
  951 }
  952 
  953 if (-e 'DATA/.auth/keys') {
  954   unlink 'DATA/.auth/keys' || warn "Can't remove the DATA/.auth/keys file. You do not have to run the setup script again, but you should remove this file by hand/n";
  955 }
  956 
  957 print qq{
  958 The WeBWorK Course setup script has finished.
  959 
  960 
  961 In order to complete the setup, please continue reading the instructions about:
  962 
  963   1) using chmod g+xs to set the group setid properly.
  964   2) running import_classlist-database.pl in order to set up the classlist, password and permissions databases.
  965   3) running setProfPermissions.pl in order to give someone (probably yourself) professor privileges.
  966   4) building problem sets (initially just go to the professor's page and click on 'Enter Build
  967   Problem set Page).
  968 };
  969 
  970 
  971 
  972 
  973 sub check_URL {
  974   my ($name_URL,$var_URL) = @_;
  975   my $response = 'y';
  976   while ($response eq 'y') {
  977     if (($var_URL =~ m|^/|) or ($var_URL =~ m|^http://|)) {
  978       $response = 'n';
  979     }
  980     else {
  981       print qq{\nThe $name_URL you entered, $var_URL , does not begin with either \n
  982 a slash (/) or with http://  .  This is almost certainly an error. \n
  983 Do you want to enter the $name_URL again? (y or n)};
  984       $response =&getAns;
  985       if ($response ne 'n') {
  986         print "\n Enter the $name_URL:\n";
  987         $var_URL=<STDIN>;
  988         chomp($var_URL);
  989         $response = 'y';
  990       }
  991       else  {
  992         $response = 'n';
  993       }
  994     }
  995   }
  996   $var_URL;
  997 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9