Sie sind auf Seite 1von 10

Building a Course Database

The database activity module allows the teacher and/or students to build, display and search a bank of record entries about any conceivable topic. The format and structure of these entries can be almost unlimited, including images, files, URLs, numbers and text amongst other things. This module will create one table per instance, but you may create as many instances as you need. The records can be linked to other tables and all resources in the course, if you allow auto-link in a name field, but you cannot build a SQL query. Adding a Database: 1. Log into your course 2. Click 3. Click the Add an activity drop-down arrow and select Database 4. Enter a Name and Introduction for the database

5. More Settings (Optional) Available from Available to Viewable from Viewable to Required Entries - The number of entries a participant is required to submit. Users will see a reminder message displayed while viewing if they have not submitted the required number of entries. The activity will not be considered complete until the user has submitted the required number of entries. Entries required before viewing - The number of entries a participant is required to submit before they are allowed to view any entries in this database activity. Note: This feature cannot be used together with the database auto-linking filter, since it's not possible for the database auto-linking filter to determine whether a user has submitted the required number of entries. Maximum entries - The maximum number of entries a participant can submit for this activity. Comments - Allow users to make comments on each entry. Require approval - Should entries be approved by a teacher before they are viewable to students? This is useful for moderating content that may be potentially offensive or inappropriate. Allow posts to be rated - If checked, post can be rated and the Grade option becomes available Grade - Only available if Allow posts to be rated is checked. This option allows teachers to grade the posts

6. Click Save and Display Create the Database Fields: A field is a named unit of information. Each entry in a database activity module can have multiple fields of multiple types e.g. a text field called 'Favorite Color' which allows you to type in your favorite shade, or a menu called 'State' that lets you choose one from a list of the 50 that make up the United States of America. By combining several fields with appropriate names and types you should be able to capture all the relevant information about the items in your database. Field Types: Checkbox A checkbox field allows one or more checkboxes. Each line in the options box is a different checkbox. The text entered is what will be the case if the checkbox is checked e.g. 'Valid' for something that can be valid or not. This word will appear beside the checkbox on entry, and then by itself when viewing if the box has been checked. Checkboxes default to their 2

unchecked status. If you wish to ensure that the user actively selects one of the options you can use radio buttons instead. Multiple checkboxes could be used, for example, in a movie database that has Horror, Comedy, Western etc. checkboxes for different film genres, and you would be able to check more than one in the case of Horror-Comedies or Comedy-Westerns. The menu (multi-select) field also achieves this, but clicking multiple checkboxes is usually a more obvious interface. Date A date field allows users to enter a date by picking a day, month and year from a drop down list. File A file field asks users to upload a file from their computer. If it is an image file then the picture field may be a better choice. Menu The text entered in the options area of the menu field will be presented as a drop-down list for the user to choose from. Each line represents a different option. Menu (Multi-select) The text entered in the options area of the menu (multi-select) will be presented as a list for the user to choose from and each line represents a different option. By holding down control or shift as they click, users will be able to select multiple options. This is a fairly advanced computer skill so it may be wise to use multiple checkboxes instead. Number The number field stores a floating number. Picture The picture field allows the user to upload an image file from their computer. Radio Buttons The radio button allows the user to choose one from a range of options. If the user doesn't select any of these options then they will be prompted to do so and can only submit the entry when one option is chosen. If you only have two options and they are opposites (true/false, yes/no) then you could simply use a single checkbox instead. However checkboxes default to their unchecked status, therefore users could submit without actively selecting one of the options. This may not always be appropriate.

Text A text field allows the user to enter text up to 60 characters in length. For longer text, or for text that requires formatting such as headers and bullet points, please use a textarea field. Textarea The textarea field allows users to enter a long string of text including formatting similar to that found when creating forum posts. URL The URL field allows the user to enter a URL. If autolink is selected, then the URL becomes a clickable link. If forced name for the link is entered, then that text will be used for the hyperlink. For example, in a database of authors you may wish people to enter the author's website. If you enter the text 'homepage' as a forced name then clicking on text "homepage" will take you to the entered URL. Latitude/longitude The latitude/longitude field allows users to enter a geographic location, by specifying the location's latitude and longitude. For example, Moodle HQ is at latitude -31.9545, longitude 115.877. When viewing the record, links are automatically generated linking to geographic data services such as Google Earth, OpenStreetMap, GeaBios,Mapstars and more. (The teacher can choose which of those links appear, if any.)

