「外部データベース登録」の版間の差分

提供:MoodleDocs
移動先:案内検索
73行目: 73行目:
== セットアップ方法 ==
== セットアップ方法 ==


You will need to perform (as a minimum) the following steps to enable external database enrolment - only a single table is required in the database which contains a record for every user/course combination. If the table is large it is a good idea to make sure appropriate indexes have been created:
外部データベース登録を有効にするには、最低、以下のステップが必要となります - ユーザおよびコースの組み合わせのレコードを含む単一のデータベーステーブルのみ必用です。If the table is large it is a good idea to make sure appropriate indexes have been created:


* Use an existing database or create a new one. Use an existing or create a new table with the following minimum fields:
* Use an existing database or create a new one. Use an existing or create a new table with the following minimum fields:

2012年3月19日 (月) 15:27時点における版


作成中です - Mitsuhiro Yoshida

ロケーション: 「設定 > サイト管理 > プラグイン > 受講登録 > 登録プラグイン管理」にて、外部データベース設定を編集することができます。

受講登録をコントロールするため、あなたは (ほとんどの種類の) 外部データベースを使用することができます。あなたの外部データベースのフィールドには、コースID、ユーザIDおよび任意のロールフィールドが含まれていると仮定します。これらのフィールドは、あなたが選択したローカルのコーステーブル、ユーザテーブルおよびロールテーブルと比較されます。

下記のリストは、Moodleでサポートされているデータソースです。あなたは適切なオプションを付けてPHPをコンパイルする、またはODBC経由にてデータベースにアクセスする必要があることに留意してください。

  • access
  • ado
  • mssql
  • borland_ibase
  • csv
  • db2
  • fbsql
  • firebird
  • ibase
  • informix72
  • informix
  • mysql
  • mysqlt
  • oci805
  • oci8
  • oci8po
  • odbc
  • odbc_mssql
  • odbc_oracle
  • oracle
  • postgres64
  • postgres7
  • postgres
  • proxy
  • sqlanywhere
  • sybase
  • vfp

登録 & 登録解除

外部データベース登録はユーザがMoodleにログインした時点で動作します。このプラグインでは、外部データベースのデータにもとづき、すべての該当するコースに学生の自動登録を試みます。また、コースが存在しない場合、任意に空のコースを作成します。正常動作を確認するには、学生としてログインした後、コースリストがあなたの希望どおりになっているかどうか確認してください。

また、ユーザがデータベースに存在しない場合、この処理ではコースからユーザを登録解除します。ユーザレコードはオリジナルの登録方法に従って登録されます。そのため、最初に外部データプラグインによって登録されたユーザに限って、外部データプラグインはユーザを登録解除することができます。

非表示コース

コース利用にて「学生はこのコースを利用できない」が設定されているコースの場合、「非表示のコースを無視する (enrol_db | ignorehiddencourse)」を有効にすることで、登録処理から除外することができます。

登録 & ロール

プラグイン設定ページの「enrol_database | defaultrole」では、コース追加時にユーザに割り当てられるロールを指定します。このデフォルトロール設定値は、コースのデフォルト設定 (初期値は「学生 (student)」) として割り当てられます。しかし、「リモートロールフィールド enrol_database | remoterolefield」にて、あなたはユーザロールの省略名を含む外部データベーステーブルのフィールドを指定することができます。例えば、この設定は適切に設定されたデータベースにより、学生および教師の両方をコースに登録するために使用できます。

コースの作成

Moodleサイト内に存在しないコースを任意に作成することができます。プラグイン設定内の「リモートの新しいコーステーブル (enrol_database newcoursetable)」オプションにコース一覧を含むテーブル名を入力してください。あなたは任意で新しいコースが作成されるカテゴリを指定することができます。また、新しいコースにコピーされる「テンプレート」コースを指定することもできます。

同期スクリプト

あなたのユーザの受講登録すべてを一度に同期できるスクリプトが提供されます - ユーザ受講登録の追加および解除 (そして、指定されていればコースを作成します)。同期スクリプト「enrol_database_sync.php」は「enrol/database」フォルダ内にあります。

このスクリプトは、外部データベースの受講登録情報とMoodleの受講登録情報を同期させるために、システムcronジョブよりコールされます。あなたは外部データベースに登録されているユーザすべてがMoodle内に作成されていることを確認する必要があります。あなたが外部認証プラグイン (db、ldap等) を使用している場合、このスクリプトを使用して同期する前に、それらのプラグインより提供されているスクリプトを使用することができます。

