[QTI] Load assessment items from the server while the cache may be stale
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
調査の方向性
Start with initializeDB() in shared/data/index.js and the startup flow in shared/app.js; trace how IndexedDB is opened before data is read. Check the EditModal loading and self-healing path, then add Jest coverage for cleanup errors, preserved changes, and failed loads. Done when the acceptance criteria hold and syncing still starts if cleanup fails.
索引モデルが issue の本文から書いたものです。
説明
Overview
After the QTI release, the cache can show users on the new assets the wrong content:
- Items cached before the release are legacy, and the new editor shows them as unsupported. The background refresh never reaches an open exercise, so they stay that way until it's reopened. Users who see their questions as unsupported may think they're broken, and delete or redo them.
- Items edited in an old tab can be cached as QTI, with
raw_datafrom before the edit, while the database row is still legacy and holds the edit. The new editor shows the old content, and the next edit there writes it back over the old tab's edit.
Until #6341, load an exercise's items from the server instead of the cache the first time it's opened after a page load, and whenever any cached item is neither QTI nor Perseus. If that fetch fails, show the cached items, as today.
This also fixes #6148, where exercises created with the old editor show as incomplete on unstable until they're opened a second time.
Part of #6337. Must be in unstable before the QTI release is cut.
Complexity: Low
Target branch: unstable
Context
loadAssessmentItems(channelEdit/vuex/assessmentItem/actions.js) is the only read of assessment items. It callsAssessmentItem.whereand commits the result to the store.Resource.wherereturns cached rows and refreshes them in the background throughconditionalFetch. It only waits for the server when nothing is cached.- The refresh writes the fetched rows to IndexedDB, overwriting the cached ones and reapplying unsynced changes (
setData). Updates from IndexedDB never reach the store, though: the plugin emits the key under"contentnode,assessment_id", andUPDATE_ASSESSMENTITEM_FROM_INDEXEDDBreadsid. - A tab on the old assets that opens an exercise with legacy items cached doesn't reload, because #6338 only reloads on QTI items. Its background refresh writes QTI rows to the shared IndexedDB. An edit made then syncs, because the database row is still legacy, while the cached row keeps the
raw_datafrom before the edit. The tab reloads into the new assets on the next open. - Edits from old tabs, and from collaborators on the old assets, reach the cache as changes to legacy fields, which leave a QTI row's
raw_dataas it was. - The store keeps an exercise's items across opens until the page reloads.
- Unsynced changes sync once no change has been made for 2 seconds.
- Type values:
'QTI'and'perseus_question'. Anything else is legacy. consolidate()leaves items it can't convert as legacy.
The Change
- In
loadAssessmentItems, wait for the server's items and commit those instead of the cached ones when an exercise being loaded hasn't been loaded from the server since the page loaded, or when any cached item is neitherQTInorperseus_question. - If that fetch fails, commit the cached items.
- Keep the checks self-contained, so #6341 can remove them.
Decisions
Choices made while planning this, and why.
- Why wait in
loadAssessmentItems, rather than clearing the cached items on startup? An earlier plan cleared the whole assessment item table on every startup while any row was legacy. Because updates and deletes from IndexedDB never reach the store, other open tabs would keep showing the cleared questions, and edits made there would record no change and be lost. Waiting deletes nothing, only affects the exercise being opened, and needs no startup scan. - Why also wait on the first open after a page load? It covers cached QTI rows whose
raw_datais older than the database, however they got there: an edit made in an old tab before it reloaded, or a change from an old tab or a collaborator on the old assets. A tab that reloads into the new assets starts a new page load, so its first open of each exercise reads the server. The cost is one round trip per exercise per page load, until #6341. An earlier plan only waited when cached items were legacy, which missed these. - Why wait for all of an exercise's items, and not only the legacy ones? Showing the QTI items first and the rest later would show an exercise with only some of its questions.
- Why fall back to the cached items when the fetch fails? They show as they do today, rather than as an empty exercise.
- Why not clear the cache with a Dexie schema version bump? A version bump runs once per browser, but cached legacy items come back from tabs still on the old assets, which share the same IndexedDB. Dexie also closes the database in every open tab on a version change, which would break those tabs.
- Why not fix the store bug instead? Updates from IndexedDB never reach the store, because the plugin emits the key under
"contentnode,assessment_id"whileUPDATE_ASSESSMENTITEM_FROM_INDEXEDDBreadsid. That bug predates QTI, affects other tables, and is tracked separately. Even with it fixed, the cached items would show until the refresh lands, and an edit made before then would still start from them, so the wait is still needed.
Known gaps
- The first open of each exercise after a page load, and any open with legacy items cached, waits for the server, as opening one with nothing cached does today.
- Exercises with items the server can't convert wait on every open, because those items stay legacy.
- When the fetch fails, the cached items show until a later open succeeds: legacy ones as unsupported, and stale ones with their old content.
- Reopening an exercise later in the same page load uses the cache. If an old tab or a collaborator on the old assets has edited a question since, its
raw_datais stale, and an edit in the new editor writes the old content back over theirs. - A question created but not yet synced isn't among the server's items. If the page reloaded in between, it's missing from the editor until the next open, and if it was the exercise's only question, the completeness check marks the exercise incomplete.
Acceptance Criteria
- The first open of an exercise after a page load shows the server's items, even when every cached item is QTI or Perseus
- Opening an exercise whose cached items include a legacy one shows the server's items, without first showing any as unsupported or showing only some of them
- Reopening an exercise in the same page load, with every cached item QTI or Perseus, shows the cached items and refreshes them in the background, as today
- If the fetch fails, the cached items are shown
- No rows are deleted and no changes are recorded
- #6148 no longer reproduces
- Jest tests cover the first-open, legacy, reopen and failed-fetch cases
AI usage
I outlined the approach and made the decisions above. Claude traced the read path on
unstableand drafted the issue, which I then checked and corrected for accuracy.
- 主要言語
- Python
- スター
- 212
- フォーク
- 321
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
learningequality/studio のほかの issue
-
Community library status changes don't update `date_updated`対応中かも @ArpitaSamanta10 が今日担当しました。 オープンcommunity-contribution-in-progress DEV: backend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
learningequality/studio#6414 · コメント 8 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
learningequality/studio#6410 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
learningequality/studio#6409 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
learningequality/studio#6407 ·
メンテナーはふだん 1 日以内に返信
-
Stripe webhook accepts events when no webhook secret is configured対応中かも @adibmbrk が今日担当しました。 オープンcommunity-contribution-in-progress DEV: backend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
learningequality/studio#6404 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
learningequality/studio の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
canonical/paas-charm#407 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
メンテナーはふだん 1 日以内に返信
-
enhancement tooling
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
`read_nexus` entry point points to a function that no longer exists対応中かも @RubelMozumder が今日担当しました。 オープンannotator bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
FAIRmat-NFDI/pynxtools#876 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: HTTP 499 (Client Closed Request) is classified as a non-retryable format_error, so a mid-flight abort fails the turn over instead of retrying対応中かも @yipinghuang1991 が今日担当しました。 オープンcomp/agent P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NousResearch/hermes-agent#156837 ·
メンテナーはふだん 1 日以内に返信