Skip to content

Commit 72b68af

Browse files
authored
Merge pull request #87 from DeepBlueCLtd/010-css-answer-hiding
010 css answer hiding
2 parents b9cb873 + d0afe80 commit 72b68af

13 files changed

Lines changed: 721 additions & 11 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ function getStorageKey(release: ReleaseId, serviceId: ServiceId): string {
555555
- N/A (no data persistence - content from DITA config only) (008-user-guidance-popups)
556556
- TypeScript 5.x / ES2020+ with Lit 3.0 (Web Components) + Existing IndexedDBStorageAdapter (`src/services/storage/indexeddb.ts`) (009-encrypt-stored-data)
557557
- IndexedDB (primary) - obfuscation at adapter layer; sessionStorage unchanged (009-encrypt-stored-data)
558+
- CSS3 + TypeScript 5.x (for JS integration) + Existing DITA template CSS (`f13ldman.css`), Lit 3.x components (010-css-answer-hiding)
559+
- N/A (CSS-only feature) (010-css-answer-hiding)
558560

559561
## Recent Changes
560562
- 001-security-refactor: Added TypeScript 5.x / JavaScript ES2020+ + Lit 3.0 (Web Components), Vite 5.x (build), Vitest (testing)

dita-demo/oxygen-webhelp/template/f13ldman.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,26 @@ td.interactive {
579579
* Style changes for Fi3ldMan project above this block
580580
* ==============================================
581581
*/
582+
583+
/* hide the answer and details cells in BrowserTest (td and th for complete hiding) */
584+
.qd-quiz td:nth-child(2), .qd-quiz td:nth-child(3),
585+
.qd-quiz th:nth-child(2), .qd-quiz th:nth-child(3) {
586+
visibility: hidden; /* avoids layout shift */
587+
}
588+
589+
/* Student mode: reveal answer column for input controls */
590+
.qd-quiz-interactive td:nth-child(2),
591+
.qd-quiz-interactive th:nth-child(2) {
592+
visibility: visible;
593+
}
594+
595+
/* Instructor mode: reveal both answer and detail columns */
596+
.qd-quiz-instructor td:nth-child(2), .qd-quiz-instructor td:nth-child(3),
597+
.qd-quiz-instructor th:nth-child(2), .qd-quiz-instructor th:nth-child(3) {
598+
visibility: visible;
599+
}
600+
601+
/* Instructor mode: ensure student answers display is visible (child of hidden cell) */
602+
.qd-quiz-instructor .qd-student-answers {
603+
visibility: visible;
604+
}

dita-demo/oxygen-webhelp/template/resources/sonar-quiz.iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dita-demo/oxygen-webhelp/template/resources/sonar-quiz.iife.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dita/template/f13ldman.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,26 @@ td.interactive {
579579
* Style changes for Fi3ldMan project above this block
580580
* ==============================================
581581
*/
582+
583+
/* hide the answer and details cells in BrowserTest (td and th for complete hiding) */
584+
.qd-quiz td:nth-child(2), .qd-quiz td:nth-child(3),
585+
.qd-quiz th:nth-child(2), .qd-quiz th:nth-child(3) {
586+
visibility: hidden; /* avoids layout shift */
587+
}
588+
589+
/* Student mode: reveal answer column for input controls */
590+
.qd-quiz-interactive td:nth-child(2),
591+
.qd-quiz-interactive th:nth-child(2) {
592+
visibility: visible;
593+
}
594+
595+
/* Instructor mode: reveal both answer and detail columns */
596+
.qd-quiz-instructor td:nth-child(2), .qd-quiz-instructor td:nth-child(3),
597+
.qd-quiz-instructor th:nth-child(2), .qd-quiz-instructor th:nth-child(3) {
598+
visibility: visible;
599+
}
600+
601+
/* Instructor mode: ensure student answers display is visible (child of hidden cell) */
602+
.qd-quiz-instructor .qd-student-answers {
603+
visibility: visible;
604+
}

dita/template/f13ldman_author_mode.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,25 @@
5555
}
5656

5757
[outputclass='bkGreen'] {
58-
background-color: #00ff00;
58+
background-color: #00ff00;
59+
}
60+
61+
/*
62+
* BrowserTest Quiz System - Author mode visual indicators
63+
* These help content authors see which cells have special behavior
64+
*/
65+
66+
/* Visual indicators for hidden quiz cells (answer + detail columns - hidden in production) */
67+
/* Using simpletable structure: simpletable > sthead/strow > stentry */
68+
/* NOTE: :nth-child may not work in Oxygen Author due to table structural selector limitations */
69+
simpletable[outputclass~='qd-quiz'] sthead stentry:nth-child(2),
70+
simpletable[outputclass~='qd-quiz'] strow stentry:nth-child(2),
71+
simpletable[outputclass~='qd-quiz'] sthead stentry:nth-child(3),
72+
simpletable[outputclass~='qd-quiz'] strow stentry:nth-child(3) {
73+
background-color: rgba(255, 200, 200, 0.5); /* Light red - hidden in prod */
74+
}
75+
76+
/* Visual indicators for interactive analysis cells */
77+
[outputclass='interactive'] {
78+
background-color: rgba(200, 255, 200, 0.5); /* Light green - interactive */
5979
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Specification Quality Checklist: CSS-Based Quiz Answer Hiding
2+
3+
**Purpose**: Validate specification completeness and quality before proceeding to planning
4+
**Created**: 2025-11-28
5+
**Feature**: [spec.md](../spec.md)
6+
7+
## Content Quality
8+
9+
- [x] No implementation details (languages, frameworks, APIs)
10+
- [x] Focused on user value and business needs
11+
- [x] Written for non-technical stakeholders
12+
- [x] All mandatory sections completed
13+
14+
## Requirement Completeness
15+
16+
- [x] No [NEEDS CLARIFICATION] markers remain
17+
- [x] Requirements are testable and unambiguous
18+
- [x] Success criteria are measurable
19+
- [x] Success criteria are technology-agnostic (no implementation details)
20+
- [x] All acceptance scenarios are defined
21+
- [x] Edge cases are identified
22+
- [x] Scope is clearly bounded
23+
- [x] Dependencies and assumptions identified
24+
25+
## Feature Readiness
26+
27+
- [x] All functional requirements have clear acceptance criteria
28+
- [x] User scenarios cover primary flows
29+
- [x] Feature meets measurable outcomes defined in Success Criteria
30+
- [x] No implementation details leak into specification
31+
32+
## Notes
33+
34+
- Spec is complete and ready for `/speckit.plan`
35+
- Key insight: CSS uses `visibility: hidden` to prevent layout shift
36+
- Tests may need updates to handle CSS-based initial hiding vs JS-based `qd-hidden` class
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Implementation Plan: CSS-Based Quiz Answer Hiding
2+
3+
**Branch**: `010-css-answer-hiding` | **Date**: 2025-11-28 | **Spec**: [spec.md](./spec.md)
4+
**Input**: Feature specification from `/specs/010-css-answer-hiding/spec.md`
5+
6+
## Summary
7+
8+
Hide quiz answer/detail columns via CSS before JavaScript executes, preventing answer visibility when JS is disabled or during page load. CSS already partially implemented in `f13ldman.css`. Need to add override rules for student/instructor modes and author mode visual indicators.
9+
10+
## Technical Context
11+
12+
**Language/Version**: CSS3 + TypeScript 5.x (for JS integration)
13+
**Primary Dependencies**: Existing DITA template CSS (`f13ldman.css`), Lit 3.x components
14+
**Storage**: N/A (CSS-only feature)
15+
**Testing**: Vitest (unit), Playwright (E2E)
16+
**Target Platform**: Chrome/Edge 96+, Firefox 102+ (offline, file:// protocol)
17+
**Project Type**: Single project (browser extension pattern)
18+
**Performance Goals**: No layout shift on column reveal
19+
**Constraints**: Bundle size ≤40KB, works offline from file:// URLs
20+
**Scale/Scope**: Single page quiz tables
21+
22+
## Constitution Check
23+
24+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
25+
26+
- [x] **Offline-First**: CSS loaded from local template file, no network required
27+
- [x] **Progressive Enhancement**: CSS hides by default, JS reveals when appropriate
28+
- [x] **Test-Driven Development**: Tests will verify CSS visibility behavior
29+
- [x] **Phase-Gated Delivery**: Single-phase implementation with test verification
30+
- [x] **Performance Constraints**: CSS-only, no bundle impact
31+
- [x] **Data Isolation**: N/A (no data storage)
32+
- [x] **Zero Configuration**: CSS in template file, no setup required
33+
34+
## Project Structure
35+
36+
### Documentation (this feature)
37+
38+
```text
39+
specs/010-css-answer-hiding/
40+
├── plan.md # This file
41+
├── research.md # Phase 0 output
42+
├── data-model.md # N/A - CSS-only feature
43+
├── quickstart.md # Phase 1 output
44+
├── contracts/ # N/A - no API contracts
45+
└── tasks.md # Phase 2 output (/speckit.tasks)
46+
```
47+
48+
### Source Code (repository root)
49+
50+
```text
51+
dita/template/
52+
├── f13ldman.css # Production CSS (hiding + overrides)
53+
└── f13ldman_author_mode.css # Author visual indicators
54+
55+
dita-demo/oxygen-webhelp/template/
56+
└── f13ldman.css # Demo copy (synced from dita/template)
57+
58+
src/init/
59+
└── bootstrap.ts # May need qd-quiz-instructor class
60+
61+
tests/
62+
├── integration/
63+
│ └── quiz-table.test.ts # Verify CSS visibility behavior
64+
└── e2e/
65+
└── workflows/
66+
├── dita-student-flow.spec.ts
67+
└── instructor-dynamic-reveal.spec.ts
68+
```
69+
70+
**Structure Decision**: CSS-only changes in DITA template, minimal JS changes in bootstrap.ts if needed for instructor class.
71+
72+
## Current State Analysis
73+
74+
**Already Implemented** (in `dita/template/f13ldman.css` lines 584-586):
75+
```css
76+
/* hide the answer and details cells */
77+
.qd-quiz td:nth-child(2), .qd-quiz td:nth-child(3) {
78+
visibility: hidden; /* avoids layout shift */
79+
}
80+
```
81+
82+
**Missing**:
83+
1. Header cells not hidden (th elements)
84+
2. Override rules for student interactive mode
85+
3. Override rules for instructor mode
86+
4. Author mode visual indicators in `f13ldman_author_mode.css`
87+
5. Sync to `dita-demo/oxygen-webhelp/template/f13ldman.css`
88+
89+
## Implementation Approach
90+
91+
### CSS Rules to Add
92+
93+
**1. Complete Base Hiding** (update existing in `f13ldman.css`):
94+
```css
95+
/* Hide answer and detail columns in quiz tables */
96+
.qd-quiz td:nth-child(2), .qd-quiz td:nth-child(3),
97+
.qd-quiz th:nth-child(2), .qd-quiz th:nth-child(3) {
98+
visibility: hidden;
99+
}
100+
```
101+
102+
**2. Student Interactive Mode Override** (add to `f13ldman.css`):
103+
```css
104+
/* Student mode: reveal answer column for input controls */
105+
.qd-quiz-interactive td:nth-child(2),
106+
.qd-quiz-interactive th:nth-child(2) {
107+
visibility: visible;
108+
}
109+
```
110+
111+
**3. Instructor Mode Override** (add to `f13ldman.css`):
112+
```css
113+
/* Instructor mode: reveal both answer and detail columns */
114+
.qd-quiz-instructor td:nth-child(2), .qd-quiz-instructor td:nth-child(3),
115+
.qd-quiz-instructor th:nth-child(2), .qd-quiz-instructor th:nth-child(3) {
116+
visibility: visible;
117+
}
118+
```
119+
120+
**4. Author Mode Indicators** (add to `f13ldman_author_mode.css`):
121+
```css
122+
/* Visual indicators for hidden quiz cells (answer column) */
123+
[outputclass~='qd-quiz'] entry:nth-child(2) {
124+
background-color: rgba(255, 200, 200, 0.5); /* Light red - hidden in prod */
125+
}
126+
127+
/* Visual indicators for hidden quiz cells (detail column) */
128+
[outputclass~='qd-quiz'] entry:nth-child(3) {
129+
background-color: rgba(255, 200, 200, 0.5); /* Light red - hidden in prod */
130+
}
131+
132+
/* Visual indicators for interactive analysis cells */
133+
[outputclass~='interactive'] {
134+
background-color: rgba(200, 255, 200, 0.5); /* Light green - interactive */
135+
}
136+
```
137+
138+
### JavaScript Changes
139+
140+
**bootstrap.ts** - Add `qd-quiz-instructor` class when instructor logs in:
141+
142+
Check if `revealQuizAnswersForInstructor()` function already adds this class. If not, add:
143+
```typescript
144+
quizTables.forEach((table) => {
145+
table.classList.add('qd-quiz-instructor');
146+
// ... existing code
147+
});
148+
```
149+
150+
### Test Verification
151+
152+
1. Run existing tests - should pass with CSS overrides
153+
2. Verify student inputs visible after login
154+
3. Verify instructor sees all columns
155+
4. Visual check in demo for no layout shift
156+
157+
## Complexity Tracking
158+
159+
No constitution violations. Simple CSS-only feature with minimal JS integration.
160+
161+
## Files to Modify
162+
163+
| File | Change |
164+
|------|--------|
165+
| `dita/template/f13ldman.css` | Add th hiding, student/instructor overrides |
166+
| `dita/template/f13ldman_author_mode.css` | Add author visual indicators |
167+
| `dita-demo/oxygen-webhelp/template/f13ldman.css` | Sync from dita/template |
168+
| `src/init/bootstrap.ts` | Add `qd-quiz-instructor` class (if needed) |
169+
170+
## Risk Assessment
171+
172+
- **Low**: CSS changes are additive, existing JS hiding continues to work
173+
- **Low**: `visibility: hidden` preserves layout, no shift concerns
174+
- **Low**: Tests check class presence, CSS is transparent to them
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Quickstart: CSS-Based Quiz Answer Hiding
2+
3+
**Branch**: `010-css-answer-hiding` | **Date**: 2025-11-28
4+
5+
## What This Feature Does
6+
7+
Hides quiz answer/detail columns using CSS (loaded before JavaScript), preventing students from seeing answers by:
8+
- Viewing page source before JS executes
9+
- Disabling JavaScript
10+
- Pausing page load mid-execution
11+
12+
## Implementation Overview
13+
14+
### 1. Base CSS Hiding
15+
```css
16+
/* In f13ldman.css */
17+
.qd-quiz td:nth-child(2), .qd-quiz td:nth-child(3),
18+
.qd-quiz th:nth-child(2), .qd-quiz th:nth-child(3) {
19+
visibility: hidden;
20+
}
21+
```
22+
23+
### 2. Student Mode Override
24+
When student logs in, `qd-quiz-interactive` class is added to table:
25+
```css
26+
.qd-quiz-interactive td:nth-child(2),
27+
.qd-quiz-interactive th:nth-child(2) {
28+
visibility: visible;
29+
}
30+
```
31+
32+
### 3. Instructor Mode Override
33+
When instructor logs in, `qd-quiz-instructor` class is added to table:
34+
```css
35+
.qd-quiz-instructor td:nth-child(2), .qd-quiz-instructor td:nth-child(3),
36+
.qd-quiz-instructor th:nth-child(2), .qd-quiz-instructor th:nth-child(3) {
37+
visibility: visible;
38+
}
39+
```
40+
41+
### 4. Author Mode Indicators
42+
In Oxygen Author mode, colored backgrounds show which cells are hidden/interactive:
43+
```css
44+
/* In f13ldman_author_mode.css */
45+
[outputclass~='qd-quiz'] entry:nth-child(2),
46+
[outputclass~='qd-quiz'] entry:nth-child(3) {
47+
background-color: rgba(255, 200, 200, 0.5); /* Light red */
48+
}
49+
50+
[outputclass~='interactive'] {
51+
background-color: rgba(200, 255, 200, 0.5); /* Light green */
52+
}
53+
```
54+
55+
## Testing
56+
57+
```bash
58+
# Run all tests
59+
npm test
60+
61+
# Run integration tests specifically
62+
npm run test:integration
63+
64+
# Run E2E tests
65+
npm run test:e2e
66+
67+
# Manual verification
68+
npm run build && open demo/quiz-examples.html
69+
```
70+
71+
## Files Modified
72+
73+
| File | Purpose |
74+
|------|---------|
75+
| `dita/template/f13ldman.css` | Base hiding + overrides |
76+
| `dita/template/f13ldman_author_mode.css` | Author visual indicators |
77+
| `dita-demo/oxygen-webhelp/template/f13ldman.css` | Demo sync |
78+
| `src/init/bootstrap.ts` | Add instructor class |

0 commit comments

Comments
 (0)