Search code examples
canvasr-exams

Issues Importing QTI File to Canvas Using exams2canvas


I'm currently working on creating quizzes for Canvas using the exams package in R, specifically with the exams2canvas function. I want to create a short-answer question where it asks students to compare and interpret the differences between a boxplot and a histogram (generated using ggplot2) on randomly selected 4 variables in the data set.

I followed the essayreg essay template closely.

I was able to import the essayreg question to the Canvas question bank but when I adapt the template to suit my questions, I can still generate the QTI zip file, but when I import it into Canvas, the questions do not appear in the question bank.

Here is a brief overview of my process:

  1. I use the exams package to create the exam questions.
  2. I export the questions to a QTI zip file using exams2canvas.
  3. I import the zip file into Canvas following the standard import procedure.

Despite following these steps, the questions are not visible in the question bank after the import. Has anyone else encountered this issue or have any suggestions on how to resolve it?

I am suspecting it has something to do with QTI1.2 or QIT2.1 etc?

Thanks for your assistance!

Rmarkdown code

---
editor_options: 
  markdown: 
    wrap: 72
---

```{r data generation, echo = FALSE, results = "hide"}
library(palmerpenguins)
library(tidyverse)
library(ggplot2)
library(patchwork)

x <- "body_mass_g"
df <- penguins |> select(all_of(x), species)

## QUESTION/ANSWER GENERATION
questions <- solutions <- explanations <- points <- rep(list(""), 1)
type <- rep(list("string"), 1)

questions[[1]] <- ""
solutions[[1]] <- c("1 mark for each statement & no half point... more text to follow, but currently not shown on Canvas.")

points[c(1)] <- 2
```

Question
========

The `palmerpenguins` R package contains size measurements for three
penguin species (Adelie, Chinstrap and Gentoo) observed on three islands
in the Palmer Archipelago, Antarctica. It contains 8 variables (n =
`r nrow(penguins)`). A glimpse of the data set is given below:

```{r output, echo=FALSE, comment=NA}
glimpse(penguins)
```

Using the ggplot2 library in R, the following code creates two plots: a
histogram of `r names(df)[1]` by species and a boxplot of
`r names(df)[1]`. 

```{r plots,  echo = FALSE, results = "asis", fig.height = 6, fig.width = 12, warning=FALSE, message=FALSE, fig.cap=""}

# Histogram 
p1 <- df |> ggplot(aes_string(x)) + 
  geom_histogram(aes(fill = species), alpha = 0.5, position = "identity") +
  labs(x= names(df)[1]) +
  scale_fill_manual(values = c("darkorange","darkorchid","cyan4"))

## boxplot
p2 <- df |> ggplot(aes(x = species, y = df[[1]])) + 
  geom_boxplot(aes(fill = species), 
               alpha = 0.7, 
               show.legend = FALSE) +
  labs(y= names(df)[1]) +
  scale_fill_manual(values = c("darkorange", "darkorchid", "cyan4"))

p1 + p2
```

One question to be given here, it is structured to be an open-ended question where students need to interpret the plots. ##ANSWER1##


```{r questionlist, echo = FALSE, results = "asis"}
answerlist(unlist(questions), markup = "markdown")
```

Solution
========

```{r solutionlist, echo = FALSE, results = "asis"}
#answerlist(paste(unlist(explanations), ".", sep = ""), markup = "markdown")
```

Meta-information
================
exname: rexams example
extype: cloze
exsolution: `r paste(solutions, collapse = "|")`
exclozetype: `r paste(type, collapse = "|")`
expoints: `r paste(points, collapse = "|")`

Solution

  • The main problem is the meta-information. Essay questions for Canvas should be extype: string questions (not cloze) with exstringtype: essay.

    Also, the questions and solutions don't need to be formatted as answerlist() here, you can simply include them in the Question and Solution part of the exercise. A few other aspects can be simplified analogously. The full adapted R/Markdown code is given below.

    With that the question is rendered correctly in Canvas:

    Canvas screenshot of the exercise Canvas screenshot of the editor

    However, why the solution text is not imported correctly, I'm not sure. Canvas is sometimes picky about certain details in the QTI XML without providing any insights how the problems can be fixed. If anyone else could provide information about what is going on here, it would be much appreciated.

    R/Markdown exercise:

    ---
    editor_options: 
      markdown: 
        wrap: 72
    ---
    
    ```{r data generation, echo = FALSE, results = "hide"}
    library("palmerpenguins")
    library("tidyverse")
    library("ggplot2")
    library("patchwork")
    
    x <- "body_mass_g"
    df <- penguins |> select(all_of(x), species)
    ```
    
    Question
    ========
    The `palmerpenguins` R package contains size measurements for three
    penguin species (Adelie, Chinstrap and Gentoo) observed on three islands
    in the Palmer Archipelago, Antarctica. It contains 8 variables (n =
    `r nrow(penguins)`). A glimpse of the data set is given below:
    
    ```{r output, echo=FALSE, comment=NA}
    glimpse(penguins)
    ```
    
    Using the `ggplot2` package in R, the following code creates two plots: A
    histogram of `r names(df)[1]` by species and a boxplot of
    `r names(df)[1]`. 
    
    ```{r plots,  echo = FALSE, results = "asis", fig.height = 6, fig.width = 12, warning=FALSE, message=FALSE, fig.cap=""}
    ## histogram 
    p1 <- df |> ggplot(aes_string(x)) + 
      geom_histogram(aes(fill = species), alpha = 0.5, position = "identity") +
      labs(x= names(df)[1]) +
      scale_fill_manual(values = c("darkorange","darkorchid","cyan4"))
    
    ## boxplot
    p2 <- df |> ggplot(aes(x = species, y = df[[1]])) + 
      geom_boxplot(aes(fill = species), alpha = 0.7, show.legend = FALSE) +
      labs(y= names(df)[1]) +
      scale_fill_manual(values = c("darkorange", "darkorchid", "cyan4"))
    
    p1 + p2
    ```
    
    One question to be given here, it is structured to be an open-ended question where students need to interpret the plots.
    
    Solution
    ========
    1 mark for each statement & no half point... more text to follow, but currently not shown on Canvas.
    
    Meta-information
    ================
    exname: rexams example
    extype: string
    exstringtype: essay
    exsolution: nil
    expoints: 2