How do I use the Database activity?

Valid for Moodle 2.5.  Updated on 1/22/2014.The database has proven to be a very popular way of collecting information from students.  For example, in one course the database was used to compile an annotated list of web sites. In another it was used for people to submit paper proposals in a way that other users could see and comment on. Unlike forums, it is possible to hide the author of individual entries although they aren’t truly anonymous.

Defining the database activity.

  1. From your course page, turn editing on and go to the Topic or Week in which you want to add the database.
  2. Click on the Add an activity drop-down box and select Database to get the factivity list or, if you are using the activity chooser, click on Add an activity or resource link and select Database . Detailed descriptions of most of the fields are provided below the following image of the form, but in most cases the default values are fine.

    Database creation interface
  3. The database name will be the link students use to access the database activity. The description is required. You may want to use the description to tell your students what should go into the various fields
  4. Approval required allows you to evaluate entries before other students see them.
  5. If you want students to be able to comment of each other's entries, use All comments on entries.
  6. The Entries required for completion values can be ignored since we currently don’t support completion reporting.
  7. With Entries required before viewing you can require that your students add a minimal number of entries to the database before they can see what other students have submitted.
  8. You can use Maximum number of entries to limit the number of entries any individual student can add.
  9. The Availability section controls when students can see and make entries to the data base.
  10. The Grade section determines which gradebook category should contain the database item.
  11. The Ratings section allows entries to be rated. We don’t have any experience with rated databases.
  12. Common module settings and Restrict access sections are standard activity options. Most of the time the default values will be fine.  With a database you may want to hid the activity until you’ve finishing defining the fields and setting up the database display.
  13. When done click one of the two save buttons at the bottom of the page.

Defining fields

Once you’ve defined the database, it will show up in the course. However, until data fields are defined, your students can't do anything with it. By clicking on database name you will bring up a page with a variety of tabs. As an instructor you have more fields than your students. The first time you go to the database you'll need to define the fields.  In this example we're looking at a database called URL Database.

Database fields interface

Click on the Fields tab and then on the pull-down menu under Create a new field. This will allow you to select what type of field to create.Database field list

 

The field type controls what kind of data is to be entered and what the user interface looks like.  For example, the Menu field allows you to specify a list of values that the user must select from.  Text provides a simple one line text field while Textarea displays a multiline text box.  See the moodle.org documentation for a description of all the field types.

Once you’ve selected a field type the values that you enter to describe the field vary with the type of field.

Database URL field

In this case, a URL field, you enter a field name  and a field description. If a forced link is provide, when the record is displayed, the forced link text will be displayed rather than the URL itself. If no forced link is provided then the user will be prompted for text to display. The displayed text will, in all cases, be a link.

When autolink is turned on, Moodle will search the course site looking at pages, labels, wikis and other locations for the text provided by the user for the link name and, when ever that text is found create a link that brings up the database record. You should never use the forced link field when autolink is checked. [At the moment, we haven’t been able to get autolink to work with URL fields but the option exists, and works, with Text fields.

Display Templates

Next you must define how the entries are to be displayed. The display layout is controlled by two templates – Single Template and List Template. In addition you can change the layout of the form needed to add entries and to search the database.

Warning: You MUST touch the Single Template even if the default values are acceptable. To do this start by clicking on the Templates tab and then the Single Template subtab.  Then click Save template. This template is used when displaying one record at a time.

Warning: If you edit a database to add new fields you will probably need to manually alter the templates to make them match the new database record.

Single Template
Database Single View Template

On the left you have a list of tags that you can use to define the display. On the right is a text box where you create the template. By default you get a simple table with the first column being a list of field names and the second column field values. The bottom row of the table contain action links. You can rearrange the template anyway you want including adding or removing tags as desired. When done click on the Save Template button. You must click on this button the first time you look at this page even if you haven’t changed anything.

List Template

The List template works the same as the single template except you can define a header at the top of the list and a footer at the bottom.

Advances Search Template

The advanced search template defines the search form.

Database search template

By default this form allows for search by author name. If you don’t want students to be able to determine which entries belong to which student, you must remove these search fields.

Add Template

The add template defines the screen used to collect the record.  Here the field tags are used to indicate where the data entered is to go rather than what data should be displayed.

Database add template
Adding data

Now that all the fields have been defined and the templates set (and the link unhide if you had hidden it earlier) you and your students can add entries.  This is done by clicking on the Add entry tab.  Fill out the form and then hit the Save and view button if done or the Save and add another if you want to add additional entries.

Database Add entry
 
You can use the Choose a link... button to find a URL but most of the time it will be easier to just type in the URL or cut and paste it from another location.
Viewing data

To view what has been entered, click on either the View list or the View single tab. The list view shows you all the records.  The single view only shows you one record at a time.

Database single view
The list view shows you all the records plus it has a search form on the bottom. In this example there are only two records to show and no header or footer were defined.
 
Database list view
Searching for data

Use the Search tab to search the database. The search will look for partial matches and is not case sensitive. For example, a search for amh would return every record containing Amherst in the searched field. The search form look the same as one provided with the list view above.

Database search