fix(api): allow inviting students to compliance courses without a certificate deadline (#840)
* Allow teachers invite students * Greptile comment fix * coderabbit comment fix
This commit is contained in:
@@ -49,8 +49,8 @@ export class ComplianceApi extends BaseApiWithErrors {
|
||||
return result?.data;
|
||||
}
|
||||
|
||||
async ensureOverview(courseId: string) {
|
||||
if (this.overviewKey === courseId && this.overview) {
|
||||
async ensureOverview(courseId: string, refresh = false) {
|
||||
if (!refresh && this.overviewKey === courseId && this.overview) {
|
||||
return this.overview;
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ export class ComplianceApi extends BaseApiWithErrors {
|
||||
return result?.data;
|
||||
}
|
||||
|
||||
async ensureLearnerHistory(courseId: string, profileId: string) {
|
||||
async ensureLearnerHistory(courseId: string, profileId: string, refresh = false) {
|
||||
const requestKey = `${courseId}:${profileId}`;
|
||||
if (this.learnerHistoryKey === requestKey && this.learnerHistory) {
|
||||
if (!refresh && this.learnerHistoryKey === requestKey && this.learnerHistory) {
|
||||
return this.learnerHistory;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
import { Badge } from '@cio/ui/base/badge';
|
||||
import { Button } from '@cio/ui/base/button';
|
||||
import { Checkbox } from '@cio/ui/base/checkbox';
|
||||
@@ -21,8 +22,8 @@
|
||||
type ComplianceStatus = CourseComplianceLearner['status'] | LearnerComplianceRecord['status'] | 'no_record';
|
||||
type StaffAction = 'reset' | 'extend' | 'waive' | null;
|
||||
|
||||
let lastRequestKey = $state<string | null>(null);
|
||||
let staffTab = $state<'overview' | 'learners'>('overview');
|
||||
let loadedCourseId = $state<string | null>(null);
|
||||
let activeAction = $state<StaffAction>(null);
|
||||
let bulkActionType = $state<Exclude<StaffAction, null> | null>(null);
|
||||
let isBulkActionModalOpen = $state(false);
|
||||
@@ -76,29 +77,20 @@
|
||||
|
||||
if (!isComplianceCourse) {
|
||||
complianceApi.reset();
|
||||
lastRequestKey = null;
|
||||
loadedCourseId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const courseId = courseApi.course.id;
|
||||
const needsRefresh = untrack(() => loadedCourseId) !== courseId;
|
||||
loadedCourseId = courseId;
|
||||
|
||||
if (isStudent && currentMember?.profileId) {
|
||||
const requestKey = `${courseId}:${currentMember.profileId}:learner`;
|
||||
if (lastRequestKey === requestKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastRequestKey = requestKey;
|
||||
void complianceApi.ensureLearnerHistory(courseId, currentMember.profileId);
|
||||
void complianceApi.ensureLearnerHistory(courseId, currentMember.profileId, needsRefresh);
|
||||
return;
|
||||
}
|
||||
|
||||
const requestKey = `${courseId}:overview`;
|
||||
if (lastRequestKey === requestKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastRequestKey = requestKey;
|
||||
void complianceApi.ensureOverview(courseId);
|
||||
void complianceApi.ensureOverview(courseId, needsRefresh);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user