Skip to main content

The PreTeXt Guide

Subsection 4.12.4 Horizontal Parsons Problems

A horizontal Parsons problem is very similar to the traditional vertical problems just described in Subsection 4.12.3. Except they are horizontal. Which means the blocks are very short (a word or symbol) and they are rearranged by the reader to form a horizontal bit of text. They are ideal for constructing a single line of computer code, such as a regular expression, or a short sentence. While similar, they have a few features which are different.
To indicate a horizontal problem, set the @layout attribute on the <blocks> element to the value horizontal. The default value is vertical and so is not necessary for the traditional versions.
The syntax for blocks is the same, and they are authored in an order that yields a correct answer. The use of an @order attribute on each <block> indicates a rearrangment to be used for a static version. Blocks may be reused. To do this, place an @xml:id on a single instance of a block to be reused. Then, to indicate its reuse as part of a correct version, use a @ref attribute on a <block>. Since the duplicate instance is not shown to the reader, the use of @order and @ref is mutually-exclusive. You can set the @reuse attribute on the @blocks element to the value yes to force the interface to allow the reader to reuse blocks, even if there is no duplication in the correct version. Otherwise, the interface reacts to the presence or absence of blocks with the @ref attribute.
Distractors may be included in the same manner as for vertical Parsons problems, by setting the @correct attribute on a <block> to the value no. The default is yes. It does not make much sense to indicate a reusable block (in either form) as a distractor, so don’t.
Another option on the @blocks element is the @randomize attribute. The default value is yes. When the value is set to no, then the blocks are always presented to the reader in the same order, which is the one given by the @order attribute.
As of 2022-11-28, the implemenation of these problems assumes that the blocks rearrange to be computer code. So you can set the @language attribute on the <exercise> element to natural, but it will not have much effect. Markup like <em> on the text of a block will be unpredictable, as will attempts to use mathematics. And the text of blocks will always be in a monospaced font, perhaps with some syntax highlighting if @language is set properly.