Search

The database activity is both powerful and complex and is useful in many situations with a little ingenuity and work.

You can also share the work of creating a database. If you want your learners to create and submit a database for a project, you can override the learner role and grant them authoring capabilities. If you then use the separate groups mode, each group can create its own database of research and submit it at the end for grading.

Remember to use roles and groups functionality to create additional flexibility to your database.

Example of a database activity used as a gallery.

In the example above the database activity is being used to capture a gallery of images. Learners are able to submit their own images and comment on images posted by others (comments can be turned on or off in the settings). 

Add a database activity

  1. Select Turn editing on.
  2. Select Database from the Add an activity/ resource menu.
  3. Enter a database activity name, this appears on the course page for learners.
  4. Customise the available settings as required, see Database Settings to learn more.
  5. Complete Common Module settings if required.
  6. Complete Restrict Access if required.
  7. Complete Activity Completion if required.
  8. Enter Tags if required.
  9. Select Save and display (or Save and return to course).

(This video is taken from the Database activity course in the Totara Academy, where you can access more resources and learning materials - including other videos). 

Creating database fields 

Once you have set up the database activity you need to set up the database fields required.

To create the fields for your database:

  1. On the database setup page, select the field type you want to add from the Create a new field dropdown menu.
  2. Enter a field name and a field description. The field name is used to create the templates, so make it unique and long enough to be descriptive, but not too long to retype.
  3. If necessary, add/select the options for each field type. For example, you can set the height and width of the text area generated by the textarea field.

(This video is taken from the Database activity course in the Totara Academy, where you can access more resources and learning materials - including other videos). 

There are a number of available field types that can be used in your database:

FieldDescriptionNotes
CheckboxSelect Checkbox from the dropdown menu. To add multiple check boxes, enter each option on a different line in the options text field.If you want to ensure that a learner actively selects only one of the options, it’s better to use the radio buttons field.
File

Allows a learner to upload a file from their computer. Select File from the dropdown menu.

If you want a learner to upload image files, it's better to use the picture field.
DateSelect Date from the dropdown menu. Creates a date field for each database entry.-
Latitude/longitude

Allows learners to enter the geographic location by specifying the location’s latitude and longitude. When learners view the entry, links are automatically generated to geographic data services such as Google Maps, Google Earth, or Multimap.





-
MenuAllows learners to select an option from a dropdown menu. Enter each option on a different line in the options text field.-
Menu (multiselect)Allows learners to select multiple options from a dropdown menu (by holding down the Control (Ctrl) or Shift key as they click).The check box field offers the same options as menu (multiselect) but with a more obvious user interface.
NumberAllows learners to enter a number (positive, negative, or zero).-
PictureAllows learners to upload an image file from their computer.-
Radio buttonsAllows learners to select just one option from a list. If used, radio buttons is a required field; a learner may only submit his database entry after selecting an option.-
Text

Allows learners to enter text up to 60 characters in length. For longer text, or for text that requires formatting, such as headers and bullet points, the textarea field should be used.

-
TextareaAllows learners to enter text longer than 60 characters in length and/or include formatting such as headers and bullet points.-
URLFor learners to enter a URL. Selecting Auto link the URL will make the URL a clickable link, and entering a forced name for the link means that the name will be used for the hyperlink.-
Required fieldIf you need to ensure one or several particular fields are always completed, then tick the box Required field when setting up the fields for your database. The field(s) will display a red asterisk when learners contribute to the database, and they will not be able to save their work until they have entered the relevant information. A new column will show the trainer which fields are required and not required.-

Edit a database activity

  1. Click Turn editing on.
  2. Click Edit next to the choice activity.
  3. Make the required changes.
  4. Click Save and display (or Save and return to course).

The first step to creating a database is adding it to the appropriate section of your course. As with most Totara activities, you first set the options for the database, then create the fields and templates.

Database settings 

SettingDescriptionNotes
Approval requiredIf enabled, entries require approving by a teacher before they are viewable by everyone.-
Allow editing of approved entriesIf disabled, approved entries are no longer editable or deletable by the user who added them. This setting has no effect unless Approval required is enabled.-

Allow comments on entries

Enables commenting on entries. The comments field appears on the single view template when this is enabled.-
Entries required for completionThe total number of entries a learner has to to enter before the database activity is complete. A reminder is displayed if the number of entries is not met.-
Entries required before viewingThe number of entries submitted before the learner can see entries by others. If this is not met, they will see the entry page only.

The database auto-linking filter should be disabled if entries are required before viewing, because the database auto-linking filter can't tell if a user has submitted the number of entries required.

Maximum number of entriesThe maximum number of entries the learner can submit before being blocked. This prevents people from spamming the system.-
Available from/toThe dates the database is both visible to learners and open for data entry.-
Read only from/toThe dates the database is available for viewing, but not open for data entry.-

