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

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

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

Revision 775 Revision 798
13 13
14use strict; 14use strict;
15use warnings; 15use warnings;
16use WeBWorK::Utils qw(runtime_use); 16use WeBWorK::Utils qw(runtime_use);
17 17
18use constant TABLES => qw(password permission user set set_user problem problem_user); 18use constant TABLES => qw(password permission key user set set_user problem problem_user);
19 19
20################################################################################ 20################################################################################
21# constructor 21# constructor
22################################################################################ 22################################################################################
23 23
24sub new($$) { 24sub new($$) {
25 my $invocant = shift; 25 my $invocant = shift;
26 my $class = ref($invocant) || $invocant; 26 my $class = ref($invocant) || $invocant;
27 my $ce = shift; 27 my $ce = shift;
28 my $self = {};
28 29
29 # load the modules required to handle each table, and create driver 30 # load the modules required to handle each table, and create driver
30 foreach my $table (TABLES) { 31 foreach my $table (TABLES) {
31 die "Layout for table $table not specified in dbLayout.\n"
32 unless defined $ce->{dbLayout}->{$table}; 32 unless (defined $ce->{dbLayout}->{$table}) {
33 #warn "ignoring table $table: layout not specified in dbLayout";
34 next;
35 }
33 36
34 my $layout = $ce->{dbLayout}->{$table}; 37 my $layout = $ce->{dbLayout}->{$table};
38 my $record = $layout->{record};
35 my $schema = $layout->{schema}; 39 my $schema = $layout->{schema};
36 my $driver = $layout->{driver}; 40 my $driver = $layout->{driver};
37 my $source = $layout->{source}; 41 my $source = $layout->{source};
42 #warn "table=$table record=$record schema=$schema driver=$driver source=$source\n";
38 43
44 runtime_use($record);
39 runtime_use($schema, $driver); 45 runtime_use($schema);
46 runtime_use($driver);
40 $self->{$table} = $schema->new($driver->new($source), $table); 47 $self->{$table} = $schema->new($driver->new($source), $table, $record);
41 } 48 }
42 49
43 bless $self, $class; 50 bless $self, $class;
44 return $self; 51 return $self;
45} 52}
294 die "newUserProblem failed: problem ", $UserProblem->problem_id, " does not exist.\n" 301 die "newUserProblem failed: problem ", $UserProblem->problem_id, " does not exist.\n"
295 unless $self->{problem}->exists($UserProblem->set_id); 302 unless $self->{problem}->exists($UserProblem->set_id);
296 return $self->{problem_user}->add($UserProblem); 303 return $self->{problem_user}->add($UserProblem);
297} 304}
298 305
299sub getUserProblem($$) { 306sub getUserProblem($$$$) {
300 my ($self, $userID, $setID, $problemID) = @_; 307 my ($self, $userID, $setID, $problemID) = @_;
301 return $self->{problem_user}->get($userID, $setID, $problemID); 308 return $self->{problem_user}->get($userID, $setID, $problemID);
302} 309}
303 310
304sub putUserProblem($$) { 311sub putUserProblem($$) {
305 my ($self, $UserProblem) = @_; 312 my ($self, $UserProblem) = @_;
306 return $self->{problem_user}->put($UserProblem); 313 return $self->{problem_user}->put($UserProblem);
307} 314}
308 315
309sub deleteUserProblem($$) { 316sub deleteUserProblem($$$$) {
310 my ($self, $userID, $setID, $problemID) = @_; 317 my ($self, $userID, $setID, $problemID) = @_;
311 return $self->{problem_user}->delete($userID, $setID, $problemID); 318 return $self->{problem_user}->delete($userID, $setID, $problemID);
312} 319}
313 320
314################################################################################ 321################################################################################
315# set+set_user functions 322# set+set_user functions
316################################################################################ 323################################################################################
317 324
325sub getGlobalUserSet($$$) {
326 my ($self, $userID, $setID) = @_;
318# *** 327 # ***
328}
319 329
320################################################################################ 330################################################################################
321# problem+problem_user functions 331# problem+problem_user functions
322################################################################################ 332################################################################################
323 333
334sub getGlobalUserProblem($$$$) {
335 my ($self, $userID, $setID, $problemID) = @_;
324# *** 336 # ***
337}
325 338
3261; 3391;

Legend:
Removed from v.775  
changed lines
  Added in v.798

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9