fix: canonical exercise completion, teacher course completion & upsert member fixes (#767)
* fix(db): preserve not-found error and dedupe member lookup in upsert (#763) Re-throw Organization member not found so the service layer can return 404. Fetch existing notification prefs by resolved member id instead of calling getOrganizationMemberEmailNotifications, which repeated the lookup. Co-authored-by: Rotimi Best <[email protected]> * fix(course): single source of truth for exercise completion; let teachers complete courses Exercise completion was computed four different ways (course progress, enrolled courses, content items, progression locks), and two of them counted any submission as complete, ignoring the exercise's 'passed' completion policy and pass threshold. My Learning and certificate eligibility could therefore report 100% while the course itself showed an unpassed exercise. - Add isExerciseCompletedSql, a policy-aware SQL predicate in the db query layer, and route every completion computation through it (getCourseProgress, getEnrolledCourses, getCourseContentItems, getCompletedExerciseIdsForMember, isExerciseCompletedForMember). - Remove the per-exercise N+1 pass checks in progression and the duplicated policy interpretation in the submission service. - Fix infinite "Checking eligibility" modal on the certificates page: open the completion modal in its final state instead of 'checking' with no follow-up. - Align teacher experience with students: certificate eligibility no longer requires the student role, completion modal triggers for any enrolled member, teachers can view/download their earned certificate, and video-watch progress tracks in the student experience regardless of org role. * chore: run api:dev without prebuild; keep full build as api:dev:full * fix(dashboard): gate video watch tracking on learner view * feat: pr reviews --------- Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
co-authored by
Rotimi Best
parent
ca3fdd5b6a
commit
27229cf8fe
+2
-2
@@ -12,7 +12,7 @@
|
||||
import { classroomio } from '$lib/utils/services/api';
|
||||
import type { CertificationEvaluationData } from '$features/course/utils/types';
|
||||
import { normalizeCertificateIssuedAt, formatBlockerMessage } from '$features/course/utils/certificate-utils';
|
||||
import { openCourseCompletionModal } from '$features/course/store/course-completion-modal';
|
||||
import { updateCourseCompletionModal } from '$features/course/store/course-completion-modal';
|
||||
|
||||
let isLoading = $state(false);
|
||||
let isPngLoading = $state(false);
|
||||
@@ -94,7 +94,7 @@
|
||||
isCourseComplete = hasEarned || !!res.data.eligibleForCertificate;
|
||||
|
||||
if (res.data.isNewCompletion && courseId) {
|
||||
openCourseCompletionModal(courseId);
|
||||
updateCourseCompletionModal(courseId, 'eligible', res.data);
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
import { toggleConfetti } from '$features/ui/confetti/store';
|
||||
import { ContentType } from '@cio/utils/constants/content';
|
||||
import { getOrderedNavigableContent } from '$features/course/utils/content';
|
||||
import { isOrgStudent } from '$lib/utils/store/app';
|
||||
import {
|
||||
openCourseCompletionModal,
|
||||
updateCourseCompletionModal,
|
||||
@@ -181,10 +180,7 @@
|
||||
|
||||
const allContentItems = getOrderedNavigableContent(courseApi.course);
|
||||
const allComplete =
|
||||
shouldMarkComplete &&
|
||||
$isOrgStudent &&
|
||||
allContentItems.length > 0 &&
|
||||
allContentItems.every((item) => item.isComplete);
|
||||
shouldMarkComplete && allContentItems.length > 0 && allContentItems.every((item) => item.isComplete);
|
||||
|
||||
if (allComplete && courseApi.course?.id) {
|
||||
const requiredExerciseId = courseApi.course?.certificate?.requiredExerciseId ?? undefined;
|
||||
|
||||
+1
-4
@@ -166,10 +166,7 @@
|
||||
updateCourseContentCompletion(currentLessonId, isComplete);
|
||||
|
||||
const allComplete =
|
||||
get(isCourseLearnerView) &&
|
||||
isComplete &&
|
||||
navigableContentItems.length > 0 &&
|
||||
navigableContentItems.every((item) => item.isComplete);
|
||||
isComplete && navigableContentItems.length > 0 && navigableContentItems.every((item) => item.isComplete);
|
||||
|
||||
if (allComplete) {
|
||||
const requiredExerciseId = courseApi.course?.certificate?.requiredExerciseId ?? undefined;
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@
|
||||
import { lessonApi } from '$features/course/api';
|
||||
import { snackbar } from '$features/ui/snackbar/store';
|
||||
import type { AssetTranscriptPayload } from '$features/media/utils/types';
|
||||
import { isOrgStudent } from '$lib/utils/store/app';
|
||||
import { isCourseLearnerView } from '$lib/utils/store/app';
|
||||
import { resolveWatchEnforcedAssetIds, type LessonVideo } from './video-card-utils';
|
||||
import { lessonVideoBus } from './lesson-video-bus.svelte';
|
||||
import { TRANSCRIPT_PANEL_ID } from './transcript-panel-definition';
|
||||
@@ -345,7 +345,7 @@
|
||||
|
||||
const seekPolicy = $derived.by(() => {
|
||||
const lesson = lessonApi.lesson;
|
||||
if (!$isOrgStudent || !lesson || lesson.completionPolicy !== 'video_watch' || !isWatchEnforcedForVideo) {
|
||||
if (!$isCourseLearnerView || !lesson || lesson.completionPolicy !== 'video_watch' || !isWatchEnforcedForVideo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@
|
||||
});
|
||||
|
||||
async function restoreWatchProgress(): Promise<void> {
|
||||
if (!$isOrgStudent || !uploadAssetId) return;
|
||||
if (!$isCourseLearnerView || !uploadAssetId) return;
|
||||
|
||||
const cachedAsset = assetWatchProgress;
|
||||
if (cachedAsset?.lastPositionSeconds && cachedAsset.lastPositionSeconds > 0) {
|
||||
|
||||
Reference in New Issue
Block a user