Skip to content

Commit

Permalink
Continued removal of old dbLayouts
Browse files Browse the repository at this point in the history
This removes all references to dbLayoutName and cases where the dbLayouts hash is used.

With this, there is only the standard dbLayout, which is now defined in `WeBWorK::DB::Layout`.
  • Loading branch information
pstaabp committed Mar 2, 2024
1 parent f90b557 commit 1dfc58e
Show file tree
Hide file tree
Showing 23 changed files with 465 additions and 916 deletions.
18 changes: 4 additions & 14 deletions bin/addcourse
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ sub usage_error {
warn "@_\n";
warn "usage: $0 [options] COURSEID\n";
warn "Options:\n";
warn " [--db-layout=LAYOUT]\n";
warn " [--users=FILE [--professors=USERID[,USERID]...] ]\n";
exit;
}
Expand All @@ -99,7 +98,6 @@ my ($dbLayout, $users, $templates_from) = ('', '', '');
my @professors;

GetOptions(
"db-layout=s" => \$dbLayout,
"users=s" => \$users,
"professors=s" => \@professors,
"templates-from=s" => \$templates_from,
Expand All @@ -114,23 +112,15 @@ $ce = WeBWorK::CourseEnvironment->new({ courseName => $courseID });
die "Aborting addcourse: Course ID cannot exceed $ce->{maxCourseIdLength} characters."
if length($courseID) > $ce->{maxCourseIdLength};

if ($dbLayout) {
die "Database layout $dbLayout does not exist in the course environment.",
" (It must be defined in defaults.config.)\n"
unless exists $ce->{dbLayouts}{$dbLayout};
} else {
$dbLayout = $ce->{dbLayoutName};
}

usage_error("Can't specify --professors without also specifying --users.")
if @professors && !$users;

my @users;
if ($users) {
# This is a hack to create records without bringing up a DB object
my $userClass = $ce->{dbLayouts}{$dbLayout}{user}{record};
my $passwordClass = $ce->{dbLayouts}{$dbLayout}{password}{record};
my $permissionClass = $ce->{dbLayouts}{$dbLayout}{permission}{record};
my $userClass = $ce->{dbLayout}{user}{record};
my $passwordClass = $ce->{dbLayout}{password}{record};
my $permissionClass = $ce->{dbLayout}{permission}{record};

runtime_use($userClass);
runtime_use($passwordClass);
Expand Down Expand Up @@ -190,7 +180,7 @@ eval {
addCourse(
courseID => $courseID,
ce => $ce,
courseOptions => { dbLayoutName => $dbLayout },
courseOptions => {},
users => \@users,
%optional_arguments,
);
Expand Down
9 changes: 2 additions & 7 deletions bin/old_scripts/wwaddindexing
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@

=head1 NAME
wwaddindexing - add indices to an existing sql_single course.
wwaddindexing - add indices to an existing course.
=head1 SYNOPSIS
wwaddindexing COURSEID
=head1 DESCRIPTION
Adds indices to the course named COURSEID. The course must use the sql_single
database layout.
Adds indices to the course named COURSEID.
=cut

Expand Down Expand Up @@ -74,10 +73,6 @@ my $ce = WeBWorK::CourseEnvironment->new({
courseName => $courseID,
});

# make sure the course actually uses the 'sql_single' layout
usage_error("$courseID: does not use 'sql_single' database layout.")
unless $ce->{dbLayoutName} eq "sql_single";

# get database layout source data
my %sources = dbLayoutSQLSources($ce->{dbLayout});

Expand Down
2 changes: 1 addition & 1 deletion bin/upgrade-database-to-utf8mb4.pl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ BEGIN
},
);

my $db = new WeBWorK::DB($ce->{dbLayouts}{ $ce->{dbLayoutName} });
my $db = new WeBWorK::DB($ce->{dbLayout});
my @table_types = sort(grep { !$db->{$_}{params}{non_native} } keys %$db);

sub checkAndUpdateTableColumnTypes {
Expand Down
3 changes: 2 additions & 1 deletion conf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Configuration extension files.
Server configuration files.

- `webwork2.mojolicious.dist.yml` contains the webwork2 Mojolicious app configuration settings. Copy this file to
`webwork2.mojolicious.yml` if you need to change those settings. You usually will need to do this. This file contains server settings, database settings and paths to external programs.
`webwork2.mojolicious.yml` if you need to change those settings. You usually will need to do this. This file
contains server settings, database settings and paths to external programs.
- `webwork2.dist.service` is a systemd configuration file for linux systems that serves the webwork2 app via the
Mojolicious hypnotoad server. If you need to change it, then copy it to `webwork2.service`.
- `webwork2-job-queue.dist.service` is a systemd configuration file for linux systems that runs the webwork2 job queue
Expand Down
10 changes: 4 additions & 6 deletions conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,10 @@ $pg{displayModeOptions}{images} = {
# as 'baseline' or 'middle'.
dvipng_align => 'baseline',

# If dbsource is set to a nonempty value, then this database connection information will be used to store dvipng
# depths. It is assumed that the 'depths' table exists in the database.
# These are set in the CourseEnvironment.
dvipng_depth_db => {}
},
};
# The dvipng_depth_db will be used to store dvipng depths. It is assumed that the 'depths'
# table exists in the database. If you wish to override using the standard database connections
# see localOverrides.conf
},

##### Directories used by PG

Expand Down
25 changes: 25 additions & 0 deletions conf/localOverrides.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,31 @@ $mail{feedbackRecipients} = [

#push (@{${pg}{modules}}, [qw(LaTeXImage)]);


##############################
# Additional Database options
###############################

# If dbsource is set to a nonempty value, then this database connection information will be used to store dvipng
# depths. It is assumed that the 'depths' table exists in the database.

# $pg{displayModeOptions}{images}{dvipng_depth_db} => {
# dbsource => 'dsn_database_string',
# user => 'dsn_database_username',
# passwd => 'dsn_database_password',
# },

# Problem Library SQL database connection information

# $problemLibrary_db = {
# dbsource => 'database_dsn',
# user => 'database_username',
# passwd => 'database_password',
# storage_engine => 'myisam',
# };



################################################################################
# Using R with WeBWorK
################################################################################
Expand Down
2 changes: 0 additions & 2 deletions conf/site.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ $admin_course_id = 'admin';
# status.
#$new_courses_hidden_status = 'hidden';

# External Programs and database settings are now defined in webwork2.mojolicious.yml

#################################################################################
# These variables describe the locations of various components of WeBWorK on your
# server. You may use the defaults unless you have things in different places.
Expand Down
16 changes: 9 additions & 7 deletions conf/webwork2.mojolicious.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ externalPrograms:
mkdir: /bin/mkdir
tar: /bin/tar
gzip: /bin/gzip
git: /bin/git
git: /usr/bin/git
curl: /usr/bin/curl
mysql: /usr/bin/mysql
mysqldump: /usr/bin/mysqldump
Expand All @@ -266,8 +266,13 @@ externalPrograms:
# use polyglossia and fontspec packages (which require xelatex or lualatex).
# pdflatex: /usr/bin/xelatex --no-shell-escape

dvipng: /usr/bin/dvipng

# In order to use imagemagick convert you need to change the rights for PDF files from
# "none" to "read" in the policy file /etc/ImageMagick-6/policy.xml. This has possible
# security implications for the server.
convert: /usr/bin/convert

dvipng: /usr/bin/dvipng
dvisvgm: /usr/bin/dvisvgm
pdf2svg: /usr/bin/pdf2svg

Expand Down Expand Up @@ -296,15 +301,12 @@ database:
# Standard permissions command used to initialize the webwork database
# GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX, LOCK TABLES ON webwork.* TO webworkWrite@localhost IDENTIFIED BY 'passwordRW';
# where webworkWrite and passwordRW must match the corresponding variables in the next section.
username: ''
password: ''
username: webworkWrite
password: passwordRW

# For a DB on localhost - default to using Unix socket. Change to 0 to use a TCP connection to 127.0.0.1.
use_socket_if_localhost: 1

# Need to add the code in lines 209-217 to a perl file
# Add line 234 to same file

# The default storange engine to use is set here:
storage_engine: myisam

Expand Down
11 changes: 0 additions & 11 deletions courses.dist/modelCourse/course.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

# This file is used to override the global WeBWorK course environment for this course.

# Database Layout (global value typically defined in global.conf)
# Several database are defined in the file conf/database.conf and stored in the
# hash %dbLayouts.
# The database layout is always set here, since one should be able to change the
# default value in global.conf without disrupting existing courses.
# global.conf values:
# $dbLayoutName = 'sql_single';
# *dbLayout = $dbLayouts{$dbLayoutName};
$dbLayoutName = 'sql_single';
*dbLayout = $dbLayouts{$dbLayoutName};

# Users for whom to label problems with the PG file name
# For users in this list, PG will display the source file name when rendering a problem.
#$pg{specialPGEnvironmentVars}{PRINT_FILE_NAMES_FOR} = ['user_id1'];
Expand Down
4 changes: 1 addition & 3 deletions lib/Mojolicious/WeBWorK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ sub startup ($app) {
writeTimingLogEntry(
$c->ce,
'[' . $c->url_for . ']',
sprintf('runTime = %.3f sec', $c->timing->elapsed('content_generator_rendering')) . ' '
. $c->ce->{dbLayoutName},
''
sprintf('runTime = %.3f sec', $c->timing->elapsed('content_generator_rendering')), ''
);
}
}
Expand Down
16 changes: 6 additions & 10 deletions lib/WeBWorK/Authen.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,22 @@ sub class {
if (exists $ce->{authen}{$type}) {
if (ref $ce->{authen}{$type} eq "ARRAY") {
my $authen_type = shift @{ $ce->{authen}{$type} };

#debug("ref of authen_type = |" . ref($authen_type) . "|");
if (ref($authen_type) eq "HASH") {
if (exists $authen_type->{ $ce->{dbLayoutName} }) {
return $authen_type->{ $ce->{dbLayoutName} };
} elsif (exists $authen_type->{"*"}) {
if (exists $authen_type->{"*"}) {
return $authen_type->{"*"};
} else {
die "authentication type '$type' in the course environment has no entry for db layout '",
$ce->{dbLayoutName}, "' and no default entry (*)";
die "authentication type '$type' in the course environment has no default entry (*)";
}
} else {
return $authen_type;
}
} elsif (ref $ce->{authen}{$type} eq "HASH") {
if (exists $ce->{authen}{$type}{ $ce->{dbLayoutName} }) {
return $ce->{authen}{$type}{ $ce->{dbLayoutName} };
} elsif (exists $ce->{authen}{$type}{"*"}) {
if (exists $ce->{authen}{$type}{"*"}) {
return $ce->{authen}{$type}{"*"};
} else {
die "authentication type '$type' in the course environment has no entry for db layout '",
$ce->{dbLayoutName}, "' and no default entry (*)";
die "authentication type '$type' in the course environment has no default entry (*)";
}
} else {
return $ce->{authen}{$type};
Expand Down
Loading

0 comments on commit 1dfc58e

Please sign in to comment.