r-exams

Less than symbol ("<") in cloze schoice in Canvas (html select dropdown) shows as &lt;


My answerlist contains "<" and ">" symbols, but these get rendered as &lt; and &gt; in the select dropdown in Canvas when I'm using cloze with multiple schoices.

For example:

Question
========

Determine the domain and range of the function below.

$$f(x) = \sqrt{x+5}-7$$

* Domain:
  - ##ANSWER1##
* Range:
  - ##ANSWER3##

Answerlist
--------

* x≤-7
* x<-7
* x≥-7
* x>-7
* x≤-5
* x<-5
* x≥-5
* x>-5
* x≤5
* x<5
* x≥5
* x>5
* x≤7
* x<7
* x≥7
* x>7
* y≤-7
* y<-7
* y≥-7
* y>-7
* y≤-5
* y<-5
* y≥-5
* y>-5
* y≤5
* y<5
* y≥5
* y>5
* y≤7
* y<7
* y≥7
* y>7

Solution
========

* Domain:
  - $x\ge-5$
* Range:
  - $y\ge-7$

Meta-information
============
extype: cloze
exclozetype: schoice|schoice
exsolution: 0000001000000000|0010000000000000
exname: radical_dom_rng

But then, in Canvas (with a similar question):

a screenshot showing the problem

I wish I had the energy to track this down on my own, but maybe someone has a quick fix? LaTeX does not render in the dropdown select menus. I guess I could get rid of the strict inequalities, but I'd rather keep them in.


Solution

  • Source of the problem:

    Usually, the < and > symbols need to be encoded as HTML so that they cannot mess up the XML formatting. Without escaping/encoding they might be misinterpreted as part of HTML tags.

    The problem then is that dropdown menus can only contain plain text and no HTML or mathematical notation etc. Hence, Canvas displays the dropdown content verbatim.

    Workaround:

    In exams 2.4-2 (the current development version on R-Forge), I have now added a workaround that converts the content of the dropdown menus from HTML to plain text.

    Caveat:

    In simple scenarios like the one from the question this should solve the problem. With more complex formatting in the dropdown contents, the formatting will be lost and the content might not be useful anymore. Also, I'm not sure whether this could lead to situations with invalid XML.

    To try the development version of the package:

    install.packages("exams", repos = "https://R-Forge.R-project.org",
      type = "source")