Grade category

This setting controls the category in which this activity's grades are placed in the gradebook.-
Grade to passThis setting determines the minimum grade required to pass. The value is used in activity and course completion, as well as in the gradebook, where pass grades are highlighted in green and fail grades in red.-
Ratings aggregate type

The aggregate type defines how ratings are combined to form the final grade in the gradebook.

  • Average of ratings: The mean of all ratings.
  • Count of ratings: The number of rated items becomes the final grade. Note that the total cannot exceed the maximum grade for the activity.
  • Maximum: The highest rating becomes the final grade.
  • Minimum: The smallest rating becomes the final grade.
  • Sum: All ratings are added together. Note that the total cannot exceed the maximum grade for the activity.

If No ratings is selected, then the activity will not appear in the gradebook.

Scale

Select the type of grading used for this activity. If scale is chosen, you can then choose the scale from the scale dropdown. If point is chosen, you can then enter the maximum grade available for this activity.

-
 -

Tags

See Tags to learn more. -

Database template

Once you have created the fields for your database, you probably want to edit the templates that define the user interface. Creating the fields produces a default template.

Database templates all work on the same principle. They are basically HTML pages with a new set of tags for the database module to interpret. When editing a template, Totara displays a list of available tags on the left side of the editing screen. Double-clicking on any of the tags adds it to the template. The database activity interprets these new tags before sending the template’s HTML to the browser for display. It looks for words enclosed in either two square brackets([[) or two hash signs (##), representing two different types of interface elements it can add to the template.

The square brackets define data tags, which tell the module to replace the word in the brackets with the value or form element of the field with the same name. So if you have a database with a name field, you would represent it in the template with [[name]]. In the single or list template, the module would replace it with the data in the name field for that entry. In the list template, the module would replace it with a text field, and put the value in the text field if you’re editing the entry instead of creating a new one.

The ## tags indicate the word should be replaced by an icon or link for interacting with the module. These tags are used to place the edit and delete icons, and links for More, Approve, Comments, and User. If you want to add the edit icon to a template, you just add a tag that looks like ##edit##. When the user looks at the page with the tag, the database module replaces it with the edit icon. If the user then clicks on the icon, it takes them to the edit template.

Aside from the replacement tags, creating a template is just like creating an HTML page. Use a table to lay out the data elements (this is an acceptable use of tables for layout), add descriptive text around the replacement tags, and publish. The database makes it easy to rapidly view your changes by flipping between the Templates tab and the tab for the template you are working on.

Edit a template

To edit a template follow these steps:

  1. On the database page, click the Templates tab.

  2. Click one of the template links below the row of tabs.
  3. When you are done, click Save template.

Template is used to create and edit new entries. In this template, data tags are replaced with the form element for the field. If the user is editing an entry, the field will have the data from the field in the form element for editing as well.

It’s important to list every field you want the user to fill in on this template. If you leave off a field, the user won’t be able to add or edit its data.

There are three basic templates necessary to use the database; list, single, and add. The three other templates; RSS, CSS, and Java Script are more advanced templates and aren’t necessary for basic database use.

Single template

The single template is the detailed view of an entry. This template should list all of the available data. Consider organising the data if you have a lot of fields in your database.

List template

The list template is the first page learners will see when they come to your database. The list template should give an overview of the entries and enable users to click through to the single or edit template.

Organising a good list template is a bit of a challenge. First, you should identify the fields that will be most helpful to users for selecting the entries they want to view. The default layout almost always has too much information.

The form has three areas: the Header, Body, and Footer. If you lay out the list template as a table, you’ll want to use the Header area as the table header, the Body for the data, and the Footer to close the table, as has been done for the Totara.org modules and plug-ins and Totara Buzz databases. But the HTML editor puts a full table in each area, which makes it difficult to get proper alignment of the elements and not repeat the headers for every entry.

A knowledge of tables in HTML is required in order to lay out the entire list template as one table.

To make the entire list template as one table:

  1. On the list template page, turn off the HTML editor.
  2. In the Header area of the template, open the table and add a row for your header text. Each column should contain one element of the header.
  3. In the Body, create another row with the data and command replacement tags.
  4. In the Footer, close the table.
  5. Save the template. 
     

Do not switch the HTML editor on while editing this template. If you turn the editor back on, it will create tables in each of the areas.

RSS template

The RSS template allows you to structure the RSS feed from the database. If you have enabled RSS feeds for the database in the database options, the database will publish the entries in a feed. This template allows you to structure how the entries in the feed appear to the readers.

CSS template

The CSS template defines the CSS styles for all of the templates in the database. If you know CSS, you can adjust the template’s fonts, spacing, colours, and other display information.

JavaScript template

Like the CSS template, the JavaScript template is used by the other templates. The JavaScript template allows you to add new behaviours to the templates by defining JavaScript routines that can be loaded when the template page loads. At the time of this writing, the JavaScript API isn’t yet documented, but the image gallery preset uses JavaScript to define the size of images in the list and single templates.

Database presets 

Presets work as templates that are shared across the site, meaning you don;t have to recreate commonly used types of databases. By default there is one preset available Image gallery which is set up with all the necessary fields to allow you to create a database used as an image gallery. You can also import and export presets, making them easy to share with others. 

The example below shows a new database activity being set up with the gallery preset.

Example of a database activity using the gallery preset.

Creating a preset

To create a preset you will first need to set up the database as you want it, with all of the desired fields, you can then save it as a preset so that you do not need to repeat the same creation steps in future. 

  1. On the database page, click the Presets tab.
  2. In the Save as preset section give the preset a clear and distinct name.
  3. Click Continue.

You can also export the database to share it with others if you do not want to make it available across the site. Make sure you keep the export file safe for future use. 

Use a preset

How you use a preset will spending if you are importing it or selecting it from available presets on the site.

  1. On the database page, click the Presets tab.

  2. Depending you how you are accessing the preset either:

    • Import: In the Import section click the Choose file button to browse for your file or drag and drop the file into the upload area. Then click Import. 

    • Select: In the Use a preset section select the preset you wish to sue and then click Choose
  3. Customise the fields and templates as you require. 

If you have already created fields in your database, you need to map them to the new fields in the preset or they will be deleted. For example, if you load the image gallery preset, you can map three fields to the image, title, and caption fields in the preset. Any other fields will be deleted and any data in them will be lost.

Adding a database entry

Once you have set up a database activity and added some fields (either from scratch or using presets) you and the other users on the course can start adding entries. 

  1. Go to the course and open the database activity by clicking on the link. 
  2. Select the Add entry tab. 
  3. Complete the available fields (mandatory fields will be marked with a red asterisk). 
  4. To finish click the Save and view button, or click the Save and add another button to repeat the process (from step 3). 

Example of adding an entry based on the gallery preset.

Grading database entries

Giving grades for entries is the single most powerful motivator for learners. It also rewards learners for their time and effort. As always, if you don’t want to assign a numerical grade to an entry, you can create a custom scale and assign a qualitative grade. When you rate an entry, the grade is added to the grade book, like a rated forum post.

We would strongly recommend combining rating and comments. Rating allows you to assign a numerical value to an entry, but it doesn’t give you a method to tell the learner why they received the particular grade. The comments box enables you to communicate the reason.

Ratings and comments can be turned into a collaborative venture with your learners. By default, learners are allowed to add comments and only trainers are allowed to rate entries. However you can enable collaborative rating by setting a learner role override.

If you don’t see the Override roles link in the Roles tab, ask your system administrator. By default trainers are unable to override roles, so this ability must be granted by your system administrator as well as setting which roles can be overridden by the trainer role.

To enable learner rating of entries:

  1. On the Updating database page, select the Roles tab.
  2. Click the Override roles link just below the tabs.
  3. Select the learner role from the list of roles in your course.
  4. Select Allow for the Rate entries capability.
  5. Click Save changes.

Database capabilities

The database module has a number of capabilities you can use to fine-tune your learners interaction with the activity.

CapabilityDescription
View entries

This allows a user to view database entries submitted by other users. This capability is moderated by any submission requirements in the database options, such as the number of entries required before viewing.

Write entries

This allows a user to create new database entries.

Write commentsThis allows a user to add comments to database entries. This capability is only active if the comments option is enabled. By default, learners are allowed to add comments. If you only want trainers to be able to add comments, you can prevent this capability with a learner role override.
View ratingsThis allows a user to view all ratings.
Rate entriesThis allows a user to rate entries by other users. This capability is only active if the Allow posts to be rated option is enabled. The capabilities to write comments and rate entries together allow learners to provide feedback on entries.
Approve unapproved entriesThis allows a user to approve entries before they are viewable by everyone. This capability is only active if the Require approval option is enabled.
Manage entriesThis allows a user to edit and delete other users’ database entries.
Manage commentsThis allows a user to edit and delete other users’ comments.
Manage templatesThis allows a user to edit and delete the interface templates of the database. If you want learners to create database activities for each other, you can enable this capability for them.
View presets from all usersThis allows a user to view the list of site presets and select them for use.
Manage all template presetsThis allows a user to delete site presets.

Plugin settings

If you go to Site administration > Plugins > Activity modules > Database you can configure the site wide setting default. 

Remember to click Save changes once you are finished. 

SettingDescriptionNotes

Enables the possibility of RSS feeds for all databases. You will still need to turn feeds on manually in the settings for each database.

-
On this page



Provide feedback about this page using the link in the bottom right of this page. 

Still have questions? Why not post them in the forums of the Totara Community?