Parent Directory
|
Revision Log
Select available modes in Global.pm per John Jones suggestion
1 ################################################################################ 2 # WeBWorK 3 # 4 # Copyright (c) 1995-2001 WeBWorK Team, University of Rochester 5 # All rights reserved 6 # 7 # $Id$ 8 ################################################################################ 9 10 ################################### 11 ## Begin Global 12 ################################### 13 14 package Global; 15 16 # The variables defined in this package set defaults and parameters for 17 # the whole weBWorK system. Defaults can be over ridden for individual 18 # courses by redefining variables in the individual course 19 # webworkCourse.ph file. For example the default SYSTEM feedback address 20 # set below as: $feedbackAddress = 'webwork@math.rochester.edu'; can (and 21 # should) be over ridden for an individual course by entering e.g. 22 # $Global::feedbackAdress = 'apizer@math.rochester.edu, 23 # gage@math.rochester.edu'; in the individual course webworkCourse.ph 24 # file. Of course you should really enter the email address(es) of the 25 # professors teaching the course. 26 27 # The system_webwork_setup.pl script also creates the file webworkConfig.pm 28 # in the lib directory. This file contains a cgiDebugMode parameter than can 29 # be set to aid in the debugging of WeBWorK scripts. 30 31 ################################ 32 # Local configuration settings # 33 ################################ 34 35 # $legalAddress defines destination addresses which are accepted for use in 36 # scripts that send mail. It is a perl regular expression. 37 $legalAddress = '^[^@]+@([-\w]+\.)+[A-Za-z]{2,4}$'; 38 #$legalAddress = '^[^@]+@([-\w]+\.)+rochester.edu$'; 39 40 # These define the default addresses to which will be used by the system. 41 $webmaster = 'webwork@math.rochester.edu'; 42 # The purpose of the following addresses is explained in the webworkCourse.ph file. 43 $feedbackAddress = $webmaster; # should be redefined for each course in webworkCourse.ph 44 $defaultFrom = $webmaster; # should be redefined for each course in webworkCourse.ph 45 $defaultReply = $webmaster; # should be redefined for each course in webworkCourse.ph 46 $smtpSender = $webmaster; # should be redefined for each course in webworkCourse.ph 47 48 # $smtpServer is the address of the sendmail server. If you are running sendmail on the 49 # same machine as webwork, use "localhost" 50 $smtpServer = 'mail.math.rochester.edu'; 51 52 # $dirDelim is the delimiter used in pathnames on your system. 53 $dirDelim = '/'; 54 55 ########################### 56 # Local external programs # 57 ########################### 58 59 # tth is used by the formatted-text display mode. 60 $externalTTHPath = "/usr/local/bin/tth"; 61 62 # dvipng is used for dpng mode 63 $externalDvipngPath = "/usr/local/bin/dvipng"; 64 65 # These two have to match, from modes.mf 66 #$dvipngMode = "ljfivemp"; 67 #$dvipngDPI = 600; 68 $dvipngMode = "toshiba"; 69 $dvipngDPI = 180; 70 71 # Adjusting shrink factor produces better results than adjusting Resolution 72 # Resolution can have fractional values, like 1.3 whereas ShrinkFactor must 73 # be an integer. The size of the output is proportional to 74 # DPI * Scaling / ShrinkFactor 75 76 #$dvipngScaling = 1.0; # reasonable for ljfivemp 77 #$dvipngShrinkFactor = 6; # reasonable for ljfivemp 78 $dvipngScaling = 4.0; # reasonable for toshiba 79 $dvipngShrinkFactor = 6; # reasonable for toshiba 80 81 # latex2html is used for the typeset display mode. WeBWorK supports version 96.1 82 # and version 98.1p1 (or later). Specify either 96.1 or 98.1p1 for 83 # $externalLaTeX2HTMLVersion -- this will effect the syntax used when calling 84 # latex2html. $externalLaTeX2HTMLInit should point to a latex2html init file 85 # that matches the version of latex2html specified. 86 $externalLaTeX2HTMLPath = "/usr/local/bin/latex2html"; 87 $externalLaTeX2HTMLVersion = "98.1p1"; 88 $externalLaTeX2HTMLInit = "${mainDirectory}lib/latex2html.init.$externalLaTeX2HTMLVersion"; 89 90 # latex, dvips, and gs are programs used to generate problem set hard copy 91 # output in various formats (DVI, PostScript, PDF). 92 $externalLatexPath = "/usr/local/bin/latex"; 93 $externalDvipsPath = "/usr/local/bin/dvips"; 94 $externalGsPath = "/usr/local/bin/gs"; 95 96 # Finally some of the above programs may call other programs (e.g. dvips 97 # calls mktexpk to generate missing fonts). The locations of these other 98 # programs must be listed in Perl's $ENV{PATH} variable. The path listed in 99 # $extendedPath is appended to Perl's $ENV{PATH}. Setting 100 # $extendedPath = ':/usr/bin:/usr/local/bin' should work in almost all cases 101 # and $extendedPath = ':/usr/local/bin' should work in most. You may have to 102 # edit this depending on where these programs are found on your system. If you 103 # have problems, check .../webwork/system/logs/error_log for messages about programs 104 # which were not found. 105 $extendedPath = ':/usr/local/bin'; 106 107 108 ##################### 109 # Display Modes # 110 ##################### 111 112 # The rendering modes for onscreen problem display which are available to the student. 113 # Modes can be added, or commented out here. Adding a new mode required additional changes. 114 # The format is [internal symbol, external name]. 115 $available_mode_list = [ 116 ['HTML', 'text'], 117 ['HTML_tth', 'formatted-text'], 118 # ['HTML_dpng' ,'typeset2'], 119 ['Latex2HTML', 'typeset'] 120 ]; 121 122 # NOTE: HTML_dpng is an experimental mode which looks very promising. Look at John Jones 123 # site 124 # http://hobbes.la.asu.edu/webwork-stuff 125 # for installation instructions. In the short term HTML_dpng may become the standard mode 126 # replacing both Latex2HTML and HTML_tth. When MathML becomes well supported, that should 127 # become the standard mode. 128 129 # The default rendering mode for onscreen problem display: 130 # 'HTML' = raw TeX source 131 # 'HTML_tth' = HTML formatted with TTH 132 # 'HTML_dpng' = HTML formatted with LaTeX/dvipng 133 # 'Latex2HTML' = Images generated by LaTeX2HTML 134 $htmlModeDefault = 'HTML'; 135 136 137 ##################### 138 # Internal settings # 139 ##################### 140 141 # The access log is stored in the logs/ directory under the system directory 142 # in a file called "access_log". It contains information about virtually 143 # every action committed by users, including all answers submitted. 144 # Usually this information is unneccessary, and the file becomes 145 # large very quickly, so this log is ordinarily turned off. However, the 146 # information it contains might be useful if, for example, a student wants an 147 # extension and claims not to have viewed the correct answers. Set to 1 to 148 # enable the access log; set to 0 to disable. 149 $logAccessData = 0; 150 151 # the number of digits in each PSVN controls how many unique PSVNs can be 152 # created. For a PSVN of n digits, the range of available PSVNs will be 153 # [10^(n-1),10^n-1]. The number of available PSVNs must be more than 154 # number_of_students*number_of_problem_sets for any given course. 155 $psvn_digits = 5; 156 157 # Change DBtie_file only if you want to change the default database. The script 158 # gdbm_tie.pl uses GDBM_File which is the recommended and most tested database. 159 # The script db_tie.pl uses DB_File (the Berkeley DB database) and db3_tie.pl 160 # uses BerkeleyDB (for version 3 of Berkeley DB). Neither of the Berkeley 161 # databases has been used much with WeBWorK. This setting can be changed for an 162 # individual course in the webworkCourse.ph file. For some other database, 163 # you will have to write your own database tie-file. Such files reside in the 164 # scripts directory. 165 $DBtie_file = 'gdbm_tie.pl'; 166 #$DBtie_file = 'db_tie.pl'; 167 #$DBtie_file = 'db3_tie.pl'; 168 169 #################################################################################### 170 ########### There should be no need to customize after this point ################# 171 #################################################################################### 172 173 use sigtrap; 174 use diagnostics; 175 use webworkConfig; 176 #use PGtranslator; 177 # this is so that PGtranslator->evalute_macros is available when webworkCourse.ph is processed. 178 179 require 5.000; 180 require Exporter; 181 @ISA = qw(Exporter); 182 @EXPORT = qw( 183 getWebworkScriptDirectory 184 getWebworkCgiURL 185 getCourseMOTDFile 186 getSystemMOTDFile 187 getCourseDatabaseDirectory 188 getCourseDatabaseTieFile 189 getCourseLogsDirectory 190 getCourseTemplateDirectory 191 getCourseURL 192 getCourseScoringDirectory 193 getCourseScriptsDirectory 194 getCourseMacroDirectory 195 getCourseHtmlDirectory 196 getCourseEmailDirectory 197 getCourseTempDirectory 198 getCourseTempURL 199 getCourseClasslistFile 200 getCourseEnvironment 201 getCourseKeyFile 202 getCoursePasswordFile 203 getCoursePermissionsFile 204 getCourseDatabaseFile 205 getCourseHtmlURL 206 getCoursel2hDirectory 207 getCoursel2hURL 208 getDirDelim 209 getDelim 210 getScoreFilePrefix 211 getScoring_log 212 getDash 213 getDat 214 getBbext 215 getStatusDrop 216 convertPath 217 getNumRelPercentTolDefault 218 getNumZeroLevelDefault 219 getNumZeroLevelTolDefault 220 getNumAbsTolDefault 221 getNumFormatDefault 222 getFunctRelPercentTolDefault 223 getFunctZeroLevelDefault 224 getFunctZeroLevelTolDefault 225 getFunctAbsTolDefault 226 getFunctNumOfPoints 227 getFunctVarDefault 228 getFunctLLimitDefault 229 getFunctULimitDefault 230 getFunctMaxConstantOfIntegration 231 getLoginURL 232 getWebworkLogsDirectory 233 getErrorLog 234 wwerror 235 getAllowDestroyRebuildProbSets 236 ); 237 238 ## URL's derived from webworkConfig.pm 239 $loginURL = "${cgiWebworkURL}login.pl"; 240 $imagesURL = "${htmlWebworkURL}images/"; 241 $helpURL = "${htmlWebworkURL}helpFiles/"; 242 $webworkDocsURL = 'http://webwork.math.rochester.edu/docs/docs/'; 243 $appletsURL = "${htmlWebworkURL}applets/"; 244 245 ## practice users 246 $practiceUser = 'practice'; # name of password-less "practice" user 247 $practiceKey = 'practice'; # a dummy key for this user, can be anything 248 249 250 ## The database handle for using mSQL: 251 $dbh = 0; 252 253 ## various gifs 254 $helpGifUrl = "${imagesURL}ww_help.gif"; 255 $logoutGifUrl = "${imagesURL}ww_logout.gif"; 256 $feedbackGifUrl = "${imagesURL}ww_feedback.gif"; 257 $currentImgUrl = "${imagesURL}ww_curr.gif"; 258 $previousImgUrl = "${imagesURL}ww_prev.gif"; 259 $nextImgUrl = "${imagesURL}ww_next.gif"; 260 $problistImgUrl = "${imagesURL}ww_problist.gif"; 261 $upImgUrl = "${imagesURL}ww_up.gif"; 262 $bluesquareImgUrl = "${imagesURL}ww_bluesq.gif"; 263 $headerImgUrl = "${imagesURL}webwork.gif"; # image to include at top of pages 264 $squareWebworkGif = "${imagesURL}square_webwork.gif"; # image to include at top of pages 265 266 ## backgrounds gifs for HTML documents 267 $background_plain_url = "${imagesURL}white.gif"; 268 $background_okay_url = "${imagesURL}green.gif"; 269 $background_warn_url = "${imagesURL}red.gif"; 270 $bg_color = '#EFEFEF'; #background color for processProblem 271 272 ## Directories 273 $coursesDirectory = convertPath("${mainDirectory}courses/"); 274 $scriptDirectory = convertPath("${mainDirectory}scripts/"); 275 $cgiDirectory = convertPath("${mainDirectory}cgi/"); 276 #$tempDirectory = convertPath("/tmp/"); 277 $authDirectory = convertPath(".auth/"); 278 $courseScriptsDirectory = convertPath("${mainDirectory}courseScripts/"); 279 $macroDirectory = convertPath("${mainDirectory}courseScripts/"); 280 $classDirectory = ''; #This must be defined in webworkCourse.ph 281 $webworkLogsDirectory = "${mainDirectory}/logs/"; 282 283 ## File names 284 $coursesFilename = 'courses-list'; 285 $coursesFile = "${coursesDirectory}$coursesFilename"; 286 $classlistFilename = 'classlist.lst'; 287 $keyFilename = 'keys'; 288 $passwordFilename = 'password'; 289 $permissionsFilename = 'permissions'; 290 $database = 'webwork-database'; 291 $CL_Database = 'classlist-database'; 292 $tipsFilename = 'tips.txt'; 293 $system_motd_filename = 'motd.txt'; 294 $course_motd_filename = 'motd.txt'; 295 $tipsFile = "${mainDirectory}$tipsFilename"; 296 297 # CGI script calls 298 299 $login_CGI = "${cgiWebworkURL}login.pl"; 300 $logout_CGI = "${cgiWebworkURL}logout.pl"; 301 $welcome_CGI = "${cgiWebworkURL}welcome.pl"; 302 $welcomeAction_CGI = "${cgiWebworkURL}welcomeAction.pl"; 303 $processProblem_CGI = "${cgiWebworkURL}processProblem8.pl"; 304 $feedback_CGI = "${cgiWebworkURL}feedback.pl"; 305 $problemEditor_CGI = "${cgiWebworkURL}problemEditor.pl"; 306 307 ## The following items control how the whole problem set is typeset by downloadPS.pl. 308 ## The files (e.g. "tex_set_ptramble.tex") are found in the .../templates directory 309 ## Note that the system dependent latex and dvips programs are defined in the file 310 ## makePS which is in the .../scripts directory. makePS must be edited to call 311 ## the correct programs. 312 ## 313 314 ## This is the tex preamble file used by downloadPS.pl in typeseting the whole problem set. 315 ## E.g. loads AMS latex and graphics packages, some macro definitions. 316 $TEX_SET_PREAMBLE = 'texSetPreamble.tex'; 317 318 ## This is the tex header file used by downloadPS.pl in typeseting the whole problem set 319 ## E.g. loads two column format, macro definitions. 320 $TEX_SET_HEADER = ''; 321 322 ## This is the header file used by downloadPS.pl to enter preliminary verbiage for the 323 ## whole problem set. E.g. Course name, student name, problem set number,instructions, due date. 324 $SET_HEADER = 'paperSetHeader.pg'; 325 326 ## This is the tex footer file used by downloadPS.pl in typeseting the whole problem set 327 $TEX_SET_FOOTER = 'texSetFooter.tex'; 328 329 330 ## The following items control how an individual problem is typeset by processProblem.pl 331 ## and l2h. Note that the system dependent latex2html program is defined in processProblem.pl. It 332 ## should really be in a seperate file like makeps. 333 334 ## This is the tex preamble file used by processProblem.pl typeseting an individual problem 335 ## Usually very similar to $TEX_SET_PREAMBLE 336 $TEX_PROB_PREAMBLE = 'texProbPreamble.tex'; 337 338 ## This is the tex header file used by processProblem.pl typeseting an individual problem 339 $TEX_PROB_HEADER = ''; 340 341 342 ## This is the header file used by probSet.pl to enter preliminary verbiage on the prob set 343 ## page. E.g. Instructions, due date. 344 $PROB_HEADER = 'screenSetHeader.pg'; 345 346 ## This is the tex footer file processProblem.pl typeseting an individual problem 347 $TEX_PROB_FOOTER = 'texProbFooter.tex'; 348 349 350 351 $courseEnvironmentFile = 'webworkCourse.ph'; 352 #$webworkCourse_ph = 'webworkCourse.ph'; 353 $DBglue_pl = 'DBglue8.pl'; 354 $HTMLglue_pl = 'HTMLglue.pl'; 355 $classlist_DBglue_pl = 'classlist_DBglue.pl'; 356 $FILE_pl = 'FILE.pl'; 357 $displayMacros_pl = 'displayMacros.pl'; 358 $scoring_log = 'scoring.log'; 359 #####$probSetHeader = 'probSetHeader'; 360 $SCRtools_pl = 'pScSet6.pl'; 361 $buildProbSetTools = 'proceduresForBuildProbSetDB.pl'; 362 363 364 ## File and Directory permissions 365 366 ## e.g. S1-1521.sco in (base course directory)/DATA 367 $sco_files_permission = 0660; 368 369 ## tie permissions (used in tie commands) 370 ## The database, password, and permissions files 371 ## always take their permissions from the Global 372 ## vaiables below. The important keys file 373 ## takes its permission from $restricted_tie_permission. 374 $restricted_tie_permission = 0600; 375 $standard_tie_permission = 0660; 376 377 ## webwork-database in (base course directory)/DATA 378 $webwork_database_permission = 0660; 379 380 ## password in (base course directory)/DATA/.auth 381 $password_permission = 0660; 382 383 ## permissions in (base course directory)/DATA/.auth 384 $permissions_permission = 0660; 385 386 ## e.g. s1ful.csv in (base course directory)/scoring 387 $scoring_files_permission = 0660; 388 389 ## e.g. s1bak1.csv in (base course directory)/scoring 390 $scoring_bak_files_permission = 0440; 391 392 ## e.g. 8587l2h.log in (base course directory)/html/tmp/l2h 393 $l2h_logs_permission = 0660; 394 395 ## e.g. set1/ in (base course directory)/html/tmp/l2h 396 $l2h_set_directory_permission = 0770; 397 398 ## e.g. 1-1082/ in (base course directory)/html/tmp/l2h/set1 399 $l2h_prob_directory_permission = 0770; 400 401 ## e.g. 1082output.html in (base course directory)/html/tmp/l2h/set1/1-1082 402 $l2h_data_permission = 0770; 403 404 ## e.g. file.gif in (base course directory)/html/tmp/gif 405 $tmp_file_permission = 0660; 406 407 ## e.g. gif/ in (base course directory)/html/tmp/ 408 $tmp_directory_permission = 0770; 409 410 ##e.g. classlist files (e.g. MTH140A.lst) in (base course directory)/templates/ 411 $classlist_file_permission = 0660; 412 413 ## Prefixes, extensions, defaults, etc 414 415 $scoreFilePrefix = 'S'; 416 $dash = '-'; # Can not be the underscore character or an upper or 417 # lowercase letter or a digit. Used in .sco file names 418 $delim = ','; # used in scoring, classlist 419 $dat = 'csv'; 420 @statusDrop = qw(drop d withdraw); 421 $courselist_delim = '::'; # used by login.pl to get course names / dirs 422 $instructor_permissions = 10; 423 $TA_permissions = 5; 424 425 $score_decimal_digits = 1; # Number of decimal digits in recorded scores. For example 426 # if this is 1 then on a 1 point problem that allows partial 427 # credit, possible scores are 0, .1, .2, ..., 1. 428 429 $maxAttemptsWarningLevel = 5; 430 # If the set definition file puts a limit on the number of 431 # times a problem may be attempted, processProblem.pl will 432 # give a warning message when <= $maxAttemptsWarningLevel 433 # attempts remain. 434 435 $noOfFieldsInClasslist = 9; 436 # The number of fields in the classlist file. This is used as 437 # a check to make sure each record in the classlist file has 438 # this number of fields 439 440 $allowStudentToChangeEMAddress = 1; # setting to 1 allows students to change their 441 # own email address. Setting to 0 disallows this 442 443 $Global::PG_environment{showPartialCorrectAnswers} = 1; ## Set to 0 or 1. If set to 1 in multipart 444 # questions the student will be told which parts are 445 # correct and which are incorrect. Usually, this is 446 # set explicitly in each individual problem. 447 448 $allowDestroyRebuildProbSets = 0; # Set to 0 or 1. If set to 1 a professor can destroy and 449 # rebuild problems sets in one operation. This is very 450 # convenient and powerful, but also very dangerous. Usually 451 # this is not allowed in courses students are using. It is 452 # often set to 1 in a private course being used only for 453 # developing problem sets. To do this, reset this in the 454 # private course's webworkCourse.ph file. 455 456 $Global::PG_environment{recordSubmittedAnswers} = 1; # Set to 0 or 1. If set to 1, submitted answers will be 457 # stored. For example in a multipart question, a student can 458 # do several parts, then logout or go onto another question. 459 # When they view the problem again, the answer blanks will be 460 # filled in with their most recent answers. This also allows 461 # professors to see exactly what a student entered. This default 462 # can be over ridden for an individual problem by setting 463 # recordSubmittedAnswers in the .pg file for the problem. 464 465 $Global::PG_environment{refreshCachedImages} = 0; # Set to 0 or 1. If set to 1, the cached images for 466 # problems will never be used and Latex2html, dvipng, or any new 467 # modes that use cached images will always be called 468 # on to create or recreate all images. This can be very time 469 # consuming so almost never should this variable be set to 1. 470 # This default can be over ridden for an individual problem by 471 # setting e.g. refreshCachedImages = 1 in the .pg file for the problem. 472 # This is the real reason for the variable and is useful for 473 # conditional problems where the second part of the problem 474 # will be displayed only if a student answers the first part 475 # correctly. In this case the cached images would only show 476 # for the first part so the second part would never appear in 477 # typeset, etc. mode. 478 479 $maxSizeRecordedAns = 256; # Student answers longer than this length in bytes will not 480 # stored in the database. 481 482 $hide_studentID_from_TAs = 0; # Set to 0 or 1. If set to 1, studentID's will be hidden 483 # from TA's. For example some Universities may use SS#'s for 484 # student ID's and you may not want TA's to view these. 485 486 ## arguments for flock() 487 488 $shared_lock = 1; 489 $exclusive_lock = 2; 490 $nonblocking_lock = 4; 491 $unlock_lock = 8; 492 493 # These values provide defaults for the various answer comparison macros found 494 # in PGanswermacros.pl. They can be over ridden for individual courses by 495 # redefining the variables in the individual course webworkCourse.ph file. 496 # They can be over ridden for individual problems by explicitly passing the 497 # desired values to the answer comparison macro 498 499 # The following effect numerical answer comparison 500 $numRelPercentTolDefault = .1; 501 $numZeroLevelDefault = 1E-14; 502 $numZeroLevelTolDefault = 1E-12; 503 $numAbsTolDefault = .001; 504 $numFormatDefault = ''; ## use perl's format in prfmt() 505 # The following effect function comparison 506 $functRelPercentTolDefault = .1; 507 $functZeroLevelDefault = 1E-14; 508 $functZeroLevelTolDefault = 1E-12; 509 $functAbsTolDefault = .001; 510 $functNumOfPoints = 3; 511 $functVarDefault = 'x'; 512 $functLLimitDefault = .0000001; 513 $functULimitDefault = .9999999; 514 # The following effects function comparison upto constant for antidifferentiation 515 $functMaxConstantOfIntegration = 1E8; 516 517 # If you want student answers to have log interpreted as log base 10, change 518 # this to 1. The default of 0 has log mean log base e. 519 520 $useBaseTenLog = 0; 521 522 523 ## These values provide defaults for the window size in the problemEditor.pl script 524 $editor_window_rows = 25; 525 $editor_window_columns = 90; 526 527 ## This is the maximum number problems sets that can be downloaded at one time 528 ## by a professor. Set this higher or lower depending on the speed of your server 529 530 $max_num_of_ps_downloads_allowed = 20; 531 532 533 # Subroutines for defining the directories and URLs 534 ###### Public vars/routines - these are imported into your namespace, ####### 535 ###### so they can be called as they are. 536 ####### 537 538 sub getWebworkScriptDirectory { convertPath($scriptDirectory ) }; 539 sub getCourseDatabaseDirectory { convertPath($databaseDirectory )}; 540 sub getCourseDatabaseTieFile { convertPath($DBtie_file )}; 541 sub getCourseLogsDirectory { convertPath($logsDirectory )}; 542 sub getCourseTemplateDirectory { convertPath($templateDirectory )}; 543 sub getCourseEmailDirectory { convertPath("${templateDirectory}email/")}; 544 sub getCourseScoringDirectory { convertPath($scoringDirectory ) }; 545 sub getCourseHtmlDirectory { convertPath($htmlDirectory )}; 546 sub getCourseTempDirectory {convertPath($courseTempDirectory)}; 547 sub getCoursel2hDirectory { convertPath( "${courseTempDirectory}l2h/" )}; 548 sub getCourseScriptsDirectory { convertPath($courseScriptsDirectory )}; 549 sub getCourseMacroDirectory { convertPath($macroDirectory )}; 550 sub getWebworkLogsDirectory { convertPath($webworkLogsDirectory)}; 551 sub getErrorLog { convertPath("${webworkLogsDirectory}error_log")}; 552 sub getCourseClasslistFile { convertPath("${coursesDirectory}$_[0]/templates/${classlistFilename}") }; 553 554 sub getCourseKeyFile { convertPath("${coursesDirectory}$_[0]/DATA/${authDirectory}${keyFilename}") }; 555 sub getCoursePasswordFile { convertPath("${coursesDirectory}$_[0]/DATA/${authDirectory}${passwordFilename}") }; 556 sub getCoursePermissionsFile { convertPath("${coursesDirectory}$_[0]/DATA/${authDirectory}${permissionsFilename}") }; 557 sub getCourseDatabaseFile { convertPath("${coursesDirectory}$_[0]/DATA/${$database}") }; 558 559 sub getCourseMOTDFile { convertPath("${coursesDirectory}$_[0]/templates/${course_motd_filename}") }; 560 sub getSystemMOTDFile { convertPath("${mainDirectory}${system_motd_filename}") }; 561 562 sub getWebworkCgiURL { $cgiWebworkURL }; 563 sub getCourseHtmlURL { $htmlURL }; 564 sub getCoursel2hURL { "${courseTempURL}l2h/" } 565 sub getCourseTempURL { $courseTempURL }; #defined in webworkCourse.ph 566 sub getDirDelim { $dirDelim }; 567 sub getDelim { $delim }; 568 sub getScoreFilePrefix { $scoreFilePrefix }; 569 sub getScoring_log { $scoring_log }; 570 sub getDash { $dash }; 571 sub getDat { $dat }; 572 sub getBbext { @dbext }; 573 sub getStatusDrop { @statusDrop }; 574 575 sub getNumRelPercentTolDefault { $numRelPercentTolDefault }; 576 sub getNumZeroLevelDefault { $numZeroLevelDefault }; 577 sub getNumZeroLevelTolDefault { $numZeroLevelTolDefault }; 578 sub getNumAbsTolDefault { $numAbsTolDefault }; 579 sub getNumFormatDefault { $numFormatDefault }; 580 sub getFunctRelPercentTolDefault { $functRelPercentTolDefault }; 581 sub getFunctZeroLevelDefault { $functZeroLevelDefault }; 582 sub getFunctZeroLevelTolDefault { $functZeroLevelTolDefault }; 583 sub getFunctAbsTolDefault { $functAbsTolDefault }; 584 sub getFunctNumOfPoints { $functNumOfPoints }; 585 sub getFunctVarDefault { $functVarDefault }; 586 sub getFunctLLimitDefault { $functLLimitDefault }; 587 sub getFunctULimitDefault { $functULimitDefault }; 588 sub getFunctMaxConstantOfIntegration { $functMaxConstantOfIntegration }; 589 590 sub getLoginURL { $loginURL }; 591 592 sub getAllowDestroyRebuildProbSets { $allowDestroyRebuildProbSets }; 593 594 sub getCourseEnvironment { 595 die "getCourseEnvironment was called without specifying a course" unless $_[0]; 596 my $fullPath = convertPath("${coursesDirectory}$_[0]/$courseEnvironmentFile"); 597 require "$fullPath" 598 || die "Can't find local environment file for 599 $fullPath\n"; 600 } 601 602 603 604 ### dump a (hopefully) descriptive error to the browser and quit 605 606 607 sub wwerror { 608 my($title, $msg, $url, $label, $query_string) = @_; 609 # <BODY BACKGROUND=\"$background_warn_url\"> 610 611 $msg = '' unless defined $msg; 612 $url = '' unless defined $url; 613 $label = '' unless defined $label; 614 $query_string = '' unless defined $query_string; 615 616 print "content-type: text/html\n\n 617 <HTML><HEAD><TITLE>Error: $title</TITLE></HEAD> 618 <BODY BGCOLOR = 'CCCCCC'> 619 620 <H2>Error: $title</H2> 621 <PRE>$msg\n 622 </PRE>"; 623 if ($url) { 624 print "<FORM ACTION=\"$url\"> 625 <INPUT TYPE=SUBMIT VALUE=\"$label\"> 626 </FORM>\n"; 627 } 628 print "</BODY></HTML>"; 629 &log_error($title, $query_string); 630 exit 1; 631 } 632 633 sub error {wwerror(@_);} ##alias for wwerror 634 635 636 # return a (scalar) tip 637 sub tip { 638 my ($tips, @tiplist); 639 local($/) = undef; 640 #undef $/; # slurp it all in 641 open(TIPS, "$tipsFile") || &error("Can't open $tipsFile"); 642 $tips = <TIPS>; 643 close(TIPS); 644 645 # add any local tips to the list before we pick a random one 646 if (-r "${templateDirectory}$tipsFilename") { 647 open(TIPS, "${templateDirectory}$tipsFilename"); 648 $tips .= '%%' . <TIPS>; 649 close(TIPS); 650 } 651 $/ = "\n"; # <> now reads until newline 652 $tips =~ s/#.*?\n//mg; # remove comments 653 @tiplist = split(/%%/, $tips); 654 return $tiplist[rand(@tiplist)]; # choose one at random 655 } 656 657 # return an array of tips 658 sub all_tips { 659 my ($tip, $tips, @tiplist); 660 661 local($/) = undef; # slurp it all in 662 open(TIPS, "$tipsFile") || &error("Can't open $tipsFile"); 663 $tips = <TIPS>; 664 close(TIPS); 665 666 # add any local tips to the list before we pick a random one 667 if (-r "${templateDirectory}$tipsFilename") { 668 open(TIPS, "${templateDirectory}$tipsFilename"); 669 $tips .= '%%' . <TIPS>; 670 close(TIPS); 671 } 672 $/ = "\n"; # <> now reads until newline 673 $tips =~ s/#.*?\n//mg; # remove comments 674 @tiplist = split(/%%/, $tips); 675 return @tiplist; 676 } 677 678 679 # begin Timing code 680 use Benchmark; 681 sub dateTime { 682 my @timeArray = localtime(time); 683 my $out = sprintf("%2.2d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d", 684 $timeArray[5],$timeArray[4]+1,@timeArray[3,2,1,0]); 685 $out; 686 } 687 688 #the ps system calls do not work on all systems, and are usually not 689 #necessary anyway. If you wish that information to be logged, simply 690 #uncomment the relevant lines, but be warned that they might need to 691 #be modified for your system 692 sub logTimingInfo { 693 my ($beginTime,$endTime,$script,$course,$user,$remoteHost,$userAgent) = @_; 694 $remoteHost = ""unless defined($remoteHost); 695 $userAgent = "" unless defined($userAgent); 696 open(TIMELOG, ">>${webworkLogsDirectory}timing_log") || 697 warn "*Unable to open timing log for writing:\n ${webworkLogsDirectory}timing_log. "; 698 699 my $mem_string = ''; 700 # my $process_string = `ps -o vsz -p $$`; 701 # $process_string =~ s/^\s*//; 702 # $process_string =~ s/\s*$//; 703 # my @process_string = split(/\s+/,$process_string); # gets memory size 704 # my $mem_string = " mem: ${process_string[1]}K"; 705 706 my $load_string = ''; 707 # my @load = split(/\n/,`ps -U wwhttpd -o state`); 708 # my $load_string = " load: " . grep(/R/,@load); 709 710 print TIMELOG $script,"\t",$course,"\t",&dateTime,"\t", 711 timestr( timediff($endTime,$beginTime), 'all' ),"\t", 712 "pid: $$ DBtie_tries: $Global::DBtie_tries" . $mem_string . $load_string,"\t",$user,"\t", 713 $remoteHost,"\t",$userAgent,"\n"; 714 close(TIMELOG); 715 } 716 # end Timing code 717 718 719 # handy routines for modules that wish to throw exceptions outside of the 720 # current package. (taken from Carp.pm) 721 # 722 # We'll want to remove this in final versions of WeBWorK. 723 724 sub log_error { 725 my ($comment, $data) = @_; 726 # my $accessLog = convertPath("${webworkLogsDirectory}access_log"); 727 my $errorLog = convertPath("${webworkLogsDirectory}error_log"); 728 # open(ACCESS, ">>$accessLog"); 729 open(ERROR, ">>$errorLog") or warn "Can't open errorLog $errorLog"; 730 # print ACCESS "ERROR ($comment) ", scalar(localtime), ': ', &shortmess($data); 731 print ERROR "ERROR ($comment) ", scalar(localtime), ': ', &shortmess($data); 732 # close(ACCESS); 733 close(ERROR); 734 } 735 736 sub log_info { 737 if( $Global::logAccessData == 1 ) { 738 my ($comment, $data) = @_; 739 my $accessLog = convertPath("${webworkLogsDirectory}access_log"); 740 open(LOG, ">>$accessLog") or warn "Can't open accessLog $accessLog"; 741 print LOG "INFO ($comment) ", scalar(localtime), ': ', &shortmess($data); 742 close(LOG); 743 } 744 } 745 746 747 ## converts full path names to to use the $dirDelim instead of / 748 sub convertPath { 749 my ($path) = @_; 750 warn "convertPath has been asked to convert an empty path<BR> |$path| at ", caller(),"<BR>" unless $path; 751 $path =~ s|/|$dirDelim|g; 752 753 $path; 754 } 755 756 # ----- 757 758 BEGIN { 759 sub PG_floating_point_exception_handler { # 1st argument is signal name 760 my($sig) = @_; 761 print "Content-type: text/html\n\n<H4>There was a floating point arithmetic error (exception SIG$sig )</H4>--perhaps 762 you divided by zero or took the square root of a negative number? 763 <BR>\n Use the back button to return to the previous page and recheck your entries.<BR>\n"; 764 exit(0); 765 } 766 767 $SIG{'FPE'} = \&PG_floating_point_exception_handler; 768 769 sub PG_warnings_handler { 770 my @input = @_; 771 my $msg_string = longmess(@_); 772 my @msg_array = split("\n",$msg_string); 773 my $out_string = ''; 774 775 # Extra stack information is provided in this next block 776 # If the warning message does NOT end in \n then a line 777 # number is appended (see Perl manual about warn function) 778 # The presence of the line number is detected below and extra 779 # stack information is added. 780 # To suppress the line number and the extra stack information 781 # add \n to the end of a warn message (in .pl files. In .pg 782 # files add ~~n instead 783 784 if ($input[$#input]=~/line \d*\.\s*$/) { 785 $out_string .= "##More details: <BR>\n----"; 786 foreach my $line (@msg_array) { 787 chomp($line); 788 next unless $line =~/\w+\:\:/; 789 $out_string .= "----" .$line . "<BR>\n"; 790 } 791 } 792 793 $Global::WARNINGS .="* " . join("<BR>",@input) . "<BR>\n" . $out_string . 794 "<BR>\n--------------------------------------<BR>\n<BR>\n"; 795 $Global::background_plain_url = $Global::background_warn_url; 796 $Global::bg_color = '#FF99CC'; #for warnings -- this change may come too late 797 } 798 799 $SIG{__WARN__}=\&PG_warnings_handler; 800 801 $SIG{__DIE__} = sub { 802 my $message = longmess(@_); 803 $message =~ s/\n/<BR>\n/; 804 my ($package, $filename, $line) = caller(); 805 # use standard die for errors eminating from XML::Parser::Expat 806 # it uses a trapped eval which sometimes fails -- apparently on purpose 807 # and the error is handled by Expat itself. We don't want 808 # to interfer with that. 809 810 if ($package eq 'XML::Parser::Expat') { 811 die @_; 812 } 813 #print "$package $filename $line \n"; 814 print 815 "Content-type: text/html\r\n\r\n <h4>Software error</h4> <p>\n\n$message\n<p>\n 816 Please inform the webwork meister.<p>\n 817 In addition to the error message above the following warnings were detected: 818 <HR> 819 $Global::WARNINGS; 820 <HR> 821 It's sometimes hard to tell exactly what has gone wrong since the 822 full error message may have been sent to 823 standard error instead of to standard out. 824 <p> To debug you can 825 <ul> 826 <li> guess what went wrong and try to fix it. 827 <li> call the offending script directly from the command line 828 of unix 829 <li> enable the debugging features by redefining 830 \$cgiURL in Global.pm and checking the redirection scripts in 831 system/cgi. This will force the standard error to be placed 832 in the standard out pipe as well. 833 <li> Run tail -f error_log <br> 834 from the unix command line to see error messages from the webserver. 835 The standard error output is being placed in the error_log file for the apache 836 web server. To run this command you have to be in the directory containing the 837 error_log or enter the full path name of the error_log. <p> 838 In a standard apache installation, this file is at /usr/local/apache/logs/error_log<p> 839 In a RedHat Linux installation, this file is at /var/log/httpd/error_log<p> 840 At Rochester this file is at /ww/logs/error_log. 841 </ul> 842 Good luck.<p>\n" ; 843 }; 844 845 846 847 } 848 849 ############### 850 ## Error message routines 851 ############### 852 853 BEGIN { #error message routines 854 855 my $CarpLevel = 0; # How many extra package levels to skip on carp. 856 my $MaxEvalLen = 0; # How much eval '...text...' to show. 0 = all. 857 858 sub longmess { 859 my $error = shift; 860 my $mess = ""; 861 my $i = 1 + $CarpLevel; 862 my ($pack,$file,$line,$sub,$eval,$require); 863 864 while (($pack,$file,$line,$sub,undef,undef,$eval,$require) = caller($i++)) { 865 if ($error =~ m/\n$/) { 866 $mess .= $error; 867 } 868 else { 869 if (defined $eval) { 870 if ($require) { 871 $sub = "require $eval"; 872 } 873 else { 874 $eval =~ s/[\\\']/\\$&/g; 875 if ($MaxEvalLen && length($eval) > $MaxEvalLen) { 876 substr($eval,$MaxEvalLen) = '...'; 877 } 878 $sub = "eval '$eval'"; 879 } 880 } 881 elsif ($sub eq '(eval)') { 882 $sub = 'eval {...}'; 883 } 884 885 $mess .= "\t$sub " if $error eq "called"; 886 $mess .= "$error at $file line $line\n"; 887 } 888 889 $error = "called"; 890 } 891 892 $mess || $error; 893 } 894 895 sub shortmess { # Short-circuit &longmess if called via multiple packages 896 my $error = $_[0]; # Instead of "shift" 897 my ($curpack) = caller(1); 898 my $extra = $CarpLevel; 899 my $i = 2; 900 my ($pack,$file,$line); 901 902 while (($pack,$file,$line) = caller($i++)) { 903 if ($pack ne $curpack) { 904 if ($extra-- > 0) { 905 $curpack = $pack; 906 } 907 else { 908 return "$error at $file line $line\n"; 909 } 910 } 911 } 912 913 goto &longmess; 914 } 915 916 917 } 918 919 ############### 920 ## End Error message routines 921 ############### 922 923 924 1; ## This line is required by perl
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |