moodler-exams

Alignment of \hat symbols in for questions generated by exams2moodle


I'm generating Moodle cloze exercises using the exams2moodle function from R's exams package.

For students using the Chromebooks or the Chrome browser on Mac, the \hat LaTeX symbol doesn't appear to align properly over letters. See how the \hat in $\hat{p}$ blends with the question mark in Part 1 below.

The issue

Some relevant info:

To fix this I've tried:

A (close to) MWE of the question code generating the issue is below:



```{r gen data, echo=FALSE, results='hide'}
H0pct=sample(8:14,1)
H0p=H0pct/100
n=rpois(1,747)
x=rpois(1,102)
phat=x/n
```

Question
===========

The proportion of left-handed people is the NZ population is known to be $`r H0pct`\%$, or $`r H0p`$.  Using the survey data from previous STAT110 students, we find that $x = `r x`$ are left-handed from $n = `r n`$ students.

**Part 1:** What is $\hat{p}$? Ensure your answer is accurate to 4 DP. ##ANSWER1##


Meta-information
===================
extype: cloze
exclozetype: num
exsolution: `r phat`
extol: 0.0001
exshuffle: TRUE

extitle: phat issue MWE
exsection: Section 6: Non-continuous data/Binomial Distribution/Hypothesis test for a proportion/phat issue MWE

Any suggested next steps to take in solving this from here are much appreciated!


Solution

  • Source of the problem: This is most likely an issue with MathJax on these browsers. It was a more general issue in MathJax that was fixed for some browsers, see: https://github.com/mathjax/MathJax/issues/1766

    Further checks: This means that the problem has got nothing to do with Moodle and/or R/exams. To try this out use

    library("exams")
    exams2html("phat.Rmd", converter = "pandoc-mathjax")
    

    and

    library("exams2forms")
    exams2webquiz("phat.Rmd")
    

    and look at the resulting HTML pages using the problematic browsers.

    Workaround: In the GitHub issue linked above it was suggested to use \widehat{...} instead of \hat{...} which has better support.