fix: improve import, evidence indexing and material-scoped grading

Preserve document revisions and evidence, harden indexing and export behavior, add explicit material selection and direct-folder import, validate model JSON schemas with safe error messages, and retain student selection while loading scoring data.
This commit is contained in:
2026-10-14 13:52:56 +08:00
parent 29c95ce5ad
commit ebe33392ca
42 changed files with 2332 additions and 304 deletions
+7 -4
View File
@@ -128,7 +128,7 @@ def test_short_paragraphs_share_a_page_chunk():
assert "实验步骤0" in chunks[0]["text"] and "实验步骤11" in chunks[0]["text"]
def test_stale_knowledge_index_reuses_document_id(db):
def test_stale_knowledge_index_preserves_history_with_a_new_document_id(db):
project_id = make_project(db, 1)
pages = [{"page_number": 1, "text": "实验方案与测量结果"}]
document = ingest(db, course_version_id=1, project_id=project_id, submission_file_id=None,
@@ -140,9 +140,12 @@ def test_stale_knowledge_index_reuses_document_id(db):
db.commit()
reindexed = ingest(db, course_version_id=1, project_id=project_id, submission_file_id=None,
title="报告", category="stage3", source_hash="same-source", pages=pages)
assert reindexed.id == document.id and reindexed.index_version == INDEX_VERSION
assert db.scalar(select(KnowledgeChunk.text).where(KnowledgeChunk.document_id == document.id)) == pages[0]["text"]
assert db.get(KnowledgePage, (document.id, 1)).text == pages[0]["text"]
assert reindexed.id != document.id and reindexed.index_version == INDEX_VERSION
assert document.status == "superseded"
assert db.scalar(select(KnowledgeChunk.text).where(KnowledgeChunk.document_id == document.id)) == "过时片段"
assert db.get(KnowledgePage, (document.id, 1)).text == "过时整页"
assert db.scalar(select(KnowledgeChunk.text).where(KnowledgeChunk.document_id == reindexed.id)) == pages[0]["text"]
assert db.get(KnowledgePage, (reindexed.id, 1)).text == pages[0]["text"]
def test_model_key_is_encrypted_and_hidden(db):