-

Note: You are currently viewing documentation for Moodle 3.10. Up-to-date documentation for the latest stable version of Moodle may be available here: Using Database.

Using Database: Difference between revisions

From MoodleDocs
m (WIP updating this page as part of docs improvement project)
Line 2: Line 2:
This page explores ways the [[Database activity]] may be used in your Moodle course.
This page explores ways the [[Database activity]] may be used in your Moodle course.
==Views==
==Views==
===View list===
===View list===
The list view shows multiple entries, possibly in a more abbreviated form to ensure all the information fits. You may use the controls at the bottom of the screen to search and sort the contents.
The list view shows multiple entries, possibly in a more abbreviated form to ensure all the information fits. You may use the controls at the bottom of the screen to search and sort the contents.
* ''View single'': one item at a time
* ''View single'': one item at a time
* ''View list'' : several items at a time (number is user defined)
* ''View list'' : several items at a time (number is user defined)
* ''Add entry'' : add an item to the database
* ''Add entry'' : add an item to the database
* ''Search''   : search the entries  
* ''Search'' : search the entries




Line 17: Line 14:


===Deleting multiple entries===
===Deleting multiple entries===
In List view, a checkbox will appear next to each entry. Select the entries you wish to delete and click the 'Delete selected' button. Alternatively, click the 'Select all' and the 'Delete all' buttons to delete all entries. A warning message will appear asking you to verify what you wish to delete.
In List view, a checkbox will appear next to each entry. Select the entries you wish to delete and click the 'Delete selected' button. Alternatively, click the 'Select all' and the 'Delete all' buttons to delete all entries. A warning message will appear asking you to verify what you wish to delete.
==Automatically linking database entries==
==Automatically linking database entries==
If the [[Database auto-linking filter]] is enabled, any entries in a database will be automatically linked to where the concept words and/or phrases appear within the same course. This includes forum postings, internal resources, week summaries etc.
If the [[Database auto-linking filter]] is enabled, any entries in a database will be automatically linked to where the concept words and/or phrases appear within the same course. This includes forum postings, internal resources, week summaries etc.


Note: If you do not want particular text to be linked (in a forum posting, say) then you should add <nolink> and </nolink> tags around the text. Alternatively the filter can be disabled for a particular activity.
Note: If you do not want particular text to be linked (in a forum posting, say) then you should add <nolink> and </nolink> tags around the text. Alternatively the filter can be disabled for a particular activity.
==Approving and undoing approval of entries==
==Approving and undoing approval of entries==
If, during database set up, 'Approval required' was set to 'Yes' then a teacher can approve an entry by clicking on the tick/checkmark icon.
If, during database set up, 'Approval required' was set to 'Yes' then a teacher can approve an entry by clicking on the tick/checkmark icon.


Line 38: Line 31:
|[[File:database highlighting.png|thumb|Highlighted entry waiting for approval]]
|[[File:database highlighting.png|thumb|Highlighted entry waiting for approval]]
|}
|}
==Importing many entries==
==Importing many entries==
You can import entries via a CSV file if you click the "Import entries" link under 'Database activity administration' in the Administration block of your course. CSV means Comma-Separated-Values and is a common format for text interchange.
You can import entries via a CSV file if you click the "Import entries" link under 'Database activity administration' in the Administration block of your course. CSV means Comma-Separated-Values and is a common format for text interchange.
Line 55: Line 47:


Sample file:
Sample file:
   name,height,weight
   name,height,weight
   Kai,180cm,80kg
   Kai,180cm,80kg
   Kim,170cm,60kg
   Kim,170cm,60kg
   Koo,190cm,20kg
   Koo,190cm,20kg
Note: Certain field types may not be supported.
Note: Certain field types may not be supported.


Do not put spaces after your commas or upload will fail!
Do not put spaces after your commas or upload will fail!


After upload page import.php comes back blank if it failed.  
After upload page import.php comes back blank if it failed.
If successful you'll read a message like, "1 entries saved".
If successful you'll read a message like, "1 entries saved".
==Exporting entries==
==Exporting entries==
You can export entries either in CSV (comma separated values) or ODS (OpenOffice Calc) formats by clicking the tab at the top or by clicking the "Export entries" link under 'Database activity administration' in the Administration block in your course. (Both CSV and ODS formats can be opened with MS Excel.)
You can export entries either in CSV (comma separated values) or ODS (OpenOffice Calc) formats by clicking the tab at the top or by clicking the "Export entries" link under 'Database activity administration' in the Administration block in your course. (Both CSV and ODS formats can be opened with MS Excel.)


