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

Annotation of /trunk/webwork/courses/demoCourse/course_webwork_setup.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 464 - (view) (download) (as text)

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9