Skip to content

fix: conjugation quiz grading, zh-TW localization, and docker tag export mismatch #67

Open
ganesh-rajput-07 wants to merge 1 commit into
Liozon:masterfrom
ganesh-rajput-07:master
Open

fix: conjugation quiz grading, zh-TW localization, and docker tag export mismatch #67
ganesh-rajput-07 wants to merge 1 commit into
Liozon:masterfrom
ganesh-rajput-07:master

Conversation

@ganesh-rajput-07

Copy link
Copy Markdown

1. Fix Conjugation & Writing Mode Grading

Issue

Correct answers in verb conjugation quizzes (e.g. ich trinke) and writing/spelling exercises were being incorrectly marked as Wrong, causing user progress to decrease despite submitting the correct answer.

Root Cause

The grading logic in /api/quiz/answer (implemented in both:

  • src/routes/api.js
  • public/js/offline-db.js

) only compared submitted answers against the word's:

  • translation
  • display

fields.

The existing expectedAnswer value sent by the client—which contains the actual conjugated or written answer expected for the exercise—was not considered during validation.

Fix

Updated both the online API route and the offline IndexedDB interceptor to validate answers against expectedAnswer in addition to the existing accepted values.


2. Fix Traditional Chinese (zh-TW) Localization Loading

Issue

Selecting Traditional Chinese (zh-TW) caused the application to either:

  • Load Simplified Chinese (zh) instead, or
  • Fail to load translations entirely in offline mode.

Root Cause

A. Locale Subtags Were Stripped

The client-side locale loader used:

split('-')[0]

which transformed:

zh-TW → zh

before attempting to fetch translation resources.

B. Case-Sensitive Filename Mismatch

Locale requests were normalized to lowercase by the server:

zh-tw

while the translation file was stored as:

zh-TW.json

This caused lookup failures on case-sensitive filesystems such as Linux and Docker environments.

Fix

  • Renamed:

    public/locales/zh-TW.json
    

    to:

    public/locales/zh-tw.json
    
  • Updated public/js/i18n.js to preserve locale subtags rather than stripping them.

  • Simplified setUiLang() to delegate locale loading directly through loadLocale().

  • Standardized locale references from zh-TW to zh-tw in:

    • public/js/offline.js
    • public/js/world-languages.js

This ensures consistent locale matching, caching, and filesystem resolution across all environments.


3. Fix Docker Archive Export Tag Mismatch

Issue

The deployment instructions generated by build-and-export.sh instructed users to run:

docker run openflashcards:latest

However, only the versioned image tag was created and exported:

openflashcards:<version>

For example:

openflashcards:2.5

As a result, first-time deployments using the provided instructions failed.

Fix

Updated build-and-export.sh to:

  1. Build both image tags:

    docker build \
      -t openflashcards:${IMAGE_TAG} \
      -t openflashcards:latest .
  2. Export both tags when creating the archive.

This ensures that deployment instructions reference an image tag that actually exists in the exported package.


Verification

Quiz Grading

  • Verified that expectedAnswer is evaluated correctly during answer validation.
  • Confirmed that conjugation and writing exercises are no longer incorrectly marked as wrong.

Localization

  • Verified that zh-tw.json resolves correctly through lowercase locale routes.
  • Confirmed that locale subtags are preserved during translation loading.
  • Tested consistency of locale references across online and offline flows.

Docker Export

  • Verified that both versioned and latest tags are created during build.
  • Confirmed that both tags are included in the Docker export archive.
  • Validated that deployment instructions now match the exported image tags.

Summary

This PR:

  • Fixes incorrect grading of conjugation and writing exercises.
  • Restores reliable loading of Traditional Chinese (zh-tw) translations.
  • Aligns Docker build artifacts with generated deployment instructions by exporting both versioned and latest image tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant