[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 235 - (download) (as text) (annotate)
Tue Oct 16 00:43:35 2001 UTC (18 years, 2 months ago) by apizer
File size: 38916 byte(s)
modified permissions

    1 #!/usr/local/bin/webwork-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 .../webwork/system/lib 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 #  In addition, the smtp mail server (defined in Global.pm) requires a valid single
  412 #  email address.  Normally this is set to the address of the course administrator.
  413 #  Undeliverable email from the Send Mail page will be returned to the smtpSender address.
  414 #  Uncomment the line below and enter a valid email address (if you leave it commented
  415 #  out the webmaster's email address from Global.pm will be used).
  416 
  417 #  \$Global::smtpSender  = 'apizer\@math.rochester.edu';
  418 
  419 
  420 #  You should customize the following three items for your course.
  421 
  422 #  If you want to write essay type problems or questionnaires where the results are
  423 #  emailed back, you have to authorize the email addresses here by uncommenting and
  424 #  editing the next line.
  425 
  426 #  \$PG_environment{'ALLOW_MAIL_TO'} = ['apizer\@math.rochester.edu','gage\@math.rochester.edu'];
  427 
  428 
  429 #  On the Professor page, one can view statistical data on problem sets for
  430 #  the whole course and section by section or by recitation.  You may want to
  431 #  exclude certain sections or recitations (e.g. those containing practice users,
  432 #  TA's, or professors) from the overall statistics.  Statistics for excluded
  433 #  sections are reported separately.  List the names of all sections and
  434 #  recitations to be excluded in a coma separated list, e.g.
  435 #  \@excluse_these_sections_from_overall_statistics = ('', 'T.A.', 'Prof section');
  436 #  \@excluse_these_recitations_from_overall_statistics = ('');
  437 #  If this list is empty or commented out, no sections will be excluded.
  438 
  439 \@excluse_these_sections_from_overall_statistics = ('');
  440 \@excluse_these_recitations_from_overall_statistics = ('');
  441 
  442 
  443 #  If the following line is uncommented, when the user(s) listed view
  444 #  a problem or download a set, the file names of the source files will be
  445 #  listed.  Replace 'leeza', etc. by appropiate login names.  It is very
  446 #  useful for professors to be able to see these file names.
  447 
  448 #\$PG_environment{'PRINT_FILE_NAMES_FOR'} = ['leeza','apizer','gage'];
  449 
  450 
  451 #  Finally, when sending bulk email to students from the sendmail page, the following
  452 #  default values are used for the From and Reply-To fields.  Normally these fields
  453 #  are filled in and these default values are not used. More importanly, the
  454 #  defaultReply value is also used in the Reply-To field on feedback email which students
  455 #  can send to the feedbackAddress by hitting the feedback button. The format is the same
  456 #  as for the feedbackAddress above.
  457 
  458 \$Global::defaultFrom = \$Global::feedbackAddress;
  459 \$Global::defaultReply = \$Global::feedbackAddress;
  460 
  461 ######################################################################################
  462 ######################################################################################
  463 
  464 #  NORMALLY, THERE SHOULD BE NO NEED FOR CHANGES BELOW THIS LINE.  RUN THE SCRIPT
  465 #  course_webwork_setup.pl AND EVERYTHING SHOULD BE SETUP CORRECTLY. IF YOU DO
  466 #  EDIT THIS FILE BY HAND, WORK CAREFULLY.  REMEMBER THAT ALL DIRECTORY NAMES MUST
  467 #  END IN A TRALING DIRECTORY DELIMITER.
  468 
  469 
  470 
  471 #  To make it easier to edit and change these directories we define
  472 #  the classDirectory.  This variable is not used outside this file
  473 #  and while it is common for all of these directories to reside inside
  474 #  one directory, it is not necessary.
  475 
  476 \$classDirectory = "\${mainDirectory}courses/$courseDirectory";
  477 
  478 #  The database directory contains data describing the students in the course
  479 #  and their scores on homework.  The cgi scripts run by the webserver must
  480 #  be able to access the contents of this directory.
  481 
  482 \$databaseDirectory = "\${classDirectory}DATA/";
  483 
  484 #  The templates directory contains the class list, the problem set definition
  485 #  files and the problem templates.
  486 
  487 \$templateDirectory = "\${classDirectory}templates/";
  488 
  489 #  The email directory contains (templates of) emails which can be sent to everyone
  490 #  on the classlist.
  491 
  492 \$emailDirectory = "\${templateDirectory}email/";
  493 
  494 #  The macros directory contains macros for the problems files and the
  495 #  problem templates. These are usually macro files which are particular to the course.
  496 #  Macro files are searched for first in the \$macroDirectory and then
  497 #  in the system's courseScript directory.  If it is commented out, the macro files are
  498 #  only searched for in the system's courseScript directory.
  499 
  500 \$macroDirectory = "\${templateDirectory}macros/";
  501 
  502 #  The scoring directory contains files used by the scoring programs. These
  503 #  files contain scoring information for the whole class and are used for
  504 #  calculating semester grades, etc.
  505 
  506 \$scoringDirectory = "\${classDirectory}scoring/";
  507 
  508 #  The html directory contains the first page for the course (index.html),
  509 #  course documentation, and also subdirectories (e.g. tmp/)
  510 #  (e.g. tmp/) containing latex2html problems, gifs, etc.  The webserver has
  511 #  direct access to the html directory and the courseURL points to this
  512 #  directory.
  513 
  514 \$htmlDirectory = "\${classDirectory}html/";
  515 
  516 #  The logs directory contains log fies, e.g. login.log, backup psvn
  517 #  logs and logs of datamunger activity.
  518 
  519 \$logsDirectory = "\${classDirectory}logs/";
  520 
  521 
  522 #  This is the temp directory used by downloadPS, etc
  523 
  524 \$courseTempDirectory = "\${classDirectory}html/tmp/";
  525 
  526 #  This is the URL of the course html directory.  It points to the \$htmlDirectory
  527 #  above and it should have been set up correctly by the course_webwork_setup.pl
  528 #  script.  See the documentatiom (run the script or read
  529 #  .../docs/techdescription/settingupcourse.html).  Note that the URL depends on
  530 #  links in you webserver's htdocs directory and must end in a trailing directory
  531 #  delimiter (/ for unix).
  532 
  533 \$htmlURL = "$HTML_URL";
  534 
  535 #  This is the URL of the course tmp directory.  This is for temporary storage of
  536 #  html files, images, etc that have to accessible to the webserver.  This directory
  537 #  contains the subdirectories l2h, gif, eps, and html (not the \${classDirectory}html
  538 #  directory). All these subdirectories and their files will be recreated if deleted
  539 #  (althought recreating l2h files is time consuminmg).  The location of this directory
  540 #  may be changed to a fast disk which is not backed up.
  541 
  542 \$courseTempURL = "\${htmlURL}tmp/";
  543 
  544 #  This is the classID, i.e the symbolic link (or directory) that points to the base
  545 #  course directory. It appears in the courses subdirectory of the main WeBWorK system.
  546 
  547 \$classID = "$CLASS_ID";
  548 
  549 #  This is the name of the default classlist file which resides in the
  550 #  templateDirectory.  This default name is used to  edit the classlist file over
  551 #  the web.
  552 
  553 \$classlistFilename  = "\${classID}.lst";
  554 
  555 # This is the name of the group and the numerical gid. (some) Files created by
  556 # the WeBWorK system will have their group set to "\$groupID". Normally this
  557 # group will contain the webserver, your loginID, and the loginID's of anyone
  558 # else who will creating and editing WeBWorK problems for your course. If you
  559 # are editing this file by hand and know the \$groupID but not the \$numericalGroupID,
  560 # ask your systems administrator or run course_webwork_setup.pl and look at the
  561 # webworkCourse.ph it produces.  You may also be able to get this information by
  562 # looking at the group file usually:  /etc/group
  563 # Finally, if you have set up a "demo" version, the "\$numericalGroupID" will be
  564 # set to -1 which means maintain the current (default) group.
  565 ENDCOURSETMP
  566 
  567 if ($file_creation_mode eq 'demo')
  568 {
  569 print COURSETMP <<"ENDCOURSETMP";
  570 
  571 \$groupID = "$groupName";
  572 \$numericalGroupID = -1;
  573 
  574 ## this sets the header file over riding the Global setting
  575 
  576 \$Global::SET_HEADER = "paperSetHeader.pg";
  577 
  578 ENDCOURSETMP
  579 }
  580 
  581 else
  582 {
  583 print COURSETMP <<"ENDCOURSETMP";
  584 
  585 \$groupID = "$groupName";
  586 \$numericalGroupID = $gid;
  587 
  588 ## this sets the header file over riding the Global setting
  589 \$Global::SET_HEADER = "paperSetHeader.pg";
  590 
  591 ## If uncommented, this sets the default mode for displayed problems
  592 ## over riding the Global setting.
  593 #\$htmlModeDefault = 'HTML_tth'; # The default mode for displayed problems
  594                  # (either 'HTML','Latex2HTML', or 'HTML_tth')
  595 
  596 # This sets the default for grading multipart problems.  The choices at present are
  597 # std_problem_grader or avg_problem_grader. The std_problem_grader gives credit for
  598 # a mutipart problem only if all parts are answers correctly. The avg_problem_grader
  599 # gives partial credit for a mutipart problems.
  600 
  601 \$PG_environment{PROBLEM_GRADER_TO_USE} = 'avg_problem_grader';
  602 #\$PG_environment{PROBLEM_GRADER_TO_USE} = 'std_problem_grader';
  603 
  604 
  605 # This allows or dissallows Destroy and Rebuild. Set to 0 or 1. If set to 1 a
  606 # professor can destroy and rebuild problems sets in one operation. This is very
  607 # convenient and powerful, but also very dangerous.  Usually  this is not allowed
  608 # in courses students are using.  It is often set to 1 in a private course being
  609 # used only for developing problem sets.
  610 
  611 \$allowDestroyRebuildProbSets = 0;
  612 
  613 ENDCOURSETMP
  614 }
  615 
  616 
  617 if ($file_creation_mode eq 'demo')
  618 {
  619 print COURSETMP <<"ENDCOURSETMP";
  620 
  621 ## File and Directory permissions
  622 
  623 ## These permissions over ride the permissions set in
  624 ## Global.pm
  625 
  626 ## e.g. S1-1521.sco in (base course directory)/DATA
  627 \$sco_files_permission = 0666;
  628 
  629 ## tie permissions (used in tie commands)
  630 ## The database, password, and permissions files
  631 ## always take their permissions from the Global
  632 ## vaiables below.  The important keys file
  633 ## takes its permission from \$restricted_tie_permission.
  634 \$restricted_tie_permission = 0666;
  635 \$standard_tie_permission = 0666;
  636 
  637 ## webwork-database in (base course directory)/DATA
  638 \$webwork_database_permission = 0666;
  639 
  640 ## password in (base course directory)/DATA/.auth
  641 \$password_permission = 0666;
  642 
  643 ## permissions in (base course directory)/DATA/.auth
  644 \$permissions_permission = 0666;
  645 
  646 ## e.g. s1ful.csv in (base course directory)/scoring
  647 \$scoring_files_permission = 0666;
  648 
  649 ## e.g. s1bak1.csv in (base course directory)/scoring
  650 \$scoring_bak_files_permission = 0666;
  651 
  652 ## e.g. 8587l2h.log  in (base course directory)/html/tmp/l2h
  653 \$l2h_logs_permission = 0666;
  654 
  655 ## e.g set1/ in (base course directory)/html/tmp/l2h
  656 \$l2h_set_directory_permission = 0777;
  657 
  658 ## e.g. 1-1082/ in (base course directory)/html/tmp/l2h/set1
  659 \$l2h_prob_directory_permission  = 0777;
  660 
  661 ## e.g. 1082output.html in (base course directory)/html/tmp/l2h/set1/1-1082
  662 \$l2h_data_permission = 0777;
  663 
  664 ENDCOURSETMP
  665 }
  666 
  667 print COURSETMP <<"ENDCOURSETMP";
  668 
  669 
  670 ## This (if uncommented) overrides the setting in Global.pm. Use 'db_tie.pl' for the
  671 ## DB database and 'gdbm_tie.pl' for the GDBM database. For a "new" database type,
  672 ## you will have to write a 'newdb_tie.pl' file. These reside in the scripts directory.
  673 
  674 #\$Global::DBtie_file = 'db_tie.pl';
  675 
  676 
  677 ## This tells WeBWorK where to find the file that connects it to a physical database.
  678 
  679 require "\${Global::scriptDirectory}\$Global::DBtie_file";
  680 
  681 ## These are the file names for the various databases associated with this course.
  682 ## These names override the generic names given in Global.pm
  683 
  684 \$CL_Database       = "\${classID}_classlist_DB";
  685 \$passwordFilename    = "\${classID}_password_DB";
  686 \$permissionsFilename   = "\${classID}_permissions_DB";
  687 \$database          = "\${classID}_webwork_DB";
  688 
  689 # The following line is required by perl
  690 1;
  691 
  692 ENDCOURSETMP
  693 close(COURSETMP);
  694 
  695 #############      END new webworkCourse.ph #########################
  696 
  697 ###################### BEGIN new index.html  #########################
  698 
  699 open(INDEXTMP, ">index.html.tmp");
  700 print INDEXTMP <<"ENDINDEXTMP";
  701 <HTML>
  702 <HEAD>
  703 <TITLE>Welcome to WeBWorK</TITLE>
  704 </HEAD>
  705 
  706 <BODY BGCOLOR="#FFFFFF">
  707 
  708 <P ALIGN=CENTER>
  709    <IMG SRC="/webwork_system_html/images/webwork.gif" ALIGN=CENTER BORDER=1 ALT="WeBWorK Logo">
  710 </P>
  711 
  712 <BLOCKQUOTE>
  713    <H1>WeBWorK Generic Course Login Page for $CLASS_ID</H1>
  714    <HR>
  715 
  716    <H2>Log in as &quot;practice&quot; user</H2>
  717 
  718    You may test out WeBWorK by logging in as a
  719    &quot;practice&quot; user.  To begin, choose the <B>login</B> button below;
  720    Use <B><KBD>practice1</KBD></B> as your login name and password.
  721 
  722    <FORM ACTION= "${CGI_URL}login.pl" METHOD="POST">
  723     <INPUT TYPE="HIDDEN" NAME="course" VALUE="$CLASS_ID">
  724     <B><INPUT TYPE=SUBMIT VALUE="Login"></B>
  725    </FORM>
  726 
  727 <P>
  728 <STRONG>For more information on WeBWorK: </STRONG>
  729 <A HREF="http://webwork.math.rochester.edu/docs/docs">Webwork docs</A>.
  730 
  731 <HR>
  732 
  733 
  734 <FORM ACTION="${CGI_URL}feedback.pl" METHOD="POST">
  735 <INPUT TYPE="image" SRC="/webwork_system_html/images/ww_feedback.gif" BORDER=1 ALT="[Feedback]"  VALUE="Feedback">
  736 
  737 Last updated: <STRONG>22 August 2000</STRONG><BR>
  738 <TT>${HTML_URL}index.html</TT>
  739 
  740 </BLOCKQUOTE>
  741 
  742 </BODY></HTML>
  743 
  744 ENDINDEXTMP
  745 close(INDEXTMP);
  746 #############      END new index.html #########################
  747 
  748 #################### prompt for creating webworkCourse.ph #################
  749 print "\n\n";
  750 if (-e 'webworkCourse.ph')
  751   {
  752   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  753   else {
  754   print "An old webworkCourse.ph exists.  Do you want to create a new\n";
  755   print "webworkCourse.ph and save the old file as webworkCourse.ph.bak1?\n";
  756   print "If you answer y, and webworkCourse.ph.bak1 already exits, it\n";
  757   print "will be saved as webworkCourse.ph.bak2. Only two backups are kept. (y or n)\n";
  758   $ans=&getAns;
  759   }
  760 
  761   if ($ans eq 'y')
  762     {
  763     rename('webworkCourse.ph.bak1',  'webworkCourse.ph.bak2');
  764     rename('webworkCourse.ph',  'webworkCourse.ph.bak1');
  765     rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp";
  766     chmod 0664, 'webworkCourse.ph';
  767     }
  768   else
  769     {
  770     print "\nThe old webworkCourse.ph has not been changed.  You can look\n";
  771     print "at webworkCourse.ph.tmp to see what the new version would have been.\n";
  772     }
  773   }
  774 else
  775   {
  776   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  777   else {
  778   print "Do you want to create a webworkCourse.ph file (we recommmend that\n";
  779   print "you do as it is required for WeBWorK to function)? (y or n)\n";
  780   $ans=&getAns;
  781   }
  782   if ($ans eq 'y')
  783     {
  784     rename('webworkCourse.ph.tmp', 'webworkCourse.ph') || die "Can't rename webworkCourse.ph.tmp.
  785        Fix the problem and run the setup script again. Stopped ";
  786     chmod 0644, 'webworkCourse.ph';
  787     }
  788   else
  789     {
  790     print "\nA webworkCourse.ph file has not been created.  You will need to\n";
  791     print "create such a file.  You can look at webworkCourse.ph.tmp to see\n";
  792     print "what the file would have looked like.\n";
  793     }
  794   }
  795 
  796 #################### prompt for creating index.html #################
  797 
  798 print "\n\n";
  799 if (-e 'html/index.html')
  800   {
  801   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  802   else {
  803     print "An old index.html exists.  Do you want to create a new\n";
  804     print "index.html and save the old file as index.html.bak1\?\n";
  805     print "If you answer y, and index.html.bak1 already exits, it\n";
  806     print "will be saved as index.html.bak2. Only two backups are kept. (y or n)\n";
  807     $ans= &getAns;
  808   }
  809 
  810   if ($ans eq 'y')
  811     {
  812     rename('html/index.html.bak1',  'html/index.html.bak2');
  813     rename('html/index.html',  'html/index.html.bak1');
  814     rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped ";
  815     chmod 0664, 'html/index.html';
  816     }
  817   else
  818     {
  819     print "\nThe old index.html has not been changed.  You can look\n";
  820     print "at index.html.tmp to see what the new version would have been.\n";
  821     }
  822   }
  823 else
  824   {
  825   if ($course_setup_mode eq 'demo') {$ans = 'y';}
  826   else {
  827     print "Do you want to create an index.html file (we recommmend that\n";
  828     print "you do as it is required for WeBWorK to function)? (y or n)\n";
  829 
  830   $ans= &getAns;
  831   }
  832   if ($ans eq 'y')
  833     {
  834     rename('index.html.tmp', 'html/index.html') || die "Can't rename index.html.tmp. Fix the problem and run the setup script again. Stopped ";
  835     chmod 0664, 'html/index.html';
  836     }
  837   else
  838     {
  839     print "\nA index.html file has not been created.  You will need to\n";
  840     print "create such a file.  You can look at index.html.tmp to see\n";
  841     print "what the file would have looked like.\n";
  842     }
  843   }
  844 
  845 
  846 ################### Prompt to change the group ##########################
  847 if ($course_setup_mode eq 'demo') {$ans = 'y';}
  848 else {
  849 print qq{
  850 Do you want to set the group for all directories and files\?
  851 It is highly recommended that you do so.  Note that the default
  852 permissions for "working" version assumes the webserver is in
  853 the group. (y or n)
  854 };
  855 
  856 
  857 $ans= &getAns;
  858 }
  859   {               ## bare block to make breaking out easy
  860   if ($ans eq 'y')
  861     {
  862 
  863 
  864     chown(-1, $gid, '.');
  865     chown(-1, $gid,  <*>);
  866     chown(-1, $gid,  <logs/*>);
  867     chown(-1, $gid,  <DATA/*>);
  868     chown(-1, $gid,  <DATA/.auth>);
  869     chown(-1, $gid,  <DATA/.auth/*>);
  870     chown(-1, $gid,  <html/*>);
  871     chown(-1, $gid, <html/tmp/*>);
  872     chown(-1, $gid, <html/tmp/l2h/*>);
  873     chown(-1, $gid, <html/tmp/l2h/*/*>);
  874     chown(-1, $gid, <html/tmp/l2h/*/*/*>);
  875     chown(-1, $gid,  <scoring/*>);
  876     chown(-1, $gid,  <templates/*>);
  877     chown(-1, $gid,  <templates/*/*>);
  878     chown(-1, $gid,  <templates/*/*/*>);
  879     print qq(\n The group has been set to "$groupName"\n\n);
  880     }
  881   }   ##end of bare block
  882 
  883 
  884 ######################### Prompt file permission changes ######################
  885 if ($course_setup_mode eq 'demo') {$ans = 'y';}
  886 else {
  887 print "\n\n\n\n";
  888 print qq(
  889 Do you want to set default "$course_setup_mode" permissions for
  890 all directories and files\? It is highly recommended that you do so.
  891 The default permissions for a "working" version assume the webserver
  892 is in the group.
  893 Set permissions\?  (y or n)
  894 );
  895   $ans= &getAns;
  896 
  897 }
  898 if ($ans eq 'y')
  899 {if ($course_setup_mode eq "demo")
  900   {      ####demo  mode
  901   chmod(0755, '.') || die "Can't set permissions correctly for  base directory. Fix the problem and run the setup script again. Stopped ";
  902   chmod(0755, <*.pl>); ## perl files
  903   chmod(0644, <*.ph>); ## ph files
  904   chmod(0777, 'scoring') || die "Can't set permissions correctly for  scoring directory. Fix the problem and run the setup script again. Stopped ";
  905   chmod(0666, <scoring/*>) ;        # files in scoring - 600, there may be no files
  906   chmod(0777, 'logs') || die "Can't set permissions correctly for  logs directory. Fix the problem and run the setup script again. Stopped ";
  907   chmod(0666, <logs/*>) ;        # files in logs - 660, there may be no files
  908   chmod(0777, 'DATA') || die "Can't set permissions correctly for  DATA directory. Fix the problem and run the setup script again. Stopped ";
  909   chmod(0666, <DATA/*>) ;        # files in DATA - 660, there may be no files
  910   chmod(0777, 'DATA/.auth') || die "Can't set permissions correctly for  DATA/.auth directory. Fix the problem and run the setup script again. Stopped ";
  911   chmod(0666, <DATA/.auth/*>) ;        # files in DATA/.auth - 660, there may be no files
  912   chmod(0775, 'html')  || die "Can't set permissions correctly for  html directory. Fix the problem and run the setup script again. Stopped ";         # html subdir - 750
  913   chmod(0664, <html/*>)  ;
  914   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
  915   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
  916   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
  917   chmod(0777, <html/tmp/l2h/*>);   # html/tmp/l2h/ subdir - 775
  918   chmod(0777, <html/tmp/l2h/*/*>) ;    # html/tmp/l2h/ subdir - 775
  919   chmod(0777, <html/tmp/l2h/*/*/*>) ;    # html/tmp/l2h/ subdir - 775
  920   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
  921   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
  922   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
  923   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
  924 # 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
  925 # chmod(0755, <courseScripts/*>)   ;
  926   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
  927   chmod(0777, <templates/*>) ;  # files and directories in templates - 777, there may be no files
  928   chmod(0777, <templates/*/*>) ;  # files and directories in templates - 777, there may be no files
  929   chmod(0777, <templates/*/*/*>) ;  # files and directories in templates - 777, there may be no files
  930   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
  931   chmod(0755, <templates/macros/*>) ;  # files in templates/macros - 640, there may be no files
  932   print "\n Permissions set to default values.\n";
  933   }
  934 else      #####working mode
  935   {
  936   chmod(0750, '.') || die "Can't set permissions correctly for base directory. Fix the problem and run the setup script again. Stopped ";
  937   chmod(0750, <*.pl>); ## perl files
  938   chmod(0640, <*.ph>); ## ph files
  939   chmod(0770, 'scoring') || die "Can't set permissions correctly for  scoring directory. Fix the problem and run the setup script again. Stopped ";
  940   chmod(0660, <scoring/*>) ;        # files in scoring - 600, there may be no files
  941   chmod(0770, 'logs') || die "Can't set permissions correctly for  logs directory. Fix the problem and run the setup script again. Stopped ";
  942   chmod(0660, <logs/*>) ;        # files in logs - 660, there may be no files
  943   chmod(0770, 'DATA') || die "Can't set permissions correctly for  DATA directory. Fix the problem and run the setup script again. Stopped ";
  944   chmod(0660, <DATA/*>) ;        # files in DATA - 660, there may be no files
  945   chmod(0770, 'DATA/.auth') || die "Can't set permissions correctly for  DATA/.auth directory. Fix the problem and run the setup script again. Stopped ";
  946   chmod(0660, <DATA/.auth/*>) ;        # files in DATA/.auth - 660, there may be no files
  947   chmod(0770, 'html')  || die "Can't set permissions correctly for  html directory. Fix the problem and run the setup script again. Stopped ";        # html subdir - 750
  948   chmod(0660, <html/*>)  ;
  949   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
  950   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
  951   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
  952   chmod(0770, <html/tmp/l2h/*>);   # html/tmp/l2h/ subdir - 775
  953   chmod(0770, <html/tmp/l2h/*/*>) ;    # html/tmp/l2h/ subdir - 775
  954   chmod(0770, <html/tmp/l2h/*/*/*>) ;    # html/tmp/l2h/ subdir - 775
  955   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
  956   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
  957   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
  958   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
  959 # 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
  960 # chmod(0750, <courseScripts/*>)   ;
  961   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
  962   chmod(0770, <templates/*>) ;  # files and directories in templates - 770, there may be no files
  963   chmod(0770, <templates/*/*>) ;  # files and directories in templates - 770, there may be no files
  964   chmod(0770, <templates/*/*/*>) ;  # files and directories in templates - 770, there may be no files
  965   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
  966   chmod(0750, <templates/macros/*>) ;  # files in templates/macros - 640, there may be no files
  967   print "\n Permissions set to default values.\n";
  968   }
  969 }
  970 
  971 if (-e 'DATA/.auth/keys') {
  972   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";
  973 }
  974 
  975 print qq{
  976 The WeBWorK Course setup script has finished.
  977 
  978 
  979 In order to complete the setup, please continue reading the instructions about:
  980 
  981   1) using chmod g+s to set the group setid properly.
  982   2) running import_classlist-database.pl in order to set up the classlist, password and permissions databases.
  983   3) running setProfPermissions.pl in order to give someone (probably yourself) professor privileges.
  984   4) building problem sets (initially just go to the professor's page and click on 'Enter Build
  985   Problem set Page).
  986 };
  987 
  988 
  989 
  990 
  991 sub check_URL {
  992   my ($name_URL,$var_URL) = @_;
  993   my $response = 'y';
  994   while ($response eq 'y') {
  995     if (($var_URL =~ m|^/|) or ($var_URL =~ m|^http://|)) {
  996       $response = 'n';
  997     }
  998     else {
  999       print qq{\nThe $name_URL you entered, $var_URL , does not begin with either \n
 1000 a slash (/) or with http://  .  This is almost certainly an error. \n
 1001 Do you want to enter the $name_URL again? (y or n)};
 1002       $response =&getAns;
 1003       if ($response ne 'n') {
 1004         print "\n Enter the $name_URL:\n";
 1005         $var_URL=<STDIN>;
 1006         chomp($var_URL);
 1007         $response = 'y';
 1008       }
 1009       else  {
 1010         $response = 'n';
 1011       }
 1012     }
 1013   }
 1014   $var_URL;
 1015 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9