1

我有以下 R/Markdown 代码,它使用 R/exams 和 kableExtra 生成随机问题以用于 Blackboard Ultra VLE。虽然当我将生成的存档从VLE 导入exams2blackboard()到 VLE 时,它在纯 HTML 中呈现良好,但表被呈现为纯文本。

R/Markdown 练习文件:

```{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")
```

因此,当我运行exams2blackboard("code.Rmd")它时,它会在 .dat 文件中生成以下 HTML 片段。

<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 当我在 Blackboard Ultra 中导入问题时,它会将表格折叠成纯文本。所以呈现如下。

男 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.13 9.22 71.13 9.8 74.77

分别计算男性和女性参与者反应的平均值和标准差。

表 1:__ 男性 女性 正确 MRT 响应的平均数 平均值 ± SD 平均值 ± SD

有没有人幸运地创建了适用于exams2blackboard 的表格?

4

0 回答 0