--- trunk/webwork-modperl/lib/WeBWorK/CourseEnvironment.pm 2002/06/25 20:29:22 412 +++ trunk/webwork-modperl/lib/WeBWorK/CourseEnvironment.pm 2002/07/25 21:45:29 440 @@ -1,3 +1,8 @@ +################################################################################ +# WeBWorK mod_perl (c) 1995-2002 WeBWorK Team, Univeristy of Rochester +# $Id$ +################################################################################ + package WeBWorK::CourseEnvironment; use strict; @@ -72,42 +77,56 @@ return $self; } -sub hash2string { - my $hr = shift; - my $indent = shift || 0; - my $result; - foreach (keys %$hr) { - $result .= "\t"x$indent . "{$_} ="; - if (ref $hr->{$_} eq 'HASH') { - $result .= "\n"; - $result .= hash2string($hr->{$_}, $indent+1); - } elsif (ref $hr->{$_} eq 'ARRAY') { - $result .= "\n"; - $result .= array2string($hr->{$_}, $indent+1); - } else { - $result .= " " . $hr->{$_} . "\n"; - } - } - return $result; -} +1; -sub array2string { - my $ar = shift; - my $indent = shift || 0; - my $result; - foreach (0 .. @$ar-1) { - $result .= "\t"x$indent . "[$_] ="; - if (ref $ar->[$_] eq 'HASH') { - $result .= "\n"; - $result .= hash2string($ar->[$_], $indent+1); - } elsif (ref $ar->[$_] eq 'ARRAY') { - $result .= "\n"; - $result .= array2string($ar->[$_], $indent+1); - } else { - $result .= " " . $ar->[$_] . "\n"; - } - } - return $result; -} +__END__ -1; +=head1 NAME + +WeBWorK::CourseEnvironment - Read configuration information from global.conf +and course.conf files + +=head1 SYNOPSIS + + use WeBWorK::CourseEnvironment; + $courseEnv = WeBWorK::CourseEnvironment->new($webworkRoot, $courseName); + + $timeout = $courseEnv->{sessionKeyTimeout}; + $mode = $courseEnv->{pg}->{options}->{displayMode}; + # etc... + +=head1 DESCRIPTION + +The WeBWorK::CourseEnvironment module reads the system-wide F and +course-specific F files used by WeBWorK to calculate and store +settings needed throughout the system. The F<.conf> files are perl source files +that can contain any code allowed under the default safe compartment opset. +After evaluation of both files, any package variables are copied out of the +safe compartment into a hash. This hash becomes the course environment. + +=head1 CONSTRUCTION + +=over + +=item new (ROOT, COURSE) + +The C method finds the file F relative to the given ROOT +directory. After reading this file, it uses the C<$courseFiles{environment}> +variable, if present, to locate the course environment file. If found, the file +is read and added to the environment. + +=back + +=head1 ACCESS + +There are no formal accessor methods. However, since the course environemnt is +a hash of hashes and arrays, is exists as the self hash of an instance +variable: + + $courseEnvironment->{someKey}->{someOtherKey}; + +=head1 AUTHOR + +Written by Sam Hathaway, sh002i (at) math.rochester.edu. + +=cut