Skip to content

Commit 1b6c462

Browse files
Merge pull request #2 from DS-100/a11y-fixes
Fix Accessibility Violations
2 parents 025aa5e + 8d388d7 commit 1b6c462

32 files changed

+1393
-837
lines changed

.github/workflows/a11y.yml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,25 @@ on:
66

77
env:
88
PRODUCTION_URL: "https://ds100.org/debugging-guide/"
9-
# must match the end of PRODUCTION_URL
10-
# leave blank if at root
119
SITE_SUBDIR: "debugging-guide"
1210

1311
jobs:
1412
axe-audit:
1513
runs-on: ubuntu-latest
1614

1715
steps:
18-
# 1. Checkout Code
1916
- name: Checkout repository
2017
uses: actions/checkout@v4
2118

22-
# 2. Setup Quarto with TinyTex
23-
- name: Set up Quarto
24-
uses: quarto-dev/quarto-actions/setup@v2
25-
env:
26-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
with:
28-
tinytex: true
29-
30-
# 3. Setup Node.js (for Axe and http-server)
19+
# Setup Node.js and install Axe and http-server
3120
- name: Set up Node.js
3221
uses: actions/setup-node@v4
3322
with:
3423
node-version: '20'
35-
36-
# 4. Setup Python
37-
- name: Set up Python
38-
uses: actions/setup-python@v4
39-
with:
40-
python-version: '3.11.9'
41-
cache: 'pip'
42-
43-
# 5. Install Python dependencies
44-
- name: Install Python dependencies
45-
run: pip install -r requirements.txt
46-
47-
# 6. Render the Site
48-
- name: Render Quarto Site
49-
run: quarto render
50-
51-
# 7. Install Tools
5224
- name: Install Axe and Server
5325
run: npm install -g @axe-core/cli http-server
5426

55-
# 8. Start Local Server (Background Process)
27+
# Start Local Server
5628
- name: Start Local Server
5729
run: |
5830
# Mimic the production path structure exactly with
@@ -65,7 +37,7 @@ jobs:
6537
6638
sleep 5
6739
68-
# 9. Run Axe Scan
40+
# Run Axe Scan
6941
- name: Run Accessibility Scan
7042
id: axe-scan
7143
run: |
@@ -86,7 +58,7 @@ jobs:
8658
--save axe-report.json \
8759
--exit
8860
89-
# 10. Upload Report (Runs even if previous step fails)
61+
# Upload Report even if previous step fails
9062
- name: Upload Accessibility Report
9163
if: always()
9264
uses: actions/upload-artifact@v4

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Debugging Guide
22

