-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
3156 lines (3014 loc) · 99.1 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Load Required Packages
library(shiny)
library(shinydashboard)
library(shinyjs)
library(shinyBS)
library(shinyalert)
library(shinyWidgets)
library(boastUtils)
library(dplyr)
# Load Question Banks and Choices ----
bankA <- read.csv(file = "questionBankA.csv", stringsAsFactors = FALSE)
bankB <- read.csv(file = "questionBankB.csv", stringsAsFactors = FALSE)
bankC <- read.csv(file = "questionBankC.csv", stringsAsFactors = FALSE)
bankD <- read.csv(file = "questionBankD.csv", stringsAsFactors = FALSE)
level1Choices <- c("Select one", "Quantitative", "Qualitative")
level1Choicesp2 <- c("Select one", "Discrete", "Continuous", "Nominal", "Ordinal")
level2Choices <- c("Select one", "Quantitative and Discrete" = "QuanDiscrete",
"Quantitative and Continuous" = "QuanContinuous",
"Qualitative and Nominal" = "QualNominal",
"Qualitative and Ordinal" = "QualOrdinal")
# Define UI ----
ui <- list(
dashboardPage(
skin = "red",
## Header ----
dashboardHeader(
title = "Variable Types & Roles",
titleWidth = 250,
tags$li(class = "dropdown", actionLink("info", icon("info"))),
tags$li(
class = "dropdown",
boastUtils::surveyLink(name = "Variable_Types_Matching_Game")
),
tags$li(
class = "dropdown",
tags$a(
id = "home",
href = "https://shinyapps.science.psu.edu/",
icon("house")
)
)
),
## Sidebar ----
dashboardSidebar(
width = 250,
sidebarMenu(
id = "pages",
menuItem("Overview", tabName = "overview", icon = icon("gauge-high")),
menuItem("Prerequisites", tabName = "prerequisite", icon = icon("book")),
menuItem("Variable Types", tabName = "game", icon = icon("gamepad")),
menuItem("Variable Roles", tabName = "game2", icon = icon("gamepad")),
menuItem("References", tabName = "references", icon = icon("leanpub"))
),
tags$div(
class = "sidebar-logo",
boastUtils::sidebarFooter()
)
),
## Body ----
dashboardBody(
tabItems(
tabItem(
### Overview ----
tabName = "overview",
h1("Variable Types and Roles Matching Game"),
p("Identify variable types by nature of measurement (quantitative
discrete, quantitative continuous, qualitative nominal, and
qualitative ordinal). Then, identify variables
by role in the analysis (explanatory, response, and confounding)."),
h2("Instructions"),
tags$ol(
tags$li("View prerequisites as needed on the 'Prerequisites' tab."),
tags$li("Continue to the 'Variable Types' tab to begin the first challenge,
which focuses on variable types by nature of measurement."),
tags$li("You must get all questions correct on both levels before moving on for this challenge."),
tags$li("Then you can continue to the 'Variable Roles'
tab to test yourself about variables by role in the analysis."),
tags$li("There, you need to get five questions correct to move on for each level."),
tags$li("Be sure to look at your results at the end of each challenge.")
),
div(
style = "text-align: center;",
bsButton(
inputId = "goToGame",
label = "Game",
icon = icon("bolt"),
size = "large"
)
),
br(),
br(),
h2("Acknowledgements"),
p(
"This app was developed and coded by Yuxin Zhang, Luxin Wang, &
Thomas McIntyre. Special thanks to Robert P. Carey III and
Alex Chen for help on some programming issues. We'd also like to
thank Mike Fleck for help with the qualitative and quantitative
variables flow diagram. This app was updated in 2023 by Taryn McHugh
and in June 2024 by Nathan Pechulis.",
br(),
br(),
"Cite this app as:",
br(),
boastUtils::citeApp(),
br(),
br(),
div(class = "updated", "Last Update: 07/22/2024 by NP.")
),
),
### Prerequisites ----
tabItem(
tabName = "prerequisite",
withMathJax(),
h2("Variable Types vs Roles"),
br(),
box(
title = strong("Variable Types: Quantitative vs Qualitative"),
status = "primary",
collapsible = TRUE,
collapsed = FALSE,
width = "100%",
tags$ul(
tags$li("Nominal variables are qualitative (categorical) variables
that do not require a specific order or rank."),
tags$li("Ordinal variables are qualitative variables that require
a specific order or rank."),
tags$li("Discrete variables are quantitative (numerical) variables
where you can make a fixed list of possible values."),
tags$li("Continuous variables are quantitative variables that can take on
an unlimited number of values within a range, they do not need
to be fixed.")
),
br(),
tags$figure(
class = "centerFigure",
tags$img(
src = "variableFlowChart.png",
width = "100%",
alt = "Flow chart with three tiers. The top is variables and it
goes into quantitaive (which can be can be discrete or continuous)
and qualitative (which can be nominal or ordinal) variables."
)
)
),
box(
title = strong("Variable Roles: Explanatory, Response, or Confounding"),
status = "primary",
collapsible = TRUE,
collapsed = FALSE,
width = "100%",
tags$ul(
tags$li("Explanatory/Independent variables are what might explain
changes in the response variable."),
tags$li("Response/Dependent variables are what is the focus of the study."),
tags$li("Confounding variables are variables that influence both the
explanatory variable and the response (thus providing an alternate
explanation for their relationship)")
),
br(),
p("In the figure below you can see that it looks like ice cream sales
impacts the number of shark attacks. This is because the confounding variable
has an impact on both the explanatory and response, making it look
like there is a relationship."),
tags$figure(
class = "centerFigure",
tags$img(
src = "ercChart.png",
width = "75%",
alt = "flow chart that describes explanatory, response, and confounding
variables"
)
)
)
),
### Game 1 ----
tabItem(
tabName = "game",
tabsetPanel(
id = "levels",
type = "hidden",
#### Preliminary Screen 1 ----
tabPanel(
title = "Preliminary Screen 1",
value = "pre1",
titlePanel("Variable Types"),
p("This challenge will deal with Quantitative vs Qualitative variables and their
subcategories. Simply click the 'Begin Game' button below to start the first level. Good luck!"),
br(),
bsButton(
inputId = "startChallenge1",
label = "Begin Game",
size = "large"
)
),
#### Level 1 ----
tabPanel(
title = "Level 1",
value = "b",
titlePanel("Matching Qualitative and Quantitative Variables"),
p("To move onto the next level, you need to match all 12 variables to their
correct variable types. To submit your answers, you must answer all questions.
After submitting, icons will appear to show your results for each question; red means both parts
of your answer are wrong, yellow means it is partially correct (a hint will appear for partial), and
green means it is entirely correct.
If you get any wrong, click 'Retry' to try again."),
hr(),
fluidRow(
column(
width = 4,
wellPanel(
uiOutput("titleQ1"),
selectInput(
inputId = "lvl1Q1",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q1p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A1")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ2"),
selectInput(
inputId = "lvl1Q2",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q2p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A2")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ3"),
selectInput(
inputId = "lvl1Q3",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q3p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A3")
)
)
),
fluidRow(
column(
width = 4,
wellPanel(
uiOutput("titleQ4"),
selectInput(
inputId = "lvl1Q4",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q4p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A4")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ5"),
selectInput(
inputId = "lvl1Q5",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q5p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A5")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ6"),
selectInput(
inputId = "lvl1Q6",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q6p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A6")
)
)
),
fluidRow(
column(
width = 4,
wellPanel(
uiOutput("titleQ7"),
selectInput(
inputId = "lvl1Q7",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q7p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A7")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ8"),
selectInput(
inputId = "lvl1Q8",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q8p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A8")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ9"),
selectInput(
inputId = "lvl1Q9",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q9p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A9")
)
)
),
fluidRow(
column(
width = 4,
wellPanel(
uiOutput("titleQ10"),
selectInput(
inputId = "lvl1Q10",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q10p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A10")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ11"),
selectInput(
inputId = "lvl1Q11",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q11p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A11")
)
),
column(
width = 4,
wellPanel(
uiOutput("titleQ12"),
selectInput(
inputId = "lvl1Q12",
label = "Quantitative or Qualitative",
choices = level1Choices
),
selectInput(
inputId = "lvl1Q12p2",
label = "Choose a category",
choices = level1Choicesp2
),
uiOutput(outputId = "lvl1A12")
)
)
),
br(),
##### Buttons ----
fluidRow(
column(
width = 1,
offset = 5,
conditionalPanel(
"(input.lvl1Q1 != 'Select one') & (input.lvl1Q1p2 != 'Select one') &
(input.lvl1Q2 != 'Select one') & (input.lvl1Q2p2 != 'Select one') &
(input.lvl1Q3 != 'Select one') & (input.lvl1Q3p2 != 'Select one') &
(input.lvl1Q4 != 'Select one') & (input.lvl1Q4p2 != 'Select one') &
(input.lvl1Q5 != 'Select one') & (input.lvl1Q5p2 != 'Select one') &
(input.lvl1Q6 != 'Select one') & (input.lvl1Q6p2 != 'Select one') &
(input.lvl1Q7 != 'Select one') & (input.lvl1Q7p2 != 'Select one') &
(input.lvl1Q8 != 'Select one') & (input.lvl1Q8p2 != 'Select one') &
(input.lvl1Q9 != 'Select one') & (input.lvl1Q9p2 != 'Select one') &
(input.lvl1Q10 != 'Select one') & (input.lvl1Q10p2 != 'Select one') &
(input.lvl1Q11 != 'Select one') & (input.lvl1Q11p2 != 'Select one') &
(input.lvl1Q12 != 'Select one') & (input.lvl1Q12p2 != 'Select one')",
bsButton(
inputId = "retryA",
label = "Retry",
size = "large"
)
)
),
column(
width = 1,
conditionalPanel(
"(input.lvl1Q1 != 'Select one') & (input.lvl1Q1p2 != 'Select one') &
(input.lvl1Q2 != 'Select one') & (input.lvl1Q2p2 != 'Select one') &
(input.lvl1Q3 != 'Select one') & (input.lvl1Q3p2 != 'Select one') &
(input.lvl1Q4 != 'Select one') & (input.lvl1Q4p2 != 'Select one') &
(input.lvl1Q5 != 'Select one') & (input.lvl1Q5p2 != 'Select one') &
(input.lvl1Q6 != 'Select one') & (input.lvl1Q6p2 != 'Select one') &
(input.lvl1Q7 != 'Select one') & (input.lvl1Q7p2 != 'Select one') &
(input.lvl1Q8 != 'Select one') & (input.lvl1Q8p2 != 'Select one') &
(input.lvl1Q9 != 'Select one') & (input.lvl1Q9p2 != 'Select one') &
(input.lvl1Q10 != 'Select one') & (input.lvl1Q10p2 != 'Select one') &
(input.lvl1Q11 != 'Select one') & (input.lvl1Q11p2 != 'Select one') &
(input.lvl1Q12 != 'Select one') & (input.lvl1Q12p2 != 'Select one')",
bsButton(
inputId = "submitA",
label = "Submit",
size = "large"
)
)
),
column(
width = 1,
offset = 3,
bsButton(
inputId = "toLvl2",
label = "Next Level",
size = "large",
icon = icon("forward"),
disabled = TRUE
)
)
),
hr(),
conditionalPanel(
"input.submitA != 0",
p(tags$strong("You must score 30 points to move onto the next level.")),
textOutput("scoreA")
)
),
#### Level 2 ----
tabPanel(
title = "Level 2",
value = "c",
h2("Quantitative and Qualitative Variables in Plots"),
p("Match the variable defined in the instructions of each plot
to the variable type until you get all 4 correct.
To submit, you must answer all questions. If you get one wrong,
click 'Retry' to try again. You can see your results after finishing
by clicking the 'Results' button."),
hr(),
fluidRow(
column(
width = 8,
p(textOutput("imgQ1")),
uiOutput("image1")
),
column(
width = 4,
wellPanel(
selectInput(
inputId = "lvl2Q1",
label = "Graph 1",
choices = level2Choices
),
uiOutput(outputId = "lvl2A1")
)
)
),
br(),
fluidRow(
column(
width = 8,
p(textOutput("imgQ2")),
uiOutput("image2")
),
column(
width = 4,
wellPanel(
selectInput(
inputId = "lvl2Q2",
label = "Graph 2",
choices = level2Choices
),
uiOutput(outputId = "lvl2A2")
)
)
),
br(),
fluidRow(
column(
width = 8,
p(textOutput("imgQ3")),
uiOutput("image3")
),
column(
width = 4,
wellPanel(
selectInput(
inputId = "lvl2Q3",
label = "Graph 3",
choices = level2Choices
),
uiOutput(outputId = "lvl2A3")
)
)
),
br(),
fluidRow(
column(
width = 8,
p(textOutput("imgQ4")),
uiOutput("image4")
),
column(
width = 4,
wellPanel(
selectInput(
inputId = "lvl2Q4",
label = "Graph 4",
choices = level2Choices
),
uiOutput(outputId = "lvl2A4")
)
)
),
br(),
##### Buttons ----
fluidRow(
column(
width = 1,
offset = 1,
bsButton(
inputId = "prevLvl1",
label = "Previous Level",
icon = icon("backward"),
size = "large"
)
),
column(
width = 1,
offset = 3,
conditionalPanel(
"(input.lvl2Q1!='Select one') & (input.lvl2Q1!= null) &
(input.lvl2Q2!='Select one') & (input.lvl2Q2!=null) &
(input.lvl2Q3!='Select one') & (input.lvl2Q3!=null) &
(input.lvl2Q4!='Select one') & (input.lvl2Q4!=null)",
bsButton(
inputId = "retryB",
label = "Retry",
size = "large"
)
)
),
column(
width = 1,
conditionalPanel(
"(input.lvl2Q1!='Select one') & (input.lvl2Q1!= null) &
(input.lvl2Q2!='Select one') & (input.lvl2Q2!=null) &
(input.lvl2Q3!='Select one') & (input.lvl2Q3!=null) &
(input.lvl2Q4!='Select one') & (input.lvl2Q4!=null)",
bsButton(
inputId = "submitB",
label = "Submit",
size = "large"
)
)
),
column(
width = 1,
offset = 3,
bsButton(
inputId = "toBtwnLvls",
label = "Results",
disabled = TRUE,
size = "large"
)
)
),
hr(),
conditionalPanel(
"input.submitB != 0",
p(tags$strong("You must score 20 points to move onto the next level.")),
textOutput("scoreB")
)
),
#### Page In Between Concepts ----
tabPanel(
title = "Concept Seperator",
value = "d",
titlePanel("Congrats on completing levels 1 and 2!"),
p("Levels 1 and 2 were all about qualitative and quantitative variables.
There are two more levels in the next challenge that go over explanatory,
response, and confounding variables. If you feel ready,
navigate to the 'Variable Roles' tab to continue. If not, you can
refresh the page to restart the first challenge and continue practicing."),
br(),
h3("Results"),
tags$ul(
tags$li(textOutput("level1ScoreResults1")),
tags$li(textOutput("level2ScoreResults1"))
)
)
)
),
### Game 2 ----
tabItem(
tabName = "game2",
tabsetPanel(
id = "levels2",
type = "hidden",
#### Preliminary Screen 2----
tabPanel(
title = "Preliminary Screen 2",
value = "pre2",
titlePanel("Variable Roles"),
p("This challenge will deal with Explanatory, Response, and Confounding variables.
Simply click 'Begin Game' to start level 3. Good luck!"),
br(),
bsButton(
inputId = "startChallenge2",
label = "Begin Game",
size = "large"
)
),
#### Level 3 ----
tabPanel(
title = "Level 3",
value = "e",
titlePanel("Explanatory and Response Variables"),
p("Correctly match each variable to it's role depending on
the context given. Once you have made your choices hit 'Submit', then
click 'New Question' for the next question. You must get both answers correct to earn 1 point and get 5 points
before moving to the next level. You have 16 attempts, if all 16 attempts are
used, follow directions and retry the level."),
hr(),
uiOutput("questionC", class = "largerFont"),
hr(),
fluidRow(
column(
width = 3,
offset = 1,
selectInput(
inputId = "explC",
label = uiOutput("varEXP"),
choices = c("", "Neither", "Explanatory", "Response")
),
uiOutput("markc1")
),
column(
width = 3,
offset = 3,
selectInput(
inputId = "respC",
label = uiOutput("varRES"),
choices = c("", "Neither", "Explanatory", "Response")
),
uiOutput("markc2")
)
),
br(),
textOutput("NumTries"),
br(),
##### Buttons ----
fluidRow(
column(
width = 1,
offset = 1,
bsButton(
inputId = "restartlvl3",
label = "Restart Level",
size = "large",
disabled = TRUE
)
),
column(
width = 1,
offset = 3,
conditionalPanel(
"(input.explC!='') & (input.respC!='')",
bsButton(
inputId = "submitC",
label = "Submit",
size = "large"
)
)
),
column(
width = 1,
bsButton(
inputId = "newQLvl3",
label = "New Question",
size = "large",
disabled = TRUE
)
),
column(
width = 1,
offset = 3,
bsButton(
inputId = "toLvl4",
label = "Next Level",
icon = icon("forward"),
size = "large",
disabled = TRUE
)
)
),
hr(),
progressBar(
id = "barLevel3",
value = 0,
display_pct = TRUE,
status = "primary"
),
),
#### Level 4 ----
tabPanel(
title = "Level 4",
value = "f",
titlePanel("Explanatory, Response, and Confounding Variables"),
p("Correctly match each variable to the variable role
depending on the context given. Once you have made your choices hit 'Submit', then
click 'New Question' for the next question. You must get all three answers
correct to earn 1 point and get 5 points before moving to the
next level. You have 7 attempts, if all 7 attempts are used, follow directions and
retry the level. When finished, you can click the 'Results' button to see your results."),
hr(),
uiOutput("questionD", class = "largerFont"),
fluidRow(
column(
width = 4,
offset = 1,
selectInput(
inputId = "resp",
label = uiOutput("varRESD"),
choices = c( "", "Explanatory", "Response", "Confounding",
"None of the above")
),
uiOutput("markd2")
),
column(
width = 4,
offset = 1,
selectInput(
inputId = "conf",
label = uiOutput("varCOND"),
choices = c("", "Explanatory", "Response", "Confounding",
"None of the above")
),
uiOutput("markd3")
)
),
fluidRow(
column(
width = 4,
offset = 1,
selectInput(
inputId = "expla",
label = uiOutput("varEXPD"),
choices = c("", "Explanatory", "Response", "Confounding",
"None of the above")
),
uiOutput("markd1")
)
),
br(),
textOutput("NumTriesLvl4"),
br(),
##### Buttons ----
conditionalPanel(
"input.toLvl4 != 0",
fluidRow(
column(
width = 1,
offset = 1,
bsButton(
inputId = "prevLvl3",
label = "Previous Level",
icon = icon("backward"),
size = "large"
)
),
column(
width = 1,
offset = 3,
conditionalPanel(
"(input.expla!='') & (input.resp!='') & (input.conf!='')",
bsButton(
inputId = "submitD",
label = "Submit",
size = "large"
)
)
),
column(
width = 1,
bsButton(
inputId = "newQLvl4",
label = "New Question",
size = "large",
disabled = TRUE
)
),
column(
width = 1,
offset = 3,
bsButton(
inputId = "finish",
label = "Results",
size = "large",
disabled = TRUE
)
)
),
hr()
),
progressBar(
id = "barLevel4",
value = 0,
display_pct = TRUE,
status = "primary"
)
),
#### Results ----
tabPanel(
title = "Results",
value = "g",
titlePanel("Congratulations! You finished the second challenge."),
br(),
h3("Results"),
tags$ul(
tags$li(textOutput("level3Score")),
tags$li(textOutput("level4Score"))
)
)
)
),
tabItem(
### References ----
tabName = "references",
h2("References"),
p(
class = "hangingindent",
"Attali, D. (2021). shinyjs: Easily Improve the User Experience of Your
Shiny Apps in Seconds. (v2.1). [R Package]. Avaliable from
https://cran.r-project.org/package=shinyjs"
),
p(
class = "hangingindent",
"Attali, D (2021). shintalert: Easily create pretty popup messages (modals),
in Shiny. (v3.0). [R Package]. Avaliable from
https://cran.r-project.org/web/packages/shinyalert/index.html"
),
p(
class = "hangingindent",
"Bailey, E. (2015). shinyBS: Twitter bootstrap components for shiny.
(v0.61). [R package]. Available from
https://CRAN.R-project.org/package=shinyBS"
),
p(
class = "hangingindent",
"Carey, R. and Hatfield, N.J. (2023). boastUtils: BOAST utilities.
(v0.1.11.2). [R Package]. Avaliable from
https://github.com/EducationShinyappTeam/boastUtils"
),
p(
class = "hangingindent",
"Chang, W. and Borges Ribeio (2021). shinydashboard: Create dashboards
with 'Shiny.' (v0.7.2). Avaliable from
https://CRAN.R-project.org/package=shinydashboard"
),
p(
class = "hangingindent",
"Chang W, Cheng J, Allaire J, Sievert C, Schloerke B, Xie Y, Allen J,
McPherson J, Dipert A, Borges B (2023). shiny: Web Application Framework
for R. R package version 1.7.4.9002. Avaliable from
https://CRAN.R-project.org/package=shiny"
),
p(
class = "hangingindent",
"Perrier, V., Meyer, F., Granjon, D. (2023) shinyWidgets: Custom Input
Widgets for Shiny. (v0.7.6). Avaliable from
https://cran.r-project.org/web/packages/shinyWidgets/index.html"
),
p(
class = "hangingindent",
"Wickham, H., François, R., Henry, L., Müller, K., and Vaughan, D.
(2023). dplyr: A grammar of data manipulation. (v1.1.2). [R Package].
Available from https://CRAN.R-project.org/package=dplyr"
),
br(),
br(),
br(),
boastUtils::copyrightInfo()
)
)
)
)
)
# Define Server ----
server <- function(input, output, session) {
## Buttons ----
observeEvent(
eventExpr = input$goToGame,
handlerExpr = {
updateTabItems(
session = session,
inputId = "pages",
selected = "game"
)
}
)
observeEvent(
eventExpr = input$info,
handlerExpr = {
sendSweetAlert(
session = session,
type = "info",
title = "Information",
text = "Go through each challenge to demonstrate your proficiency in distinguishing
between different variable types and roles."
)
}
)
observeEvent(
eventExpr = input$startChallenge1,
handlerExpr = {
updateTabsetPanel(
session = session,
inputId = "levels",
selected = 'b'
)
}
)
observeEvent(
eventExpr = input$prevLvl1,
handlerExpr = {
updateTabsetPanel(
session = session,
inputId = "levels",
selected = 'b'
)
}
)
observeEvent(
eventExpr = input$toLvl2,
handlerExpr = {