From 3f14af7af161292a848759d21ec7a2c2f31fa9f3 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:22:20 +0000 Subject: [PATCH 1/6] Show five Google Forms as native forms that contact Google only on submit The mentee, mentor, resource, lesson plan feedback and anonymous feedback forms are now part of the page. An hourly workflow compares them with the live forms and proposes an update when one changes in Google. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/README.md | 10 + .github/workflows/google-forms-check.yml | 120 ++++++++ ...mxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg.json | 23 ++ ...JIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg.json | 16 ++ ...uCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA.json | 172 ++++++++++++ ...1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg.json | 85 ++++++ ...wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w.json | 74 +++++ assets/scss/custom.scss | 37 +++ content/dei/form-mentee.md | 2 +- content/dei/form-mentor.md | 2 +- content/privacy.md | 4 +- layouts/partials/google_form.html | 69 +++++ layouts/partials/site_head.html | 1 + layouts/shortcodes/gform.html | 29 +- scripts/build_google_forms.py | 265 ++++++++++++++++++ scripts/check_seo_html.py | 24 ++ scripts/tests/test_build_google_forms.py | 130 +++++++++ static/js/google-form.js | 86 ++++++ 18 files changed, 1135 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/google-forms-check.yml create mode 100644 assets/gforms/1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg.json create mode 100644 assets/gforms/1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg.json create mode 100644 assets/gforms/1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA.json create mode 100644 assets/gforms/1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg.json create mode 100644 assets/gforms/1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w.json create mode 100644 layouts/partials/google_form.html create mode 100644 scripts/build_google_forms.py create mode 100644 scripts/tests/test_build_google_forms.py create mode 100644 static/js/google-form.js diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 3f64a1477ff..956e96685a9 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -78,6 +78,16 @@ Triggers `deploy.yaml` after successful processing via `repository_dispatch`. ## Quality Checks +### [google-forms-check.yml](workflows/google-forms-check.yml) +**Keeps the site's forms in step with Google** + +| Trigger | Action | +|---------|--------| +| Hourly schedule, manual dispatch | Compares `assets/gforms/` with the live Google Forms | +| PR touching the definitions or this check | Runs the same comparison | + +If a form has changed, the scheduled run opens a pull request with the updated definitions and one issue assigned to the site maintainer. Merge that pull request promptly, because Google may discard responses sent from the site until then. The issue closes itself once the definitions match again. + ### [spell-check.yaml](workflows/spell-check.yaml) **Spelling validation using codespell** diff --git a/.github/workflows/google-forms-check.yml b/.github/workflows/google-forms-check.yml new file mode 100644 index 00000000000..cfad997b743 --- /dev/null +++ b/.github/workflows/google-forms-check.yml @@ -0,0 +1,120 @@ +name: Google Forms Check + +# ======================= +# Keep the site's forms in step with Google +# ======================= +# Purpose: The site posts answers to the Google Forms in assets/gforms/ without seeing Google's +# reply, so a form edited in Google can lose responses unnoticed. +# Triggers: Hourly, manual dispatch, and pull requests that touch the definitions or this check +# Reports: Opens one issue and a pull request with the updated definitions, and closes the issue +# once the definitions match again + +on: + schedule: + - cron: '17 * * * *' + workflow_dispatch: + pull_request: + paths: + - 'assets/gforms/**' + - 'scripts/build_google_forms.py' + - '.github/workflows/google-forms-check.yml' + +permissions: + contents: read + +env: + ISSUE_TITLE: A Google Form on forrt.org has changed + SYNC_BRANCH: google-forms-sync + +jobs: + check: + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + # A pull request opened with the default token would not start the other checks. + token: ${{ secrets.FORRT_PAT || github.token }} + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.12' + + - name: Compare the definitions with the live forms + id: compare + run: | + set +e + python3 scripts/build_google_forms.py --check 2>&1 | tee check-output.txt + echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT" + + - name: Propose updated definitions + id: propose + if: steps.compare.outputs.code == '1' && github.event_name != 'pull_request' + continue-on-error: true # The issue below must still be opened. + env: + GH_TOKEN: ${{ secrets.FORRT_PAT || github.token }} + run: | + # Writes nothing if a form can no longer be reproduced; the issue then reports why. + python3 scripts/build_google_forms.py || true + if [ -z "$(git status --porcelain -- assets/gforms)" ]; then + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git switch -C "$SYNC_BRANCH" + git add assets/gforms + git commit -m "Update Google Form definitions" + git push --force origin "$SYNC_BRANCH" + url=$(gh pr list --head "$SYNC_BRANCH" --state open --json url --jq '.[0].url // empty') + if [ -z "$url" ]; then + url=$(gh pr create --base main --head "$SYNC_BRANCH" \ + --title "Update Google Form definitions" \ + --body "A Google Form shown on forrt.org changed. This updates the site's copy to match. Merge it soon: until then, Google may discard responses sent from the site.") + fi + echo "url=$url" >> "$GITHUB_OUTPUT" + + - name: Report the change in an issue + if: steps.compare.outputs.code == '1' && github.event_name != 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + PR_URL: ${{ steps.propose.outputs.url }} + run: | + { + echo "A Google Form shown on forrt.org no longer matches the copy the site uses. Until this is fixed, Google may discard responses sent from the site, and visitors are not told." + echo + echo '```' + cat check-output.txt + echo '```' + echo + if [ -n "$PR_URL" ]; then + echo "**To fix:** review and merge $PR_URL." + else + echo "**To fix:** the site cannot reproduce this form automatically. Undo the change in Google, or update \`scripts/build_google_forms.py\` and \`layouts/partials/google_form.html\`." + fi + } > issue-body.md + number=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') + if [ -n "$number" ]; then + gh issue edit "$number" --body-file issue-body.md + else + gh issue create --title "$ISSUE_TITLE" --body-file issue-body.md --assignee LukasWallrich + fi + + - name: Close the issue once the forms match + if: steps.compare.outputs.code == '0' && github.event_name != 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + run: | + number=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') + if [ -n "$number" ]; then + gh issue close "$number" --comment "The site's copy matches the live forms again." + fi + + - name: Fail the run unless the forms match + if: steps.compare.outputs.code != '0' + run: exit 1 diff --git a/assets/gforms/1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg.json b/assets/gforms/1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg.json new file mode 100644 index 00000000000..1b7989d3ca1 --- /dev/null +++ b/assets/gforms/1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg.json @@ -0,0 +1,23 @@ +{ + "id": "1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg", + "title": "", + "description": "This is a simple, anonymous, open-text short survey for users of FORRT's Lesson Plans to give their feedback (critical or otherwise) so that we can learn how to better these resource. Please also feel free to share your experience, students experience, and any suggestions that may have arisen. If you would like to provide us with files, please email us at info@forrt.org", + "confirmation": "Your response has been recorded.", + "collect_email": false, + "items": [ + { + "type": "paragraph", + "entry": "973290020", + "title": "What is your experience using FORRT's lesson plans? Any feedback or experience or suggestion is welcomed.", + "help": "", + "required": true + }, + { + "type": "short", + "entry": "446372946", + "title": "What is your email? (if you want us to contact you back)", + "help": "", + "required": false + } + ] +} diff --git a/assets/gforms/1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg.json b/assets/gforms/1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg.json new file mode 100644 index 00000000000..7aa97fb1cce --- /dev/null +++ b/assets/gforms/1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg.json @@ -0,0 +1,16 @@ +{ + "id": "1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg", + "title": "FORRT's Anonymous Feedback Form", + "description": "Give us feedback. Any feedback. Anonymously.", + "confirmation": "Your response has been recorded.", + "collect_email": false, + "items": [ + { + "type": "paragraph", + "entry": "1734919805", + "title": "Anonymity is an effective way of gaining honest and unbiased feedback. It is our hope that the anonymous form below allows us to address issues that we would otherwise be unaware of, and be able to make decisions faster and more effectively uninhibited feedback. If you have any feedback concerning our community, our open educational materials, our website, our Slack, our Publications, … we would be more than happy to hear from you!", + "help": "", + "required": false + } + ] +} diff --git a/assets/gforms/1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA.json b/assets/gforms/1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA.json new file mode 100644 index 00000000000..3e652464730 --- /dev/null +++ b/assets/gforms/1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA.json @@ -0,0 +1,172 @@ +{ + "id": "1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA", + "title": "Resource Submission for FORRT", + "description": "Dear Colleagues,

FORRT is collecting online resources on open and reproducible science topics to be catalogued and enriched to increase its findability, accessibility, interoperability, and reusability (FAIR). As a part of FORRT's mission, we aim to provide pedagogical materials for educators who are interested in teaching the next generation of researchers and consumers of science open and reproducible practices and embed its principles on their teaching.

Note that by submitting a resource, there is no transfer of copyright or licence. FORRT merely lists externally hosted resources and tries to keep it updated, tagged with educational metadata, and increase these resources' FAIR use.

