Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Edouard-Legoupil/XlsFormPrettyPrint

Repository files navigation

DEPRECATED -- See https://github.com/unhcr-americas/XlsFormUtil !!

An RMD template to convert a survey questionnaire from a master XlsForm to a Word version for easy review

When customizing and adjusting a household survey questionnaire during the design phase, it's often necessary to have one testing version (i.e. encoded in xlsform) and a more legible version in word that can be then shared with non-technical experts for them to comment and review.

Moving between a paper version and an encoded-machine ready version is not smooth. Instead of having the master version in word and updating once while the xlsform, it's more convenient to generate a word output to collect feedback in word tracking mode.

{XlsFormPrettyPrint} is a small utility to quickly generate a nicely printed version in word of a master version in xlsform. This way all comments from the circulated version can be easily re-injected back in the master without loosing all the coding.

The default prettyprinting template brings in a single grid different parts of the xlsform. The prettyprinting can be done separately for each different language in case the xlsform includes more than one. The template increases legibility for both question blocks:

  1. begin_group --> depending on the level are output with a different style of heading level
  2. begin_repeat --> displayed as a header but with a specific distinct color and note

and within each block, each question details is included:

  1. question code & type
  2. question label & hint
  3. if select_one or select_multiple, modalities code and label as a nested table
  4. if present - question constraint with warning message as well as related question skip logic

In addition, the package includes:

  • a function interview_duration to come up with an estimation of the interview duration time, a critical element to consider to ensure high quality data,

  • a function xlsform_compare to compare different version of a similar xlsform.

Install the package

install.packages("pak")
pak::pkg_install('Edouard-Legoupil/XlsFormPrettyPrint')  

Quick start

Once {XlsFormPrettyPrint} installed, you can create a new RMD using the custom template.

Using RStudio:

  • Step 1: Click the "File" menu then "New File" and choose "R Markdown".

  • Step 2: In the "From Template" tab, choose the xlsform2word one.

template_img

You will then just need to fill in the YAML parameters:

  • dir: the directory in which to find the xlsform and where to save the output file (absolute path or relative to current working directory).

  • xlsformfile: Name of the questionnaire file as character. The package is not designed to validate your xlsform. Please use xlsform validator beforehand.

  • label_language: Language to be used in case you have more than one - for instance "Español (es)", "Français (fr)" or "English (en)" . If not specified, the 'default_language' in the 'settings' worksheet is used. If that is not specified and more than one language is in the XlsForm, the language that comes first within column order will be used.

  • Step 3: Knit the notebook to get your word version.

You can check and example here: the xlsform and the resulting word

Reference

The package mostly leverages the capacity of the {flextable} package and embed UNHCR template from {unhcrdown}.

Two other R package / projects QuestionnaireHTML and ODK2Doc were built with the same goal but with a limited scope and styling capacity. Last there's also from a similar project in python: https://github.com/pmaengineering/ppp