A bash script for converting a plain-text file of multiple-choice questions to H5P
(Before using this bash script, note that a convenient way for creating a single H5P of any type is probably by using a free H5P viewer/editor app such as Lumi. However, if you have a substantial amount of multiple-choice question sets to create, then this bash script comes in handy.)
This repository contains a bash script for creating an H5P of multiple-choice questions (with a single correct answer) using the H5P Question Set template via the linux command line. Simply:
./mcq2h5p.sh myMCQuestions.txt
where myMCQuestions.txt
(it may be named in some other way) is a plain text input file that contains your multiple-choice questions and corresponding answers written in H5P Question Set template markup, e.g.,
1. Which of the following is a letter?
10
9
*A
2. Which of the following is a number?
*35
a
q
z
3. 15 + 1 + 3 = _____
16
21
*19
11
(Note that the file for questions must end in two blank lines. Also, the tips, correct- and wrong-answer feedback have not been implemented so that one cannot use them by using this script.)
The H5P is created in the main directory and is called myNewH5P-mcq.h5p
. There are a number of ways to view/play this newly created H5P:
To use:
git clone https://github.com/justineuro/h5p-mcq-maker.git
.myMCQuestions.txt
(it may be some other filename), containing your MC questions and answers written in H5P Question Set template markup, and save it under the h5p-mcq-maker
directory that you just cloned.control.txt
file to set the parameters for your new H5P (includes TITLE
, AUTHOR
, LICENSE
, INTRODUCTION
, PASS_PERCENTAGE
, DISABLE_BACKWARDS_NAVIGATION
, RANDOM_QUESTIONS
, POOL_SIZE
, and N_QUESTIONS
; see mcq2h5p.sh
for a description of these parameters).h5p-mcq-maker
directory, issue the command:
./mcq2h5p.sh myMCQuestions.txt
where myMCQuestions.txt
may be some other file containing your MC questions and answers. (Note: This file must end in two blank lines.)
The h5p.json
and content.json
files will be created in the appropriate locations inside the myNewH5P-mcq
directory (this will be zipped-up to create your new H5P). Your newly created Question Set H5P, filename: myNewH5P-mcq.h5p,
will be found in the h5p-mcq-maker
directory.
[… section omitted …]
mcq2h5p.sh
This folder includes (among others):
mcq2h5p.sh
- a bash script that converts a plain text file containing multiple-choice questions and answers to a Question Set H5P.myNewH5P-mcq
- a folder that contains the libraries inside the question-set-616.h5p
re-use template that’s available from the Examples & downloads section at https://h5p.org; the h5p.json
and content/content.json
files will be over-written to produce your new H5P. Among other libraries, this folder contains: H5P.QuestionSet-1.20
, H5P.MultiChoice-1.16
, and H5P.Question-1.5
.control.txt
- a plain text file containing the control parameters for your new H5P (e.g., TITLE
, AUTHOR
, LICENSE
, INTRODUCTION
, PASS_PERCENTAGE
, DISABLE_BACKWARDS_NAVIGATION
, RANDOM_QUESTIONS
, POOL_SIZE
, and N_QUESTIONS
; these are used for creating the h5p.json
and content.json
of your new H5P). You would want to edit this to suit your own specifications.myMCQuestions.txt
- an example of 10 multiple-choice questions, five (5) of which are selected each time the H5P is viewed/played. (Note that the MathJax
symbol “\
” has to be triply escaped. Thus, \(
should be written as \\\\(
and \sqrt{2}
should be written as \\\\sqrt{2}
.)myNewH5P-mcq.h5p
- the H5P created by mcq2h5p.sh
from myMCQuestions.txt
.mcq2h5p-eof.sh
when N_QUESTIONS
is not setAn alternative bash script, mcq2h5p-eof.sh
, is available for use when the control file doesn’t contain an initially set value for N_QUESTIONS
, the total number of questions in the questions file. The number of questions is determined after the script has read the entire questions file.
In a manner similar to the previous script, usage is:
./mcq2h5p-eof.sh myMCQuestions.txt
mcq2h5p-eof.sh
This folder includes (among others):
mcq2h5p-eof.sh
- a bash script that converts a plain text file containing multiple-choice questions and answers to a Question Set H5P where the control file (control-eof.txt
) doesn’t necessarily have an initial set value for N_QUESTIONS
.myNewH5P-mcq-eof
- a folder similar to myNewH5P-mcq
folder above.control-eof.txt
- a plain text file containing the control parameters for your new H5P (e.g., TITLE
, AUTHOR
, LICENSE
, INTRODUCTION
, PASS_PERCENTAGE
, DISABLE_BACKWARDS_NAVIGATION
, RANDOM_QUESTIONS
, POOL_SIZE
, and possibly N_QUESTIONS
; these are used for creating the h5p.json
and content.json
of your new H5P). You would want to edit this to suit your own specifications. You may also want to try different values for N_QUESTIONS
or omit it altogether.myMCQuestions.txt
- as above.myNewH5P-mcq-eof.h5p
- the H5P created by mcq2h5p-eof.sh
from myMCQuestions.txt
.
h5p-mcq-maker by Justine Leon A. Uro is licensed under a Creative Commons Attribution 4.0 International License.
Based on a work at https://github.com/justineuro/h5p-mcq-maker.