For more information about FORRT, see: https://forrt.org", + "confirmation": "Your response has been recorded.", + "collect_email": false, + "items": [ + { + "type": "paragraph", + "entry": "343628871", + "title": "Title", + "help": "", + "required": true + }, + { + "type": "paragraph", + "entry": "2106837918", + "title": "URL/DOI (please check DOI by collating DOI at the end of https://doi.org/ )", + "help": "", + "required": true + }, + { + "type": "paragraph", + "entry": "1189322724", + "title": "Provider/Creators", + "help": "Separate creators with commas, writing each name as it would appear in a by-line (first name(s), then family name), e.g. Jane Q. Smith, Wei Zhang, Center for Open Science. Please don't use \"and\" or \"&\", citation style (Smith, J.), or titles and degrees (Dr, PhD). If an organisation's name contains a comma, leave the comma out.", + "required": true + }, + { + "type": "checkbox", + "entry": "521976517", + "title": "Material Type (see: https://help.oercommons.org/support/solutions/articles/42000046908-material-types for Glossary of terms)", + "help": "", + "required": true, + "other": true, + "options": [ + "Activity/Lab", + "Asssessment", + "Case Study", + "Data Set", + "Diagram/Illustration", + "Full Course", + "Game", + "Homework/Assignment", + "Interactive", + "Lecture", + "Lecture Notes", + "Lesson", + "Lesson Plan", + "Module", + "Primary Source", + "Reading", + "Simulation", + "Student Guide", + "Syllabus", + "Teaching/Learning Strategy", + "Textbook", + "Unit of Study" + ] + }, + { + "type": "checkbox", + "entry": "418720899", + "title": "Education Level", + "help": "", + "required": true, + "options": [ + "College / Upper Division (Undergraduates)", + "Graduate / Professional", + "Career / Technical", + "Adult Education" + ] + }, + { + "type": "paragraph", + "entry": "1474814934", + "title": "Abstract", + "help": "", + "required": true + }, + { + "type": "checkbox", + "entry": "739787223", + "title": "Language", + "help": "", + "required": true, + "other": true, + "options": [ + "English", + "French", + "Spanish", + "German" + ] + }, + { + "type": "checkbox", + "entry": "911686928", + "title": "Conditions of Use", + "help": "", + "required": true, + "options": [ + "Public Domain", + "CC BY", + "CC BY-ND", + "CC BY-SA", + "CC BY-NC", + "CC BY-NC-SA", + "CC BY-NC-ND", + "I don't see any of these" + ] + }, + { + "type": "checkbox", + "entry": "1021404143", + "title": "Primary User", + "help": "", + "required": true, + "other": true, + "options": [ + "Student", + "Teacher", + "Administrator", + "Parent", + "Librarian" + ] + }, + { + "type": "checkbox", + "entry": "429156235", + "title": "Subject Areas", + "help": "", + "required": true, + "options": [ + "Applied Science", + "Arts and Humanities", + "Business and Communication", + "Career and Technical Education", + "Education", + "English Language Arts", + "History", + "Law", + "Life Science", + "Math & Statistics", + "Physical Science", + "Social Science" + ] + }, + { + "type": "checkbox", + "entry": "2005582855", + "title": "FORRT Clusters | see: https://forrt.org/clusters", + "help": "", + "required": true, + "options": [ + "Reproducibility and Replicability Knowledge", + "Conceptual and Statistical Knowledge", + "Reproducible Analyses", + "Preregistration", + "Open Data and Materials", + "Replication Research", + "Academic Life and Culture" + ] + }, + { + "type": "paragraph", + "entry": "422644170", + "title": "User Tags (separate by comma if more than one; capitalize each word, except for prepositions)", + "help": "", + "required": true + } + ] +} diff --git a/assets/gforms/1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg.json b/assets/gforms/1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg.json new file mode 100644 index 00000000000..d32334799b9 --- /dev/null +++ b/assets/gforms/1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg.json @@ -0,0 +1,85 @@ +{ + "id": "1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg", + "title": "Mentee sign-up form", + "description": "In this form, we aim to collect information about mentees (i.e., those seeking help in one of the categories below) as part of FORRT's \"Support for underprivileged and underrepresented ERCs\" as well as FORRT's \" Remote Mentorship program.\"

Please note you will only be contacted in case there is a possible match, which you can accept or not.", + "confirmation": "Thank you for submitting your response. We have received your data and should soon come back to you.", + "collect_email": true, + "items": [ + { + "type": "short", + "entry": "131757446", + "title": "What is your name?", + "help": "", + "required": false + }, + { + "type": "radio", + "entry": "27675187", + "title": "What is your current position?", + "help": "", + "required": false, + "other": true, + "options": [ + "Bachelor student", + "Master student", + "PhD student", + "Post-doc" + ] + }, + { + "type": "paragraph", + "entry": "1657258605", + "title": "What's the field of expertise on which you would like to obtain help (e.g., cognitive psychology, behavioral economics, etc.). Be as specific as possible.", + "help": "", + "required": false + }, + { + "type": "radio", + "entry": "1094432515", + "title": "What would you like help with?", + "help": "", + "required": false, + "other": true, + "options": [ + "Application materials for academic positions", + "Grant/funding applications for academic positions/research", + "Application materials for transitioning out of academia to industry", + "Feedback on a manuscript (wherein you are the writer/first author)", + "Feedback on research idea/development", + "Help with statistical analyses", + "Help with specifics of Open and Reproducible Science (e.g., preregistrations, registered reports, multiverse analyses)", + "Help with written (academic) English and/or copy-editing", + "External remote mentorship for a Bachelor thesis", + "External remote mentorship for a Master thesis" + ] + }, + { + "type": "paragraph", + "entry": "538904471", + "title": "Please write here the specifics of what you need help with. This will be sent to a potential mentor who will evaluate their fit with your request/description. Please be as specific as you can.", + "help": "", + "required": false + }, + { + "type": "radio", + "entry": "3151414", + "title": "Would you say you are:", + "help": "", + "required": false, + "other": true, + "options": [ + "student/ERC from underprivileged and underrepresented background", + "non-WEIRD background (Western, educated, and from industrialized, rich, and democratic countries)", + "studying/working in a institution without local \"Open and Reproducible Science\" friendly personnel", + "None of the above" + ] + }, + { + "type": "paragraph", + "entry": "1206553351", + "title": "Please leave any comments or remarks or questions (for example suggestions for this form or other additional info you would like to share)", + "help": "", + "required": false + } + ] +} diff --git a/assets/gforms/1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w.json b/assets/gforms/1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w.json new file mode 100644 index 00000000000..937d54d552f --- /dev/null +++ b/assets/gforms/1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w.json @@ -0,0 +1,74 @@ +{ + "id": "1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w", + "title": "Mentor sign-up form", + "description": "In this form, we aim to collect information about potential mentors (i.e., those providing help) as part of FORRT's \"Support for underprivileged and underrepresented ERCs\" as well as FORRT's Remote Mentorship program.

