Tutor (prompt tutor-v3-stepwise-plain): plain text instead of LaTeX/markdown, with rag/services/mathtext.py converting whatever still slips through; full step-by-step solutions with a check before the final answer; three tones by grade; the last 6 messages of the conversation go to the model and follow-ups are no longer served from another user's cache; book solutions the checker disputes are kept out of the context; a questionId gives the tutor the practice question and the student's wrong answer. /api/health reports when the AI credit runs out. rag_model_benchmark compares chat models on verified book problems (run on the server; credit ran out mid-run). Map: only lessons that have questions count toward finishing an island, lessonIds[0] / nextLessonId is always the next lesson to play, and a finished island stays finished. The Seyar characters (sigma/delta/pi) are seeded. Audit fixes, each reproduced before fixing: - the plan is stored on the order, so paying a monthly order after starting a yearly checkout no longer grants a year - opening checkout no longer demotes an active subscription; renewals extend from the current expiry; expired subscriptions are not reported active - one discount code per order and only before the gateway; a 100% code completes the purchase; lost Zarinpal confirmations are re-verified - the unused /api/payment/webhook "mark paid" endpoint is removed - XP counts only answers recorded on the server - 6-digit OTP, each code dies after 5 wrong guesses; POST /api/auth/logout - a guest who signs up keeps their account and progress (test phones excluded) - affiliate commission on the first real payment; guests excluded - parents with several children no longer get a 500 - SQLite runs transactions IMMEDIATE, since it ignores select_for_update - admin login is rate-limited; display names drop phone numbers and links; userQuestion is capped at 2000 characters - server-side heart enforcement exists behind HEARTS_ENFORCED (off until the frontend handles 403 no_hearts) Not done on purpose: rotating the server's secret key and moving to Postgres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
2.3 KiB
Python
39 lines
2.3 KiB
Python
from django.db.models.signals import post_delete, post_save
|
|
from django.dispatch import receiver
|
|
|
|
from .models import Grade, Lesson, Node, Question, Unit, UserAnswer, UserLessonCompletion
|
|
from .services import touch_node_progress_on_answer, update_node_progress_on_lesson_completion
|
|
|
|
|
|
@receiver(post_save, sender=UserAnswer, dispatch_uid='content_touch_node_progress_on_answer')
|
|
def _on_user_answer_created(sender, instance, created, **kwargs):
|
|
if not created:
|
|
return
|
|
touch_node_progress_on_answer(instance.user_id, instance.question)
|
|
|
|
|
|
@receiver(post_save, sender=UserLessonCompletion, dispatch_uid='content_update_node_progress_on_completion')
|
|
def _on_lesson_completion_created(sender, instance, created, **kwargs):
|
|
if not created:
|
|
return
|
|
update_node_progress_on_lesson_completion(instance.user_id, instance.lesson)
|
|
|
|
|
|
# با هر تغییرِ برنامهی درسی (از ادمین یا seed)، نسخهی کشِ محتوا یک واحد جلو
|
|
# میرود و همهی کلیدهای content:grades / content:tree را یکجا باطل میکند.
|
|
@receiver(post_save, sender=Grade, dispatch_uid='content_bump_curriculum_grade_save')
|
|
@receiver(post_delete, sender=Grade, dispatch_uid='content_bump_curriculum_grade_delete')
|
|
@receiver(post_save, sender=Unit, dispatch_uid='content_bump_curriculum_unit_save')
|
|
@receiver(post_delete, sender=Unit, dispatch_uid='content_bump_curriculum_unit_delete')
|
|
@receiver(post_save, sender=Node, dispatch_uid='content_bump_curriculum_node_save')
|
|
@receiver(post_delete, sender=Node, dispatch_uid='content_bump_curriculum_node_delete')
|
|
@receiver(post_save, sender=Lesson, dispatch_uid='content_bump_curriculum_lesson_save')
|
|
@receiver(post_delete, sender=Lesson, dispatch_uid='content_bump_curriculum_lesson_delete')
|
|
# سوال هم: نقشه فقط درسهای سوالدار را برای تمام شدنِ جزیره میشمارد، پس
|
|
# اولین سوالِ یک درس (از ادمین یا import) باید نقشهی کششده را باطل کند.
|
|
@receiver(post_save, sender=Question, dispatch_uid='content_bump_curriculum_question_save')
|
|
@receiver(post_delete, sender=Question, dispatch_uid='content_bump_curriculum_question_delete')
|
|
def _bump_curriculum_cache_version(sender, **kwargs):
|
|
from .views import bump_curriculum_version
|
|
bump_curriculum_version()
|