3-
[![Accessibility Checks](https://github.com/DS-100/debugging-guide/actions/workflows/a11y.yml/badge.svg)](https://github.com/DS-100/debugging-guide/actions/workflows/a11y.yml)
3+
[![pages-build-deployment](https://github.com/DS-100/debugging-guide/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/DS-100/debugging-guide/actions/workflows/pages/pages-build-deployment) [![Accessibility Checks](https://github.com/DS-100/debugging-guide/actions/workflows/a11y.yml/badge.svg)](https://github.com/DS-100/debugging-guide/actions/workflows/a11y.yml)
44

55
Website link: https://ds100.org/debugging-guide/
66

@@ -42,7 +42,7 @@ pip3 install -r requirements.txt # will take a while
4242
ipython kernel install --user
4343
```
4444

45-
If you get an `error: externally-managed-environment` on the third line, run `pip3 install -r requirements.txt --break-system-packages`
45+
If you get an `error: externally-managed-environment` on the third line, run `pip3 install -r requirements.txt --break-system-packages`. You may also run into issues if you're running on Apple silicon. I fixed this by running `conda install -c conda-forge scikit-learn==1.2.2 scikit-image==0.25.2` before `pip3 install -r requirements.txt`.
4646

4747
Remember to always activate the right environment before running anything with `conda activate data100quarto`.
4848

@@ -95,9 +95,11 @@ A pdf view of how this notebook renders in Quarto can be found [here](https://dr
9595

9696
To give you the most control when inserting images, we use html with the following format to center images/figs and control their size:
9797

98-
```<center><img src = "IMAGE_NAME" width = "IMAGE_WIDTH_IN_PIXELS"></img></a></center>```
98+
```<center><img src = "IMAGE_NAME" width = "IMAGE_WIDTH_IN_PIXELS" alt="alt text here"></img></a></center>```
9999

100-
For example, `<center><img src = "images/updated_basic.png" width = "700"></img></a></center>`.
100+
For example, `<center><img src = "images/updated_basic.png" width = "700" alt="description of image"></img></a></center>`.
101+
102+
In some instances, the images may be completely described in the text of the page. In these cases, you may leave the alt text blank i.e. `alt=""`. BUT THE ALT TEXT MUST STILL BE INCLUDED.
101103

102104

103105
## Generating Output + Rendering Website

_quarto.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
11
project:
2-
type: book
2+
type: website
33
output-dir: docs
44

5-
book:
5+
website:
66
site-url: "https://ds100.org/debugging-guide/"
7+
page-footer:
8+
center:
9+
- text: Accessibility
10+
href: "https://dap.berkeley.edu/get-help/report-web-accessibility-issue"
11+
- text: Nondiscrimination
12+
href: "https://ophd.berkeley.edu/policies-and-procedures/nondiscrimination-policy-statement"
713
favicon: data100_logo.png
814
title: "Data 100 Debugging Guide"
915
image: data100_logo.png
10-
author: ["Yash Dave", "Lillian Weng", "Wesley Zheng", "Emrie Loh"]
1116
repo-url: https://github.com/DS-100/debugging-guide
1217
search:
1318
location: sidebar
1419
type: textbox
15-
chapters:
16-
- index.md
17-
- jupyter101/jupyter101.md
18-
- jupyter_datahub/jupyter_datahub.md
19-
- autograder_gradescope/autograder_gradescope.md
20-
- pandas/pandas.md
21-
- regex/regex.md
22-
- visualizations/visualizations.md
23-
- projA1/projA1.md
24-
- projA2/projA2.md
25-
- sql/sql.md
26-
2720
sidebar:
2821
logo: "data100_logo.png"
22+
style: "docked"
23+
title: "Data 100 Debugging Guide"
24+
logo-alt: "Data 100 logo"
25+
tools:
26+
- icon: github
27+
href: https://github.com/DS-100/debugging-guide
28+
contents:
29+
- index.md
30+
- jupyter101/jupyter101.md
31+
- jupyter_datahub/jupyter_datahub.md
32+
- autograder_gradescope/autograder_gradescope.md
33+
- pandas/pandas.md
34+
- regex/regex.md
35+
- visualizations/visualizations.md
36+
- projA1/projA1.md
37+
- projA2/projA2.md
38+
- sql/sql.md
2939
format:
3040
html:
31-
theme: cosmo
41+
theme: cosmos
3242
toc: true
3343
toc-depth: 5
3444
toc-expand: 3 # depth to expand index
3545
callout-icon: false
3646
number-sections: false
37-
pdf: default
38-
# navbar:
39-
# search: false
40-
# right:
41-
# - icon: github
42-
# href: https://github.com/
43-
# aria-label: GitHub
44-
# - icon: arrows-fullscreen
47+
include-after-body:
48+
- a11y-fixes.html

a11y-fixes.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script>
2+
document.addEventListener("DOMContentLoaded", function() {
3+
// 1. Select the specific parent div within the callout header that has the
4+
// collapse attributes (data-bs-toggle).
5+
var calloutToggles = document.querySelectorAll(
6+
'.callout-header[data-bs-toggle="collapse"]'
7+
);
8+
9+
calloutToggles.forEach(function(toggle) {
10+
// 2. Force the ARIA role to be 'button'
11+
// This is crucial because a 'div' is not allowed to use aria-expanded.
12+
toggle.setAttribute('role', 'button');
13+
14+
// 3. Ensure it is keyboard-focusable (critical accessibility fix)
15+
if (toggle.getAttribute('tabindex') === null) {
16+
toggle.setAttribute('tabindex', '0');
17+
}
18+
});
19+
20+
// Scrollable Region Accessibility Fix:
21+
// Target ALL <pre> elements, as they are the source of the scrollable-region-focusable errors.
22+
var scrollableRegions = document.querySelectorAll('pre');
23+
24+
scrollableRegions.forEach(function(region) {
25+
// Check if the element has horizontal overflow (is scrollable).
26+
const hasScrollbar = region.scrollWidth > region.clientWidth || region.scrollHeight > region.clientHeight;
27+
28+
if (hasScrollbar) {
29+
// If it is scrollable AND it doesn't already have tabindex="0" (or a different value)
30+
if (region.getAttribute('tabindex') === null || region.getAttribute('tabindex') === undefined) {
31+
region.setAttribute('tabindex', '0');
32+
}
33+
}
34+
});
35+
});
36+
</script>

autograder_gradescope/autograder_gradescope.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
title: Autograder and Gradescope / Pensieve
33
format:
44
html:
5-
toc: true
6-
toc-depth: 5
75
toc-location: right
86
code-fold: false
9-
theme:
10-
- cosmo
11-
- cerulean
12-
callout-icon: false
137
jupyter:
148
jupytext:
159
text_representation:
@@ -34,16 +28,16 @@ jupyter:
3428

3529
When you pass a test, you'll see a nice message and a cute emoji!
3630

37-
<center><img src = "passing_autograder.png" width = "200"></img></a></center>
31+
<center><img src = "passing_autograder.png" width = "200" alt="Screenshot of a grader cell for question q2a with cell ouput 'q2a passed'"></img></a></center>
3832

3933
When you don't, however, the message can be a little confusing.
4034

41-
<center><img src = "autograder_error.png" width = "600"></img></a></center>
35+
<center><img src = "autograder_error.png" width = "600" alt="Example of a cell output for a failing autograder test showing what test failed, what the code that was evaluated was, the expected output, and an error that was raised during the course of the test."></img></a></center>
4236
<br>
4337

4438
The best course of action is to find the test case that failed and use that as a starting point to debug your code.
4539

46-
<center><img src = "autograder_error_annot.png" width = "700"></img></a></center>
40+
<center><img src = "autograder_error_annot.png" width = "700" alt="An annotated version of the previous image which includes the note 'The most useful error message is usually at the bottom'"></img></a></center>
4741

4842
In the example above, we see that the test case in green, `max_swing in set(bus['name'])`, is not passing. The actual output (in blue) is often hard to parse, so the best course of action is to:
4943

@@ -100,11 +94,11 @@ This can happen if you import external packages when you are not instructed to d
10094

10195
If your Gradescope submission page has been stuck running on this page for a while:
10296

103-
<center><img src = "gradescope_loading.png" width = "350"></img></a></center>
97+
<center><img src = "gradescope_loading.png" width = "350" alt="Autograder Results. The autograder hasn't finish running yet."></img></a></center>
10498

10599
or if it times out:
106100

107-
<center><img src = "gradescope_timeout.png" width = "650"></img></a></center>
101+
<center><img src = "gradescope_timeout.png" width = "650" alt="Autograder Results. In a red box 'The autograder failed to respond in the expected amount of time. If the autograder continues to fail, contact your course staff for help in debugging this issue. Make sure to include a link to this page so they can help you most effectively.'"></img></a></center>
108102

109103
it means that the Gradescope autograder failed to execute in the expected amount of time. TThis could be due to an inefficiency in your code or an issue on Gradescope's end, so we recommend resubmitting and allowing the autograder to rerun. If the issue persists after a few attempts, you may need to investigate your code for inefficiencies.
110104

docs/Data-100-Debugging-Guide.pdf

-155 KB
Binary file not shown.

0 commit comments

Comments
 (0)