Please note you will only be contacted in case there is a possible match, which you can accept or not.", + "confirmation": "Thank you for submitting your response. We have received your data and should soon come back to you.", + "collect_email": true, + "items": [ + { + "type": "short", + "entry": "413603008", + "title": "What is your name?", + "help": "", + "required": false + }, + { + "type": "radio", + "entry": "1285476145", + "title": "What's your current position or job description?", + "help": "", + "required": false, + "other": true, + "options": [ + "Professor", + "Associate Professor / Senior Lecturer", + "Assistant Professor / Lecturer", + "Transitioned to industry", + "Postdoc / Research Associate / Senior Researcher", + "PhD / graduate student" + ] + }, + { + "type": "paragraph", + "entry": "392756963", + "title": "What's your field of expertise? Be as specific as possible but mention all areas on which you may be knowledgeable (e.g., cognitive psychology, behavioral economics, etc.)", + "help": "", + "required": false + }, + { + "type": "checkbox", + "entry": "1257320734", + "title": "What can you help with?", + "help": "", + "required": false, + "other": true, + "options": [ + "Revising application materials for academic positions", + "Revising grant/funding proposals for academic positions/research", + "Revising application materials for transitioning out of academia to industry", + "I have a research project in my area that I would onboard a underprivileged/underrepresented early-career research (specify details below)", + "Providing feedback on a manuscript (wherein underrepresented minority is the writer/first author)", + "Provide feedback on research idea/development", + "Provide help with statistical analyses", + "Provide help with specifics of Open and Reproducible Science (e.g., preregistrations, registered reports, multiverse analyses)", + "Provide help with written (academic) English and/or copy-editing", + "Provide external remote mentorship for a Bachelor thesis", + "Provide external remote mentorship for a Master thesis" + ] + }, + { + "type": "paragraph", + "entry": "283543367", + "title": "If you chosen provide remote mentorship above, please describe as best as you can the topics you would be willing to be a mentor. We will always consult with the Mentor when we found a potential match before contacting the mentee.", + "help": "", + "required": false + }, + { + "type": "paragraph", + "entry": "408042070", + "title": "Please leave any comments or remarks (e.g., suggestions for this form, remarks about availability, your expertise, etc.)", + "help": "", + "required": false + } + ] +} diff --git a/assets/scss/custom.scss b/assets/scss/custom.scss index cd057c2cf31..b80c7d54e96 100644 --- a/assets/scss/custom.scss +++ b/assets/scss/custom.scss @@ -3444,6 +3444,43 @@ form.newsletter-form p.newsletter-note { margin: 6px 0 0; color: #4a5568; font-s .newsletter-form.is-done .newsletter-note { display: none; } .newsletter-form.is-done .newsletter-status { margin-top: 0; } +/* ============================================================ + * Google Forms rendered as the site's own forms (layouts/partials/google_form.html) + * ============================================================ */ +.gform { + max-width: 720px; margin: 1.5rem auto; padding: 24px; + color: #2d3748; font-size: 1rem; line-height: 1.5; text-align: left; overflow-wrap: anywhere; + background: #fff; border: 1px solid #d9d4c5; border-radius: 4px; +} +.gform .gform-heading { margin: 0 0 8px; font-size: 1.4rem; } +.gform p.gform-description, .gform p.gform-text { margin: 0 0 20px; font-size: 1rem; } +.gform-question { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; } +.gform .gform-title { display: block; width: 100%; margin: 0 0 6px; font-size: 1rem; font-weight: 600; } +.gform .gform-title:has(b) { font-weight: 400; } +.gform-required { color: #a3271f; } +.gform p.gform-help { margin: 0 0 8px; color: #4a5568; font-size: 0.9rem; } +.gform-input { + display: block; width: 100%; padding: 8px 10px; + color: #2d3748; font-size: 1rem; background: #fff; border: 1px solid #718096; border-radius: 4px; +} +.gform-input:focus { border-color: #004055; outline: 2px solid #004055; outline-offset: 0; } +.gform .gform-option { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 6px; font-weight: 400; } +.gform-option input[type=radio], .gform-option input[type=checkbox] { flex: none; margin-top: 5px; } +.gform .gform-other { flex-wrap: wrap; align-items: center; } +.gform-other label { display: flex; gap: 8px; margin: 0; font-weight: 400; } +.gform-other .gform-input { flex: 1 1 200px; width: auto; padding: 4px 8px; } +.gform-clear { padding: 0; color: #004055; font-size: 0.9rem; text-decoration: underline; background: none; border: 0; } +.gform-submit { padding: 10px 24px; color: #fff; font-weight: 600; background: #004055; border: 0; border-radius: 4px; } +.gform-submit:hover { background: #00566f; } +.gform-submit:focus-visible { outline: 3px solid #2d3748; outline-offset: 2px; } +.gform-submit:disabled { background: #718096; cursor: progress; } +.gform p.gform-note { margin: 10px 0 0; color: #4a5568; font-size: 0.875rem; line-height: 1.4; } +.gform-note a { color: inherit; text-decoration: underline; } +.gform p.gform-status { margin: 12px 0 0; font-size: 1rem; font-weight: 600; } +.gform p.gform-status:empty { display: none; } +.gform p.gform-status.is-error { color: #a3271f; } +.gform-status:focus:not(:focus-visible) { outline: none; } + /* ============================================================ * Combined Achievements & Awards section (two columns) * ============================================================ */ diff --git a/content/dei/form-mentee.md b/content/dei/form-mentee.md index 1a3d684f069..6ade124e887 100644 --- a/content/dei/form-mentee.md +++ b/content/dei/form-mentee.md @@ -50,4 +50,4 @@ subtitle = "Fill out the form below or ***[open the Google form in a new window] css_class = "text-center" +++ -{{< gform src="1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg" width="100%" height="500px" alt="Loading..." >}} \ No newline at end of file +{{< gform src="1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg" heading="false" width="100%" height="500px" alt="Loading..." >}} \ No newline at end of file diff --git a/content/dei/form-mentor.md b/content/dei/form-mentor.md index 25b098361ab..a5af5167161 100644 --- a/content/dei/form-mentor.md +++ b/content/dei/form-mentor.md @@ -52,4 +52,4 @@ subtitle = "Fill out the form below or ***[open the Google form in a new window] +++ -{{< gform src="1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w" width="100%" height="500px" alt="Loading..." >}} \ No newline at end of file +{{< gform src="1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w" heading="false" width="100%" height="500px" alt="Loading..." >}} \ No newline at end of file diff --git a/content/privacy.md b/content/privacy.md index 898f41a487e..277e728c8be 100644 --- a/content/privacy.md +++ b/content/privacy.md @@ -19,7 +19,7 @@ We have not appointed a data protection officer. ## Summary - Google Analytics runs only if you allow it. -- Videos, forms, calendars and teaching activities load only if you click to load them. +- Videos, calendars, teaching activities and a few forms load only if you click to load them. Other forms are part of our pages and send your answers to Google only when you press Submit. - The newsletter form contacts EmailOctopus and Google reCAPTCHA only when you press **Subscribe**. - Our host receives your IP address and other technical data each time you open a page, and so do the services listed below on the few pages that use them. @@ -78,7 +78,7 @@ Videos use the `youtube-nocookie.com` player. **Newsletter.** The sign-up form is part of our pages and loads nothing from other services until you press **Subscribe**. Pressing it loads Google reCAPTCHA, which checks for spam: Google receives your IP address and browser data, may set cookies, and handles this data under its [privacy policy](https://policies.google.com/privacy). Your email address then goes to EmailOctopus (Three Hearts Digital Ltd, 86-90 Paul Street, London EC2A 4NE, UK), which stores it as our processor, under the data processing schedule in its terms, and we use it to send the newsletter. Its [sub-processors are listed here](https://emailoctopus.com/legal/subprocessors). The legal basis is your consent (Art. 6(1)(a) GDPR). You can unsubscribe through the link in every email, and we then remove you from the list. The European Commission has found that the UK provides adequate protection. -**Forms and feedback.** Our Google Forms and the feedback forms on glossary and other pages store what you enter, and any email address you choose to give, in Google Sheets. We hold this in our forrtproject@gmail.com account, and use it to act on your message or application. We keep it for as long as we need it for that purpose, and then delete it. The legal basis is our legitimate interest in improving our resources and running our programmes (Art. 6(1)(f) GDPR), or your consent where a form asks for it. Google stores this data and may process it in the USA, as described under Analytics. +**Forms and feedback.** Forms that are part of our pages load nothing from Google until you press **Submit**. Pressing it sends your answers to Google, which also receives your IP address and browser data. Our Google Forms and the feedback forms on glossary and other pages store what you enter, and any email address you choose to give, in Google Sheets. We hold this in our forrtproject@gmail.com account, and use it to act on your message or application. We keep it for as long as we need it for that purpose, and then delete it. The legal basis is our legitimate interest in improving our resources and running our programmes (Art. 6(1)(f) GDPR), or your consent where a form asks for it. Google stores this data and may process it in the USA, as described under Analytics. **Email.** If you email us, we use your message and address to reply (Art. 6(1)(f) GDPR). Google Mail hosts our email. We keep messages for as long as we need them to deal with your request. diff --git a/layouts/partials/google_form.html b/layouts/partials/google_form.html new file mode 100644 index 00000000000..b18d7c18bfc --- /dev/null +++ b/layouts/partials/google_form.html @@ -0,0 +1,69 @@ +{{/* A Google Form rendered as the site's own form, from a definition in assets/gforms/. + Nothing loads from Google. Pressing Submit posts the answers to the form's response address + (static/js/google-form.js); without JavaScript the browser posts them and lands on Google's + confirmation page. Styles: assets/scss/custom.scss (.gform). */}} +{{ $form := .form }} +{{ $prefix := printf "gform-%s" (substr $form.id -8) }} +
+
+ {{ if .heading }}{{ with $form.title }}

{{ . }}

{{ end }}{{ end }} + {{ with $form.description }}

{{ . | safeHTML }}

{{ end }} + + {{ if $form.collect_email }} +
+ + +
+ {{ end }} + + {{ range $form.items }} + {{ $id := printf "%s-%s" $prefix (.entry | default "") }} + {{ $name := printf "entry.%s" (.entry | default "") }} + {{ $question := . }} + {{ if eq .type "text" }} +

{{ .title | safeHTML }}

+ {{ else if in (slice "short" "paragraph") .type }} +
+ + {{ with .help }}

{{ . | safeHTML }}

{{ end }} + {{ if eq .type "short" }} + + {{ else }} + + {{ end }} +
+ {{ else if in (slice "radio" "checkbox") .type }} + {{ $type := .type }} +
+ {{ .title | safeHTML }}{{ if .required }} *{{ end }} + {{ with .help }}

{{ . | safeHTML }}

{{ end }} + {{ range .options }} + + {{ end }} + {{ if .other }} +
+ + +
+ {{ end }} + {{ if and (eq $type "radio") (not .required) }} + + {{ end }} +
+ {{ end }} + {{ end }} + + + + +

This data will be submitted to our Google account when you press Submit. See our privacy policy.

+
+

