Skip to content

Commit 8fa2ca9

Browse files
committed
Updated challenge Shiny application
1 parent bc91941 commit 8fa2ca9

File tree

12 files changed

+21
-6
lines changed

12 files changed

+21
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: BioDataScience3
2-
Version: 2021.0.0
2+
Version: 2021.0.1
33
Title: A Series of Learnr Documents for Biological Data Science 3
44
Description: Interactive documents using learnr for studying biological data science (second course).
55
Authors@R: c(

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# BioDataScience3 News
22

3+
## Change in version 2021.0.1
4+
5+
- Updated wine challenge (C03Sa_challenge -> C03Ca_ml_wine).
6+
37
## Change in version 2021.0.0
48

59
- Start of 2021 series.
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# cd /data1
55
# sudo mkdir C03_challenge
66
# sudo chown rstudio-connect: C03_challenge
7-
# Then, put wine2quality.rds (from sdd_preparation ) into that directory
7+
# Then, put wine2quality.rds (from sdd_preparation) into that directory
88
# scp wine2quality.rds econum@sdd.umons.ac.be:.
99
# sudo mv /home/econum/wine2quality.rds /data1/C03_challenge
1010
# sudo chown rstudio-connect:/data1/C03_challenge/wine2quality.rds
@@ -19,7 +19,9 @@ library(flipdownr)
1919

2020
# Indicate title and deadline here
2121
title <- "Challenge vins"
22-
deadline <- "2020-11-16 20:00:00"
22+
# Note: define real deadline in environment variables in RStudio Connect
23+
deadline <- Sys.getenv("CHALLENGE_DEADLINE",
24+
unset = "2020-01-01 00:00:00")
2325

2426
# Read data from the SQLite database
2527
dir <- "/data1/C03_challenge"
@@ -33,6 +35,11 @@ wine2quality <- read$rds(file.path(dir, "wine2quality.rds"))$value
3335
is_done <- function()
3436
as.POSIXct(deadline) < Sys.time()
3537

38+
# If the time difference between current date and countdown
39+
# is more than 100 days, we consider the next challenge has not started yet
40+
not_started_yet <- function()
41+
difftime(Sys.time(), as.POSIXct(deadline), units = "days") > 100
42+
3643
# The function that calculates score and returns also a message
3744
score_model <- function(x, reference = wine2quality) {
3845
if (!is.factor(x))
@@ -60,7 +67,7 @@ score_model <- function(x, reference = wine2quality) {
6067
round(prec * 100, 1), "%. Votre proposition n'est pas retenue !")))
6168
# Le classement du modèle se fait sur base du rappel pour la classe "excellent"
6269
recall <- res["excellent", "Recall"]
63-
score <- recall * 100 # In percents
70+
score <- recall * 100 # In percents
6471
structure(score,
6572
message = paste0("Votre proposition est accept\u00e9e. Son score est de ",
6673
round(score, 3), "."))
@@ -84,7 +91,7 @@ save_data <- function(data) {
8491
paste(data, collapse = "', '")
8592
)
8693
# Submit the update query and disconnect
87-
dbGetQuery(db, query)
94+
dbSendStatement(db, query)
8895
dbDisconnect(db)
8996
}
9097

@@ -132,7 +139,11 @@ server <- function(input, output) {
132139
validate(need(ext == "rds", "Vous devez indiquer un fichier RDS"))
133140
# Check that there is still time remaining
134141
if (is_done()) {
135-
"Ce challenge est fini, vous ne pouvez plus soumettre de proposition !"
142+
if (not_started_yet()) {
143+
"Ce challenge n'a pas encore commenc\u00e9, attendez le d\u00e9part !"
144+
} else {
145+
"Ce challenge est fini, vous ne pouvez plus soumettre de proposition !"
146+
}
136147
} else {
137148
# Check that filename is correct (repos__model.rds)
138149
if (!grepl("^.+__.+\\.rds", file$name)) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)