Documentation Tool - Replace .docx Template?

Greetings! 

This isn't really a bug more than a question regarding the .docx document that is generated from the export of the Documentation Tool. After I fill out my form and export the .docx document, the spell checker in my US version of Microsoft Word begins to mark many of the words incorrect.  I figured out the reason is because the template is using a French dictionary by default, so it doesn't recognize many of my english language words.

Is there a way to replace the .docx template on my installation of this content type? I assume there is also a specific template file that would need to be used so that H5P can write to it.

We are running on Drupal 7 and have tested on Chrome, Firefox, MacOS and Windows 10.

Thank you!

Peter

 

Content types: 
thomasmars's picture

Hi,
If you go to sites/default/files/h5p/libraries you will find all your libraries, look for a folder called H5P.DocumentExportPage with a version number. This one will contain the template used to render the exported file. If you open it up you will see some placeholders for where the different data will be inserted. This template can be edited however you like, including changing the default dictionary, I believe. Be aware that when updating this library to a new version the file would be overridden, so you would have to replace it again.

Hope this helps, let me know if you run into any troubles.

I appreciate this post is quite old, but hopefully someone might pick this up.

Do you have any advice to find this file on a Moodle installation? We have our installation hosted on a remote server and so need to direct the hosting company to the right subdirectory to locate the template.

I've attached a copy of the screenshot of the subdirectory that they have looked in to no success.

Attachments: 
thomasmars's picture

Hi,
The library files are not stored in the plugin directory, they are stored in the file area using Moodle's file API, which uses the directory you assigned for "moodleData". Moodle hashes the files into buckets so it is very hard to tell you where to look for the documentation tool files on your system. You can use API calls in php to determine this as shown in the File API documentation, but if this is beyond your capabilities it will be quite hard to change this.

A different approach, albeit one that also requires some developer knowledge, is to hook into the content type and change where the document template is fetched from by changing the code, so you can grab the document template from an address that you have more control over, for instance your special theme. The way you would do this is by overriding the H5P renderer, and replace line 90 in document-export-page.js to grab the exportTemplate.docx from a custom location (www.example.com/exportTemplate.docx) instead of fetching it using self.getLibraryFilePath('exportTemplate.docx'). An example of overriding the H5P renderer can be found in the h5pmods-moodle-plugin repository.

Sorry if this was too technical, but there's currently no good, non-developer, user-friendly system for changing the export template unfortunately.

Hi Thomas,

Thanks for getting back to me so quickly, I believe I understand the majority of what you have said!

I've asked the hosting company to look in to the first set of instructions, we're hesitant to create an external document template without having access to the original template for reference - just to ensure that we don't remove any placeholders. Is there any way of finding a copy without trawling through the File API for the current exportTemplate.docx file?

Kind regards,

Jonny

thomasmars's picture

Hi Jonny,

The original exportTemplate.docx can be found in the version control repository on github: h5p-document-export-page. It can be downloaded and modified from there.

Best regards, Thomas