插件过滤器稳定版

Database Activity filter

filter_moddataNicolas Dunand

  • Moodle 4.5
  • 更新 2025-04-04

A simple filter allowing the use of the Database activity to use data sets in Moodle. These data sets are mapped to users using course groups.
The first intended usage was to provide data sets for questions from Moodle’s question engine.
Database Activity filter for Moodle 3.11-4.1
A simple filter allowing the use of the Database activity to use data sets in Moodle. These data sets are mapped to users using course groups.
The first intended usage was to provide data sets for questions from Moodle’s question engine, as described in the Usage section below.
Usage
General usage
Create a database activity in a course, and set it to be unavailable to students. It is not necessary to have it unavailable, but it prevents from tampering or unwanted access to the raw data. The database activity name has to be name of the form `[A-Za-z0-9_]`, such as for instance “datasets”.
Create the following fields:
datasetname: short text
itemname: short text
fieldname: text area OR short text
Any number of fields `fieldname` can be used, as long as the field name is of the form `[A-Za-z0-9_]`.
Use the database activity import feature to import from a CSV file formated as below, using quotes where necessary:
datasetname;itemname;”fieldname”;..;..
For each dataset, there should be `n` items. Supposing there are `m` datasets, there would be `n * m` records in the CSV file / the Database activity. This step can also be done by manually creating records in the Database activity.
Create groups within the course for user-to-dataset mapping; these groups should be named `dataset_datasetname`. Then add students to a group, thus linking them to a dataset.
Whenever you want to display content from a user’s dataset to the user, use the following syntax:
`{{database_activity_name:itemname:fieldname}}`
For instance, to use the item named “item1”, and display the “data1” field from the user’s current dataset, using datasets defined in the Database activity named “datasets”, the syntax would be:

返回插件目录