+
diff --git a/layouts/partials/site_head.html b/layouts/partials/site_head.html index d00091ccb87..27590beb4a5 100644 --- a/layouts/partials/site_head.html +++ b/layouts/partials/site_head.html @@ -211,6 +211,7 @@ + {{/* Netlify Identity integration. */}} {{ if .IsHome | and (site.Params.cms.netlify_cms | default true) }} diff --git a/layouts/shortcodes/gform.html b/layouts/shortcodes/gform.html index 74961c28ba1..1e67af46c5c 100644 --- a/layouts/shortcodes/gform.html +++ b/layouts/shortcodes/gform.html @@ -1,10 +1,19 @@ -{{ $url := printf "https://docs.google.com/forms/d/e/%s/viewform" (.Get "src") }} -{{ partial "click_to_load.html" (dict - "src" (printf "%s?embedded=true" $url) - "link" $url - "provider" "Google Forms" - "label" "This form" - "title" "Google Form" - "width" (.Get "width") - "height" (.Get "height") -) }} +{{/* A Google Form. Forms with a definition in assets/gforms/ (scripts/build_google_forms.py) render + as the site's own form; any other form stays behind a click-to-load placeholder. + Set heading="false" where the page already names the form. */}} +{{ $id := .Get "src" }} +{{ $heading := ne (.Get "heading") "false" }} +{{ with resources.Get (printf "gforms/%s.json" $id) }} + {{ partial "google_form.html" (dict "form" (. | transform.Unmarshal) "heading" $heading) }} +{{ else }} + {{ $url := printf "https://docs.google.com/forms/d/e/%s/viewform" $id }} + {{ partial "click_to_load.html" (dict + "src" (printf "%s?embedded=true" $url) + "link" $url + "provider" "Google Forms" + "label" "This form" + "title" "Google Form" + "width" (.Get "width") + "height" (.Get "height") + ) }} +{{ end }} diff --git a/scripts/build_google_forms.py b/scripts/build_google_forms.py new file mode 100644 index 00000000000..3a858d8f84b --- /dev/null +++ b/scripts/build_google_forms.py @@ -0,0 +1,265 @@ +#!/usr/bin/env python3 +"""Build the definitions of the Google Forms that forrt.org renders as its own forms. + +Source: the public viewform page of each Google Form listed in FORMS. +Output: assets/gforms/
.json, read by layouts/shortcodes/gform.html. + + python3 scripts/build_google_forms.py # rewrite the definitions from the live forms + python3 scripts/build_google_forms.py --check # compare the definitions with the live forms + +The site posts answers to Google without being able to read the reply, so Google discards a +response that no longer matches the form and the visitor is not told. The script stops on any +feature the site's form does not reproduce (sections, branching, answer validation, other +question types) rather than writing a definition that would lose responses. + +.github/workflows/google-forms-check.yml runs --check every hour. It exits 1 if a form has changed +or can no longer be reproduced, and 2 if Google could not be reached. +""" + +import html +import json +import re +import sys +import time +import urllib.error +import urllib.request +from html.parser import HTMLParser +from pathlib import Path + +FORMS = { + "mentee": "1FAIpQLSfY6yQ2givfg1TBoCuh_55HrUE7YsEjKAIj0-4MidII_3LSEg", + "mentor": "1FAIpQLSfkbhb2qSxj_wj5qXYQAFZZ0WxkFyLChL0ZFYnWL0QVMaSw8w", + "resources": "1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA", + "lesson plans feedback": "1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg", + "anonymous feedback": "1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg", +} + +OUTPUT_DIR = Path(__file__).resolve().parent.parent / "assets" / "gforms" +DEFAULT_CONFIRMATION = "Your response has been recorded." +EMAIL_FROM_RESPONDER = 3 + +QUESTION_TYPES = {0: "short", 1: "paragraph", 2: "radio", 4: "checkbox"} +TEXT_ONLY_TYPES = {6, 11} # A text block, and an image whose caption is kept without the image. + + +class FormNotSupported(Exception): + """The form uses something the site's form cannot reproduce.""" + + +class GoogleUnreachable(Exception): + """Google did not answer, which says nothing about the form.""" + + +class RichText(HTMLParser): + """Keep links and emphasis from Google's rich text, and turn blocks into line breaks.""" + + INLINE = {"b", "strong", "i", "em", "u"} + BLOCK = {"div", "p", "li", "ul", "ol"} + + def __init__(self): + super().__init__(convert_charrefs=True) + self.parts = [] + self.open_links = 0 + + def handle_starttag(self, tag, attrs): + if tag in self.INLINE: + self.parts.append(f"<{tag}>") + elif tag == "br": + self.parts.append("
") + elif tag in self.BLOCK: + self.line_break() + elif tag == "a": + href = dict(attrs).get("href") or "" + if re.match(r"https?://|mailto:", href): + self.parts.append(f'') + self.open_links += 1 + + def handle_endtag(self, tag): + if tag in self.INLINE: + self.parts.append(f"") + elif tag in self.BLOCK: + self.line_break() + elif tag == "a" and self.open_links: + self.parts.append("") + self.open_links -= 1 + + def handle_data(self, data): + self.parts.append(html.escape(data.replace("\xa0", " "), quote=False)) + + def line_break(self): + if self.parts and self.parts[-1] != "
": + self.parts.append("
") + + +def rich_text(markup): + """Return Google's rich text reduced to the tags the site allows.""" + if not markup: + return "" + parser = RichText() + parser.feed(markup) + parser.close() + text = "".join(parser.parts) + text = re.sub(r"(
\s*){3,}", "

