# Forum: support

Monitor Forum | Start New Thread
 Nested Flat Threaded Ultimate Show 25 Show 50 Show 75 Show 100
 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-04-06 20:51 [forum:45084] All working perfectly now! Installation of the package from the R Studio console, and url compiles as it should with \texttt{}. thanks Achim! I'll be in touch if I find anything else that confuses me :-) all the best, BR

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-04-05 19:29 [forum:45080] Argh, this still seems to be flaky. However, for me it just worked so you might try again. If it doesn't, then it would be easiest to check out the SVN and build/INSTALL by hand. In case you haven't got subversion installed: sudo apt-get install subversion And then svn checkout svn://r-forge.r-project.org/svnroot/exams/pkg/exams R CMD build exams R CMD INSTALL exams_2.2-2.tar.gz In the "build" step you may require a few further R packages. Of if you don't want to install these: R CMD build --no-build-vignettes exams hth, Z

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-04-05 09:19 [forum:45079] Looks like the same availability problem as before: > install.packages("exams", repos = "http://R-Forge.R-project.org") Installing package into ‘/home/ravenwood/R/x86_64-pc-linux-gnu-library/3.3’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘exams’ is not available (for R version 3.3.3) This happens both in the Ubuntu terminal, and in the console in R Studio. Before it was happening only in the terminal.

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-04-04 21:55 [forum:45078] Bill, if you could check whether going back from \verb{...| to \texttt{...} still works as desired with the current R-Forge version, that would be useful. I hope we have resolved all issues now. As for other checks: I think we have no features that need specific testing...but I'm sure that there are some glitches in the code waiting to be found ;-) So if you notice anything, feedback and comments are always welcome!

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-04-04 12:41 [forum:45077] No prob, I've been using \verb| | instead of \texttt{} and the urls have been compiling fine so far. Please let me know if I can be of help with any testing on my end with Moodle etc. I'll be using the exams package every week for the rest of this semester, so will have plenty of opportunity to play with all the capabilities. BR

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-04-02 23:56 [forum:45070] Bill, thanks for spotting this. This was indeed a bug in the regular expression I employed to substitute \url{} with \href{} constructs. This matched on the wrong closing }. I have just committed a fix (provided by Fritz) in revision 991. R-Forge will probably need some time to re-build the package but then your example should work ok, I hope. Thanks for your perseverance! Z

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-04-01 11:08 [forum:45067] Hi Achim, hope you're feeling better! Here's the minimum .Rnw file that gives the error: ====start=== <>= ## DATA GENERATION df = data.frame(x = 2, y= 3) write.csv(df, file = "fecund.csv", quote = FALSE, row.names = FALSE) @ \begin{question} The results are recorded in \url{fecund.csv}, where column \texttt{eggs} \begin{answerlist} \item question \end{answerlist} \end{question} %% META-INFORMATION %% \extype{cloze} %% \exclozetype{num} %% \exsolution{5} %% \exname{t-test with data} %% \extol{.1} ==== end==== For this I type exams2moodle("testURL.Rnw", converter = "pandoc-mathjax") and this gives the following for the url reference:

The results are recorded in , where column eggsfecund.csv, where column eggs

As you can see, it is confused by the \texttt{} on the same line as the \url{} and it doubles some of the text in response. thanks for looking at this! Bill

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-04-01 00:07 [forum:45066] Bill, I have to apologize for the late reply. I caught a virus flu last week and needed (well, actually still need) some days to recover. I just ran the following: install.packages("exams", repos = "http://R-Forge.R-project.org") library("exams") exams2moodle(c("boxhist", "tstat"), name = "pandoc", converter = "pandoc-mathjax") and imported the resulting pandoc.xml into our Moodle sandbox. This worked fine - both the mathematical formulae in "tstat" and the pluginfile in "boxhist" worked as intended. Could you please try (a) whether exactly this example also works for you? And if not, provide a minimal self-contained example for a situation where this kind of approach doesn't work?

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-24 11:31 [forum:45057] Hi again Achim, I guess I spoke too soon when I said that pandoc was working with the url syntax. When I imported the xlm into Moodle, the url vanished and the name associated with it was inserted later in the exercise text. So here's what happened: the text \url{fecund.csv} was translated by the default converter as: fecund.csv This works fine. However, the \url{fecund.csv} is translated by pandoc-mathjax as: , This does not work and no link text is produced in the exercise imported into Moodle. However, that link text migrates over to another position in the text, see this:

Ecologists hypothesize that a female shrimp of type B has greater fitness than type A, because type B produces more eggs. A random sample of $$204$$ shrimp of type A and $$162$$ shrimp of type B are collected and the total egg production of each is counted. The results are recorded in , where column eggs displays the egg count of each sampled female, and column type indicates the type of female. Scan these results into R using scan() and perform a t.test()fecund.csv, where column eggs displays the egg count of each sampled female, and column type indicates the type of female. Scan these results into R using scan() and perform a t.test() to test the hypothesis that the mean egg production is the same in the two female types.

Note that fecund.csv that is supposed to be the linked text is stuck after the last \texttt{} command in the exercise text. And I'm using the straight \url{}, not surrouding it with texttt{}. So as far as I can tell urls seem to be broken with the pandoc converter at the moment. thanks for looking at this, Bill

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-03-23 21:42 [forum:45056] Bill, yes, I hadn't forgotten about the stuff but I needed to check with Niki and Fritz before. (Fritz is the only one of the package authors who teaches with Moodle. Niki and I just have a small Moodle sandbox for testing the R/exams package.) So the $course$ is there because this is what the Moodle XML documentation says (https://docs.moodle.org/32/en/Moodle_XML_format#Overall_structure_of_XML_file) and also exporting XML from Moodle contained the $course$. So our reading is that this shouldn't be an issue for you. And the /moodlequiz/ part can either be change by setting the 'name' argument in exams2moodle(..., name = "foobar") or it can be suppressed by setting exams2moodle(..., iname = FALSE). I hope the latter will work for you. But please keep asking if this does not resolve the issues.

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-23 11:28 [forum:45055] Thanks Achim it's nice to be getting help with one of the main developers :-) I'll use the simple \url{} syntax, nice to know. The main (small) thing left for me know is how to create the xml without the $course$/moodlequiz/ in the category specification. I need to delete this from the xml every time in order for the import to go into the right directory in the Moodle question bank categories. Any help on this is appreciated! thanks again Bill

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-03-23 11:03 [forum:45053] Thanks, Bill, both for testing and the positive feedback! We're very glad if the package is useful :-) We are currently working on making the package more accessible for non-R users as well. A shiny-based graphical user interface is under development. Let's see. As for the \url{}: It is sufficient to do \url{file.csv} instead of \texttt{\url{file.csv}}, both are processed in the same way. The install.packages issue is really weird, I've notified the R-Forge maintainers. Possibly something in the server config. And I'm also not sure where the browser issue comes from. I'll try to have a look at this on one of our Ubuntu machines. Thanks!

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-23 07:10 [forum:45052] I forgot to say that the vertical space/font problem persists for exams2html(), so this appears to be a browser problem, not a Moodle problem.

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-23 06:42 [forum:45051] Stranger and stranger ..... Using a terminal window running R as before, I get the same error message, Warning message: package ‘exams’ is not available (for R version 3.3.3) So I tried installing exams from R Studio, and it installed perfectly no problem, into the same directory. And I used exams2moodle( ... converter = "pandoc-mathjax") on a file containing \texttt{\url{file.csv}} and it compiled fine, converting the URL reference to in the xml. So now I'm wondering why exams won't install from the terminal window ?!?! never seen this happen before. I just tried reinstalling it from the terminal and got the same error message. Thanks again for your help -- hopefully this url thing won't become a FAQ. All is working perfectly here. This is a wonderful package, that I especially appreciate after having spent some 5 years teaching this course using the formula question in Moodle ... which is a great question type for anything mathematical, but way too time consuming with all the windows, and the wait time after every mouse click, and too limiting with very primitive functions. For R users exams is a joy :-)

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-03-22 22:09 [forum:45050] Bill, thanks again! R-Forge: There was some problem with the repository earlier but now this should work again (at least it just did for me): install.packages("exams", repos="http://R-Forge.R-project.org") Browser: Weird, that's almost the setup that I use myself (same version on Debian instead of Ubuntu). Do you experience the same problem with, say, exams2html("tstat") outside of Moodle? Otherwise it might be some Moodle plugin that is responsible. Title text: Yes, this does not look ideal. I'll have to ask my co-authors about this.

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-22 20:00 [forum:45049] Achim, when I hit install.packages("exams", repos="http://R-Forge.R-project.org") I get: Warning message: package ‘exams’ is not available (for R version 3.3.3) The browser I'm using is the latest version of Firefox, 52.0.1 (64-bit) for Ubuntu. I will look around for , not really a big issue. The only other question I have is this: in the xml file the category location is given as $course$/moodlequiz/Marine Ecology/Labs/First4/Lab 4/chi square with data R exams What I would like it to say is: Marine Ecology/Labs/First4/Lab 4/chi square with data R exams How do create the xml file without those first two labels there, the $course$/moodlequiz/ ? thanks again!

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-03-22 15:32 [forum:45048] Bill, thanks for the follow-up: (1) I don't know whether pandoc can be tweaked to use rather than . But it also consistently uses rather than for \textit and rather than for \textbf etc. (2) To prevent this \url{...} issue from becoming an FAQ: I have tweaked our pandoc converter so that \url{...} is replaced internally by \href{...}{\texttt{...}} prior to calling pandoc. So you should be able to use \url{...} in the .Rnw exercises "as usual". It would be great if you could test this after installing the latest version of exams: install.packages("exams", repos="http://R-Forge.R-project.org") (3) Would you share which browser you have been using when experiencing the problems with MathML? Then we could try to look into what's going on there.

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-22 12:25 [forum:45043] Thanks Achim! I installed pandoc and gave it a try, got the message Loading required namespace: rmarkdown Error in if (!after) c(values, x) else if (after >= lengx) c(x, values) else c(x[1L:after], : argument is of length zero and then I looked at your previous response in this forum and changed the url reference to \href{file.csv}{\texttt{file.csv}} and the LaTeX equation formatted perfectly. Interestingly, with pandoc the \texttt{} was translated into in the xml rather than . Do you know what LaTeX environment I would use to get in pandoc? thanks again!

 RE: LaTeX formatted equations in exams2moodle() [ reply ]By: Achim Zeileis on 2017-03-21 21:21 [forum:45036] Bill, thanks for your question - and great that "exams" is useful for you! May I ask which browser/version you are using? In current versions of Firefox the rendering of MathML should work seamlessly. Safari should also be ok, Internet Explorer needs the MathPlayer plugin and Chrome doesn't support MathML at all. I haven't seen the problems you mention, though (line break and vertical space). In any case, I think using exams2moodle(..., converter = "pandoc-mathjax") should do what you want to do. It replaces the $...$ inline math mode with $$...$$ which is supported by Moodle as an alternative to $$...$$. As for the pros and cons of using MathML vs. LaTeX+MathJax: - The main technical difference is that when MathML is embedded into web pages, it is typically rendered by the browser whereas MathJax rendering is done on the server. Both produce nicely formatted output if they work correctly. - Rendering on the server has the advantage that this works with any modern browser and users don't have to worry about it. - However, the MathJax plugin in Moodle may not be enabled in some Moodle installations. And while it is relatively easy for teachers to tell the students to use Firefox, it may be more difficult to convince their institution to enable MathJax in their Moodle installation. - Also, if the connection to the server is not so fast, the rendering by MathJax takes noticably more time and uses more bandwidth. For these (and for further "historic" reasons) exams2moodle() employs converter = "ttm" for conversion to HTML+MathML. However, changing to converter = "pandoc-mathjax" is easy and should produce the result you are looking for.

 LaTeX formatted equations in exams2moodle() [ reply ]By: Bill Ravenwood on 2017-03-21 17:50 [forum:45035] Hello Achim, Thank you for exams() -- this is saving tremendous time for me in teaching statistics classes. I apologize if this is a naive question -- but I have looked in the forum and not found something similar. I'm using exams2moodle() and all works beautifully except formatted equations, even the most simple like $\alpha = 0.05$. The problem is that about an inch of vertical space is added above and below every line containing $$, and the font of the math is too small. What I'm wondering is why is R used at all to format LaTex equations in exams? Moodle itself renders LaTeX equations beautifully, so why not just leave the$$ syntax in the xml code, and let moodle format the equations? If I create a simple question with exams(), such as "What kind of error is symbolized by $\alpha$? and import it into Moodle, there is an inch of vertical space above and below this line and the font of alpha is a couple points smaller than the rest of the text. If I just create that same identical question by hand within Moodle, then there is no vertical space, and the font size is correct, on the same browser. If I again create this question with exams() and import it into Moodle, and then edit the HTML within Moodle to delete the MathML material and replace it with $$\alpha = 0.05$$, then the font size is perfect, and the vertical space is gone (in Moodle two dollar signs are necessary to surround equations within text). So it appears that if exams2moodle() would just keep the LaTeX equation source, with the dollar signs, instead of using R to format equations, then the result is perfect and exactly as expected for Moodle users. As presently implemented, the result looks ragged, with way too much white space, and with font size a bit too small. Any comments/suggestions are appreciated, and thank you for taking the time to read this. Again, thanks for this beautiful package.

Thanks to: