I've recently made my first app where users play a sound and then write what they heard. It contains about 200 sounds and prior to publication, the app generated random sounds each time I ran it. However, after publication, that randomized order is fixed; is it possible that only the order the app generated at the specific moment got published?
Thank you in advance for any advice.
library(shiny)
library(readxl)
tabulka <- read_excel("komplet.xlsx")
ui <- fluidPage(
titlePanel("Fonetické cvičení - Čínština"),
sidebarLayout(
sidebarPanel("Po přehrání nahrávky napiš, co slyšíš. Slabiku pinyinem, tón číslem (např. hong2xing1). 加油朋友们!",
br(),
br(),
actionButton("play", "Přehrát/Další nahrávka")),
mainPanel(textInput("pinyin", "Pinyin:"),
actionButton("Zkontrolovat", "Zkontrolovat"),
br(),
textOutput("feedback")
)),
)
server <- function(input, output) {
rv <- reactiveValues()
observeEvent( input$play, {
rv$vyhodnoceni <<- ""
radek <- sample(1:nrow(tabulka), size = 1)
nahravka <- tabulka[radek, 1]
rv$spravnaOdpoved <- tabulka[radek, 2]
insertUI(selector = "#play",
where = "afterEnd",
immediate = TRUE,
ui = tags$audio(src = paste0("https://fu.ff.cuni.cz/PROG/semestralky/chobotska/", nahravka), type = "audio/wav", autoplay = NA, controls = NA)
)
})
output$feedback <- renderText({
return(rv$vyhodnoceni)
})
observeEvent( input$Zkontrolovat, {
odhad <- input$pinyin
if (odhad == rv$spravnaOdpoved) {
rv$vyhodnoceni <<- "Výborně, to je správně!"
} else {
rv$vyhodnoceni <<-"Špatně, zkus to znovu" }
})
}
shinyApp(ui = ui, server = server)