fix: Scorm 缺少播放页身份时只报学时
This commit is contained in:
@@ -1033,6 +1033,23 @@ async def _study_scorm(session: StudySession, kid: str, pkg_id: str,
|
|||||||
if _completed(progress):
|
if _completed(progress):
|
||||||
return
|
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)
|
sco_cnt = await session.scorm_count(kid)
|
||||||
session_id = str(_uuid.uuid4())
|
session_id = str(_uuid.uuid4())
|
||||||
sco_id = kid
|
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
|
scorm_data = existing.get("data") if existing else None
|
||||||
if not scorm_data or not isinstance(scorm_data, dict):
|
if not scorm_data or not isinstance(scorm_data, dict):
|
||||||
scorm_data = {
|
scorm_data = {
|
||||||
"cmi__core__lesson_status": "completed",
|
"cmi__core__lesson_status": "incomplete",
|
||||||
"cmi__core__lesson_location": "1",
|
"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__session_time": "00:00:01",
|
||||||
"cmi__core__exit": "suspend",
|
"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(1, int(sco_cnt or 1))
|
||||||
total_pages = max(len(answers), 10)
|
|
||||||
|
|
||||||
for page_idx in range(total_pages):
|
for page_idx in range(total_pages):
|
||||||
if _halted(stop, hours):
|
if _halted(stop, hours):
|
||||||
return
|
return
|
||||||
scorm_data["cmi__core__lesson_location"] = str(page_idx + 1)
|
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"
|
scorm_data["cmi__core__session_time"] = "00:00:01"
|
||||||
try:
|
try:
|
||||||
await session.scorm_save(
|
await session.scorm_save(
|
||||||
@@ -1471,7 +1486,8 @@ class AutoStudyWorker:
|
|||||||
elif ctype == "scorm":
|
elif ctype == "scorm":
|
||||||
await _study_scorm(
|
await _study_scorm(
|
||||||
session, kid, "", wait, self._async_stop, hours,
|
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:
|
except SessionExpired:
|
||||||
hours.user_stop.set()
|
hours.user_stop.set()
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ def play_page_vars(html: str) -> dict[str, str]:
|
|||||||
"packageID": read("packageID"),
|
"packageID": read("packageID"),
|
||||||
"orgID": read("orgID"),
|
"orgID": read("orgID"),
|
||||||
"userID": read("userID"),
|
"userID": read("userID"),
|
||||||
|
"scormId": read("scormId") or read("scoId"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user