fix: skip calibration if its not active in experiment

This commit is contained in:
averel10
2026-04-10 07:38:04 +02:00
parent 3bb7f0cc6c
commit 4cbac5f4d2
2 changed files with 17 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ import { auth } from '@/lib/auth';
import { headers } from 'next/headers';
import type { DatasetEntryForAnnotation } from '@/lib/dialects';
import { experiment } from '@/lib/model/experiment';
import { getDialectScoresFromCalibration, isCalibrationDone } from '@/app/actions/calibration-scoring';
import { getDialectScoresFromCalibration } from '@/app/actions/calibration-scoring';
/**

View File

@@ -117,6 +117,22 @@ export async function isCalibrationDone(experimentId: number): Promise<boolean>
const session = await auth.api.getSession({ headers: await headers() });
if (!session) throw new Error('Nicht angemeldet');
// Check if calibration is enabled for this experiment
const exp = await db
.select()
.from(experiment)
.where(eq(experiment.id, experimentId))
.limit(1);
if (exp.length === 0) {
throw new Error('Experiment not found');
}
// If calibration is not enabled, consider it done
if (!exp[0].calibrationEnabled) {
return true;
}
// Check if participant exists for this user and experiment
const participantRecord = await db
.select()