fix: delete annotations and participants before experiment, skip calibration when disabled, remove Startseite link from annotation view
This commit is contained in:
@@ -113,7 +113,6 @@ function calculateDialectScores(
|
||||
* Returns true if calibration is completed or not required, false if calibration is pending.
|
||||
*/
|
||||
export async function isCalibrationDone(experimentId: number): Promise<boolean> {
|
||||
console.log('Checking calibration status for experimentId:', experimentId);
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) throw new Error('Nicht angemeldet');
|
||||
|
||||
@@ -123,11 +122,11 @@ export async function isCalibrationDone(experimentId: number): Promise<boolean>
|
||||
.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;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { experiment_calibration } from '@/lib/model/experiment_calibration';
|
||||
import { annotation } from '@/lib/model/annotation';
|
||||
import { participant } from '@/lib/model/participant';
|
||||
import { dataset_entry } from '@/lib/model/dataset_entry';
|
||||
import { and, eq, count, sql, isNotNull } from 'drizzle-orm';
|
||||
import { and, eq, count, sql } from 'drizzle-orm';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { auth, requireAdmin } from '@/lib/auth';
|
||||
import { isParticipantCalibrationDone } from './calibration-scoring';
|
||||
@@ -111,9 +111,11 @@ export async function deleteExperiment(id: number) {
|
||||
}
|
||||
|
||||
try {
|
||||
// Delete all experiment_calibration records first
|
||||
// Delete all child records first (FK constraints)
|
||||
await db.delete(annotation).where(eq(annotation.experimentId, id));
|
||||
await db.delete(participant).where(eq(participant.experimentId, id));
|
||||
await db.delete(experiment_calibration).where(eq(experiment_calibration.experimentId, id));
|
||||
|
||||
|
||||
// Delete the experiment
|
||||
await db.delete(experiment).where(eq(experiment.id, id));
|
||||
|
||||
|
||||
@@ -189,9 +189,6 @@ export default function AnnotationPageView({
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-gray-600">Unbekannter Annotation-Typ: {viewType}</p>
|
||||
<Link href="/" className="text-blue-600 hover:underline mt-4 inline-block">
|
||||
← Startseite
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -274,12 +271,7 @@ export default function AnnotationPageView({
|
||||
>
|
||||
{sidebarOpen ? '✕' : '☰'}
|
||||
</button>
|
||||
<Link
|
||||
href="/"
|
||||
className="text-sm px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md transition-colors"
|
||||
>
|
||||
← Startseite
|
||||
</Link>
|
||||
|
||||
{Object.keys(dialectScores).length > 0 && (
|
||||
<button
|
||||
onClick={() => setIsCalibrationModalOpen(true)}
|
||||
|
||||
Reference in New Issue
Block a user