[system] / trunk / webwork2 / lib / WeBWorK / CourseEnvironment.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/CourseEnvironment.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 422 Revision 700
1################################################################################
2# WeBWorK mod_perl (c) 2000-2002 WeBWorK Project
3# $Id$
4################################################################################
5
1package WeBWorK::CourseEnvironment; 6package WeBWorK::CourseEnvironment;
7
8=head1 NAME
9
10WeBWorK::CourseEnvironment - Read configuration information from global.conf
11and course.conf files.
12
13=cut
2 14
3use strict; 15use strict;
4use warnings; 16use warnings;
5use Safe; 17use Safe;
6use WeBWorK::Utils qw(readFile); 18use WeBWorK::Utils qw(readFile);
11# $courseName name of the course being used 23# $courseName name of the course being used
12sub new { 24sub new {
13 my $invocant = shift; 25 my $invocant = shift;
14 my $class = ref($invocant) || $invocant; 26 my $class = ref($invocant) || $invocant;
15 my $webworkRoot = shift; 27 my $webworkRoot = shift;
28 my $webworkURLRoot = shift;
16 my $courseName = shift; 29 my $courseName = shift || "";
17 my $safe = Safe->new; 30 my $safe = Safe->new;
18 31
19 # set up some defaults that the environment files will need 32 # set up some defaults that the environment files will need
20 $safe->reval("\$webworkRoot = '$webworkRoot'"); 33 $safe->reval("\$webworkRoot = '$webworkRoot'");
34 $safe->reval("\$webworkURLRoot = '$webworkURLRoot'");
21 $safe->reval("\$courseName = '$courseName'"); 35 $safe->reval("\$courseName = '$courseName'");
22 36
23 # determine location of globalEnvironmentFile 37 # determine location of globalEnvironmentFile
24 my $globalEnvironmentFile = "$webworkRoot/conf/global.conf"; 38 my $globalEnvironmentFile = "$webworkRoot/conf/global.conf";
25 39
71 bless $self, $class; 85 bless $self, $class;
72 return $self; 86 return $self;
73} 87}
74 88
751; 891;
90
91__END__
92
93=head1 SYNOPSIS
94
95 use WeBWorK::CourseEnvironment;
96 $courseEnv = WeBWorK::CourseEnvironment->new($webworkRoot, $courseName);
97
98 $timeout = $courseEnv->{sessionKeyTimeout};
99 $mode = $courseEnv->{pg}->{options}->{displayMode};
100 # etc...
101
102=head1 DESCRIPTION
103
104The WeBWorK::CourseEnvironment module reads the system-wide F<global.conf> and
105course-specific F<course.conf> files used by WeBWorK to calculate and store
106settings needed throughout the system. The F<.conf> files are perl source files
107that can contain any code allowed under the default safe compartment opset.
108After evaluation of both files, any package variables are copied out of the
109safe compartment into a hash. This hash becomes the course environment.
110
111=head1 CONSTRUCTION
112
113=over
114
115=item new (ROOT, COURSE)
116
117The C<new> method finds the file F<conf/global.conf> relative to the given ROOT
118directory. After reading this file, it uses the C<$courseFiles{environment}>
119variable, if present, to locate the course environment file. If found, the file
120is read and added to the environment.
121
122=back
123
124=head1 ACCESS
125
126There are no formal accessor methods. However, since the course environemnt is
127a hash of hashes and arrays, is exists as the self hash of an instance
128variable:
129
130 $courseEnvironment->{someKey}->{someOtherKey};
131
132=head1 AUTHOR
133
134Written by Sam Hathaway, sh002i (at) math.rochester.edu.
135
136=cut

Legend:
Removed from v.422  
changed lines
  Added in v.700

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9