", text) + return re.sub(r"^(\s|
)+|(\s|
)+$", "", text) + + +def plain_as_rich(text): + """Escape plain text for use where rich text is expected, keeping its line breaks.""" + return html.escape((text or "").replace("\xa0", " ").strip(), quote=False).replace("\n", "
") + + +def item_text(item, position, plain_position): + """Return the rich version of an item's title or help text, or else its plain version.""" + rich = item[11] if len(item) > 11 and item[11] else [] + markup = rich[position] if len(rich) > position else None + return rich_text(markup) or plain_as_rich(item[plain_position]) + + +def parse_question(item): + """Convert one item of Google's form data to the definition the site renders.""" + title = item_text(item, 1, 1) + kind = item[3] + if kind in TEXT_ONLY_TYPES: + return {"type": "text", "title": title} if title else None + if kind not in QUESTION_TYPES: + raise FormNotSupported(f"question type {kind}: {item[1]!r}") + + entries = item[4] + if len(entries) != 1: + raise FormNotSupported(f"question with {len(entries)} answer fields: {item[1]!r}") + entry = entries[0] + if len(entry) > 4 and entry[4]: + raise FormNotSupported(f"answer validation: {item[1]!r}") + + question = { + "type": QUESTION_TYPES[kind], + "entry": str(entry[0]), # A string, because Hugo reads JSON numbers as floats. + "title": title, + "help": item_text(item, 2, 2), + "required": bool(entry[2]), + } + if kind in (2, 4): + options = [] + for option in entry[1]: + if len(option) > 2 and option[2]: + raise FormNotSupported(f"branching: {item[1]!r}") + if len(option) > 4 and option[4]: + question["other"] = True + else: + options.append(option[0]) + question["options"] = options + return question + + +def parse_form(form_id, page): + """Convert a viewform page to the definition the site renders.""" + match = re.search(r"FB_PUBLIC_LOAD_DATA_\s*=\s*(.*?);\s*", page, re.S) + if not match: + raise FormNotSupported("no public form data; the form may be closed or need a sign-in") + data = json.loads(match.group(1)) + info = data[1] + settings = info[10] or [] + if data[18] or (len(settings) > 6 and settings[6] not in (1, EMAIL_FROM_RESPONDER)): + raise FormNotSupported("the form needs a Google sign-in") + + description = info[24][1] if len(info) > 24 and info[24] else None + confirmation = info[2][0] if info[2] and info[2][0] else DEFAULT_CONFIRMATION + items = [parse_question(item) for item in info[1] or []] + return { + "id": form_id, + "title": (info[8] or "").strip(), # Forms without a public title get no heading. + "description": rich_text(description) or plain_as_rich(info[0]), + "confirmation": confirmation.strip(), + "collect_email": len(settings) > 6 and settings[6] == EMAIL_FROM_RESPONDER, + "items": [item for item in items if item], + } + + +def fetch(form_id, attempts=3, pause=20): + url = f"https://docs.google.com/forms/d/e/{form_id}/viewform" + request = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) + for attempt in range(1, attempts + 1): + try: + with urllib.request.urlopen(request, timeout=60) as response: + return response.read().decode("utf-8") + except urllib.error.HTTPError as error: + if error.code in (401, 403, 404): + raise FormNotSupported(f"Google answered {error.code}; the form may need a sign-in or be gone") + problem = error + except (urllib.error.URLError, TimeoutError) as error: + problem = error + if attempt < attempts: + time.sleep(pause) + raise GoogleUnreachable(f"{form_id}: {problem}") + + +def label(question): + """Name a question in a report, without its markup.""" + return re.sub(r"<[^>]+>", "", question["title"])[:80] + + +def differences(saved, live): + """List what differs between a saved definition and the live form.""" + if saved is None: + return ["no saved definition"] + changes = [f"{key} changed" for key in ("title", "description", "confirmation", "collect_email") + if saved.get(key) != live.get(key)] + old = {question.get("entry", question["title"]): question for question in saved["items"]} + new = {question.get("entry", question["title"]): question for question in live["items"]} + changes += [f"question added: {label(new[key])}" for key in new if key not in old] + changes += [f"question removed: {label(old[key])}" for key in old if key not in new] + changes += [f"question changed: {label(new[key])}" for key in new if key in old and old[key] != new[key]] + if not changes and saved["items"] != live["items"]: + changes.append("questions reordered") + return changes + + +def saved_definition(form_id): + path = OUTPUT_DIR / f"{form_id}.json" + return json.loads(path.read_text(encoding="utf-8")) if path.exists() else None + + +def check(): + """Report every form that no longer matches its saved definition.""" + problems = [] + for name, form_id in FORMS.items(): + try: + live = parse_form(form_id, fetch(form_id)) + except FormNotSupported as problem: + problems.append(f"{name}: {problem}") + continue + problems += [f"{name}: {change}" for change in differences(saved_definition(form_id), live)] + for problem in problems: + print(problem) + if problems: + return 1 + print(f"All {len(FORMS)} forms match their saved definitions.") + return 0 + + +def build(): + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) + definitions = {} + for name, form_id in FORMS.items(): + try: + definitions[form_id] = parse_form(form_id, fetch(form_id)) + except FormNotSupported as problem: + print(f"{name} ({form_id}): {problem}. No definitions were written.", file=sys.stderr) + return 1 + for form_id, definition in definitions.items(): + text = json.dumps(definition, indent=2, ensure_ascii=False) + "\n" + (OUTPUT_DIR / f"{form_id}.json").write_text(text, encoding="utf-8") + print(f"Wrote {len(definitions)} form definitions to {OUTPUT_DIR}") + return 0 + + +def main(): + try: + return check() if "--check" in sys.argv[1:] else build() + except GoogleUnreachable as problem: + print(f"Could not reach Google: {problem}", file=sys.stderr) + return 2 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/check_seo_html.py b/scripts/check_seo_html.py index e250012d5c1..159695a99a3 100644 --- a/scripts/check_seo_html.py +++ b/scripts/check_seo_html.py @@ -31,6 +31,7 @@ 11. The FLoRA page (replication-hub/flora/) contains the FLoRA citation DOI. 13. List cards use a page's `image.alt_text` (#1203), tested on a post that sets it. + 14. No page embeds a Google Form that assets/gforms/ defines as the site's own form. Report-only sections (never fail): pages with zero or several

, the site-wide share of images that carry both width and height, pages whose @@ -406,6 +407,27 @@ def check_third_party_forms(pages): return sorted(p.path for p in pages if p.loads("recaptcha") or p.loads("eocampaign1.com")) +def check_native_google_forms(public_dir, form_ids): + """Forms defined in assets/gforms/ are never embedded from Google.""" + problems = [] + for folder, _, files in os.walk(public_dir): + for name in files: + if not name.endswith(".html"): + continue + path = os.path.join(folder, name) + with open(path, encoding="utf-8", errors="replace") as handle: + text = handle.read() + for form_id in form_ids: + if 'data-embed-src="https://docs.google.com/forms/d/e/%s/' % form_id in text: + problems.append("%s embeds %s" % (os.path.relpath(path, public_dir), form_id)) + return problems + + +def native_google_form_ids(): + folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "assets", "gforms") + return [name[:-len(".json")] for name in sorted(os.listdir(folder)) if name.endswith(".json")] + + def main(public_dir): pages = load_pages(public_dir) home = next((p for p in pages if p.path == "index.html"), None) @@ -428,6 +450,8 @@ def main(public_dir): item for items in conditional.values() for item in items] results["8. curated resources carry one clean LearningResource"] = check_learning_resource(pages) results["12. no page loads EmailOctopus or reCAPTCHA before a visitor subscribes"] = check_third_party_forms(pages) + results["14. Google Forms in assets/gforms are native, not embedded"] = check_native_google_forms( + public_dir, native_google_form_ids()) print("\nSummary") for title in sorted(results, key=lambda t: int(t.split(".")[0])): diff --git a/scripts/tests/test_build_google_forms.py b/scripts/tests/test_build_google_forms.py new file mode 100644 index 00000000000..488ee00cf04 --- /dev/null +++ b/scripts/tests/test_build_google_forms.py @@ -0,0 +1,130 @@ +"""Run with python3 -m unittest discover -s scripts/tests -p test_build_google_forms.py.""" +import json +from pathlib import Path +import sys +import tempfile +import unittest + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +import build_google_forms as forms +import check_seo_html as seo + + +def page(items, email_setting=1, sign_in=0): + """A viewform page holding Google's form data for these items.""" + info = [None] * 26 + info[0] = "Plain description" + info[1] = items + info[2] = ["Thanks!"] + info[8] = "A form" + info[10] = [None, None, None, 2, None, None, email_setting] + info[24] = [None, "Rich description"] + data = [None] * 20 + data[1] = info + data[3] = "File name" + data[18] = sign_in + return "" % json.dumps(data) + + +def question(kind, options=None, required=1, validation=None): + return [1, "Question", "Help", kind, [[1234567890, options, required, None, validation]]] + + +class ParseForm(unittest.TestCase): + def test_entry_ids_stay_exact_strings(self): + form = forms.parse_form("id", page([question(0)])) + self.assertEqual(form["items"][0]["entry"], "1234567890") + + def test_other_option_is_a_flag_and_not_an_answer(self): + options = [["Yes", None, None, None, 0], ["", None, None, None, 1]] + parsed = forms.parse_form("id", page([question(2, options)]))["items"][0] + self.assertEqual(parsed["options"], ["Yes"]) + self.assertTrue(parsed["other"]) + + def test_responder_email_is_collected(self): + self.assertTrue(forms.parse_form("id", page([], email_setting=3))["collect_email"]) + self.assertFalse(forms.parse_form("id", page([]))["collect_email"]) + + def test_unsupported_features_stop_the_build(self): + branching = [["Yes", None, 99, None, 0]] + cases = { + "section": page([[1, "Part two", None, 8]]), + "dropdown": page([question(3, [["Yes", None, None, None, 0]])]), + "branching": page([question(2, branching)]), + "validation": page([question(0, validation=[[1, 2, ["x"]]])]), + "verified email": page([], email_setting=2), + "sign-in": page([], sign_in=1), + "no data": "", + } + for name, html in cases.items(): + with self.subTest(name), self.assertRaises(forms.FormNotSupported): + forms.parse_form("id", html) + + +class Differences(unittest.TestCase): + def setUp(self): + options = [["Yes", None, None, None, 0], ["No", None, None, None, 0]] + self.saved = forms.parse_form("id", page([question(2, options, required=0)])) + self.live = json.loads(json.dumps(self.saved)) + + def test_identical_forms_match(self): + self.assertEqual(forms.differences(self.saved, self.live), []) + + def test_missing_definition_is_reported(self): + self.assertEqual(forms.differences(None, self.live), ["no saved definition"]) + + def test_changes_that_would_lose_responses_are_reported(self): + cases = { + "now required": lambda q: q.update(required=True), + "new entry id": lambda q: q.update(entry="999"), + "renamed option": lambda q: q["options"].__setitem__(0, "Yes!"), + "other added": lambda q: q.update(other=True), + } + for name, change in cases.items(): + with self.subTest(name): + live = json.loads(json.dumps(self.saved)) + change(live["items"][0]) + self.assertTrue(forms.differences(self.saved, live)) + + def test_new_question_is_named(self): + self.live["items"].append({"type": "short", "entry": "5", "title": "New one", "required": True}) + self.assertEqual(forms.differences(self.saved, self.live), ["question added: New one"]) + + def test_email_collection_is_reported(self): + self.live["collect_email"] = True + self.assertEqual(forms.differences(self.saved, self.live), ["collect_email changed"]) + + +class RichText(unittest.TestCase): + def test_keeps_emphasis_and_web_links(self): + self.assertEqual( + forms.rich_text('See FORRT'), + 'See FORRT') + + def test_removes_scripts_attributes_and_unsafe_links(self): + cleaned = forms.rich_text('xz') + self.assertEqual(cleaned, "xz") + + def test_escapes_text(self): + self.assertEqual(forms.rich_text("a <b> c"), "a <b> c") + + def test_blocks_become_line_breaks(self): + self.assertEqual(forms.rich_text("
one
two
"), "one
two") + + +class NativeFormCheck(unittest.TestCase): + def failures(self, html): + with tempfile.TemporaryDirectory() as public: + (Path(public) / "index.html").write_text(html, encoding="utf-8") + return seo.check_native_google_forms(public, ["abc"]) + + def test_native_form_passes(self): + self.assertEqual(self.failures(''), []) + + def test_embedded_form_fails(self): + html = '
' + self.assertEqual(len(self.failures(html)), 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/static/js/google-form.js b/static/js/google-form.js new file mode 100644 index 00000000000..eab4184f383 --- /dev/null +++ b/static/js/google-form.js @@ -0,0 +1,86 @@ +// Google Forms rendered as the site's own forms (layouts/partials/google_form.html). Nothing goes +// to Google until a visitor presses Submit. Google's reply cannot be read from another site, so +// these checks mirror the form's rules: a response that breaks them would be discarded unseen. +(() => { + const OTHER = '__other_option__'; + + document.querySelectorAll('.gform').forEach((form) => { + const body = form.querySelector('.gform-body'); + const button = form.querySelector('.gform-submit'); + const status = form.querySelector('.gform-status'); + + const otherText = (choice) => choice.closest('.gform-other').querySelector('input[type=text]'); + + const refresh = () => { + // Answers of only spaces count as empty. + form.querySelectorAll('input[required][type=text], textarea[required]').forEach((field) => { + field.setCustomValidity(field.value.trim() ? '' : 'Please answer this question.'); + }); + form.querySelectorAll(`input[value="${OTHER}"]`).forEach((choice) => { + const text = otherText(choice); + text.setCustomValidity(choice.checked && !text.value.trim() ? 'Please fill in your answer.' : ''); + }); + form.querySelectorAll('[data-gform-pick-one]').forEach((group) => { + const boxes = group.querySelectorAll('input[type=checkbox]'); + const ticked = [...boxes].some((box) => box.checked); + boxes[0].setCustomValidity(ticked ? '' : 'Please tick at least one option.'); + }); + form.querySelectorAll('.gform-clear').forEach((clear) => { + clear.hidden = !clear.closest('fieldset').querySelector('input[type=radio]:checked'); + }); + }; + + form.addEventListener('input', (event) => { + // Typing an "Other" answer selects that option. + const row = event.target.matches('input[type=text]') && event.target.closest('.gform-other'); + if (row && event.target.value.trim()) row.querySelector(`input[value="${OTHER}"]`).checked = true; + refresh(); + }); + + form.addEventListener('click', (event) => { + if (!event.target.matches('.gform-clear')) return; + const group = event.target.closest('fieldset'); + group.querySelectorAll('input[type=radio]').forEach((radio) => { radio.checked = false; }); + refresh(); + group.querySelector('input[type=radio]').focus(); + }); + + const answers = () => { + const data = new URLSearchParams(); + new FormData(form).forEach((value, name) => { + const text = value.trim(); + if (!text) return; + if (name.endsWith('.other_option_response')) { + const choice = form.querySelector(`input[name="${name.replace('.other_option_response', '')}"][value="${OTHER}"]`); + if (!choice.checked) return; + } + data.append(name, text); + }); + return data; + }; + + form.addEventListener('submit', async (event) => { + event.preventDefault(); + refresh(); + if (!form.reportValidity()) return; + button.disabled = true; + status.classList.remove('is-error'); + status.textContent = 'Sending…'; + try { + await fetch(form.action, { + method: 'POST', mode: 'no-cors', credentials: 'omit', referrerPolicy: 'no-referrer', body: answers(), + }); + body.hidden = true; + status.textContent = form.dataset.gformConfirmation; + status.focus(); + } catch { + status.classList.add('is-error'); + status.textContent = 'Sorry, that did not work. Your answers are still here, so please try again.'; + } finally { + button.disabled = false; + } + }); + + refresh(); + }); +})(); From 92f2abe494b78ec0151ffbb64e1693c8c49496ba Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:25:42 +0000 Subject: [PATCH 2/6] Show the FLoRA submission form as a native form too Co-Authored-By: Claude Opus 5.5 --- ...L55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ.json | 173 ++++++++++++++++++ content/replication-hub/submit/index.md | 2 +- scripts/build_google_forms.py | 1 + 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 assets/gforms/1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ.json diff --git a/assets/gforms/1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ.json b/assets/gforms/1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ.json new file mode 100644 index 00000000000..f7e8d35f2fe --- /dev/null +++ b/assets/gforms/1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ.json @@ -0,0 +1,173 @@ +{ + "id": "1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ", + "title": "Submit Replication or Reproduction Study to FLoRA", + "description": "Please use this form if you would like to submit a reproduction or replication study in a brief and semi-structured format.
When can a study be considered to be a reproduction?
The study is assigned to one original study that tested at least one same hypothesis.
The study uses the same dataset as the original study.
When can a study be considered to be a replication?
The study is assigned to one original study that tested at least one same hypothesis.
The study tries to mirror the methods of the original study and justify deviations
Replicated and reported tests use data that differ from the data used in the original study.

