Closed gabrielgraciano closed 6 months ago
Hi @gabrielgraciano - Can you share an example of your code? Also, take a look at this article and see if that helps you in including a plot in your quiz.
` library(htmltools) library(shinyquiz)
q1 <- create_question(
HTML('
)
quiz <- create_quiz(q1)
quiz ` It is just a simple example. I would like to add a png image to the quiz. Thanks for providing the link!
For an image, it is recommended to follow the standard Shiny approach of including the image file in the www
directory of the shiny app and then using htmltools::img(src = {path to your image})
in the quiz question. Here is a reproducible example so you can see the code and directory structure.
If you already have the image hosted somewhere, you can simple use htmltools::img(src = {url to your image})
and forgo the www
directory.
Hey, Joe!
Sorry for the delay. Thanks for the response and effort in sending me an example. I am still coding the quiz I want to make and you helped me a lot.
Thanks again!
In the reproducible example here, the quiz grows long-wise due to the image. Is it possible to have, for instance, the question and image in a column to the left while the answer choices are put in a column to the right? This way, the overall quiz can remain compact? I've been running into an issue where I have to scroll up and down to see all of the quiz within the HTML document where I'm utilizing the package.
Unfortunately it's not flexible enough right now to place the answer area to the right. Since the prompt argument can take arbitrary HTML, you could leverage shiny/bootstrap to put the prompt contents side-by-side. E.g. Have the question text on the left, the image on the right, and the answer below.
create_question(
shiny::fluidRow(
shiny::column(
width = 6,
htmltools::p("My question text")
),
shiny::column(
width = 6,
htmltools::img(src = "test-image.png"),
)
),
add_choice('choice1'),
add_choice('choice2', correct = TRUE),
label = 'Select the correct choice'
)
That'll work, then. Thanks for the follow-up!
Hello. I am trying to plot an image as part of my quiz but it is not working. I am using htmltools library. Could you help me, please? Thanks in advance