Database

 
 
Picture of Itamar Tzadok
Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Currently under testing a new Dataform view type that allows exporting entries to pdf. At this stage the pdf export supports, on top of the flexible layout and rich content of the Dataform entries, html header, footer, background frame, background center watermark, document protection, digital signature and per entry page break. See illustration below of entry per page export with html header, watermark and digital signature.

This pdf export development has been made possible by the generous support of Onlinecampus Virtuelle PH - www.virtuelle-ph.at.

The view type will be released next week.

Among other improvements to be released next week, a refactoring of the Dataform CSV import/export. The new CSV will allow exporting almost every bit of information from the Dataform including (traditional painful issues such as) dates as dates (rather than timestamps) user information, entry information and even images in base64. The import will be able to import back the standard data and at least some of more exotic data, including import of dates and time from date time strings. The CSV export will also allow exporting only entries in view to the effect that Dataform filters could be used to export designated subsets.

smile

 

 

 

 

 
Average of ratings:Useful (1)
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

I'm very excited to hear about the PDF export option. I have just installed the Dataform module and have been experimenting with it but I have a very fundamental problem. I can add fields, make a view and add new entries (or it appears that I am adding them) but I cannot view anything that I have added....

Is there any documentation for this module that might help me get it up and working properly?

Regards

Jason

P.S. I am on Moodle 2.2.1+

P.P.S. Oops, I just found the website with the documentation for Dataform. I will work through that site and see if I can figure things out.

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Dataform module - MoodleDocs is probably the most updated docs on the Dataform but still far from adequate. Documentation for the PDF view as well as some other recent features will be added this weekend (to the Moodle docs).

If you encounter any problem, just post it here and I will try to help. smile 

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks. Does that mean that the PDF view is currently available in the Dataform mod that is downloadable here from Moodle.org?

I don't see the capability in the version I downloaded....maybe I'm missing it or I need to download the newest version...?

Regards

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

For documentation the Moodle docs would be the most updated. Most updated builds are always on git. The PDF view is already available in the master build on git but that's a dev build and may be unstable. smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks again. Just to clarify,

Is the newest version, with the PDF view, available from the Moodle.org site via the Plugin Download page?

Also, if not, can you provide the Git link? I couldn't find it from the Moodle Git page.

Regards

Jason

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

I was able to find the master version on Git and have installed it on my Moodle instance. When adding the PDF view, I get the error that am attaching as a screenshot here. Is there a specific environment (Moodle version, etc.) that is required?

I am using Moodle 2.2.1+

Regards

Jason


 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Turn debugging on and see if there is more info on the error. I've tested a fresh installation of the most recent commit (earlier today) on 2.2.5+ and a simple dataform activity with a simple pdf view seemed to work properly. smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks. Yes, sorry, I should have done that before. Here are the details from the error:

Debug info: Incorrect integer value: 'useremail' for column 'groupby' at row 1
INSERT INTO mdl_dataform_views (type,dataid,name,description,visible,filter,perpage,groupby,sectionpos,param1,section,param2,param3,param4,patterns) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => 'pdf',
1 => '1',
2 => 'PDF',
3 => 'PDF Test',
4 => '2',
5 => 0,
6 => 0,
7 => 'useremail',
8 => 0,
9 => 'O:8:"stdClass":11:{s:11:"orientation";s:0:"";s:4:"unit";s:2:"mm";s:6:"format";s:2:"A4";s:11:"destination";s:1:"D";s:12:"transparency";s:3:"0.5";s:6:"header";O:8:"stdClass":3:{s:7:"enabled";s:1:"0";s:9:"margintop";i:0;s:10:"marginleft";i:10;}s:6:"footer";O:8:"stdClass":2:{s:7:"enabled";s:1:"0";s:6:"margin";i:10;}s:7:"margins";O:8:"stdClass":4:{s:4:"left";s:1:"0";s:3:"top";s:1:"0";s:5:"right";s:1:"0";s:4:"keep";s:1:"0";}s:9:"pagebreak";s:4:"auto";s:10:"protection";O:8:"stdClass":4:{s:11:"permissions";a:2:{i:0;s:5:"print";i:1;s:4:"copy";}s:9:"user_pass";s:0:"";s:10:"owner_pass";s:0:"";s:4:"mode";s:1:"0";}s:9:"signature";O:8:"stdClass":3:{s:8:"password";s:0:"";s:4:"type";s:1:"1";s:4:"info";a:4:{s:4:"Name";s:0:"";s:8:"Location";s:0:"";s:6:"Reason";s:0:"";s:11:"ContactInfo";s:0:"";}}}',
10 => 'ft:1tr:1ct:<div class="mdl-align"> <table class="generaltable" align="center"> <tbody> <tr class="r0"> <td class="cell c0" style="border: 0 none;">##viewsmenu##</td> <td class="cell c1" style="border: 0 none;"></td> <td class="cell c2" style="border: 0 none;">##filtersmenu##</td> <td class="cell c3" style="border: 0 none;">##quicksearch##</td> <td class="cell c4 lastcol" style="border: 0 none;">##quickperpage##</td> </tr> <tr class="r1"> <td class="cell c0 lastcol" style="border: 0 none;" colspan="5">##addnewentry## ##export:all##</td> </tr> <tr class="r0 lastrow"> <td class="cell c0 lastcol" style="border: 0 none;" colspan="5">##pagingbar##</td> </tr> </tbody> </table> </div>',
11 => 'ft:1tr:1ct:<div class="entry"> <table class="generaltable" align="center"> <tbody> <tr class="r0"> <td class="cell c0" style="text-align: right;">Guide:</td> <td class="cell c1 lastcol">Guide</td> </tr> <tr class="r1"> <td class="cell c0" style="text-align: right;">Skit No:</td> <td class="cell c1 lastcol">Skit No</td> </tr> <tr class="r0"> <td class="cell c0" style="text-align: right;">Title:</td> <td class="cell c1 lastcol">Title</td> </tr> <tr class="r1"> <td class="cell c0" style="text-align: right;">StarterInfo:</td> <td class="cell c1 lastcol">StarterInfo</td> </tr> <tr class="r0"> <td class="cell c0" style="text-align: right;">Development:</td> <td class="cell c1 lastcol">Development</td> </tr> <tr class="r1"> <td class="cell c0" style="text-align: right;">Checker:</td> <td class="cell c1 lastcol">Checker</td> </tr> <tr class="r0 lastrow"> <td class="cell c0 lastcol" colspan="2">##edit## ##delete##</td> </tr> </tbody> </table> </div>',
12 => NULL,
13 => NULL,
14 => 'a:2:{s:4:"view";a:7:{i:0;s:13:"##viewsmenu##";i:1;s:15:"##filtersmenu##";i:2;s:15:"##quicksearch##";i:3;s:16:"##quickperpage##";i:4;s:15:"##addnewentry##";i:5;s:13:"##pagingbar##";i:6;s:14:"##export:all##";}s:5:"field";a:7:{i:1;a:1:{i:0;s:9:"Guide";}i:2;a:1:{i:0;s:11:"Skit No";}i:3;a:1:{i:0;s:9:"Title";}i:4;a:1:{i:0;s:15:"StarterInfo";}i:5;a:1:{i:0;s:15:"Development";}i:6;a:1:{i:0;s:11:"Checker";}s:5:"entry";a:2:{i:0;s:8:"##edit##";i:1;s:10:"##delete##";}}}',
)]
Stack trace:
  • line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 173 of /mod/dataform/view/view_class.php: call to mysqli_native_moodle_database->insert_record()
  • line 76 of /mod/dataform/view/view_edit.php: call to dataform_view_base->add()

Jason

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Given the information provided in the previous post, I changed the groupby setting to a different field and got the PDF function to work.

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Yes, the group by setting in both the view and filter is currently unstable and due to recent changes it was set by default to the last option instead of remaining empty. This should be fixed in the next commit.

Feedback on the pdf view would be appreciated. smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks. I'll try and get some PDF feedback to you later today. For now, I've just discovered another small issue:

When I use a "text" field and choose the "You must enter only letters here." option for field rules, I am not allowed to enter spaces. I'm not sure if that is intentional or not but if I want to make a field that is name specific and apply a rule to disallow numbers, I can't use this because it doesn't allow spaces. Also, when I enter invalid information (i.e. a full name with a space) I don't get an error message. The entry just doesn't get added to the database. I only discovered this issue via testing.

Thanks again

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Thanks Jason. The validation rules are the standard moodleform rules and that's how they work. The missing error is due to a core bug (MDL-36433) which I've recently fixed and has been integrated to 2.3.4 and 2.4. You can try applying the patch to your installation or if you php it should be fairly easy to go to the target file of the fix and add there the one character that fixes the problem. Validation messages are still missing from the multiselect and checkbox fields and seems to not be supported for the respective form elements by the core moodleform.

By the way I've just pushed an updated build to git. In addition to fixing the groupby default value, there is an enhancement of the Time field to allow years before 1970

hth smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks and sorry for not getting back with you sooner. I kind of shut down during the holidays. wink

I am going to update my Moodle instance today and will update the Dataform package then as well.

I have managed to get the PDF export working fairly well but am having a little issue with formatting. I'm trying to design a format that will allow for the same style of PDF export regardless of the contents but the size of the fields seems to be controlled by the amount of text in them even if I try to manipulate the size via the Dataform display area.

Also, I have noticed that clicking on the PDF Export link results in all of the entries in the database being exported. Is there any way to only export the entry being viewed? It seems like it would be advantagous to have "export all" and "export current" links.

Regards (and Happy New Year!)

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

The tcpdf has a limited support or css but I don't know yet its actual limitation. This requires some more experimentation and then there may be ways to better control formatting.

The expot all is a misnomer. It actually exports the current display and observes the filter, so if you filter to 1 entry per page it will export only the entry you are viewing. Or maybe its in a more recent build than what you have installed? At any rate, the scope of the export is still under development.

smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks, I figured out the pdf export issue. Yes, if I select display one entry and then use the export link, I then only get the one entry exported.

