-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input type to allow rankings #6
Comments
It could be a workaround but not a preferred method IMO. Especially for
people working with surveys a lot. Based on my attached visual, its more
like a radio button for each row. I hope this helps.
…On Sat, Feb 6, 2021, 10:09 PM Jonathan D. Trattner ***@***.***> wrote:
Would something like Shiny's sliderInput work?
library(shiny)ui <- fluidPage(
shiny::sliderInput("skillA", "How would you rate skill A?",
min = 0, max = 4, value = 2)
)server <- function(input, output, session) {}
shinyApp(ui, server)
[image: Screen Shot 2021-02-06 at 10 09 12 PM]
<https://user-images.githubusercontent.com/51417262/107135362-f26de100-68c7-11eb-88b3-4421978e4c3e.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF2IZSV5E5FY6ZCPSA7SVQTS5X77ZANCNFSM4XG6K3OQ>
.
|
Should users be allowed to select multiple buttons per row, or no? |
No, just 1 value per row.
…On Mon, Feb 8, 2021, 1:04 PM Jonathan D. Trattner ***@***.***> wrote:
Should users be allowed to select multiple buttons per row, or no?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF2IZSXGEG5WRVYRYABGKC3S6ARTTANCNFSM4XG6K3OQ>
.
|
Hi,
(with R 4.0.3, shiny_1.6.0, shinysurveys_0.1.2-dev, on Ubuntu and Firefox)
If, with Firefox webdeveloper tools, I replace the 'name' of the two input values for a single line (say, "S+"), as below, the behaviour is different:
With the above, at least I can select a value for R, and a value for S+. Nothing prevents the user to select R as 1st and S+ as 1st (which can make sense: ties). Some control could be implemented later in a way similar to shinyFeedback (see https://cran.r-project.org/web/packages/shinyFeedback/vignettes/shinyFeedback-intro.html ). |
Also, it might be interesting to have a look at the shinyRadioMatrix package (https://github.com/szelepke/shinyRadioMatrix ). |
Hi @mayeulk! Thanks for the looking into this. I believe this happens because the input ID for both rows of the ranking input are the same, so when you interact with it one overrides the other. Does the following fix it for you? library(shiny)
library(shinysurveys)
df <- data.frame(question = c("What is your favorite food?", "Rank the software according to your preference:", "Rank the software according to your preference:"),
option = c("Your Answer", "R", "S+"),
input_type = c("text", "rank_{{2}}", "rank_{{2}}"),
# Note the input IDs are specific for the language option
input_id = c("favorite_food", "software_R", "software_S+"),
dependence = rep(NA, 3),
dependence_value = rep(NA, 3),
required = rep(F, 3)
)
ui <- fluidPage(
surveyOutput(df = df,
survey_title = "Hello, World!",
survey_description = "Welcome! This is a demo survey showing off the {shinysurveys} package.")
)
server <- function(input, output, session) {
renderSurvey(df = df)
observeEvent(input$submit, {
showModal(modalDialog(
title = "Congrats, you completed your first shinysurvey!",
"You can customize what actions happen when a user finishes a survey using input$submit."
))
})
}
shinyApp(ui, server) |
Hello, |
Note that in the development version, I have superseded the library(shiny)
#remotes::install_github("jdtrat/shinysurveys@extend-shinysurveys")
library(shinysurveys)
df <- data.frame(question = c("What is your favorite food?", rep("R",2), rep("S+",2)),
option = c("Your Answer", rep(c("Least Favorite", "Favorite"), 2)),
input_type = c("text", rep("matrix",4)),
# Note the input IDs are specific for the language option
input_id = c("favorite_food", rep("rankLanguage",4)),
dependence = rep(NA, 5),
dependence_value = rep(NA, 5),
required = rep(F, 5)
)
ui <- fluidPage(
surveyOutput(df = df,
survey_title = "Hello, World!",
survey_description = "Welcome! This is a demo survey showing off the {shinysurveys} package.")
)
server <- function(input, output, session) {
renderSurvey(df = df)
observeEvent(input$submit, {
showModal(modalDialog(
title = "Congrats, you completed your first shinysurvey!",
"You can customize what actions happen when a user finishes a survey using input$submit."
))
print(input$rankLanguage)
})
}
# When printed in console:
# question_id question_type response
# r matrix Favorite
# s matrix. Least Favorite
|
I am needing to create a survey which asks users to rank a couple of options on a scale of 1-4.
![20210206_215540](https://user-images.githubusercontent.com/24415434/107135186-6ad3a280-68c6-11eb-8199-4d47950aa252.jpg)
The text was updated successfully, but these errors were encountered: