```{r setup, warning=FALSE, message=FALSE, include=FALSE}
# Load required packages
library(learnr)
library(xfun)
```

```{r nonbinary_quiz1, echo=FALSE}
question("Q1. Say, we are exploring the association between diabetes exposure (no, diabetes type 1, diabetes type 2) and CVD outcome (no, acute, chronic). Which of the following code can be used to fit the model?",
  answer("fit <- glm(CVD ~ diabetes, data = analytic.data, family = binomial)"),
  answer("fit <- glm(I(CVD == 'chronic') ~ diabetes, data = analytic.data, family = binomial)"),
  answer("fit <- multinom(CVD ~ diabetes, data = analytic.data)", correct = TRUE),
  answer("fit <- svy_vglm(CVD ~ diabetes, data = analytic.data)"),
  allow_retry = TRUE,
  random_answer_order = FALSE,
  incorrect = "We use glm for binary outcome and svyglm for survey data analysis.",
)
```

```{r nonbinary_quiz2, echo=FALSE}
question("Q2. Say, we want to explore the relationship between arthritis (binary exposure) and time to CVD development (survival outcome). Which of the following code can be used to fit the cox porportional hazards model?",
  answer("fit2 <- survfit(Surv(time, cvd) ~ arthritis, data = analytic.data)", message = "We use survfit to create survival curves, e.g., KM plot."),
  answer("fit2 <- survdiff(Surv(time, cvd) ~ arthritis, data = analytic.data)", message = "We use survdiff to compare survival times between groups."),
  answer("fit2 <- coxph(Surv(time, cvd) ~ arthritis, data = analytic.data)", correct = TRUE),
  answer("fit2 <- glm(cvd ~ arthritis, data = analytic.data)", message = "We use glm for fitting generalized linear models, not survival models."),
  allow_retry = TRUE,
  random_answer_order = TRUE
)
```
