Note: You are currently viewing documentation for Moodle 3.8. Up-to-date documentation for the latest stable version of Moodle may be available here: Dataform building.

Dataform building: Difference between revisions

From MoodleDocs
(Created page with "{{Dataform}} {{Dataform Docs Note 1}} ==Views== Dataform views allow you to control the way entries and other information is displayed in the activity. Views management is don...")
 
m (Text replacement - "<mediaplayer>(.*)<\/mediaplayer>" to "{{MediaPlayer | url = $1}}")
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Dataform}}
{{Dataform | innertrail =  ► Creating an Activity }}
{{Dataform Docs Note 1}}
==Views==
Dataform views allow you to control the way entries and other information is displayed in the activity. Views management is done under the Manage | Views tab and requires [[Capabilities/mod/dataform:managetemplates|Manage Dataform templates]] capability.


[[File:df-views-index.png|700px]]
==Building a simple activity==
{{MediaPlayer | url = http://www.youtube.com/watch?v=Ab9jLl8ZV90}}


===Adding a view===
[[es:Dataform Hello World]]
To add a view select the view type from the 'Add a view' dropdown. This will open the view configuration form where you can configure the view templates and behaviour. Typically, views have default configuration and if this default configuration serves your purpose you can simply enter a name for the view and save.
===Setting the default view===
The Dataform activity must have a default view to fall back on to when the activity is accessed without specifying the target view (for instance, when you access the activity from the activity link on the course page).


A Dataform activity without a default view is not ready and a message will be displayed on its front page and in the view list advising you to set a default view.
==Preventing participants from viewing other entries==
One setting and two permissions can affect whether the user can is limited to viewing only his/her entries.


You can select the default view by clicking the 'Default' box in the view list. The selected default view is marked by a check sign. You can change the default view at any time. Since the default view must be visible, if you set a hidden view to default, this view will automatically become visible and you will not be able to hide it as long as it is the default view.
===Separate participants by activity setting===
===Setting view visibility===
[[File:df-activity-settings-separate-participants.png]]
A view can be either visible or hidden. Visible views can be accessed by users with capability [[Capabilities/mod/dataform:viewaccess|mod/dataform:viewaccess]] that is granted by default to all roles. Hidden views can be accessed by users with capability [[Capabilities/mod/dataform:viewaccesshidden|mod/dataform:viewaccesshidden]] that is granted by default only to the teacher role. Users without the required capability will not see views with the respective visibility setting in the standard views navigation menu (##viewsmenu##).
Setting the view visibility can be done from the views index by clicking the eye icon of the designated view or from the visibility setting in the view configuration form.
The default view must be visible and setting a hidden view as the default view will automatically change its visibility to visible.
===Forcing a view filter===
When filters are defined for the activity you can force a filter on a view by selecting the filter either from the index list or in the view configuration form.
When the view forces a filter, users without capability [[Capabilities/mod/dataform:viewfilteroverride|mod/dataform:viewfilteroverride]] cannot apply other activity filters (the activity filters menu will not be displayed) and user advanced filters (if the option is added to the view) will be appended to the forced filter. 
===Resetting a view===
Each view type has default templates which are generated and automatically added to the configuration form when adding a new view. The default View template typically consists of navigation menus, quick filters, add new entry link and entries display. The default Entry template (where applicable) typically adds the base pattern for each field and the edit and delete action buttons. As you build the activity you may change the templates of a view and in some cases you may wish to reset the templates to their defaults. This can be done by clicking the reset icon of the designated view in the views index or in the view configuration form.
===Updating a view===
===Duplicating one or more views===
===Deleting one or more views===
===Access and Notifications info===
===Patterns validation and replacement===


==Fields==
The activity setting 'Separate participants' set to 'Yes' will restrict all roles which do not have the 'mod/dataform:manageentries' capability to their own entries. By default permissions, that's all roles below editing teacher. This means that non-editing teachers are also restricted to their own entries by this setting. If you want to allow non-editing teachers (graders/TAs) access to certain entries you can use an Entry access rule and set the rule with entry filter to fetch the designated entries and a role override where you assign the designated non-editing teacher to the editing teacher role.
Dataform fields are used to enter, edit and store unit of information in an entry.


==Filters==
===Separate participants by permission===
Dataform filters are used for sorting and filtering the activity entries in browse mode.
[[File:df-activity-permissions-entryanyview.png]]
==Access rules==
Dataform access rules can be used for controlling access to various areas/components of a Dataform activity.
==Notification rules==
Dataform notification rules can used for defining and sending custom notifications to the activity participants.
==CSS==
You can use CSS to manipulate the layout and styles of entries and content in any of the Dataform views. Any html element in the designated view, that has an id or a CSS class can be assigned specialized styles by including the style definitions in the CSS tab.


The Dataform allows you to add CSS in the CSS tab in three ways:
By default the mod/dataform:entryanyview permission is granted to everyone. You can exclude certain roles in the activity level by removing the role from the permission (Prevent), or by adding the role under Prohibited. Note that if you want to then grant the permission to particular users from the excluded role, use the Prevent method and then add an Entry access rule with a proper override.
* '''Include external CSS''' - You can specify a list of urls to external CSS files and these files will be loaded to the Dataform view page.
* '''CSS code''' - You can enter CSS definitions directly.
* '''Upload CSS files''' - You can upload CSS files into the Dataform files area in Moodle's file system. These files become part of the Dataform instance to which they are uploaded and are included in Dataform presets and backups.  


[[Image:df-css-tab.png|frame|center|The Dataform CSS tab]]
==Setting entry actions to open in different views==
==Javascript==
Yes. There are many other patterns which are not visible via the UI and only some are currently listed in the docs.
You can use javascript to manipulate the way entries are displayed and behave in any of the Dataform views. Any html element in the designated view, that has an id or a css class can be accessed and manipulated by javascript.


The Dataform allows you to add javascript in three ways:
In the entry level you can use (note redundant spaces between brackets)
* '''Include external javascript''' - You can specify a list of urls to external javascript files and these files will be loaded to the Dataform view page.
* '''Javascript code''' - You can enter javascript code directly. This is usually required in addition to including javascript files so as to apply the desired effects to particular views or particular items in views.
* '''Upload javascript files''' - You can upload javascript files into the Dataform files area in Moodle's file system. These files become part of the Dataform instance to which they are uploaded and are included in Dataform presets and backups.


[[Image:df-js-tab.png|frame|center|The Dataform JS tab]]
[ [EAC:more:viewname]]
==Tools==
 
TBC
[ [EAC:edit:viewname]]
==Setting permissions==
 
TBC
Which will send you to view or edit (respectively) the entry in the specified view.
 
Also
 
[ [EAC:moreurl:viewname]]
 
which you can use in the href of a tag to create a custom link to the target view.
 
 
In the view level you can use:
 
##viewurl:viewname##
 
which displays the url of the specified view and you can use in the href of a tag.
 
##viewlink:viewname##
 
which displays a link to the specified view
 
There is also a composite version of the viewlink pattern which looks like this:
 
##viewlink:Single view;Add a new entry;editentries=-1;##
 
This particular instance will mimic the addnewentry pattern but in the specified view. Details on the syntax should be available in this post: https://moodle.org/mod/forum/discuss.php?d=256813#p1123734.
 
The view patterns are also parsed in the entry level so you can use the composite viewlink pattern in the entry with the entry id pattern:
 
##viewlink:Edit view;Edit this submission;editentries=[ [entryid]];##
 
or
 
##viewlink:Details view;More details ...;eids=[ [entryid]];##
 
 
Another relevant view function is redirection of the view to another view in the activity after form submission. The setting under the 'Submission' section in the view configuration form. There you can also set the redirection timeout and message, and also add additional submission buttons as well as custom labels for these buttons.

Latest revision as of 12:22, 26 October 2017


Building a simple activity

Preventing participants from viewing other entries

One setting and two permissions can affect whether the user can is limited to viewing only his/her entries.

Separate participants by activity setting

df-activity-settings-separate-participants.png

The activity setting 'Separate participants' set to 'Yes' will restrict all roles which do not have the 'mod/dataform:manageentries' capability to their own entries. By default permissions, that's all roles below editing teacher. This means that non-editing teachers are also restricted to their own entries by this setting. If you want to allow non-editing teachers (graders/TAs) access to certain entries you can use an Entry access rule and set the rule with entry filter to fetch the designated entries and a role override where you assign the designated non-editing teacher to the editing teacher role.

Separate participants by permission

df-activity-permissions-entryanyview.png

By default the mod/dataform:entryanyview permission is granted to everyone. You can exclude certain roles in the activity level by removing the role from the permission (Prevent), or by adding the role under Prohibited. Note that if you want to then grant the permission to particular users from the excluded role, use the Prevent method and then add an Entry access rule with a proper override.

Setting entry actions to open in different views

Yes. There are many other patterns which are not visible via the UI and only some are currently listed in the docs.

In the entry level you can use (note redundant spaces between brackets)

[ [EAC:more:viewname]] 
[ [EAC:edit:viewname]]

Which will send you to view or edit (respectively) the entry in the specified view.

Also

[ [EAC:moreurl:viewname]]

which you can use in the href of a tag to create a custom link to the target view.


In the view level you can use:

##viewurl:viewname## 

which displays the url of the specified view and you can use in the href of a tag.

##viewlink:viewname## 

which displays a link to the specified view

There is also a composite version of the viewlink pattern which looks like this:

##viewlink:Single view;Add a new entry;editentries=-1;##

This particular instance will mimic the addnewentry pattern but in the specified view. Details on the syntax should be available in this post: https://moodle.org/mod/forum/discuss.php?d=256813#p1123734.

The view patterns are also parsed in the entry level so you can use the composite viewlink pattern in the entry with the entry id pattern:

##viewlink:Edit view;Edit this submission;editentries=[ [entryid]];##

or

##viewlink:Details view;More details ...;eids=[ [entryid]];##


Another relevant view function is redirection of the view to another view in the activity after form submission. The setting under the 'Submission' section in the view configuration form. There you can also set the redirection timeout and message, and also add additional submission buttons as well as custom labels for these buttons.