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

Dataform FAQ: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Dataform}}
{{Dataform | innertrail =  ► See also }}
==How can I set up the Dataform to allow students to view only their own entries?==
==How can I set up the Dataform to allow students to view only their own entries?==
Set the group mode of the Dataform activity to "Separate participants".
Set [[Dataform_settings#Separate_participants|Separate participants]] in the activity settings to 'Yes'.
 
==How can I enable a sort function by clicking on the field headings?==
 
 
==How can I add highlighting like on the Module and plugins page?==
 


==How can I list entries content horizontally in an aligned table?==
==How can I list entries content horizontally in an aligned table?==
Use the Tabular view type
Use the [[Dataformview Tabular|Tabular view type]] or the [[Dataformview Aligned|Aligned view type]].
*[http://moodle.org/mod/forum/discuss.php?d=74243 How can I list database information horizontally instead of vertically? Forum discussion]


==Is there a Time stamp for Dataform entries?==
==Is there a Time stamp for Dataform entries?==
*Time added: <nowiki>##timeadded##</nowiki>
The internal [[Dataformfield entrytime|Entry time field]] allows you to display the time-created and time-modified of the entry.
*Time modified: <nowiki>##timemodified##</nowiki>


==How can I make the title of an entry into a link?==
==How can I make the title of an entry into a link?==
To make the title of an entry in list view link to the single view, add the following code to the list template:
To make the title of an entry in list view link to the single view, add the following code to the list template:
  <nowiki><a href="##moreurl##">[[Title]]</a></nowiki>
  <nowiki><a href="##moreurl##">[[Title]]</a></nowiki>


==How can I make email addresses clickable?==
==How can I make email addresses clickable?==
To make email addresses clickable, add the following code to the view template:
To make email addresses clickable, add the following code to the view template:
  <nowiki><a href="mailto:[[Email]]">[[Email]]</a></nowiki>
  <nowiki><a href="mailto:[[Email]]">[[Email]]</a></nowiki>
where 'Email' is the text field for entering an email addresses.
where 'Email' is the text field for entering an email addresses.


==How can I delete a file attached to an entry?==
==How can I delete a file attached to an entry?==
 
*Edit the entry.
 
*Right-click on the file in the file manager.
==How can I disapprove an entry which has been approved?==
*Select 'delete'.
 
*Save the entry.
Click on the approved icon (green tick) to disapprove the entry.


==How can I add a default sort order of entries?==
==How can I add a default sort order of entries?==
In the Filters tab
In the Filters tab
* Add a new filter.
* Add a new filter.
Line 46: Line 32:
==How can I prevent students from adding entries?==
==How can I prevent students from adding entries?==
In the Dataform settings, set max number of entries to 0.
In the Dataform settings, set max number of entries to 0.
You can also prevent adding and editing entries in a particular view by disabling all submission buttons in the view's submission settings.


==How can I add entries en masse?==
==How can I add entries en masse?==
In the general section of the view template add the tag ##addnewentries## (as opposed to the default ##addnewentry##). This tag displays a dropdown to select the number of entries to add.
In the general section of the view template add the tag ##addnewentries## (as opposed to the default ##addnewentry##). This pattern displays a dropdown to select the number of entries to add.


==How can I edit/delete entries en masse?==
==How can I edit/delete entries en masse?==
In the view template add the selector tags and bulk edit and delete tags. In the entries list tick the checkboxes of the entries to edit/delete and click the the respective bulk action button.
In the view template add the selector, bulk-edit and bulk-delete patterns. In the entries list tick the checkboxes of the entries to edit/delete and click the the respective bulk action link.


==How can I completely reset a Dataform activity?==
==How can I completely reset a Dataform activity?==
In the Dataform administration section of the Settings block, click 'Renew'.
In the Dataform administration section of the Settings block, click 'Renew'.
==How can I display totals from number fields within an entry (line) and for a set of entries (column) in the view?==
You can enter in the entry template or view template (as the case may be) formula patterns in which you specify arithmetic operations on field patterns or other formula patterns. For example, an entry template in a tabular view with line and column formulas:
[[File:df-formula-in-tabular-view3.png]]
And the display is:
[[File:df-formula-in-tabular-view4.png]]
(See forum post at https://moodle.org/mod/forum/discuss.php?d=140433#p991346)
Note the '!' prefix in the field pattern inside the formula. This is a flag which disables editing mode for the field pattern. Typically we don't want field patterns in formula to open for editing (as input elements) and so if the view allows editing we need to add these flags to editable field patterns in the formula.
You can aggregate formulas with the same higher indices. So, for instance, the formula
%%F:=SUM(_F1_)%%
will display the sum total of all the formulas that look like
%%F1:=...%%
anywhere in the view.
The formula
%%F:=SUM(_F1_,AVERAGE(_F2_))%%
will display the sum total of all the F1 formulas + the average of all the F2 formulas.
The rule is that the aggregated formulas must have a higher index than the aggregating formula.
It becomes a bit tricky if you want both line totals and column totals. For line totals you would typically use the entry id as the index of the aggregated formula since it is unique per line. Something like:
%%F[[entryid] ]:=...%%
But that won't work for column total. It seems that currently the only way to do that is to add another hidden formula in each cell for the column totals. So you could have something like:
%%F[[entryid] ]:=...%% <nowiki><span class="hide">%%F1:=...%%</span></nowiki>
Both formulas will yield the same figure in the cell but only one will be displayed. The line total will use the first and the column total will use the second.
To reduce clutter in the view template you can use designated text fields for complex formulas. You enter the formula in the field's template and use the pattern [[T@fieldname] ]. The field template currently doesn't support html so you would have to add the html for hiding the second in the view template. This could look something like:
[[T@LineFormula] ] <nowiki><span class="hide">[[T@ColumnFormula] ]</span></nowiki>
Again, this technique is useful mainly when you have long formulas in complex view templates.
The Dataform uses the same moodle library that is used by the gradebook formulas and you can find a list of functions (in addition to the standard arithmetic operators) at http://docs.moodle.org/en/Grade_calculations.




==See also==
Using Moodle forum discussions:


[[Category:FAQ]]
[[Category:FAQ]]

Latest revision as of 15:04, 25 August 2016

How can I set up the Dataform to allow students to view only their own entries?

Set Separate participants in the activity settings to 'Yes'.

How can I list entries content horizontally in an aligned table?

Use the Tabular view type or the Aligned view type.

Is there a Time stamp for Dataform entries?

The internal Entry time field allows you to display the time-created and time-modified of the entry.

How can I make the title of an entry into a link?

To make the title of an entry in list view link to the single view, add the following code to the list template:

<a href="##moreurl##">[[Title]]</a>

How can I make email addresses clickable?

To make email addresses clickable, add the following code to the view template:

<a href="mailto:[[Email]]">[[Email]]</a>

where 'Email' is the text field for entering an email addresses.

How can I delete a file attached to an entry?

  • Edit the entry.
  • Right-click on the file in the file manager.
  • Select 'delete'.
  • Save the entry.

How can I add a default sort order of entries?

In the Filters tab

  • Add a new filter.
  • Add sorting criteria to the filter.
  • Click on the 'default' button of the filter in the filters list.

How can I prevent students from adding entries?

In the Dataform settings, set max number of entries to 0.

You can also prevent adding and editing entries in a particular view by disabling all submission buttons in the view's submission settings.

How can I add entries en masse?

In the general section of the view template add the tag ##addnewentries## (as opposed to the default ##addnewentry##). This pattern displays a dropdown to select the number of entries to add.

How can I edit/delete entries en masse?

In the view template add the selector, bulk-edit and bulk-delete patterns. In the entries list tick the checkboxes of the entries to edit/delete and click the the respective bulk action link.

How can I completely reset a Dataform activity?

In the Dataform administration section of the Settings block, click 'Renew'.

How can I display totals from number fields within an entry (line) and for a set of entries (column) in the view?

You can enter in the entry template or view template (as the case may be) formula patterns in which you specify arithmetic operations on field patterns or other formula patterns. For example, an entry template in a tabular view with line and column formulas:

df-formula-in-tabular-view3.png

And the display is:

df-formula-in-tabular-view4.png

(See forum post at https://moodle.org/mod/forum/discuss.php?d=140433#p991346)

Note the '!' prefix in the field pattern inside the formula. This is a flag which disables editing mode for the field pattern. Typically we don't want field patterns in formula to open for editing (as input elements) and so if the view allows editing we need to add these flags to editable field patterns in the formula.

You can aggregate formulas with the same higher indices. So, for instance, the formula

%%F:=SUM(_F1_)%%

will display the sum total of all the formulas that look like

%%F1:=...%%

anywhere in the view.

The formula

%%F:=SUM(_F1_,AVERAGE(_F2_))%%

will display the sum total of all the F1 formulas + the average of all the F2 formulas.

The rule is that the aggregated formulas must have a higher index than the aggregating formula.

It becomes a bit tricky if you want both line totals and column totals. For line totals you would typically use the entry id as the index of the aggregated formula since it is unique per line. Something like:

%%F[[entryid] ]:=...%%

But that won't work for column total. It seems that currently the only way to do that is to add another hidden formula in each cell for the column totals. So you could have something like:

%%F[[entryid] ]:=...%% <span class="hide">%%F1:=...%%</span>

Both formulas will yield the same figure in the cell but only one will be displayed. The line total will use the first and the column total will use the second.

To reduce clutter in the view template you can use designated text fields for complex formulas. You enter the formula in the field's template and use the pattern [[T@fieldname] ]. The field template currently doesn't support html so you would have to add the html for hiding the second in the view template. This could look something like:

[[T@LineFormula] ] <span class="hide">[[T@ColumnFormula] ]</span>

Again, this technique is useful mainly when you have long formulas in complex view templates.

The Dataform uses the same moodle library that is used by the gradebook formulas and you can find a list of functions (in addition to the standard arithmetic operators) at http://docs.moodle.org/en/Grade_calculations.