diff --git a/.Rbuildignore b/.Rbuildignore index 90b5bb3..1496b00 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,6 +2,8 @@ ^renv\.lock$ ^_pkgdown\.yml$ ^docs$ +^venv$ +^legacy$ ^pkgdown$ ^\.github$ ^.*\.Rproj$ diff --git a/.gitignore b/.gitignore index ce3638b..05c2f8e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,8 @@ renv/ renv.lock # Shiny deployment -rsconnect/ \ No newline at end of file +rsconnect/ + +venv/ + +legacy/ \ No newline at end of file diff --git a/README.md b/README.md index 488dcae..79af800 100644 --- a/README.md +++ b/README.md @@ -54,16 +54,48 @@ The quizzes now include automatic submission to Google Forms for tracking studen - **Automatic submission**: Results are submitted to Google Form via POST request - **Modular components**: Reusable username and submission components -### Google Form Setup +### Configuring Google Form Integration + +To connect quizzes to your own Google Form, update the configuration in `modules/_submission.Rmd`. + +#### 0. Google Form Structure + +Your Google Form should have exactly 3 questions: +1. **Tutorial/Module ID** (text field) +2. **GitHub username** (text field) +3. **Learnrhash** (long text field for quiz results) + +#### 1. Find Entry IDs + +To get the entry IDs for your form fields: + +1. **Open your Google Form** (the live form, not edit mode) +2. **Open browser inspector** (F12 or right-click → Inspect) +3. **Search for "entry"** in the HTML (Ctrl+F) +4. **Copy the entry IDs** - they appear as `entry.1234567890` + +The entry IDs will be in the order your questions are set up in the form. + +#### 2. Update form_url and Entry IDs + +Update the variables at the top of `modules/_submission.Rmd`: + +```r +# Google Form setup +form_url <- "https://docs.google.com/forms/d/e/YOUR-FORM-ID/formResponse" + +# Entry ID mappings +tutorial_id_entry_id <- "entry.YOUR-MODULE-ID" # For module name +github_username_entry_id <- "entry.YOUR-USERNAME-ID" # For GitHub username +learnrhash_entry_id <- "entry.YOUR-LEARNRHASH-ID" # For quiz results +``` + +#### Example Current Setup - **Form URL**: https://docs.google.com/forms/d/e/1FAIpQLScnw9R8wMU5SfFqNVXGeEkiIygLTB_Dc6jWBmbwEeHuekBDzg/formResponse -- **Entry IDs** (tidy format): - - `entry.1315905314` - Raw learnrhash - - `entry.61564704` - GitHub username - - `entry.1169139257` - Module name -- **Data structure**: Each submission creates a row with: - - Hash column: Complete learnrhash for decoding - - Username column: GitHub username for filtering - - Module column: Module identifier (fetched from tutorial ID metadata) +- **Entry IDs**: + - `entry.1169139257` - Module name (1st question) + - `entry.61564704` - GitHub username (2nd question) + - `entry.1315905314` - Learnrhash (3rd question) ## Deployment Process diff --git a/config.R b/config.R index 44b9ee4..73d1dff 100644 --- a/config.R +++ b/config.R @@ -13,4 +13,15 @@ quiz_names <- c( base_url <- "https://hjj91u-nicolo-massari.shinyapps.io/" # Main app configuration -main_app_name <- "openwashdata-quiz-hub" \ No newline at end of file +main_app_name <- "openwashdata-quiz-hub" + +# in modules/_submission.Rmd +# +# # Google Form setup +# form_url <- "https://docs.google.com/forms/d/e/1FAIpQLScnw9R8wMU5SfFqNVXGeEkiIygLTB_Dc6jWBmbwEeHuekBDzg/formResponse" +# +# # Entry ID mappings +# learnrhash_entry_id <- "entry.1315905314" +# github_username_entry_id <- "entry.61564704" +# tutorial_id_entry_id <- "entry.1169139257" +# diff --git a/modules/_submission.Rmd b/modules/_submission.Rmd index 3d1ac41..1d51d97 100644 --- a/modules/_submission.Rmd +++ b/modules/_submission.Rmd @@ -1,3 +1,13 @@ +```{r, context="server"} +# Google Form setup +form_url <- "https://docs.google.com/forms/d/e/1FAIpQLScnw9R8wMU5SfFqNVXGeEkiIygLTB_Dc6jWBmbwEeHuekBDzg/formResponse" + +# Entry ID mappings +learnrhash_entry_id <- "entry.1315905314" +github_username_entry_id <- "entry.61564704" +tutorial_id_entry_id <- "entry.1169139257" +``` + ## Quiz Submission Please click the button below to submit your quiz results: @@ -35,11 +45,10 @@ observeEvent(input$submit, { # Prepare form data for Google Form with separate fields - form_data <- list( - "entry.1315905314" = learnrhash_submission, # Raw learnrhash only - "entry.61564704" = github_username, # GitHub username - "entry.1169139257" = tutorial_id # Module name - ) + form_data <- list() + form_data[[learnrhash_entry_id]] <- learnrhash_submission + form_data[[github_username_entry_id]] <- github_username + form_data[[tutorial_id_entry_id]] <- tutorial_id # Submit to Google Form response <- httr::POST(form_url, body = form_data, encode = "form") diff --git a/modules/md-01-quiz.Rmd b/modules/md-01-quiz.Rmd index 461b3ae..c8021b6 100644 --- a/modules/md-01-quiz.Rmd +++ b/modules/md-01-quiz.Rmd @@ -28,8 +28,6 @@ tutorial_options( knitr::opts_chunk$set(echo = FALSE) -# Google Form setup -form_url <- "https://docs.google.com/forms/d/e/1FAIpQLScnw9R8wMU5SfFqNVXGeEkiIygLTB_Dc6jWBmbwEeHuekBDzg/formResponse" ``` ## Introduction