Skip to main content Skip to navigation

Add a database activity

The database activity allows participants to build, display and search a database of entries about any topic. This activity is a powerful and versatile tool which can be used for contact, absence and extension request forms, for image galleries, collecting project resources, generating timesheets and recording contact hours or time spent on CPD, and even as a support tool to capture help requests for a moodle help desk. This video is an excellent introduction to some of these.

Add a database activity

1. To add a database activity, turn editing on, click on the 'Add an activity or resource' link in the section or topic where you want it to appear.

2. Choose 'database' from the list of activities and resources.

Set the name and description

Database name and description

Entries

Defining the settings for the entries gives the options to substnatially change the way that participants engage with the database and the learning outcomes.

Database settings - entries

Approval required

If set to "yes", the entry will only be visible to everyone once it has been checked and approved.

Allow editing of approved entries

If 'approval required' is set to yes, then the editor / teacher can choose whether approved entries can still be edited once approved or if they are then locked.

Allow comments on entries

Allows participants to comment on each others database entries.

Entries required before viewing

Require participants to add 1 or more entries to the database before they can see what other participants have added.

Maximum numbers of entries

Restrict the total number of entries. Combining this with the previous option can help constrain and encourage students to add a specific number of items.

Grade to pass and ratings

These settings are optional, and collapsed by default.

Database grades and ratings

  1. NB Ratings 'aggregate type' must be set to something other than 'No ratings' before grade to pass can be used.
  2. Here you can set a passing grade for the database. This may be connected with Activity completion and Conditional activities such that a student will not be able to access a follow up activity until they have achieved the required grade in the database.
  3. Database entries can be rated using a scale. By default, only teachers can rate database entries. This is a useful tool for giving students participation grades.
  4. The total grade that a participant can achieve cannot exceed the maximum grade set here.

Setting up the database activity

In the steps below we will create a very simple database to capture information about books - the author, cover art, link to an online source. We will also cover the additional fields for Comments and Ratings that students and teachers can use to extend the use of the database activity.

Database

1. Define database fields

There are multiple field types and these can be added multiple times if required.

Database fields

Add a text input (single line) field

Add a text field

Add a picture field and set the size for the different views (list and single)

Add a picture field

Add a menu (drop down selection list) field

Add a menu field

Add a URL field

Add a URL field

For more information on the full list of fields available see Field types.

2. Presets

Rather than having to create a new database from scratch, the database activity module has a presets feature. You can create your own presets and share them with other Moodle users, import existing presets from zip files or from presets stored in Moodle.

Database presets

The Activity Examples course on the School demo site has a number of database activities with presets for download.

3. Add a database template

Add entry, list and single view templates are created automatically using the information added. It is possible to create more complex templates using CSS (to create specific display styles) and javascript (to perform scripted actions such as mathematical calculations and text manipulations).

Moodle.org has a page dedicated to understanding database templates that we recommend if you wish to delve into this more deeply.

Single template
  1. Created by default from the fields added. This can be altered by adding / removing fields.
  2. All available tags are listed on the left.

Database - single view template

List template

As with the single view template, this automatically adds the fields created earlier. In list view, an extra field is added by default, 'delcheck', which adds a checkbox at the top left of each entry to make it easier to perform mass delete functions on the database entries.

Database list view template

Add template

Use this template to change the input page under 'Add entry'. Fields added to this databse are available and displayed by default.

Add entry template

CSS and Javascript templates

CSS

It is possible to add HTML to templates and the CSS template allows you to further specify a specific visual style e.g. by adding a class to one of the fields such as Author in the HTML view, this can be used to target a particular style e.g. 'color' to that specific item on only that template e.g.

HTML code for the 'Add entry' template:

<td class="authorName template-field cell c0" style=""><b>Author:</b> </td>

CSS entry under CSS template:

.authorName{
color: red;
}

Result:

CSS example

Javascript

You can use javascript to manipulate the way elements are displayed in either the List, Single or Add templates. You need to enclose the part you want to manipulate in some named html element. The naming is essential as it allows you to identify the element for manipulation.

4. Adding an entry

New entry

Database - add entry

Approving entries

If (during database set up) 'Approval required' has been set to 'Yes' then an editor / teacher will approve entries by clicking on the tick icon.

Database approve entry

5. Viewing the database
Single view

Step through the entries, one by one, using the numbers or .

Database Single template
List view

Scroll down through the full list of entries.

Database - list view

Comment on entries

Add your comment and click 'save comment'. This will only available on single view.

Comment on entry

Rate entries

If rating is enabled, the editor / teacher can rate entries to give the participant who added this a 'score' towards their grade for this activity.

Rate database entry

Search

The 'search' page, like the templates, is automatically generated to include the fields added that have been used when adding entries - in the image below, for example, the drop down list against 'Genre' lists only those genres that have entries linked to them. The design of this page can also be changed via the templates section under 'Advanced search template'.

Search the database


For more guidance on the database activity, please see:

The information on this page relates to Moodle v3.4 and was last updated October 2018.

Contents

Filter by tool, task or content