Three magical tools: VisualNEO Win, Pandoc and Typora

Last week I had a very tedious task to perform: I had to make 40 music theory exams as an ODT document (1). Each student should have his own unique exam, containing a specific number of tasks. The ODT document contains several sections as embedded objects (like pictures) sections and formatting styles for various elements.

How can I create these exams? Well, the hard way. First I can make an ODT template with some questions. Second, I open the template, add to each question specific content (such as pictures of musical scores and specific instructions as constructing four-note chords) and save the document. I’ve to do this 40 times. To be honest, not my job.

So, I thought about a less tedious solution. The results of my thinking so far:

1. With VisualNEO Win, I can do repetitive tasks easily: creating 40 files is in fact running a loop for 40 times.
2. Pandoc (2) is an excellent command line document converter. Pandoc can convert -amongst others- a HTML-file (3) and Markdown file (4) into an ODT document. Example:

pandoc -o test.odt

Many command line options are available. “Pandoc is your swiss-army knife”, the developers say.

3. The choice between generating a HTML- or Markdown file with VisualNEO Win was an easy decision: the Markdown syntax is simple. In addition, Markdown can handle HTML commands!

So the easy way was:
a. create a md-file (md = Markdown) – with help of VisualNEO Win and
b. convert the md-file into an ODT document using Pandoc.

The last question was how to create a Markdown document. Well, I found a handy tool: Typora (5), a lightweight plain text editor that makes creating a .md file very easy: it renders what’s typed on the screen in Markdown format. You can e.g. type the string ‘my word’ and to make it bold, select it and press CTRL+B (or via the Menu -> Format). Typora now replaces ‘my word’ into the Markdown command **my word**. However, Typora has a clean interface: you’ll see the Markdown-code only when you click ‘my word’ (or via the Source Code Mode: Menu -> View).

Tip 1: explore in Typora the right mouse click-menu!
Tip 2: Typora has an excellent built-in Markdown Reference (Menu > Help)

So, I made an example-exam with Typora and looked into the source code, for knowing how to write my VisualNEO Win commands.

Well, if you are inspired to make a VisualNEO Win application, you can read now some suggestions. For demonstration purposes, I’ll show only the making of a header and 2 questions. For you, the next Markdown commands will be sufficient (but you can extend them easily);

Heading like <h1>: #header-like-html-h1
Heading like <h2>: ##header-like-html-h2
Bold: **this bold text**
Italic: *this is italic text*
Unordered lists: 
- item1
- item2


Okay, now my suggestions.

1. Define first a semicolon separated list of students and parse that list. Tip: do not use spaces in the student’s name.

StrParse "[list-of-students]" ";" "[student]" "[no-of-students]"

2. Define variables for the automatically generated question 2 (see below)

SetVar "[types]" "major;minor;dominant;diminished;half-diminished"
StrParse "[types]" ";" "[type]" "[no-of-types]"

SetVar "[pitches]" "C;C#;Db;D#;Eb;E;E#;F;F#;Gb;G;G#;Ab;A;A#;Bb;B;B#"
StrParse "[pitches]" ";" "[pitch]" "[no-of-pitches]"

SetVar "[inversions]" "first;second;third"
StrParse "[inversions]" ";" "[inversion]" "[no-of-inversions]"

3. Create the Markdown documents

Loop "1" "[no-of-students]" "[x]"

.make a header and write the result into a document with the name of the student in the filename
.note that Markdown has LN [#10] as line ending

SetVar "[header]" "##University of Arts[#10]"
SetVar "[header]" "[header]#Exam Music Theory - January 2021[#10][#10]"

FileWrite "[PubDir][student[x]]" "Append" "[header]"

.do some processing for question 1 and extend the current document
.note that I insert a picture by the traditional HTML command

SetVar "[question-1]" "**Question 1:**[#10]Study the next example. Which modulation technique uses the composer?[#10][#10]"
SetVar "[question-1]" "[question-1]*Enter your answer below the example*[#10][#10]"
SetVar "[question-1]" "[question-1]<img src='question-1-[x].png' />[#10][#10]"

FileWrite "[PubDir][student[x]]" "Append" "[question-1]"

.do some processing for question 2 and extend the current document

Random "[no-of-types]" "[type-selection]"
Math "[type-selection]+1" "0" "[type-selection]"

Random "[no-of-pitches]" "[pitch-selection]"
Math "[pitch-selection]+1" "0" "[pitch-selection]"

Random "[no-of-inversions]" "[inversion-selection]"
Math "[inversion-selection]+1" "0" "[inversion-selection]"

SetVar "[question-2]" "**Question 2:**[#10]Construct a [type[type-selection]] seventh chord with root [pitch[pitch-selection]]. Write it out in the [inversion[inversion-selection]] inversion.[#10][#10]"

FileWrite "[PubDir][student[x]]" "Append" "[question-2]"


Now you’ve 40 .md documents, that need to be converted by Pandoc:

– download the portable version of Pandoc (6) and unzip it into the folder you want.
– put the .md files you want to convert in your Pandoc directory.

In case of my 40 .md documents, I used the following with VisualNEO:

FileList "[PubDir]*.md" "Files" "[all-md-files]"
StrParse "[all-md-files]" "[#13]" "[fname]" "[number-of-md-files]"

Loop "1" "[number-of-md-files]" "[index]"

ExtractFileName "[fname[index]]" "[students-filename-and-extension]"

.remove the extension
StrReplace "[students-filename-and-extension]" ".md" "" "[students-filename]" ""

Run "cmd" "/c pandoc -o [students-filename].odt [students-filename].md" "Normal" "" ""

That’s it! Within a TEAMS session, each student got his own exam as an ODT document, answered the questions (within limited time) and send the filled-in exam to me. It was the best answer I could give now to prevent cheating on online exams.

Thanks for reading!

Reinier Maliepaard

(1) ODT documents can be opened with word processors like Microsoft Word, LibreOffice Writer or AbiWord.