7. Click the Create a new field drop-down arrow and select Picture

8. Enter the Picture options 9. Click Add

The newly created picture field

10. To edit the field, click the 11. To delete the field, click the

icon under Action icon under Action

12. Click the Create a new field drop-down arrow and select Text

13. In the next window, enter the Field Name and Field description

14. Check the Allow autolink check box 15. Add another Text field for the authors first name Field name First Name Field description Authors First Name Do not autolink 16. Add another Text field to display one of the authors literary creations (do not autolink) Field name Literary Creation Field description A Literary Creation by the Author Do not autolink 17. Add a URL field to display the Authors web site or a web site featuring the author (do not autolink)

Add Entries to the Database: 18. Click the Add entry tab

19. In the New entry window, enter the field information

20. Click Save and view 21. Click Continue Defining the Template: Before your entry can be properly viewed, the template must be defined. Templates for the Database activity module allow you to control the visual layout of information when listing, viewing or editing database entries. It is a similar to the technique used to mail merge letters in word processors such as Open Office Writer or Microsoft Word. 7

22. Click the Template tab

23. Select the List template

24. Enter the Header Information (Optional) 25. Enter the Footer for the template (Optional) 26. Click Save template

27. Click View list to view your entry

Advanced Database Options Tag Usage: The content of each field you create for your database and some special tags (listed below) can be inserted into the output template by the use of tags. Fields have the format [[fieldname]] All other tags have the format ##sometag## To use the tags in the box on the left of the page, use the HTML viewer and then place your cursor in the text area of your target edit and then click on the tag you want to place. Alternatively, you may simply type the appropriate name within the required symbols like ##this## or [[this]], respectively.

creates a clickable icon link that allows you to edit the current entry (only appears if you have the rights to do this) ##delete## creates a link that lets you delete the current entry (only appears if you have the rights to do this) ##approve## create a link that lets you approve the current database entry (only appears if you have the rights to do this) ##more## creates a link to the single view, which may contain more detailed info ##moreurl## creates just the URL for the above link, useful for creating your own links. You can click on the link icon and type ##moreurl## into URL field or in source view type
##edit## <a href="##moreurl##">[[fieldname]]</a>

creates a link to the view/edit comments page, the link text is the current number of comments (only appears if comments are turned on) ##user## creates a link to the user page of the user who submitted the entry, link text is their name
##comments##

##timeadded## ##timemodified## ##firstname## ##lastname## ##lastname##

Available Templates: List Template This template allows you to control the fields used and their layout when viewing multiple entries at once (e.g. search results). It is possible that this view may simply provide an overview with more detailed information available by clicking on an entry to access the single view of the entry. See Designing a list view in Moodle database activity for instructions on how to create a list template table. The list template can also be used as a way to export your database as a CSV file. Single Template This is used to display a single entry at a time and so has more space for display and can use, for example, larger versions of images or optionally provide more information than shown in the list view Advanced Search Template An advanced search template is for creating the interface form used in the advanced search Add Template This template creates the interface form used when adding or editing database entries. RSS Template Lets you control the content of the RSS feed for database entries. CSS Template If any of the HTML in your other templates requires CSS to provide visual style you can specify it here. Java-script Template You can use java-script to manipulate the way elements are displayed in the List, Single or Add templates. Basically 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. Let's say, for example, you have a field in your database that stores a person's name and when you display the names in the List View you want to count the times a name matches some criteria and display the result. Your database will contain a field which we will call "name". In your List template you will be able to display the contents of that field by using the [[name]] construct at the place where you want that information displayed.

Note: When you first create a database the templates will be pre-filled with appropriate HTML. If you later add fields then you can press the reset templates button and it will add HTML for the new fields in a similar fashion. If you have edited any of the templates in the meantime then your changes will be lost. It is recommended that you finalize the database fields before changing the template code. 10

Das könnte Ihnen auch gefallen