-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
835 lines (717 loc) · 22.9 KB
/
server.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
library(shiny)
library(rhandsontable)
library(ggplot2)
library(dplyr)
library(tidyverse)
library(stringr)
library(shinythemes)
###### SERVER FUNCTIONS ######
server <- function(input, output, session) {
#### Data ####
## Extract the CSV
FileData <- reactive({
infile <- input$file1
if (FileReady() == F) {
return(NULL)
}
read.csv(infile$datapath,
header = TRUE,
sep = ",",
quote = '"',
stringsAsFactors = FALSE
)
})
## Show Uploaded Data
output$contents <- renderTable({
df <- FileData()
if (input$disp == "head") {
return(head(df))
}
else {
return(df)
}
})
###### PREPPING THE FILES ######
##### IHT #####
#### IHT PREP ELEMENTARY LEVEL ####
ElementaryIHT <- reactive({
FileData() %>%
as_tibble() %>%
## Remove duplicates
distinct(student_studentNumber, .keep_all = T) %>%
filter(student_grade <=6) %>%
# fix the kindergarten output from campus to match what IHT needs
mutate(student_grade = replace(student_grade, student_grade == "KF", "K")) %>%
# replace commas in classroom teacher display name to make splitting easier
mutate(courseSection_teacherDisplay = str_replace_all(courseSection_teacherDisplay, ",", "-")) %>%
# split the classroom teacher from the PE teacher
separate(courseSection_teacherDisplay, into = c("peTeach", "elemteach"), sep = "-", extra = "drop") %>%
# filter out the teacher
filter(peTeach == input$teacherDropdown) %>%
# Select and rename variables
select(c(
"grade level" = student_grade,
"section" = student_homeroomTeacher,
"student id" = student_studentNumber,
"last name*" = student_lastName,
"first name" = student_firstName,
"secondary email" = contacts_email,
"gender*" = student_gender,
"birthdate" = student_birthdate
)) %>%
# add the blank columns
add_column("email" = NA, .before = "secondary email") %>%
add_column(height = NA, weight = NA, .before = "birthdate") %>%
add_column(rhr = NA, max = NA, .after = "birthdate") -> ihtELM
return(ihtELM)
})
#### IHT PREP JR. HIGH SCHOOL LEVEL ####
JrHighSchoolIHT <- reactive({
FileData() %>%
as_tibble() %>%
## Remove duplicates
distinct(student_studentNumber, .keep_all = T) %>%
filter(student_grade >=7 , student_grade <9)%>%
mutate(sectionName = paste0("Period", sectionSchedule_periodStart))%>%
mutate(schoolYear = paste0(student_startYear, "-", cal_endYear))%>%
unite("IHTClassName", sectionName, schoolYear) %>%
# Select and rename variables
select(c(
"grade level" = student_grade,
"section" = IHTClassName,
"student id" = student_studentNumber,
"last name*" = student_lastName,
"first name" = student_firstName,
"secondary email" = contacts_email,
"gender*" = student_gender,
"birthdate" = student_birthdate
)) %>%
# add the blank columns
add_column("email" = NA, .before = "secondary email") %>%
add_column(height = NA, weight = NA, .before = "birthdate") %>%
add_column(rhr = NA, max = NA, .after = "birthdate") -> ihtJH
return(ihtJH)
})
#### IHT PREP HIGH SCHOOL LEVEL ####
HighSchoolIHT <- reactive({
FileData() %>%
as_tibble() %>%
## Remove duplicates
distinct(student_studentNumber, .keep_all = T) %>%
filter(student_grade >= 9) %>%
mutate(className = paste0("Period ", sectionSchedule_periodStart,
" Day ", sectionSchedule_scheduleStart, " ",
input$fallOrSpring, " ",
ifelse(input$fallOrSpring == "Fall", student_startYear, cal_endYear)
)
)%>%
# filter out the teacher
filter(str_detect(className, pattern = input$periodDropdown)) %>%
# Select and rename variables
select(c(
"grade level" = student_grade,
"section" = className,
"student id" = student_studentNumber,
"last name*" = student_lastName,
"first name" = student_firstName,
"secondary email" = contacts_email,
"gender*" = student_gender,
"birthdate" = student_birthdate
)) %>%
# add the blank columns
add_column("email" = NA, .before = "secondary email") %>%
add_column(height = NA, weight = NA, .before = "birthdate") %>%
add_column(rhr = NA, max = NA, .after = "birthdate") -> ihtHS
return(ihtHS)
})
#### IHT PREPPED ####
preppedIHT <- reactive({
if (input$SchoolDropdown == "Elementary") {
return(ElementaryIHT())
}
else if (input$SchoolDropdown == "Junior High") {
return(JrHighSchoolIHT())
}
else if (input$SchoolDropdown == "High School") {
return(HighSchoolIHT())
}
else {
return(NULL)
}
})
##### HMH #####
#### HMH Class file ####
HMHClass <- reactive({
FileData() %>%
distinct(courseSection_courseID, courseSection_sectionNumber, .keep_all = T) %>%
mutate(courseSection_courseName, COURSESUBJECT = ifelse(courseSection_courseName == "American Government", "Government", "History")) %>%
mutate(courseSection_courseName, GRADE = ifelse(courseSection_courseName == "American Government", "11", "9")) %>%
mutate("CLASSLOCALID" = paste(cal_endYear, courseSection_courseNumber, courseSection_sectionNumber, sep = "_")) %>%
mutate("CLASSNAME" = paste(cal_endYear, courseSection_courseName, "Sec", courseSection_sectionNumber, sep = " ")) %>%
add_column("TERMID" = NA, "ORGANIZATIONID" = 250932, "CLASSDESCRIPTION" = NA, "ORGANIZATIONTYPEID" = NA, HMHAPPLICATIONS = "ED") %>%
select(c(
"SCHOOLYEAR" = cal_endYear,
CLASSLOCALID,
"COURSEID" = courseSection_courseID,
"COURSENAME" = courseSection_courseName,
COURSESUBJECT,
CLASSNAME,
CLASSDESCRIPTION,
"CLASSPERIOD" = sectionSchedule_periodStart,
ORGANIZATIONTYPEID,
ORGANIZATIONID,
GRADE,
TERMID,
HMHAPPLICATIONS
)) -> CLASS
return(CLASS)
})
#### HMH Users file ####
HMHUsers <- reactive({
FileData() %>%
distinct(student_studentNumber, .keep_all = T) %>%
mutate(student_studentNumber, "ROLE" = ifelse(student_studentNumber >= 500000, "T", "S")) %>%
mutate("USERNAME" = pcontact_email) %>%
add_column("MIDDLENAME" = NA, "ORGANIZATIONTYPEID" = "MDR", "ORGANIZATIONID" = 250932, "PRIMARYEMAIL" = NA, HMHAPPLICATIONS = "ED") %>%
mutate("LASID" = student_studentNumber) %>%
select(
"SCHOOLYEAR" = cal_endYear,
ROLE,
LASID,
"SASID" = student_stateID,
"FIRSTNAME" = student_firstName,
MIDDLENAME,
"LASTNAME" = student_lastName,
"GRADE" = student_grade,
USERNAME,
"PASSWORD" = student_studentNumber,
ORGANIZATIONTYPEID,
ORGANIZATIONID,
PRIMARYEMAIL,
HMHAPPLICATIONS
) -> USERS
return(USERS)
})
#### HMH Class Assignments file ####
HMHClassAssignments <- reactive({
FileData() %>%
mutate("CLASSLOCALID" = paste(cal_endYear, courseSection_courseNumber, courseSection_sectionNumber, sep = "_")) %>%
mutate("ROLE" = ifelse(student_studentNumber >= 500000, "T", "S")) %>%
mutate("POSITION" = ifelse(student_studentNumber >= 500000, "L", NA)) %>%
select(
"SCHOOLYEAR" = cal_endYear,
CLASSLOCALID,
"LASID"=student_studentNumber,
ROLE,
POSITION
) -> CLASSASSIGNMENTS
return(CLASSASSIGNMENTS)
})
#### HMH Prepped ####
preppedHMH <- reactive({
if (input$hmhFileDropdown == "Class") {
return(HMHClass())
}
else if (input$hmhFileDropdown == "Users") {
return(HMHUsers())
}
else if (input$hmhFileDropdown == "Class Assignments") {
return(HMHClassAssignments())
}
else {
return(NULL)
}
})
##### Waterford #####
#### Waterford Prepped File ####
WaterfordPrep <- reactive({
df <- FileData()
df %>%
distinct(student_studentNumber, .keep_all = T) %>%
mutate(student_grade = replace(student_grade, student_grade == "KF", "K")) %>%
mutate(student_grade = replace(student_grade, student_grade == "01", "1st Grade")) %>%
mutate(student_grade = replace(student_grade, student_grade == "02", "2nd Grade")) %>%
mutate("firstName" = gsub(" ", "", str_remove_all(student_firstName, "[~!@#$%^&*(){}_+:<>?,./;'-]"))) %>%
mutate("middleName" = gsub(" ", "", str_remove_all(student_middleName, "[~!@#$%^&*(){}_+:<>?,./;'-]"))) %>%
mutate("lastName" = gsub(" ", "", str_remove_all(student_lastName, "[~!@#$%^&*(){}_+:<>?,./;'-]"))) %>%
mutate("preferredName" = gsub(" ", "", str_remove_all(coalesce(student_alias, firstName), "[~!@#$%^&*(){}_+:<>?,./;'-]"))) %>%
mutate("classGrade" = student_grade) %>%
mutate("schoolName" = substr(student_calendarName, 6, 100000)) %>%
add_column(
"sisName" = NA,
"sisID" = NA,
"schoolSISName" = NA,
"schoolSISID" = NA,
"pLanguage" = NA,
"Ethnicity" = NA,
"Disabilities" = NA,
"hStatus" = NA,
"sp" = NA,
"Email" = NA,
"Username" = NA,
"Password" = NA
) %>%
select(
"First Name" = firstName,
"Middle Name" = middleName,
"Last Name" = lastName,
# "Prefered Name"=preferredName,
"Unique Student ID" = student_studentNumber,
"Grade" = student_grade,
"Class Name" = student_homeroomTeacher,
"Class Grade" = classGrade,
"Class SIS NAME" = sisName,
"Class SIS ID" = sisID,
"School Name" = schoolName,
"School SIS NAME" = schoolSISName,
"School SIS ID" = schoolSISID,
"Gender" = student_gender,
"Birthday" = student_birthdate,
"Primary Language" = pLanguage,
Ethnicity,
Disabilities,
"Household Status" = hStatus,
"Special Programs" = sp,
Email,
Username,
Password
) -> waterford
return(waterford)
})
##### PLTW #####
#### PLTW Elementary Classes ####
ElementaryPLTW <- reactive({
elemPLTW <- FileData()
elemPLTW$schoolName <- substr(elemPLTW$student_calendarName, 7, length(elemPLTW$student_calendarName))
start_date <- input$startDate
end_date <- input$endDate
elemPLTW %>%
mutate(
courseCode = case_when(
student_grade == "KF" ~ "ELE_K",
student_grade == "1" ~ "ELE_1",
student_grade == "2" ~ "ELE_2",
student_grade == "3" ~ "ELE_3",
student_grade == "4" ~ "ELE_4",
student_grade == "5" ~ "ELE_5",
TRUE ~ "Error"
),
startDate = format(as.Date(start_date), "%m/%d/%Y"),
endDate = format(as.Date(end_date), "%m/%d/%Y")) %>%
filter(courseCode != "Error") %>%
filter(schoolName == input$schoolNamePLTW) %>%
select(
"TEACHER EMAIL" = courseSection_TeacherEmail,
"COURSE CODE" = courseCode,
"COURSE BEGIN DATE" = startDate,
"COURSE END DATE" = endDate,
"STUDENT FIRST" = student_firstName,
"STUDENT LAST" = student_lastName,
"STUDENT GRADE" = student_grade,
"STUDENT STATE ID NUMBER" = student_stateID,
"GENDER" = student_gender,
"DOB" = student_birthdate
) -> result
return(result)
})
#### PLTW High School Classes ####
HighSchoolPLTW <- reactive({
hsPLTW <- FileData()
start_date <- input$startDate
end_date <- input$endDate
hsPLTW %>%
#left_join(TeacherEmails)%>%6662045
mutate(courseCode= case_when(
courseSection_courseNumber == "171501" ~ "PBS",
courseSection_courseNumber == "162607" ~ "CSP",
courseSection_courseNumber == "162601" ~ "IED",
courseSection_courseNumber == "162603" ~ "POE",
TRUE ~ "Error"
),
startDate = format(as.Date(start_date), "%m/%d/%Y"),
endDate = format(as.Date(end_date), "%m/%d/%Y")) %>%
filter(courseCode != "Error")%>%
select("TEACHER EMAIL" = courseSection_TeacherEmail,
"COURSE CODE"= courseCode,
"COURSE BEGIN DATE"= startDate,
"COURSE END DATE"= endDate,
"STUDENT FIRST" = student_firstName,
"STUDENT LAST" = student_lastName,
"STUDENT GRADE" = student_grade,
"STUDENT STATE ID NUMBER" = student_stateID,
"GENDER"= student_gender,
"DOB" = student_birthdate
)->result
return(result)
})
preppedPLTW <- reactive({
if(input$rosterTypePLTW == "Elementary"){
ElementaryPLTW()
}
else{
HighSchoolPLTW()
}
})
###### Table Outputs ######
## Preped data for IHT
output$displayIHT <- renderTable({
return(preppedIHT())
})
## Prepped data for HMH
output$displayHMH <- renderTable({
return(preppedHMH())
})
## Prepped Data for Waterford
output$displayWaterford <- renderTable({
return(WaterfordPrep())
})
## Prepped Data for Waterford
output$displayPLTW <- renderTable({
return(preppedPLTW())
})
#### EXPORT DATA ####
## HMH
output$downloadDataHMH <- downloadHandler(
filename = function() {
paste(input$hmhFileDropdown, ".csv", sep = "")
},
content = function(file) {
if (input$hmhFileDropdown == "Class") {
write.csv(HMHClass(), file, row.names = FALSE, na = "")
}
else if (input$hmhFileDropdown == "Users") {
write.csv(HMHUsers(), file, row.names = FALSE, na = "")
}
else if (input$hmhFileDropdown == "Class Assignments") {
write.csv(HMHClassAssignments(), file, row.names = FALSE, na = "")
}
else {}
}
)
## IHT
output$downloadDataIHT <- downloadHandler(
filename = function() {
paste("IHT", ".csv", sep = "")
},
content = function(file) {
write.csv(preppedIHT(), file, row.names = FALSE, na = "")
}
)
## PLTW
output$downloadDataPLTW <- downloadHandler(
filename = function() {
paste(input$rosterType, ".csv", sep = "")
},
content = function(file) {
write.csv(preppedPLTW(), file, row.names = FALSE, na = "")
}
)
## Waterford
output$downloadDataWaterford <- downloadHandler(
filename = function() {
paste("waterford", ".csv", sep = "")
},
content = function(file) {
write.csv(WaterfordPrep(), file, row.names = FALSE, na = "")
}
)
#### UI ####
## select the level of institution for IHT
output$schoolSelectIHT <- renderUI({
items <- c("Elementary", "Junior High", "High School")
selectInput("SchoolDropdown", "School", items)
})
## select the teacher for elementary teachers in IHT
output$teacherSelect <- renderUI({
## This gets the list of teachers
df <- FileData() %>%
as_tibble() %>%
distinct(student_studentNumber, .keep_all = T) %>%
mutate(student_grade = replace(student_grade, student_grade == "KF", "K")) %>%
mutate(courseSection_teacherDisplay = str_replace_all(courseSection_teacherDisplay, ",", "-")) %>%
separate(courseSection_teacherDisplay, into = c("peTeach", "elemteach"), sep = "-", extra = "drop")
if (is.null(df)) {
return(NULL)
}
if (input$SchoolDropdown != "Elementary") {
return(NULL)
}
items <- unique(df$peTeach)
selectInput("teacherDropdown", "Select the teacher", items)
})
## Period select for high School IHT
output$periodSelect <- renderUI({
## This gets the list of periods
df <- FileData() %>%
as_tibble() %>%
distinct(student_studentNumber, .keep_all = T) %>%
mutate(student_grade = replace(student_grade, student_grade == "KF", "K")) %>%
mutate(courseSection_teacherDisplay = str_replace_all(courseSection_teacherDisplay, ",", "-")) %>%
separate(function_IHTClassName, into = c("peTeach", "elemteach"), sep = 9, extra = "drop")
if (is.null(df)) {
return(NULL)
}
if (input$SchoolDropdown != "High School") {
return(NULL)
}
items <- unique(df$peTeach)
items <- items[order(nchar(items), items)]
selectInput("periodDropdown", "Select the period", items)
})
##### Add the tabs that are ready to go #####
observeEvent(input$append, {
id <- paste0("Dropdown", input$append, "a")
## HMH TAB
if (ReadyHMH() == T) {
appendTab(
inputId = "tabs",
tabPanel(
"HMH",
titlePanel("HMH Rosters"),
fluidRow(
column(width = 3, uiOutput("hmhFileOptions")),
column(width = 9, downloadButton("downloadDataHMH", "Download"))
),
## this shows the uploaded data set
mainPanel(
tableOutput("displayHMH")
)
)
)
}
## IHT TAB
if (ReadyIHT() == T) {
appendTab(
inputId = "tabs",
tabPanel(
"IHT",
# condition = "output.readyPLTW == true",
titlePanel("IHT Rosters"),
sidebarLayout(
sidebarPanel(
uiOutput("schoolSelectIHT"),
uiOutput("teacherSelect"),
uiOutput("periodSelect"),
radioButtons("fallOrSpring", label="Fall or Spring?", choices = c("Fall", "Spring"), inline = T),
downloadButton("downloadDataIHT", "Download")
),
## this shows the uploaded data set
mainPanel(
tableOutput("displayIHT")
)
)
)
)
}
## PLTW TAB
if (readyPLTW2() == T) {
appendTab(
inputId = "tabs",
tabPanel(
"PLTW",
titlePanel("PLTW Rosters"),
sidebarLayout(
sidebarPanel(
selectInput("rosterTypePLTW", "Select School Level", choices= c("Elementary","Secondary" )),
uiOutput("schoolSelectElemPLTW"),
dateInput("startDate", "Class Start Date", value=lubridate::today(), format = "mm/dd/yyyy"),
dateInput("endDate", "Class End Date", value=lubridate::today(), format = "mm/dd/yyyy"),
downloadButton("downloadDataPLTW", "Download")
),
## this shows the uploaded data set
mainPanel(
tableOutput("displayPLTW")
)
)
)
)
}
## Waterford Tab
if (ReadyWaterford() == T) {
appendTab(
inputId = "tabs",
tabPanel(
"Waterford",
titlePanel("Waterford Roster"),
fluidRow(downloadButton("downloadDataWaterford", "Download")),
## this shows the uploaded data set
mainPanel(
tableOutput("displayWaterford")
)
)
)
}
shinyjs::hide("append")
})
## File options for HMH
output$hmhFileOptions <- renderUI({
items <- c("CLASS"="Class","USERS"="Users", "CLASSASSIGNMENTS"="Class Assignments")
selectInput("hmhFileDropdown", "Select Output File", items)
})
## select the level of institution for PLTW
output$schoolSelectElemPLTW <- renderUI({
if (FileReady() == F) {
return(NULL)
}
if (readyPLTW2() == F) {
return(NULL)
}
if (input$rosterTypePLTW == "Elementary") {
elemPLTW <- FileData()
elemPLTW$schoolName <- substr(elemPLTW$student_calendarName, 7, length(elemPLTW$student_calendarName))
items <- unique(elemPLTW$schoolName)
selectInput("schoolNamePLTW", "School", items)
}
else {
return(NULL)
}
})
## does the file have all field for PLTW
output$readyPLTW <- reactive({
if (FileReady() == F) {
return(FALSE)
}
check <- c(
"student_grade", #
"courseSection_TeacherEmail", #
"student_calendarName", #
"student_firstName", #
"student_lastName", #
"student_grade", #
"student_stateID", #
"student_gender", #
"student_birthdate"
)
test <- check %in% names(FileData())
if (all(test) == T) {
return(TRUE)
}
else {
return(FALSE)
}
})
## does the file have all field for PLTW
readyPLTW2 <- reactive({
if (FileReady() == F) {
return(NULL)
}
check <- c(
"student_grade", #
"courseSection_TeacherEmail", #
"student_calendarName", #
"student_firstName", #
"student_lastName", #
"student_grade", #
"student_stateID", #
"student_gender", #
"student_birthdate"
)
test <- check %in% names(FileData())
if (all(test) == T) {
return(TRUE)
}
else {
message("PLTW not ready to go")
return(FALSE)
}
})
## does the file have all field for IHT
ReadyIHT <- reactive({
if (FileReady() == F) {
return(NULL)
}
check <- c(
"cal_endYear",
"student_startYear",
"student_grade", #
"student_homeroomTeacher", #
"student_studentNumber", #
"student_lastName", #
"student_firstName", #
"student_gender", #
"student_birthdate", #
"student_calendarName", #
"courseSection_teacherDisplay", #
"roster_endDate",
"sectionSchedule_periodStart", #
"sectionSchedule_scheduleStart", #
"contacts_email"
)
test <- check %in% names(FileData())
if (all(test) == TRUE) {
return(TRUE)
}
else {
message("IHT not ready to go")
return(FALSE)
}
})
## does the file have all field for HMH
ReadyHMH <- reactive({
if (FileReady() == F) {
return(NULL)
}
check <- c(
"student_firstName",
"student_lastName",
"student_grade",
"student_stateID",
"courseSection_courseID",
"student_endDate",
"courseSection_courseNumber",
"roster_endDate",
"courseSection_teacherDisplay",
"student_studentNumber",
"courseSection_sectionNumber",
"courseSection_courseName",
"sectionSchedule_periodStart",
"cal_endYear",
"pcontact_email"
)
test <- check %in% names(FileData())
if (all(test) == T) {
return(TRUE)
}
else {
message("HMH not ready to go")
return(FALSE)
}
})
## does the file have all field for Waterford
ReadyWaterford <- reactive({
if (FileReady() == F) {
return(NULL)
}
check <- c(
"student_firstName",
"student_middleName",
"student_lastName",
"student_alias",
"student_studentNumber",
"student_grade",
"student_gender",
"student_birthdate",
"student_calendarName",
"student_homeroomTeacher"
)
test <- check %in% names(FileData())
if (all(test) == T) {
return(TRUE)
}
else {
message("Waterford Not Ready To Go")
return(FALSE)
}
})
#### ERROR CHECKING ####
## is there a file ready and waiting?
FileReady <- reactive({
infile <- input$file1
if (is.null(infile)) {
# User has not uploaded a file yet
return(FALSE)
}
return(TRUE)
})
outputOptions(output, "readyPLTW", suspendWhenHidden = FALSE)
}