[system] / trunk / webwork-modperl / conf / database.conf.dist Repository:
ViewVC logotype

View of /trunk/webwork-modperl/conf/database.conf.dist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4074 - (download) (annotate)
Tue May 16 21:10:35 2006 UTC (7 years, 1 month ago) by sh002i
File size: 7118 byte(s)
add sql_moodle database layout

    1 #!perl
    2 ################################################################################
    3 # WeBWorK Online Homework Delivery System
    4 # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/
    5 # $CVSHeader: webwork2/conf/database.conf.dist,v 1.17 2006/05/16 18:58:04 sh002i Exp $
    6 #
    7 # This program is free software; you can redistribute it and/or modify it under
    8 # the terms of either: (a) the GNU General Public License as published by the
    9 # Free Software Foundation; either version 2, or (at your option) any later
   10 # version, or (b) the "Artistic License" which comes with this package.
   11 #
   12 # This program is distributed in the hope that it will be useful, but WITHOUT
   13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   14 # FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
   15 # Artistic License for more details.
   16 ################################################################################
   17 
   18 =head1 NAME
   19 
   20 database.conf - define stantad database layouts
   21 
   22 =head1 SYNOPSIS
   23 
   24 In global.conf:
   25 
   26  include "conf/database.conf";
   27  *dbLayout = $dbLayouts{layoutName};
   28 
   29 =head1 DESCRIPTION
   30 
   31 This file contains definitions for the commonly-used database layouts. Database
   32 layouts consist of all the information necessary to describe how to access data
   33 used by WeBWorK. For more information on the format of a database layout,
   34 consult the documentation for the WeBWorK::DB module.
   35 
   36 A database layout is selected from the list of possible layouts by adding a
   37 line like the one below to the F<global.conf> or F<course.conf> file.
   38 
   39  $dbLayoutName = "layoutName";
   40  *dbLayout = $dbLayouts{$dbLayoutName};
   41 
   42 =cut
   43 
   44 %dbLayouts = (); # layouts are added to this hash below
   45 
   46 =head1 THE SQL_SINGLE DATABASE LAYOUT
   47 
   48 The C<sql_single> layout is similar to the C<sql> layout, excpet that it uses a
   49 single database for all courses. This is accomplised by prefixing each table
   50 name with the name of the course. The names and passwords of these accounts are
   51 given as parameters to each table in the layout.
   52 
   53  usernameRO     the name of the read-only account
   54  usernameRW     the name of the read-write account
   55  passwordRO     the password for the read-only account
   56  passwordRW     the password for the read-write account
   57 
   58 Be default, the name of the read-only account is "webworkRead", and the name of
   59 the read-write account is "webworkWrite". There are no passwords by default.
   60 It is not recommended that you use only passwords to secure database access.
   61 Most RDBMSs allow IP-based authorization as well. As the system administrator,
   62 IT IS YOUR RESPONSIBILITY TO SECURE DATABASE ACCESS.
   63 
   64 Don't confuse the accounts above with the accounts of the users of a course.
   65 These are system-wide accounts which allow WeBWorK to talk to the database
   66 server.
   67 
   68 Other parameters that can be given are as follows:
   69 
   70  tableOverride  an alternate name to use when referrring to the table (used
   71                 when a table name is a resereved word)
   72  fieldOverride  a hash mapping WeBWorK field names to alternate names to use
   73                 when referring to those fields (used when one or more field
   74         names are reserved words)
   75  debug          if true, SQL statments are printed before being executed
   76 
   77 =cut
   78 
   79 # params common to all tables
   80 my %sqlParams = (
   81   usernameRO => $database_username,
   82   passwordRO => $database_password,
   83   usernameRW => $database_username,
   84   passwordRW => $database_password,
   85   debug      => $database_debug,
   86 );
   87 
   88 $dbLayouts{sql_single} = {
   89   password => {
   90     record => "WeBWorK::DB::Record::Password",
   91     schema => "WeBWorK::DB::Schema::SQL",
   92     driver => "WeBWorK::DB::Driver::SQL",
   93     source => $database_dsn,
   94     params => { %sqlParams,
   95       tableOverride => "${courseName}_password",
   96     },
   97   },
   98   permission => {
   99     record => "WeBWorK::DB::Record::PermissionLevel",
  100     schema => "WeBWorK::DB::Schema::SQL",
  101     driver => "WeBWorK::DB::Driver::SQL",
  102     source => $database_dsn,
  103     params => { %sqlParams,
  104       tableOverride => "${courseName}_permission",
  105     },
  106   },
  107   key => {
  108     record => "WeBWorK::DB::Record::Key",
  109     schema => "WeBWorK::DB::Schema::SQL",
  110     driver => "WeBWorK::DB::Driver::SQL",
  111     source => $database_dsn,
  112     params => { %sqlParams,
  113       tableOverride => "${courseName}_key",
  114       fieldOverride => { key => "key_not_a_keyword" },
  115     },
  116   },
  117   user => {
  118     record => "WeBWorK::DB::Record::User",
  119     schema => "WeBWorK::DB::Schema::SQL",
  120     driver => "WeBWorK::DB::Driver::SQL",
  121     source => $database_dsn,
  122     params => { %sqlParams,
  123       tableOverride => "${courseName}_user",
  124     },
  125   },
  126   set => {
  127     record => "WeBWorK::DB::Record::Set",
  128     schema => "WeBWorK::DB::Schema::SQL",
  129     driver => "WeBWorK::DB::Driver::SQL",
  130     source => $database_dsn,
  131     params => { %sqlParams,
  132       tableOverride => "${courseName}_set"
  133     },
  134   },
  135   set_user => {
  136     record => "WeBWorK::DB::Record::UserSet",
  137     schema => "WeBWorK::DB::Schema::SQL",
  138     driver => "WeBWorK::DB::Driver::SQL",
  139     source => $database_dsn,
  140     params => { %sqlParams,
  141       tableOverride => "${courseName}_set_user"
  142     },
  143   },
  144   problem => {
  145     record => "WeBWorK::DB::Record::Problem",
  146     schema => "WeBWorK::DB::Schema::SQL",
  147     driver => "WeBWorK::DB::Driver::SQL",
  148     source => $database_dsn,
  149     params => { %sqlParams,
  150       tableOverride => "${courseName}_problem"
  151     },
  152   },
  153   problem_user => {
  154     record => "WeBWorK::DB::Record::UserProblem",
  155     schema => "WeBWorK::DB::Schema::SQL",
  156     driver => "WeBWorK::DB::Driver::SQL",
  157     source => $database_dsn,
  158     params => { %sqlParams,
  159       tableOverride => "${courseName}_problem_user"
  160     },
  161   },
  162 };
  163 
  164 =head1 THE SQL_MOODLE DATABASE LAYOUT
  165 
  166 The C<sql_moodle> layout is similar to the C<sql_single> layout, except it uses
  167 a Moodle database for user information and authentication.
  168 
  169 =cut
  170 
  171 # params used by moodle-backed tables
  172 my %moodleParams = (
  173   usernameRO  => $moodle_username,
  174   passwordRO  => $moodle_password,
  175   usernameRW  => $moodle_username,
  176   passwordRW  => $moodle_password,
  177   debug       => $database_debug,
  178   tablePrefix => $moodle_prefix,
  179   courseName  => $courseName,
  180 );
  181 
  182 $dbLayouts{sql_moodle} = {
  183   # start with sql_single table definitions
  184   %{$dbLayouts{sql_single}},
  185 
  186   # then override user, password, and permission tables
  187   # use the same record classes as sql_single
  188   user => {
  189     record => "WeBWorK::DB::Record::User",
  190     schema => "WeBWorK::DB::Schema::Moodle::User",
  191     driver => "WeBWorK::DB::Driver::SQL",
  192     source => $moodle_dsn,
  193     params => { %moodleParams },
  194   },
  195   password => {
  196     record => "WeBWorK::DB::Record::Password",
  197     schema => "WeBWorK::DB::Schema::Moodle::Password",
  198     driver => "WeBWorK::DB::Driver::SQL",
  199     source => $moodle_dsn,
  200     params => { %moodleParams },
  201   },
  202   permission => {
  203     record => "WeBWorK::DB::Record::PermissionLevel",
  204     schema => "WeBWorK::DB::Schema::Moodle::Permission",
  205     driver => "WeBWorK::DB::Driver::SQL",
  206     source => $moodle_dsn,
  207     params => { %moodleParams },
  208   },
  209 
  210 # moodlekey => {
  211 #   # never actually use this, as this is a wierd record type...
  212 #   record => "WeBWorK::DB::Record::Key",
  213 #   schema => "WeBWorK::DB::Schema::Moodle::Key",
  214 #   driver => "WeBWorK::DB::Driver::SQL",
  215 #   source => $sqlMoodleSource,
  216 #   params => { %sqlParams,
  217 #     tablePrefix => "mdl_",
  218 #   },
  219 # },
  220 };

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9