Skip to content

Commit d32fbb7

Browse files
committed
Fix "under" date semantics in oracle queries and add --all to generation scripts
Q80 and Q107 incorrectly used date ranges meaning "before year X" instead of "during year X" (Swedish "under"). Changed to use YEAR() consistently. Q106 also migrated from date range to YEAR() for consistency. Removed legacy extract-oracle.ts, added --all flag to generate-language.ts and generate-erd.ts, simplified generate-all script, and updated README with architecture docs.
1 parent 477cc62 commit d32fbb7

8 files changed

Lines changed: 145 additions & 426 deletions

File tree

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,55 @@ SQL Validator is a fully client-side web application powered by sql.js. Designed
1010
- **Question Highlighting**: Started and completed questions are highlighted in the question selector making it easy to track progress.
1111
- **Import/Export Data**: Import and export queries and views to file for sharing and/or backups.
1212
- **Image Export**: Export queries and views as images in light mode for assignment submission.
13+
- **Multi-Language Support**: Full i18n support with Swedish and English included. Adding a new language only requires a new language pack file.
1314

1415
## Usage
1516
### Public Deployment
1617
A public instance of SQL Validator is available at [https://sql-validator.e-su.se](https://sql-validator.e-su.se), powered with Cloudflare Pages.
1718

1819
### Running Locally
19-
To deploy SQL Validator locally, follow these steps:
2020
1. Clone the repository: `git clone https://github.com/Edwinexd/sql-validator.git`
2121
2. Install dependencies: `npm install`
2222
3. Start the development server: `npm start`
2323

24+
## Architecture
25+
### Oracle System
26+
The **oracle** (`data/oracle.json`) is the single source of truth for the database schema, canonical data, and all 110 reference SQL queries. It uses language-agnostic placeholders (e.g. `{{table:Person}}`, `{{col:Person.city}}`, `{{city:6}}`) that are resolved at generation time using a language pack.
27+
28+
The oracle is encrypted (`data/oracle.enc`) before committing so students cannot see the answers.
29+
30+
### Language Packs
31+
Language definitions live in `languages/` (e.g. `sv.ts`, `en.ts`). Each pack provides:
32+
- Localized names, addresses, cities, course names, room names
33+
- Per-person IDs, postal codes, phone numbers
34+
- Schema translations (table and column names)
35+
- 110 localized question descriptions
36+
- UI strings
37+
38+
### Generation Pipeline
39+
The `generate-language.ts` script combines the oracle with a language pack to produce per-language output:
40+
1. Creates a SQLite database with localized schema and data
41+
2. Runs all reference queries to produce expected result sets
42+
3. Outputs `questionpool.json` and `data.sqlite3` into `public/languages/<code>/`
43+
44+
The `generate-erd.ts` script produces light/dark SVG database diagrams from the generated databases.
45+
46+
Both scripts support `--all` to auto-discover and process all languages.
47+
48+
### Scripts
49+
| Script | Description |
50+
|---|---|
51+
| `npm run generate-all` | Regenerate all languages (question pools, databases, ERDs) |
52+
| `npm run generate-lang -- --lang <code> --plain` | Generate a single language using unencrypted oracle |
53+
| `npm run generate-lang -- --all --plain` | Generate all languages |
54+
| `npm run generate-erd -- --all` | Regenerate ERD diagrams for all languages |
55+
| `npm run encrypt-oracle -- <password>` | Encrypt `oracle.json` to `oracle.enc` |
56+
| `npm run decrypt-oracle -- <password>` | Decrypt `oracle.enc` to `oracle.json` |
57+
58+
### Adding a New Language
59+
1. Create a new file in `languages/` (e.g. `de.ts`) implementing the `LanguageDefinition` interface
60+
2. Run `npm run generate-all`
61+
2462
## Screenshots
2563
## Main Application
2664
<div style="display: flex; padding: 0;">

data/oracle.enc

-115 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"decrypt-oracle": "tsx scripts/decrypt-oracle.ts",
5151
"encrypt-oracle": "tsx scripts/encrypt-oracle.ts",
5252
"generate-erd": "tsx scripts/generate-erd.ts",
53-
"generate-all": "tsx scripts/generate-language.ts --lang sv --plain && tsx scripts/generate-erd.ts --db public/languages/sv/data.sqlite3 --out public/languages/sv && tsx scripts/generate-language.ts --lang en --plain && tsx scripts/generate-erd.ts --db public/languages/en/data.sqlite3 --out public/languages/en"
53+
"generate-all": "tsx scripts/generate-language.ts --all --plain && tsx scripts/generate-erd.ts --all"
5454
},
5555
"eslintConfig": {
5656
"extends": [

public/languages/en/questionpool.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

public/languages/sv/questionpool.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)