Skip to content

feat: update jwt api - #630

Merged
tungnxt89 merged 10 commits into
developfrom
feat-update-jwt-api
Sep 27, 2026
Merged

tungnxt89 merged 10 commits into
developfrom
feat-update-jwt-api

Conversation

@daonham

@daonham daonham commented Jun 16, 2026

Copy link
Copy Markdown
Member

No description provided.

@daonham
daonham requested a review from tungnxt89 June 16, 2026 10:15
daonham and others added 9 commits July 22, 2026 10:19
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
LP_User_Item_Quiz::get_results() caches what it calculates under
"<quiz>/user/<user>/course/<course>". start_quiz() clears that key, but
submit_quiz() never did, so the entry written while the attempt was still in
progress — every question unanswered — outlived the submission. wp_cache_* is
per-request on a plain install, which is why this stayed invisible; with a
persistent object cache (LiteSpeed, Redis, Memcached) the stale entry survives
and every read after the submit serves it.

The symptom is a quiz answered in full that comes back 0%, "not passed", with
all questions marked Skipped, while the /quiz/finish response itself carries
the correct score. Reproduced on a live install: start → finish with no read in
between returned 15.38% and read back 15.38%; the same flow with one read
between start and finish returned 13.33% and read back 0% with all 15 questions
empty.

LP_User_Item_Quiz now owns the key and exposes clear_results_cache(), which
submit_quiz() calls once the attempt is completed. instant_check_question()
rewrites the same stored result, so it clears the cache too.

Verified against a local install, scoring one request end to end: without the
change the read after the submit reported 0% and 5 empty answers against a
submit response of 80%; with it the read reports 80% and matches.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
LP_Abstract_User::finish_course() completes the enrollment through
LP_User_Item::complete(), which writes straight to learnpress_user_items. That
path never calls UserCourseModel::clean_caches(), so the model cached under
"userCourseModel/find/<user>/<course>/lp_course" keeps reporting the enrollment
as in progress. wp_cache_* is per-request on a plain install and the staleness
dies with the request; with a persistent object cache (LiteSpeed, Redis,
Memcached) it survives and every later read serves the pre-finish status.

The symptom is a course finished successfully that still offers "Finish
course", with the sidebar showing the old progress. Confirmed on a live
install: the listing endpoint, which reads the row straight from SQL, reported
finished/passed with an end time, while the single-course endpoint - which goes
through UserCourseModel::find() - still reported enrolled/in-progress for the
same enrollment.

finish_course() now cleans the model cache once the row is written.

Verified against a local install in a single request: without the change a read
taken after the finish reported enrolled/in-progress against a row that already
held finished/passed; with it the read matches the row.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tungnxt89
tungnxt89 merged commit 7a60527 into develop Sep 27, 2026
4 of 5 checks passed
@tungnxt89
tungnxt89 deleted the feat-update-jwt-api branch September 28, 2026 06:48
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.

2 participants