以下、Moodle 2.0のcronエントリ例です:

   # 5 minutes past 4am
   5 4 * * * /usr/bin/php -c /path/to/php.ini /path/to/moodle/enrol/database/cli/sync.php


メモ:

  • 大量のユーザ受講登録がある場合、「-d memory_limit=256M」を渡すことで、メモリ制限を上げることができます。
  • デバッグおよびログの目的のため、あなたは次のコマンドを自由に使うこともできます: -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
  • これは、あなたのMoodleサイトに登録されているユーザのみに対して動作します (上記コメントをご覧ください)。

セットアップ方法

外部データベース登録を有効にするには、最低、以下のステップが必要となります - ユーザおよびコースの組み合わせのレコードを含む単一のデータベーステーブルのみ必用です。If the table is large it is a good idea to make sure appropriate indexes have been created:

  • Use an existing database or create a new one. Use an existing or create a new table with the following minimum fields:
    • course identifier (to match unique course identifier in Moodle)
    • user identifier (to match unique user identifier in Moodle)
    • (optional) role identifier (to match unique role identifier in Moodle)
  • Populate the database table. Each user/course combination to have a record in the table
  • In Moodle, go to Site Administration => Courses => Enrolments, find External Database in the list and click Settings
  • In the top panel, select the database type (make sure you have the necessary configuration in PHP for that type) and then supply the information to connect to the database.
  • The middle panel creates the mapping between Moodle and the external database. The first three settings are for the local (Moodle) field names and the last three for the remote (external database) settings. They are in the same order.
    • enrol_localcoursefield / enrol_remotecoursefield - in Moodle the name of the field in the course settings the uniquely identifies the course (e.g., idnumber). In the external database the name of the matching field.
    • enrol_localuserfield / enrol_remoteuserfield - in Moodle the name of the field in the user profile that uniquely identified the user (e.g., idnumber). In the external database the name of the matching field.
    • enrol_db_localrolefield / enrol_db_remoterolefield - (optional) in Moodle the name of the field in the role edit page the uniquely identifies the role (e.g., shortname). In the external database the name of the matching field.
  • The Roles panel specifies the role that the user will get in the course if their role is not specified in the external database.
  • The final panel enables auto creation of courses.
  • Save changes, and then tick the box to enable external database enrolment.

Database enrolment does not appear in the course enrolment drop down menu. Why?

The course enrolment drop down menu only lists interactive enrolment plugins. External database enrolment is not such a plugin, so it doesn't appear in the list. Similarly, the "Course Enrollable" setting (in the Course Settings) page also only applies to interactive enrolment plugins and has no effect on external database enrollment.

As of this writing, the only interactive enrolment plugins are manual (also know as internal), paypal and authorize.net.

Field Mapping Example:

Choose your fields from the Moodle database:

  • enrol_localcoursefield: A course identifier from mdl_course, e.g. "idnumber"
  • enrol_localuserfield: A user identifier from mdl_user, e.g. "idnumber"
  • enrol_localrolefield: (optional) A role identifier from mdl_role, e.g. "shortname"

Create a view in your external database which matches the chosen field values from Moodle:

  • enrol_remotecoursefield: A matching course identifier from your external database table, e.g. "course_number"
  • enrol_remoteuserfield: A matching user identifier from your external database table, e.g. "userid"
  • enrol_remoterolefield: (optional) A matching role identifier from your external database table, e.g. "role_name"

Potential Gotchas

  • It almost goes without saying that the integrity of the external database is important. If data is missing from the database then there is a potential for users being unenrolled from some or all of their courses. The unenrollment process will remove them from any group assignments and also poll each module type to give the module the option of removing that user's data if appropriate (for example, however, forum posts are never deleted). It is therefore prudent that you take the utmost care to ensure that the data in the external bass is correct at all times.
  • Minor Security Issue Consider that if the ID field you use to identify your students is editable by the students (in their profile), then there is a potential for them changing this to the id of another valid student and gaining access to resources that they should not. However, they will still appear as themselves, they cannot impersonate the other user or otherwise gain access to their resources.

Errors and Diagnostics

The plugin produces a number of diagnostic messages and/or errors which are recorded to the PHP error log (as defined in the php.ini file). In addition messages about courses that are in the database for the user but that do not exist in the Moodle site will only be produced if debugging is set to ALL or DEVELOPER.

関連情報