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