Is this form for references, studies, or findings?
In this form, we ask you to enter references that include at least one replication or reproduction. You can indicate how many studies are included in the reference. Specifically, we are looking for unique pairs of 'original study + replication study'.

Will I become a contributor to the FORRT Library of Reproduction and Replication Attempts (FLoRA) by using this form?
You need to submit at least five new and correct entries via this form and write an email to lukas.roeseler@uni-muenster.de if you would like to be listed as a contributor to the FORRT Replication Database.

How long does it take for my entry to be added to the FORRT Replication Database?
As of spring 2026, the database is undergoing major expansion. Time for addition may range from one week to multiple months. Please send us an email if you want to learn about the status of your submission.", + "confirmation": "Your response has been recorded.", + "collect_email": false, + "items": [ + { + "type": "text", + "title": "This form is part of the FORRT Replication Hub. For more info send an e-mail to Lukas Röseler." + }, + { + "type": "radio", + "entry": "737171809", + "title": "I have read the instructions and confirm that this study is not already listed in FLoRA. For this, I have searched for it via the Replication Atlas.", + "help": "", + "required": true, + "options": [ + "I confirm." + ] + }, + { + "type": "radio", + "entry": "595177222", + "title": "Type of \"Repetition\" Study", + "help": "", + "required": true, + "options": [ + "Replication (different data)", + "Reproduction (same data)", + "Both" + ] + }, + { + "type": "radio", + "entry": "1677363533", + "title": "Type of Replication Reference (must be a complete and citable study, i.e., no preregistration, no email exchange, no published data without report; if there are multiple replication studies of the same target study in a paper, please try to code what the authors say about each individual study with one filled-out form per study)", + "help": "", + "required": true, + "other": true, + "options": [ + "Individual Study (i.e., one paper with one study)", + "Multiple Studies (i.e., one paper with multiple studies)", + "Multilab Replication", + "Results only (i.e., there is no paper with a thorough description of the study)" + ] + }, + { + "type": "radio", + "entry": "1334392718", + "title": "Meta Paper: For a replication reference that includes multiple studies: Are all studies on the same topic or does it include unrelated replications/reproductions (e.g., Open Science Collaboration, 2015 includes many unrelated studies). For example, a paper reporting replications of two different original papers would not be considered a meta paper.", + "help": "", + "required": true, + "options": [ + "Does not apply (single-study report)", + "All studies are on the same topic", + "Studies are not all on the same topic" + ] + }, + { + "type": "short", + "entry": "1001824025", + "title": "Field (e.g., Psychology, Management Science, ...)", + "help": "", + "required": false + }, + { + "type": "short", + "entry": "1957272128", + "title": "Description (e.g., \"cascade effect (eye tracking) \", \"red romance effect\", \"people are more sensitive to the dosage of harm-based transgressions than purity transgressions\")", + "help": "", + "required": true + }, + { + "type": "paragraph", + "entry": "355822122", + "title": "Reference - Original in APA format with DOI", + "help": "", + "required": true + }, + { + "type": "paragraph", + "entry": "2125624621", + "title": "Reference - Replication in APA format with DOI
If your submission is referring to a study included in a meta-paper that is not also published as a stand-alone report (e.g., Open Science Collaboration, 2015), please paste here the reference to the meta-paper.", + "help": "", + "required": true + }, + { + "type": "short", + "entry": "2047756561", + "title": "Report URL - Replication
If your submission is referring to a study included in a meta-paper OR if your reference has not been assigned a DOI please put here the (stable) URL to the individual report.", + "help": "", + "required": false + }, + { + "type": "radio", + "entry": "46854000", + "title": "Current Review Status of the Replication", + "help": "", + "required": false, + "other": true, + "options": [ + "Peer-reviewed (published in a journal)", + "Peer-reviewed (independent community such as PCI)", + "Thesis", + "Not peer-reviewed (e.g., preprint)" + ] + }, + { + "type": "radio", + "entry": "748965106", + "title": "Replication outcome as reported by the replication authors (please select)", + "help": "", + "required": true, + "options": [ + "Success", + "Failure", + "Mixed", + "Uninformative (should is coded if the replication authors explicitly say so, e.g., because their sample was too small)", + "Statistically successful but flawed (refers to replications where that is the main message [e.g., “we replicated x using the original methods, but show that they are not a valid test of the hypotheses”])", + "Descriptive / not applicable (when consistency with original is not of interest, e.g. for some qualitative replications)", + "Does not apply because it is a reproduction [please fill out next question]" + ] + }, + { + "type": "radio", + "entry": "1895061627", + "title": "Reproduction outcome as reported by th reproduction authors (please select)", + "help": "", + "required": true, + "options": [ + "computationally successful, robust", + "computationally successful, robustness challenges", + "computationally successful, robustness not checked", + "computational issues, robust", + "computational issues, robustness challenges", + "computational issues, robustness not checked", + "computation not checked, robust", + "computation not checked, robustness challenges", + "computation not checked, robustness not checked", + "Does not apply because it is a reproduction [please fill out previous question]" + ] + }, + { + "type": "paragraph", + "entry": "2141826125", + "title": "Replication abstract
Paste abstract from the replication study here. Note that this will not be part of the published dataset.", + "help": "", + "required": true + }, + { + "type": "short", + "entry": "1231534344", + "title": "Outcome quote
Copy the part from the replication abstract or text that describes the replication outcome, if there is no phrase in the abstract, check conclusion > discussion > results).", + "help": "", + "required": true + }, + { + "type": "short", + "entry": "706143012", + "title": "Outcome page number (location of the quote, e.g., \"abstract\", \"p. 2\")", + "help": "", + "required": true + }, + { + "type": "short", + "entry": "1126723589", + "title": "Contributor (first & last name and email address, only required if you would like to become a contributor)", + "help": "", + "required": false + } + ] +} diff --git a/content/replication-hub/submit/index.md b/content/replication-hub/submit/index.md index 5009d897a6d..2bae0f61630 100644 --- a/content/replication-hub/submit/index.md +++ b/content/replication-hub/submit/index.md @@ -14,4 +14,4 @@ If you want to check if a replication study is already included in the database, the easiest way is to use the References Annotator -{{< click_to_load src="https://docs.google.com/forms/d/e/1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ/viewform" provider="Google" label="This document" width="100%" height="800px" >}} +{{< gform src="1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ" heading="false" >}} diff --git a/scripts/build_google_forms.py b/scripts/build_google_forms.py index 3a858d8f84b..86d1a558f5c 100644 --- a/scripts/build_google_forms.py +++ b/scripts/build_google_forms.py @@ -32,6 +32,7 @@ "resources": "1FAIpQLSfPceN5opEeauCBSvapoB-ADpH0IoT24XOLfQGaVEF0EJGFOA", "lesson plans feedback": "1FAIpQLSckPkeCR6_hsmxqV9yQ66oLgLOhnnHBrk4ejgIBTsOQ0mZ6gg", "anonymous feedback": "1FAIpQLSebwqYgFmH3QJIMtPFUhuKeU1Rdbz5WqwP8iXd2cUPgZvUHRg", + "FLoRA submission": "1FAIpQLSeMCwdtP0TPgL55stniuyyTxnNwyC34mO4VUuLcQwYrLI89sQ", } OUTPUT_DIR = Path(__file__).resolve().parent.parent / "assets" / "gforms" From e4513734b428bb276401d1256e4f79abf9326180 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:31:15 +0000 Subject: [PATCH 3/6] Limit the Google Forms check's write access to code on main Also compare form IDs, catch iframe embeds and clarify which forms load on request. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/README.md | 2 +- .github/workflows/google-forms-check.yml | 28 ++++++++++++++++++++---- content/privacy.md | 2 +- scripts/build_google_forms.py | 2 +- scripts/check_seo_html.py | 2 +- scripts/tests/test_build_google_forms.py | 13 +++++++++-- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 956e96685a9..ac5321cebf8 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -78,7 +78,7 @@ Triggers `deploy.yaml` after successful processing via `repository_dispatch`. ## Quality Checks -### [google-forms-check.yml](workflows/google-forms-check.yml) +### [google-forms-check.yml](google-forms-check.yml) **Keeps the site's forms in step with Google** | Trigger | Action | diff --git a/.github/workflows/google-forms-check.yml b/.github/workflows/google-forms-check.yml index cfad997b743..22305dd6d8c 100644 --- a/.github/workflows/google-forms-check.yml +++ b/.github/workflows/google-forms-check.yml @@ -27,7 +27,27 @@ env: SYNC_BRANCH: google-forms-sync jobs: - check: + # Runs code from the pull request, so it gets no write access and no secrets. + verify: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.12' + + - name: Compare the definitions with the live forms + run: python3 scripts/build_google_forms.py --check + + # Runs only the code on main, because it holds a token that can write to the repository. + sync: + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest permissions: contents: write @@ -55,7 +75,7 @@ jobs: - name: Propose updated definitions id: propose - if: steps.compare.outputs.code == '1' && github.event_name != 'pull_request' + if: steps.compare.outputs.code == '1' continue-on-error: true # The issue below must still be opened. env: GH_TOKEN: ${{ secrets.FORRT_PAT || github.token }} @@ -80,7 +100,7 @@ jobs: echo "url=$url" >> "$GITHUB_OUTPUT" - name: Report the change in an issue - if: steps.compare.outputs.code == '1' && github.event_name != 'pull_request' + if: steps.compare.outputs.code == '1' env: GH_TOKEN: ${{ github.token }} PR_URL: ${{ steps.propose.outputs.url }} @@ -106,7 +126,7 @@ jobs: fi - name: Close the issue once the forms match - if: steps.compare.outputs.code == '0' && github.event_name != 'pull_request' + if: steps.compare.outputs.code == '0' env: GH_TOKEN: ${{ github.token }} run: | diff --git a/content/privacy.md b/content/privacy.md index 277e728c8be..049c918677e 100644 --- a/content/privacy.md +++ b/content/privacy.md @@ -65,7 +65,7 @@ If you decline or do not choose, Google Analytics does not load. ## Embedded content {#embedded-content} -Other services, some of them in the USA, host our videos, forms, calendars and some teaching activities. Each one shows a placeholder until you select **Load**, or a thumbnail until you press play. Your click is your consent for that item on that page view (Art. 6(1)(a) GDPR). Once it loads, the provider receives your IP address and browser data, may set cookies, and handles the data under its own privacy policy. +Other services, some of them in the USA, host our videos, calendars and some of our forms and teaching activities. Each one shows a placeholder until you select **Load**, or a thumbnail until you press play. Your click is your consent for that item on that page view (Art. 6(1)(a) GDPR). Once it loads, the provider receives your IP address and browser data, may set cookies, and handles the data under its own privacy policy. | Provider | Content | |---|---| diff --git a/scripts/build_google_forms.py b/scripts/build_google_forms.py index 86d1a558f5c..698e115f14a 100644 --- a/scripts/build_google_forms.py +++ b/scripts/build_google_forms.py @@ -203,7 +203,7 @@ def differences(saved, live): """List what differs between a saved definition and the live form.""" if saved is None: return ["no saved definition"] - changes = [f"{key} changed" for key in ("title", "description", "confirmation", "collect_email") + changes = [f"{key} changed" for key in ("id", "title", "description", "confirmation", "collect_email") if saved.get(key) != live.get(key)] old = {question.get("entry", question["title"]): question for question in saved["items"]} new = {question.get("entry", question["title"]): question for question in live["items"]} diff --git a/scripts/check_seo_html.py b/scripts/check_seo_html.py index 159695a99a3..06af897cec7 100644 --- a/scripts/check_seo_html.py +++ b/scripts/check_seo_html.py @@ -418,7 +418,7 @@ def check_native_google_forms(public_dir, form_ids): with open(path, encoding="utf-8", errors="replace") as handle: text = handle.read() for form_id in form_ids: - if 'data-embed-src="https://docs.google.com/forms/d/e/%s/' % form_id in text: + if 'src="https://docs.google.com/forms/d/e/%s/' % form_id in text: problems.append("%s embeds %s" % (os.path.relpath(path, public_dir), form_id)) return problems diff --git a/scripts/tests/test_build_google_forms.py b/scripts/tests/test_build_google_forms.py index 488ee00cf04..6687dd19d78 100644 --- a/scripts/tests/test_build_google_forms.py +++ b/scripts/tests/test_build_google_forms.py @@ -90,6 +90,10 @@ def test_new_question_is_named(self): self.live["items"].append({"type": "short", "entry": "5", "title": "New one", "required": True}) self.assertEqual(forms.differences(self.saved, self.live), ["question added: New one"]) + def test_definition_for_another_form_is_reported(self): + self.live["id"] = "other" + self.assertEqual(forms.differences(self.saved, self.live), ["id changed"]) + def test_email_collection_is_reported(self): self.live["collect_email"] = True self.assertEqual(forms.differences(self.saved, self.live), ["collect_email changed"]) @@ -122,8 +126,13 @@ def test_native_form_passes(self): self.assertEqual(self.failures(''), []) def test_embedded_form_fails(self): - html = '
' - self.assertEqual(len(self.failures(html)), 1) + for attribute in ("data-embed-src", "src"): + with self.subTest(attribute): + html = '
' % attribute + self.assertEqual(len(self.failures(html)), 1) + + def test_link_to_the_google_form_passes(self): + self.assertEqual(self.failures('Open'), []) if __name__ == "__main__": From 2b9e87dbaf72653ddbea8e878e82db236320d8e8 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:33:29 +0000 Subject: [PATCH 4/6] Time out stalled form submissions and send answers as typed Co-Authored-By: Claude Opus 5.5 --- content/privacy.md | 4 ++-- static/js/google-form.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/privacy.md b/content/privacy.md index 049c918677e..1604e9382f2 100644 --- a/content/privacy.md +++ b/content/privacy.md @@ -1,10 +1,10 @@ --- title: Privacy policy date: 2026-11-03 -lastmod: 2026-11-11 +lastmod: 2026-11-18 --- -*Last updated: 11 November 2026* +*Last updated: 18 November 2026* This policy explains what happens to personal data when you use forrt.org, why, and what rights you have. diff --git a/static/js/google-form.js b/static/js/google-form.js index eab4184f383..72d168880a0 100644 --- a/static/js/google-form.js +++ b/static/js/google-form.js @@ -48,13 +48,12 @@ const answers = () => { const data = new URLSearchParams(); new FormData(form).forEach((value, name) => { - const text = value.trim(); - if (!text) return; + if (!value.trim()) return; if (name.endsWith('.other_option_response')) { const choice = form.querySelector(`input[name="${name.replace('.other_option_response', '')}"][value="${OTHER}"]`); if (!choice.checked) return; } - data.append(name, text); + data.append(name, value); }); return data; }; @@ -69,6 +68,7 @@ try { await fetch(form.action, { method: 'POST', mode: 'no-cors', credentials: 'omit', referrerPolicy: 'no-referrer', body: answers(), + signal: AbortSignal.timeout(60000), }); body.hidden = true; status.textContent = form.dataset.gformConfirmation; From abba8c010b0eac07d368d123ee2cbe8f304b56a8 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:42:33 +0000 Subject: [PATCH 5/6] Check the Google Forms weekly as part of the link check A changed form now raises an issue, replacing the hourly workflow and its automatic pull request. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/README.md | 13 +-- .github/workflows/google-forms-check.yml | 140 ----------------------- .github/workflows/link-check.yaml | 54 ++++++++- scripts/build_google_forms.py | 4 +- 4 files changed, 60 insertions(+), 151 deletions(-) delete mode 100644 .github/workflows/google-forms-check.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md index ac5321cebf8..8ea32dde861 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -78,15 +78,14 @@ Triggers `deploy.yaml` after successful processing via `repository_dispatch`. ## Quality Checks -### [google-forms-check.yml](google-forms-check.yml) -**Keeps the site's forms in step with Google** +### [link-check.yaml](link-check.yaml) +**Weekly link check, and a check that the site's forms match Google** -| Trigger | Action | -|---------|--------| -| Hourly schedule, manual dispatch | Compares `assets/gforms/` with the live Google Forms | -| PR touching the definitions or this check | Runs the same comparison | +| Trigger | Runs on | +|---------|---------| +| Mondays at 01:30 UTC, manual dispatch | `main` | -If a form has changed, the scheduled run opens a pull request with the updated definitions and one issue assigned to the site maintainer. Merge that pull request promptly, because Google may discard responses sent from the site until then. The issue closes itself once the definitions match again. +Besides checking links, it compares `assets/gforms/` with the live Google Forms. If a form has changed, it opens an issue assigned to the site maintainer. Fix it promptly by running `python3 scripts/build_google_forms.py` and committing the result, because Google may discard responses sent from the site until then. The issue closes itself once the definitions match again. ### [spell-check.yaml](workflows/spell-check.yaml) **Spelling validation using codespell** diff --git a/.github/workflows/google-forms-check.yml b/.github/workflows/google-forms-check.yml deleted file mode 100644 index 22305dd6d8c..00000000000 --- a/.github/workflows/google-forms-check.yml +++ /dev/null @@ -1,140 +0,0 @@ -name: Google Forms Check - -# ======================= -# Keep the site's forms in step with Google -# ======================= -# Purpose: The site posts answers to the Google Forms in assets/gforms/ without seeing Google's -# reply, so a form edited in Google can lose responses unnoticed. -# Triggers: Hourly, manual dispatch, and pull requests that touch the definitions or this check -# Reports: Opens one issue and a pull request with the updated definitions, and closes the issue -# once the definitions match again - -on: - schedule: - - cron: '17 * * * *' - workflow_dispatch: - pull_request: - paths: - - 'assets/gforms/**' - - 'scripts/build_google_forms.py' - - '.github/workflows/google-forms-check.yml' - -permissions: - contents: read - -env: - ISSUE_TITLE: A Google Form on forrt.org has changed - SYNC_BRANCH: google-forms-sync - -jobs: - # Runs code from the pull request, so it gets no write access and no secrets. - verify: - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.12' - - - name: Compare the definitions with the live forms - run: python3 scripts/build_google_forms.py --check - - # Runs only the code on main, because it holds a token that can write to the repository. - sync: - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - permissions: - contents: write - issues: write - pull-requests: write - - steps: - - name: Checkout repository - uses: actions/checkout@v6 - with: - # A pull request opened with the default token would not start the other checks. - token: ${{ secrets.FORRT_PAT || github.token }} - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.12' - - - name: Compare the definitions with the live forms - id: compare - run: | - set +e - python3 scripts/build_google_forms.py --check 2>&1 | tee check-output.txt - echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT" - - - name: Propose updated definitions - id: propose - if: steps.compare.outputs.code == '1' - continue-on-error: true # The issue below must still be opened. - env: - GH_TOKEN: ${{ secrets.FORRT_PAT || github.token }} - run: | - # Writes nothing if a form can no longer be reproduced; the issue then reports why. - python3 scripts/build_google_forms.py || true - if [ -z "$(git status --porcelain -- assets/gforms)" ]; then - exit 0 - fi - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git switch -C "$SYNC_BRANCH" - git add assets/gforms - git commit -m "Update Google Form definitions" - git push --force origin "$SYNC_BRANCH" - url=$(gh pr list --head "$SYNC_BRANCH" --state open --json url --jq '.[0].url // empty') - if [ -z "$url" ]; then - url=$(gh pr create --base main --head "$SYNC_BRANCH" \ - --title "Update Google Form definitions" \ - --body "A Google Form shown on forrt.org changed. This updates the site's copy to match. Merge it soon: until then, Google may discard responses sent from the site.") - fi - echo "url=$url" >> "$GITHUB_OUTPUT" - - - name: Report the change in an issue - if: steps.compare.outputs.code == '1' - env: - GH_TOKEN: ${{ github.token }} - PR_URL: ${{ steps.propose.outputs.url }} - run: | - { - echo "A Google Form shown on forrt.org no longer matches the copy the site uses. Until this is fixed, Google may discard responses sent from the site, and visitors are not told." - echo - echo '```' - cat check-output.txt - echo '```' - echo - if [ -n "$PR_URL" ]; then - echo "**To fix:** review and merge $PR_URL." - else - echo "**To fix:** the site cannot reproduce this form automatically. Undo the change in Google, or update \`scripts/build_google_forms.py\` and \`layouts/partials/google_form.html\`." - fi - } > issue-body.md - number=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') - if [ -n "$number" ]; then - gh issue edit "$number" --body-file issue-body.md - else - gh issue create --title "$ISSUE_TITLE" --body-file issue-body.md --assignee LukasWallrich - fi - - - name: Close the issue once the forms match - if: steps.compare.outputs.code == '0' - env: - GH_TOKEN: ${{ github.token }} - run: | - number=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') - if [ -n "$number" ]; then - gh issue close "$number" --comment "The site's copy matches the live forms again." - fi - - - name: Fail the run unless the forms match - if: steps.compare.outputs.code != '0' - run: exit 1 diff --git a/.github/workflows/link-check.yaml b/.github/workflows/link-check.yaml index 92f1e9386bd..a3c45610b29 100644 --- a/.github/workflows/link-check.yaml +++ b/.github/workflows/link-check.yaml @@ -3,9 +3,11 @@ name: Link Checker # ======================= # Website Link Validation # ======================= -# Purpose: Downloads the latest built site and checks all links (internal + external) +# Purpose: Downloads the latest built site and checks all links (internal + external), and +# compares the site's copies of Google Forms (assets/gforms/) with the live forms # Triggers: Weekly on Mondays at 01:30 UTC or manual dispatch -# Reports: Updates the existing open "link-check"-labeled issue (or creates one if none exists) +# Reports: Updates the existing open "link-check"-labeled issue (or creates one if none exists). +# A changed Google Form gets its own issue, which closes once the copies match again # Config: See .lychee.toml for exclusion patterns and request settings on: @@ -494,3 +496,51 @@ jobs: gh issue create --title "$TITLE" --body-file "$BODY_FILE" --label link-check fi + google-forms: + name: Check Google Forms + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + ISSUE_TITLE: A Google Form on forrt.org has changed + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Compare the site's forms with the live Google Forms + id: compare + run: | + set +e + python3 scripts/build_google_forms.py --check 2>&1 | tee /tmp/google-forms.txt + echo "code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT" + + - name: Create or update the issue + if: steps.compare.outputs.code == '1' + run: | + { + echo "A Google Form shown on forrt.org no longer matches the copy the site uses. Until this is fixed, Google may discard responses sent from the site, and visitors are not told." + echo + echo '```' + cat /tmp/google-forms.txt + echo '```' + echo + echo "**To fix:** run \`python3 scripts/build_google_forms.py\` and commit the result. If it stops with an error, the site cannot reproduce the change: undo it in Google or update \`layouts/partials/google_form.html\`." + } > /tmp/google-forms-issue.md + EXISTING=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') + if [ -n "$EXISTING" ]; then + gh issue edit "$EXISTING" --body-file /tmp/google-forms-issue.md + else + gh issue create --title "$ISSUE_TITLE" --body-file /tmp/google-forms-issue.md --assignee LukasWallrich + fi + + - name: Close the issue once the forms match + if: steps.compare.outputs.code == '0' + run: | + EXISTING=$(gh issue list --state open --search "\"$ISSUE_TITLE\" in:title" --json number --jq '.[0].number // empty') + if [ -n "$EXISTING" ]; then + gh issue close "$EXISTING" --comment "The site's copy matches the live forms again." + fi + + - name: Fail the run if Google could not be reached + if: steps.compare.outputs.code == '2' + run: exit 1 diff --git a/scripts/build_google_forms.py b/scripts/build_google_forms.py index 698e115f14a..bbfe23959e3 100644 --- a/scripts/build_google_forms.py +++ b/scripts/build_google_forms.py @@ -12,8 +12,8 @@ feature the site's form does not reproduce (sections, branching, answer validation, other question types) rather than writing a definition that would lose responses. -.github/workflows/google-forms-check.yml runs --check every hour. It exits 1 if a form has changed -or can no longer be reproduced, and 2 if Google could not be reached. +.github/workflows/link-check.yaml runs --check every Monday and opens an issue if a form differs. +It exits 1 if a form has changed or can no longer be reproduced, and 2 if Google could not be reached. """ import html From 52f87211b4bb5c7707d02b262fc249e53a63ef47 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 18 Nov 2026 17:50:16 +0000 Subject: [PATCH 6/6] Fail the form check on any unexpected exit code Co-Authored-By: Claude Opus 5.5 --- .github/workflows/README.md | 2 +- .github/workflows/link-check.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 8ea32dde861..3fc63feb729 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -85,7 +85,7 @@ Triggers `deploy.yaml` after successful processing via `repository_dispatch`. |---------|---------| | Mondays at 01:30 UTC, manual dispatch | `main` | -Besides checking links, it compares `assets/gforms/` with the live Google Forms. If a form has changed, it opens an issue assigned to the site maintainer. Fix it promptly by running `python3 scripts/build_google_forms.py` and committing the result, because Google may discard responses sent from the site until then. The issue closes itself once the definitions match again. +Besides checking links, it compares `assets/gforms/` with the live Google Forms. If a form has changed, it opens an issue assigned to the site maintainer. Fix it promptly by running `python3 scripts/build_google_forms.py` and committing the result, because Google may discard responses sent from the site until then. If the script stops with an error, the site cannot reproduce the change: undo it in Google or update `layouts/partials/google_form.html`. The issue closes itself once the definitions match again. ### [spell-check.yaml](workflows/spell-check.yaml) **Spelling validation using codespell** diff --git a/.github/workflows/link-check.yaml b/.github/workflows/link-check.yaml index a3c45610b29..c69d7939388 100644 --- a/.github/workflows/link-check.yaml +++ b/.github/workflows/link-check.yaml @@ -541,6 +541,6 @@ jobs: gh issue close "$EXISTING" --comment "The site's copy matches the live forms again." fi - - name: Fail the run if Google could not be reached - if: steps.compare.outputs.code == '2' + - name: Fail the run if the comparison could not finish + if: steps.compare.outputs.code != '0' && steps.compare.outputs.code != '1' run: exit 1