fix: Scorm 缺少播放页身份时只报学时

This commit is contained in:
2026-11-16 02:52:57 +08:00
parent 1da76931f8
commit 05a069525b
2 changed files with 26 additions and 9 deletions
+25 -9
View File
@@ -1033,6 +1033,23 @@ async def _study_scorm(session: StudySession, kid: str, pkg_id: str,
if _completed(progress):
return
if not user_id or not org_id:
while not _halted(stop, hours):
try:
await session.submit_scorm_heartbeat(kid, pkg_id, step, sco_id="", end=False)
progress = await session.update_progress(kid, pkg_id)
except Exception:
_touch(worker, ok=False)
raise
schedule = _progress_of(progress)
_beat(worker, schedule, ok=True)
if _completed(progress):
await hours.refresh()
return
if await _heartbeat_wait(worker, interval, stop, hours, schedule):
return
return
sco_cnt = await session.scorm_count(kid)
session_id = str(_uuid.uuid4())
sco_id = kid
@@ -1041,24 +1058,22 @@ async def _study_scorm(session: StudySession, kid: str, pkg_id: str,
scorm_data = existing.get("data") if existing else None
if not scorm_data or not isinstance(scorm_data, dict):
scorm_data = {
"cmi__core__lesson_status": "completed",
"cmi__core__lesson_status": "incomplete",
"cmi__core__lesson_location": "1",
"cmi__core__lesson_progress": "1.00",
"cmi__core__lesson_progress": "0.00",
"cmi__core__session_time": "00:00:01",
"cmi__core__exit": "suspend",
"cmi__suspend_data": "",
"cmi__suspend_data": {},
}
else:
scorm_data["cmi__core__lesson_status"] = "completed"
scorm_data["cmi__core__lesson_progress"] = "1.00"
answers = await session.scorm_extract_answers(kid)
total_pages = max(len(answers), 10)
total_pages = max(1, int(sco_cnt or 1))
for page_idx in range(total_pages):
if _halted(stop, hours):
return
scorm_data["cmi__core__lesson_location"] = str(page_idx + 1)
scorm_data["cmi__core__lesson_progress"] = f"{(page_idx + 1) / total_pages:.2f}"
scorm_data["cmi__core__lesson_status"] = "completed" if page_idx + 1 == total_pages else "incomplete"
scorm_data["cmi__core__session_time"] = "00:00:01"
try:
await session.scorm_save(
@@ -1471,7 +1486,8 @@ class AutoStudyWorker:
elif ctype == "scorm":
await _study_scorm(
session, kid, "", wait, self._async_stop, hours,
user_id, org_id, worker, study_time=study_time,
str(params.get("userID") or ""), str(params.get("orgID") or ""),
worker, study_time=study_time,
)
except SessionExpired:
hours.user_stop.set()
+1
View File
@@ -92,6 +92,7 @@ def play_page_vars(html: str) -> dict[str, str]:
"packageID": read("packageID"),
"orgID": read("orgID"),
"userID": read("userID"),
"scormId": read("scormId") or read("scoId"),
}