FoivosV
FoivosV

Reputation: 11

kableExtra HTML tables in exams2blackboard do not render properly in Blackboard Ultra VLE

I have the following R/Markdown code that uses R/exams and kableExtra to generate a randomised question for use in the Blackboard Ultra VLE. Although it renders fine in plain HTML when I import the generated archive from exams2blackboard() into the VLE the tables are rendered as plain text.

The R/Markdown exercise file:

```{r data generation, echo = FALSE, results = "hide"}
## DATA GENERATION
create_table <- function() {
male <- rnorm(12, mean=85, sd=10)
female <- rnorm(12, mean=80, sd=7)
matrix(c(male, female), nrow = 12, dimnames = list(NULL,c("Male", "Female")))
}

create_table_empty <- function() {
  header <- c("", "Male", "Female")
  dat <- c("Mean number of correct MRT responses", "Mean ± SD", "Mean ± SD")
  matrix(dat,nrow = 1, dimnames = list(NULL,header))
}

public <- create_table()
empty_table <- create_table_empty()
row.names(public) <- NULL
maleMean <- mean(public[,1])
maleSD <- sd(public[,1])
femaleMean <- mean(public[,2])
femaleSD <- sd(public[,2])
repeat {
  if(maleMean > femaleMean && femaleSD < maleSD) {
    break
   }
   public <- create_table()
   empty_table <- create_table_empty()
   row.names(public) <- NULL
   maleMean <- mean(public[,1])
   maleSD <- sd(public[,1])
   femaleMean <- mean(public[,2])
   femaleSD <- sd(public[,2])
 }

sol <- c( maleMean, maleSD, femaleMean, femaleSD)
questions <- c(paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2], digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2), "±", format(sol[4], digits = 2)),
  paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2] + runif(1, min=1, max=3), digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2), "±", format(sol[4] - runif(1, min=1, max=3),digits = 2)),
  paste("Male Mean ± SD: ", format(sol[1] + runif(1, min=5, max=15), digits = 2),"±", format(sol[2], digits = 2) , ", Female Mean ± SD: ", format(sol[3] + runif(1, min=10, max=30), digits = 2), "±", format(sol[4], digits = 2)),
  paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2], digits = 2), ", Female Mean ± SD: ", format(sol[3] + runif(1, min=10, max=30), digits = 2), "±", format(sol[4] - runif(1, min=1, max=3), digits = 2)),
  paste("Male Mean ± SD: ", format(sol[1] + runif(1, min=10, max=30),digits = 2),"±", format(sol[2]- runif(1, min=1, max=3), digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2) , "±", format(sol[4], digits = 2) )) 
```

Question
========

```{r, echo = FALSE, comment = NA, results='asis'}
library("knitr")
library("kableExtra")
library("dplyr")

public %>% 
  kable(digits = 2,format = "html", booktabs = TRUE) %>%
  column_spec (1:2,border_left = T, border_right = T) %>%
  row_spec(1:12, hline_after = T, ) %>%
  kable_styling(
    bootstrap_options = "bordered", full_width = FALSE, position = "left")
```

Calculate the mean and standard deviation for the male and female participants' responses respectively. 

```{r, echo = FALSE, comment = NA, results='asis'}
empty_table %>% 
  kable(caption = "Table 1:__",format = "html", booktabs = TRUE) %>%
  column_spec (1:2,border_left = T, border_right = T) %>%
  row_spec(0:1, hline_after = T, ) %>%
  kable_styling(bootstrap_options = "bordered", full_width = FALSE, position = "left")
```

So when I run exams2blackboard("code.Rmd") it generates the following HTML snippet in the .dat file.

<table class="table table-bordered" style="width: auto !important; ">
<thead>
<tr>
<th style="text-align:right;">
Male
</th>
<th style="text-align:right;">
Female
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
80.45
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
89.37
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
84.76
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
92.89
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
76.23
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
78.47
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
97.08
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
75.27
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
81.66
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
85.22
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
85.11
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
79.01
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
86.78
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
84.86
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
100.67
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
73.63
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
94.16
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
79.34
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
92.22
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
71.18
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
72.81
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
77.73
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
95.00
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
74.89
</td>
</tr>
</tbody>
</table>
<p>Calculate the mean and standard deviation for the male and female participants’ responses respectively.</p>
<table class="table table-bordered" style="width: auto !important; ">
<caption>
Table 1:__
</caption>
<thead>
<tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
Male
</th>
<th style="text-align:left;">
Female
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;border-left:1px solid;border-right:1px solid;">
Mean number of correct MRT responses
</td>
<td style="text-align:left;border-left:1px solid;border-right:1px solid;">
Mean ± SD
</td>
<td style="text-align:left;">
Mean ± SD
</td>
</tr>
</tbody>
</table>

Bur when I import the question in Blackboard Ultra it collapses the table into plain text. So it renders as follows.

Male Female 80.45 89.37 84.76 92.89 76.23 78.47 97.08 75.27 81.66 85.22 85.11 79.01 86.78 84.86 100.67 73.63 94.16 79.34 92.22 71.18 72.81 77.73 95.00 74.89

Calculate the mean and standard deviation for the male and female participants’ responses respectively.

Table 1:__ Male Female Mean number of correct MRT responses Mean ± SD Mean ± SD

Has anyone had any luck creating tables that work with exams2blackboard?

Upvotes: 1

Views: 82

Answers (0)

Related Questions