As for the formatting, I am still having difficulty getting the exported file to retain the formatting that appears on the screen when viewing the entry with the PDF view. Specifically, empty space in fields is not preserved. I'm wondering if there is any way to work around this in order to get a somewhat standard format for entries that are exported...?

Jason

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

This is an update to my previous post. I have figured out how to 'force' the formatting in the PDF export by adding blank lines in cells that contain field labels/explanations. Doing so ensures that a certain amount of space is allocated in the PDF export regardless of whether it is full or not. It takes a bit of time to get the export to look the way I want it but it is possible. smile

I attempted to add a watermark by adding a jpeg image but for some reason the watermark does not appear on the exported pdf. Are you aware of any issues with the watermark feature? Or, does it require something other than a jpeg image?

Regards

Jason

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

P.S. In regards to the watermark image. I saw from the screen shots above that a png image was used so I tried that instead of a jpeg but unfortunately it didn't work. Any help you can provide (when you have time) will be appreciated.

Regards

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

The view should accept all major image types. I've had reports on initial failure to show the watermark and then success, but no details on the why and how. Do you get any error messages in debugging? Are the dimensions of the image you are using smaller than the page size? The view tries to center the image and it calculates its target position but it doesn't scale it down and it is possible that too wide images are pushed out of the frame and hence are not displayed.

After you get the watermark to show up note that by default the Dataform view adds only one page and if the entry content is longer than one page the pdf will add more as needed but the Dataform view knows only one and so the watermark will appear only on the first page of the export. In order to show the watermark on all pages of an exported long entry, you need to tell the Dataform view to page break and you can do that by means of the ##pagebreak## tag.

smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Sorry for my silence. I tried tweaking everything I could think of but couldn't get the watermark to work. I've given up for now as it isn't that important to us at the moment.

Actually, I have a different question about the Dataform. I've designed a database (dataform) that students use to input specific activities that they design. I'm using the PDF export feature (view) and it is working perfectly. I would like to include a field that counts each users entries and am wondering if there is a tag that I can add to accomplish this? I tried ##entryid## but this only provides a number that serves to count the total number of entries instead of the unique entries by each user. I'd like to do both (user entries count and total count) if possible.

Your help will be most appreciated.

Sincerely

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Sorry for my silence, Jason. Extremely busy but will try to help as much as I can.

Currently there are two view tags that should display entries count:

##numentriestotal## for total number of entries in the dataform.

##numentriesdisplayed## for number of entries under current filter.

See if these work for you and let me know which other counts could be useful so that we consider them for next release. smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

No need for apologies. I'm sorry for bothering you with a private message. wink

I will try both of these and see if they accomplish what I'm shooting for.

Thanks.

Jason

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

I just did a quick test with the two tags you provided (##numentriestotal## and ##numentriesdisplayed##) but unfortunately those both result in the same number being displayed on each entry.

What I mean is, for example, if there are 8 entries in the database (dataform) and I use ##numentriestotal## then I get 8 on each entry (if I use that tag in the repeated entry formatting area). If I use ##numentriesdisplayed## I also get the same number in each entry (the number of entries displayed).

What I'm wanting is a unique number in each entry, which ##entryid## does accomplish but I would like that number to be a count for each user rather than for the total number of entries (which I guess technically isn't quite what ##entryid## provides because the numbers don't change when an entry is deleted when using ##entryid##.

Sorry, that sounds really confusing....does it make sense?

Jason

 
Average of ratings: -
Picture of Itamar Tzadok
Re: Dataform updates: PDF export
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Yes, it makes sense. The ##numentriestotal## and ##numentriesdisplayed## tags are view tags, not entry tags, and they display entries count in the view level.

What you seem to be looking for is extended entry owner info that in this case would allow you to display user info related to participation in the activity. That's an excellent idea but needs to be implemented.

The closest we can get to this right now is generic field type that allows you to enter SQL query. But the field is still experimental and has not been released yet.

I'll see if I can allocate time for this. Please keep sending reminders and don't worry about bothering me. It's all part of my commitment to maintaining this plugin. smile

 
Average of ratings: -
Mt. Fuji
Re: Dataform updates: PDF export
Group Particularly helpful Moodlers

Itamar,

Thanks. Yes, a generic field that allows for use of raw SQL would definitely work! smile Maybe if the experimental field progresses enough that it can be tested by a third party (me smile ) I could give it a try?

I'll wait for a while and post again if I don't see/hear anything. smile

Thanks again.

Jason

 
Average of ratings: -
Picture of Martyn Colliver
Re: Dataform updates: PDF export
 

This looks excellent for completing forms that students need to fill in for examinations.

Currently having trouble with two things:

  1. I can't seem to get a PDF footer (but I can get a header)
  2. When setting the Page Break to ENTRY, as I want a separate page for each student, I get the following errror:

    Fatal error: Undefined class constant 'PAGEBREAK' in /home/moodle25/moodle/mod/dataform/view/pdf/view_class.php on line 185

This is using the 2.5 BETA of Moodle so will just change server and see how it works in 2.4.

 
Average of ratings: -