Line 81: Line 69:


For information on converting the date export (and import) format, see the discussion [https://moodle.org/mod/forum/discuss.php?d=220505 Standard Database Module - Dates].
For information on converting the date export (and import) format, see the discussion [https://moodle.org/mod/forum/discuss.php?d=220505 Standard Database Module - Dates].
==Enabling an RSS feed of recently added entries==
==Enabling an RSS feed of recently added entries==
To enable an RSS feed from a database activity, an administrator must first enable RSS feeds for database activities across the whole site as described in [[RSS feeds settings]]. A section called 'RSS' will then appear on the edit settings page of the database activity.  
To enable an RSS feed from a database activity, an administrator must first enable RSS feeds for database activities across the whole site as described in [[RSS feeds settings]]. A section called 'RSS' will then appear on the edit settings page of the database activity.  
# Edit the database activity settings and set the number of entries in the RSS feed e.g. 5.
# Edit the database activity settings and set the number of entries in the RSS feed e.g. 5.
# Check that the RSS template includes the required fields.
# Check that the RSS template includes the required fields.
# Log out and then access the database activity as a guest.
# Log out and then access the database activity as a guest.
# Copy the 'RSS feed for this activity' link in the administration block.
# Copy the 'RSS feed for this activity' link in the administration block.
The RSS feed may then be displayed in an [[Remote RSS feeds block]] or elsewhere.
The RSS feed may then be displayed in an [[Remote RSS feeds block]] or elsewhere.
==Exporting to an external portfolio==
==Exporting to an external portfolio==
If an external [[Portfolios|portfolio]] such as [[Mahara_portfolio|Mahara]] has been enabled by the administrator then users have the option to export individual entries to that portfolio if the ##export## tag is added to list and/or single templates. They will see at the bottom of a database entry an "export" icon to click on and select the portfolio to export to:
If an external [[Portfolios|portfolio]] such as [[Mahara_portfolio|Mahara]] has been enabled by the administrator then users have the option to export individual entries to that portfolio if the ##export## tag is added to list and/or single templates. They will see at the bottom of a database entry an "export" icon to click on and select the portfolio to export to:


[[File:Exportdatabasentry.png]]
[[File:Exportdatabasentry.png]]
== Example databases ==
Moodle.org has two good examples of the database module in action:
* [http://moodle.org/mod/data/view.php?id=6140 Moodle Buzz], a database of the titles, authors and web links to news articles mentioning Moodle
* [http://moodle.org/mod/data/view.php?d=26 Themes], a database with screenshots, download links and user comments about Moodle [[Themes|themes]]
== Creative uses ==
== Creative uses ==
You could use the database module to:
You could use the database module to:
* allow collaboration on building a collection of web links/books/journal references related to a particular subject
* allow collaboration on building a collection of web links/books/journal references related to a particular subject
* display student created photos/posters/websites/poems for peer comment and review
* display student created photos/posters/websites/poems for peer comment and review
* gather comments and votes on a shortlist of potential logos/mascot names/project ideas
* gather comments and votes on a shortlist of potential logos/mascot names/project ideas
* provide a [http://moodle.org/mod/forum/discuss.php?d=52699 student file storage area]
* provide a [http://moodle.org/mod/forum/discuss.php?d=52699 student file storage area]
* maintain a log of what was done in a face-to-face class each day, so that absent students can get caught up themselves. [http://moodle.org/mod/forum/discuss.php?d=115047 Example]
* maintain a log of what was done in a face-to-face class each day, so that absent students can get caught up themselves. [http://moodle.org/mod/forum/discuss.php?d=115047 Example]
 
== See also ==
== See also ==
*[https://school.moodledemo.net/course/view.php?id=57&section=3 Examples of databases in the School demo site] (available for download)
*[https://school.moodledemo.net/course/view.php?id=57&section=3 Examples of databases in the School demo site] (available for download)
* [[Glossary module]], which performs a similar though more specialised, text-based role
* [[Glossary module]], which performs a similar though more specialised, text-based role
* Moodle in English [http://moodle.org/mod/forum/view.php?id=3505 Database activity module forum]
* Moodle in English [http://moodle.org/mod/forum/view.php?id=3505 Database activity module forum]
[[de:Datenbank nutzen]]
[[de:Datenbank nutzen]]
[[es:Usando BasedeDatos]]
[[es:Usando BasedeDatos]]

Revision as of 17:10, 7 September 2021

This page explores ways the Database activity may be used in your Moodle course.

Views

View list

The list view shows multiple entries, possibly in a more abbreviated form to ensure all the information fits. You may use the controls at the bottom of the screen to search and sort the contents.

  • View single: one item at a time
  • View list : several items at a time (number is user defined)
  • Add entry : add an item to the database
  • Search : search the entries


26databaseview.png


Deleting multiple entries

In List view, a checkbox will appear next to each entry. Select the entries you wish to delete and click the 'Delete selected' button. Alternatively, click the 'Select all' and the 'Delete all' buttons to delete all entries. A warning message will appear asking you to verify what you wish to delete.

Automatically linking database entries

If the Database auto-linking filter is enabled, any entries in a database will be automatically linked to where the concept words and/or phrases appear within the same course. This includes forum postings, internal resources, week summaries etc.

Note: If you do not want particular text to be linked (in a forum posting, say) then you should add <nolink> and </nolink> tags around the text. Alternatively the filter can be disabled for a particular activity.

Approving and undoing approval of entries

If, during database set up, 'Approval required' was set to 'Yes' then a teacher can approve an entry by clicking on the tick/checkmark icon.

Once an entry has been approved, it is possible to undo the approval by clicking the circle with a line through it icon.

Entry approved
Approval undone

Entries waiting for approval may be highlighted for the teacher and the user who added the entry.

Highlighted entry waiting for approval

Importing many entries

You can import entries via a CSV file if you click the "Import entries" link under 'Database activity administration' in the Administration block of your course. CSV means Comma-Separated-Values and is a common format for text interchange.

Databaseupload.png

The easiest way to determine the format of the text file is to manually add an entry to the database and then export it. The resulting export text file may then be edited and used for importing entries. Here's a sample of what a very simple file will look like.

Upload csv sample.png

The expected file format is a plain text file with a list of field names as the first record. The data then follows, one record per line.

The field delimiter defaults to a comma character and the field enclosure is not set by default (field enclosures are characters that surround each field in each record).

Records should be delimited by new lines (usually generated by pressing RETURN or ENTER in your text editor). Tabs can be specified using \t and newlines by \n.

Sample file:

 name,height,weight
 Kai,180cm,80kg
 Kim,170cm,60kg
 Koo,190cm,20kg

Note: Certain field types may not be supported.

Do not put spaces after your commas or upload will fail!

After upload page import.php comes back blank if it failed. If successful you'll read a message like, "1 entries saved".

Exporting entries

You can export entries either in CSV (comma separated values) or ODS (OpenOffice Calc) formats by clicking the tab at the top or by clicking the "Export entries" link under 'Database activity administration' in the Administration block in your course. (Both CSV and ODS formats can be opened with MS Excel.)

Databasexport.png

When using the CSV format, the user can select either the comma, semicolon, or tab to separate the fields. The selection of the proper character is important. If users select to use a comma to separate the fields and some of the fields contain data with commas then the number of columns is going to be misaligned and likely cause confusion.

Users can select which fields from the database they wish to have exported. By default, all fields are checked to be included. Choose the fields that you wish to have included in the export.

Once the export type and the fields to be exported have been selected, clicking on the Export entries pushbutton will generate the file. The user will usually have the option of either opening or saving the file.

For information on converting the date export (and import) format, see the discussion Standard Database Module - Dates.

Enabling an RSS feed of recently added entries

To enable an RSS feed from a database activity, an administrator must first enable RSS feeds for database activities across the whole site as described in RSS feeds settings. A section called 'RSS' will then appear on the edit settings page of the database activity.

  1. Edit the database activity settings and set the number of entries in the RSS feed e.g. 5.
  2. Check that the RSS template includes the required fields.
  3. Log out and then access the database activity as a guest.
  4. Copy the 'RSS feed for this activity' link in the administration block.

The RSS feed may then be displayed in an Remote RSS feeds block or elsewhere.

Exporting to an external portfolio

If an external portfolio such as Mahara has been enabled by the administrator then users have the option to export individual entries to that portfolio if the ##export## tag is added to list and/or single templates. They will see at the bottom of a database entry an "export" icon to click on and select the portfolio to export to:

Exportdatabasentry.png

Creative uses

You could use the database module to:

  • allow collaboration on building a collection of web links/books/journal references related to a particular subject
  • display student created photos/posters/websites/poems for peer comment and review
  • gather comments and votes on a shortlist of potential logos/mascot names/project ideas
  • provide a student file storage area
  • maintain a log of what was done in a face-to-face class each day, so that absent students can get caught up themselves. Example

See also