Difference between revisions of "Dataform Import Export"

Jump to: navigation, search
Line 18: Line 18:
  
 
Do not put spaces after your commas or upload will fail!
 
Do not put spaces after your commas or upload will fail!
 +
 +
====Importable patterns====
 +
{| class=""  style="background-color:inherit;border:0;" 
 +
|- style="font-weight:bold;background-color:#F2F2F2;" |
 +
| Field || Patterns
 +
|-
 +
| style="text-align:left;" | [[Dataformfield entryactions|Entry actions]] || None
 +
|-
 +
| style="text-align:left;" | [[Dataformfield entryauthor|Entry author]] || {{Dataformfield entryauthor import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield entrygroup|Entry group]] || {{Dataformfield entrygroup import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield entrytime|Entry time]] || {{Dataformfield entrytime import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield checkbox|Checkbox]] || {{Dataformfield checkbox import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield entrystate|Entry state]] || {{Dataformfield entrystate import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield file|File]] || {{Dataformfield file import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield commentmdl|Comment Mdl]] || None
 +
|-
 +
| style="text-align:left;" | [[Dataformfield number|Number]] || {{Dataformfield number import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield picture|Picture]] || {{Dataformfield picture import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield radiobutton|Radio button]] || {{Dataformfield radiobutton import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield ratingmdl|Rating Mdl]] || None
 +
|-
 +
| style="text-align:left;" | [[Dataformfield select|Select]] || {{Dataformfield select import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield selectmulti|Select (multiple)]] || {{Dataformfield selectmulti import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield text|Text]] || {{Dataformfield text import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield textarea|Text area]] || {{Dataformfield textarea import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield time|Time]] || {{Dataformfield time import csv}}
 +
|-
 +
| style="text-align:left;" | [[Dataformfield url|Url]] || {{Dataformfield url import csv}}
 +
|}
  
 
===Export===
 
===Export===

Revision as of 13:45, 12 March 2014


CSV

You can import entries into the Dataform from entries data in CSV format. CSV means Comma-Separated-Values and is a common format for text interchange.

Import

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). The CSV 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!

Importable patterns

Field Patterns
Entry actions None
Entry author Importing entry author info allows for adding entries on behalf of users. You can use either one of the following patterns provided that the respective user attribute (id, idnumber, username) is unique in your Moodle site.
  • [[EAU:id]]
  • [[EAU:idnumber]]
  • [[EAU:username]]
Entry group Importing entries with group info allows you to add entries for specific groups. You can use either one of the following patterns. Currently you can import group info for an entry even if the designated entry author is not a member of that group.
  • [[EGR:id]]
  • [[EGR:idnumber]]
Entry time Importing entries with entry time info allows you to add entries with specific time created and modified. When both time created and time modified are imported, if time modified is earlier than time created it will be adjusted to the time created.

The imported value can be a string containing an English date/time (including relative date/time such as 'tomorrow') or a Unix timestamp.

  • [[ETM:timecreate]]
  • [[ETM:timemodified]]
Checkbox By default only options that exist in the field configuration will be imported. If you set 'Allow adding options' to Yes, options which do no exist in the field configuration will also be imported and added to the configuration. Multiple options should be separated by #.

Applicable patterns:

  • [[fieldname]]
Entry state Imports entry states by state label. For example, with an entrystate field that contains the states Submitted, Under review, Reviewed, Accepted and Rejected, the import CSV value can be either Submitted, Under review, Reviewed, Accepted or Rejected. Note that since Submitted every new entry is by default in that state and there is no need to import it explicitly.

Applicable patterns:

  • [[fieldname]]
File You can import entries with file field content. The field import settings allow you to upload a zip file with the content files. The imported value in the csv should be a comma delimited list of file names. For each imported entry, if the zip file contains files with the specified file names, these files will be added to the entry content. If imported entries specify the same file names, each entry will have its own copies of the imported files.

Applicable patterns:

  • [[fieldname]]
Comment Mdl None
Number Imports numbers, e.g. 42, 42.6778, -133.

Applicable patterns:

  • [[fieldname]]
Picture You can import entries with images. The field import settings allow you to upload a zip file with image files. The imported value in the csv should be a comma delimited list of file names. For each imported entry, if the zip file contains files with the specified file names, these files will be added to the entry content. If imported entries specify the same file names, each entry will have its own copies of the imported files.

Applicable patterns:

  • [[fieldname]]
Radio button By default only options that exist in the field configuration will be imported. If you set 'Allow adding options' to Yes, options which do no exist in the field configuration will also be imported and added to the configuration.

Applicable patterns:

  • [[fieldname]]
Rating Mdl None
Select By default only options that exist in the field configuration will be imported. If you set 'Allow adding options' to Yes, options which do no exist in the field configuration will also be imported and added to the configuration.

Applicable patterns:

  • [[fieldname]]
Select (multiple) By default only options that exist in the field configuration will be imported. If you set 'Allow adding options' to Yes, options which do no exist in the field configuration will also be imported and added to the configuration. Multiple options should be separated by #.

Applicable patterns:

  • [[fieldname]]
Text Imports plain text, e.g. Hello world, Dataform.

Applicable patterns:

  • [[fieldname]]
Text area Imports multi-line text, either plain or html. For importing html, the field should be configured to enable editor. For example, the import value
<span style="background-color:#006699;color:#FFF">Big Blue Marble</span>

would be imported as such and displayed as Big Blue Marble when the field enables editor, and as simple text Big Blue Marble if editor is not enabled in the field.

Applicable patterns:

  • [[fieldname]]
Time The imported value can be a string containing an English date/time (including relative date/time such as 'tomorrow') or a Unix timestamp.

Applicable patterns:

  • [[fieldname]]
Url Imports valid urls, e.g. moodle.org, www.substantialmethods.com.

Applicable patterns:

  • [[fieldname]]

Export

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.

The content to export is determined by the field tags you include in the view template. The subset of entries export can be controlled by applying available filters to the export view.

To export the displayed entries in the export view, click on the Export pushbutton. You will usually have the option of either opening or saving the file.

Portfolios

Export

Exporting Dataform entries requires Moodle Download Portfolio enabled by site admin. Then, the ##export## may be added to a view designated for export and allow exporting entries to a downloadable file.