Files
devplacepy/devplacepy/schemas/quiz.py
T
retoor 8e9d3fad98 Add the trust and safety subsystem and the App Store compliance work
Implements the moderation and consent obligations a social platform carries,
so the web version and any client that speaks to it enforce the same rules.

Moderation core (services/moderation/, database/moderation.py): a reportable
target registry, the content filter and its choke points, the report queue with
atomic resolution, enforcement actions, consent tracking, maturity gating, and
account deletion with a grace window.

Surfaces: POST /reports plus the member report list, /admin/moderation and the
per-report admin view, /workspaces, terms acceptance at /auth/terms, consent and
account deletion under /profile, the report button and dialog partials, the
maturity gate, and the moderation stylesheet and ReportDialog client.

Every user-generated surface stays reportable by construction: new content tables
are registered in REPORTABLE_TARGETS or listed in UNREPORTABLE_TABLES with a
reason, and the registry test fails the suite on anything left unclassified.

Docs: community guidelines, content moderation, intellectual property, privacy,
terms, contact, and the admin-only moderation operations page, plus the
moderation API group and the Devii moderation actions.

Compliance record: applecomp.md is the requirement register, applechanges.md the
gap analysis against this codebase, and appleimpl.md the implementation design
they resolve to.

Tests cover the report flow, admin moderation, consent, account deletion, terms
acceptance, workspaces, and the registry invariant across the unit, api, and e2e
tiers.
2026-08-09 00:18:20 +02:00

232 lines
5.6 KiB
Python

# retoor <retoor@molodetz.nl>
from __future__ import annotations
from typing import Any, Optional
from devplacepy.schemas.base import _Out
from devplacepy.schemas.content import CommentItemOut, UserOut
class QuizOptionOut(_Out):
uid: str = ""
position: int = 0
label: str = ""
is_correct: Optional[bool] = None
match_value: Optional[str] = None
class QuizAnswerOut(_Out):
uid: str = ""
question_uid: str = ""
position: int = 0
answer_text: str = ""
option_uids: list[str] = []
answered: bool = False
answered_at: str = ""
is_correct: bool = False
awarded_points: float = 0.0
feedback: str = ""
graded_by: str = ""
confidence: float = 0.0
class QuizQuestionOut(_Out):
uid: str = ""
quiz_uid: str = ""
position: int = 0
kind: str = ""
kind_label: str = ""
prompt: str = ""
explanation: str = ""
points: int = 1
media_attachment_uid: str = ""
case_sensitive: bool = False
options: list[QuizOptionOut] = []
option_count: int = 0
match_choices: list[str] = []
correct_boolean: Optional[bool] = None
expected_answer: Optional[str] = None
grading_criteria: Optional[str] = None
numeric_value: Optional[float] = None
numeric_tolerance: Optional[float] = None
answer: Optional[QuizAnswerOut] = None
class QuizOut(_Out):
uid: str = ""
slug: str = ""
url: str = ""
title: str = ""
description: str = ""
status: str = "draft"
published_at: str = ""
shuffle_questions: bool = False
shuffle_options: bool = False
reveal_answers: bool = False
allow_review: bool = True
time_limit_seconds: int = 0
pass_percent: int = 0
question_count: int = 0
total_points: int = 0
attempt_count: int = 0
stars: int = 0
created_at: str = ""
author: Optional[UserOut] = None
viewer_owns: bool = False
viewer_is_admin: bool = False
viewer_can_edit: bool = False
viewer_can_play: bool = False
viewer_state: str = "todo"
validation_errors: list[str] = []
class QuizDetailOut(_Out):
maturity: Optional[str] = None
quiz: QuizOut = QuizOut()
questions: list[QuizQuestionOut] = []
comments: list[CommentItemOut] = []
attachments: list[Any] = []
reactions: dict = {}
bookmarked: bool = False
star_count: int = 0
my_vote: int = 0
leaderboard: list[Any] = []
viewer_state: str = "todo"
viewer_attempt_uid: str = ""
class QuizListItemOut(_Out):
uid: str = ""
slug: str = ""
url: str = ""
title: str = ""
description: str = ""
status: str = "published"
created_at: str = ""
time_ago: str = ""
author: Optional[UserOut] = None
question_count: int = 0
total_points: int = 0
attempt_count: int = 0
time_limit_seconds: int = 0
pass_percent: int = 0
stars: int = 0
my_vote: int = 0
comment_count: int = 0
bookmarked: bool = False
reactions: dict = {}
recent_comments: list[CommentItemOut] = []
viewer_state: str = "todo"
viewer_best_percent: float = 0.0
viewer_best_points: float = 0.0
viewer_attempt_uid: str = ""
class QuizScoreboardEntryOut(_Out):
rank: int = 0
user: Optional[UserOut] = None
total_points: float = 0.0
quizzes_completed: int = 0
avg_percent: float = 0.0
perfect_count: int = 0
class QuizProgressOut(_Out):
completed: int = 0
todo: int = 0
avg_percent: float = 0.0
total_points: float = 0.0
rank: int = 0
perfect_count: int = 0
class QuizScoreboardOut(_Out):
scoreboard: list[QuizScoreboardEntryOut] = []
viewer_standing: Optional[QuizScoreboardEntryOut] = None
limit: int = 0
class QuizzesOut(_Out):
quizzes: list[QuizListItemOut] = []
search: str = ""
filter: str = "all"
counts: dict = {}
pagination: dict = {}
scoreboard: list[QuizScoreboardEntryOut] = []
viewer_standing: Optional[QuizScoreboardEntryOut] = None
viewer_progress: QuizProgressOut = QuizProgressOut()
viewer_can_create: bool = False
class QuizAttemptOut(_Out):
uid: str = ""
quiz_uid: str = ""
quiz_slug: str = ""
quiz_title: str = ""
user_uid: str = ""
status: str = ""
started_at: str = ""
expires_at: str = ""
completed_at: str = ""
remaining_seconds: int = 0
answered_count: int = 0
question_count: int = 0
score_points: float = 0.0
max_points: int = 0
score_percent: float = 0.0
passed: bool = False
pass_percent: int = 0
allow_review: bool = True
questions: list[QuizQuestionOut] = []
class QuizAttemptPageOut(_Out):
quiz: QuizOut = QuizOut()
attempt: QuizAttemptOut = QuizAttemptOut()
class QuizResultOut(_Out):
quiz: QuizOut = QuizOut()
attempt: QuizAttemptOut = QuizAttemptOut()
review: list[QuizQuestionOut] = []
fallback_count: int = 0
class QuizAnswerResultOut(_Out):
ok: bool = True
answer: QuizAnswerOut = QuizAnswerOut()
attempt: QuizAttemptOut = QuizAttemptOut()
class QuizLeaderboardEntryOut(_Out):
rank: int = 0
user: Optional[UserOut] = None
score_points: float = 0.0
score_percent: float = 0.0
passed: bool = False
completed_at: str = ""
class QuizLeaderboardOut(_Out):
quiz_uid: str = ""
entries: list[QuizLeaderboardEntryOut] = []
class QuizDocumentOut(_Out):
title: str = ""
description: str = ""
settings: dict = {}
questions: list[Any] = []
class QuizBuilderOut(_Out):
quiz: QuizOut = QuizOut()
questions: list[QuizQuestionOut] = []
kinds: list[Any] = []
validation_errors: list[str] = []
class QuizFormPageOut(_Out):
viewer_can_create: bool = False