Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
^renv\.lock$
^_pkgdown\.yml$
^docs$
^venv$
^legacy$
^pkgdown$
^\.github$
^.*\.Rproj$
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ renv/
renv.lock

# Shiny deployment
rsconnect/
rsconnect/

venv/

legacy/
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion config.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ quiz_names <- c(
base_url <- "https://hjj91u-nicolo-massari.shinyapps.io/"

# Main app configuration
main_app_name <- "openwashdata-quiz-hub"
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"
#
19 changes: 14 additions & 5 deletions modules/_submission.Rmd
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 0 additions & 2 deletions modules/md-01-quiz.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down