Add 'approve without feedback' button for homework review
Curators/admins can mark a submission APPROVED (and complete the lesson) without writing feedback. The student sees 'ДЗ принято ✓' and can no longer resubmit. No email is sent on silent approval. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -108,6 +108,51 @@ export async function setReviewing(submissionId: string) {
|
||||
revalidatePath(`/curator/homework/${submissionId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Принять ДЗ без письменного ответа: ставим APPROVED и засчитываем урок,
|
||||
* фидбек не создаём и студенту письмо не шлём (тихое принятие).
|
||||
*/
|
||||
export async function approveWithoutFeedback(submissionId: string) {
|
||||
await requireCurator();
|
||||
|
||||
const submission = await prisma.homeworkSubmission.findUnique({
|
||||
where: { id: submissionId },
|
||||
include: {
|
||||
homework: {
|
||||
include: {
|
||||
lesson: {
|
||||
select: {
|
||||
id: true,
|
||||
module: { select: { course: { select: { slug: true } } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!submission) throw new Error("Submission not found");
|
||||
|
||||
const lesson = submission.homework.lesson;
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
await tx.homeworkSubmission.update({
|
||||
where: { id: submissionId },
|
||||
data: { status: "APPROVED", statusAt: new Date() },
|
||||
});
|
||||
await tx.lessonProgress.upsert({
|
||||
where: { userId_lessonId: { userId: submission.userId, lessonId: lesson.id } },
|
||||
create: { userId: submission.userId, lessonId: lesson.id },
|
||||
update: {},
|
||||
});
|
||||
});
|
||||
|
||||
revalidatePath("/curator/homework");
|
||||
revalidatePath(`/curator/homework/${submissionId}`);
|
||||
revalidatePath(`/courses/${lesson.module.course.slug}/lessons/${lesson.id}`);
|
||||
revalidatePath(`/courses/${lesson.module.course.slug}`);
|
||||
revalidatePath("/dashboard");
|
||||
}
|
||||
|
||||
export async function deleteSubmission(submissionId: string) {
|
||||
await requireCurator();
|
||||
await prisma.homeworkSubmission.delete({ where: { id: submissionId } });
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useState, useTransition, useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { submitFeedback, setReviewing } from "./actions";
|
||||
import { submitFeedback, setReviewing, approveWithoutFeedback } from "./actions";
|
||||
import { AudioRecorder } from "@/components/curator/audio-recorder";
|
||||
|
||||
interface FileItem {
|
||||
@@ -69,6 +69,13 @@ export function FeedbackForm({
|
||||
});
|
||||
}
|
||||
|
||||
function handleApproveNoFeedback() {
|
||||
startTransition(async () => {
|
||||
await approveWithoutFeedback(submissionId);
|
||||
router.push("/curator/homework");
|
||||
});
|
||||
}
|
||||
|
||||
const isWorking = pending || uploading;
|
||||
|
||||
return (
|
||||
@@ -164,6 +171,17 @@ export function FeedbackForm({
|
||||
{pending ? "Отправка..." : "Отправить ответ"}
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleApproveNoFeedback}
|
||||
disabled={isWorking}
|
||||
className="btn-aubade px-4 py-2 text-sm"
|
||||
style={{ opacity: isWorking ? 0.5 : 1 }}
|
||||
title="Засчитать ДЗ без письменного ответа"
|
||||
>
|
||||
Принять и отметить выполненным
|
||||
</button>
|
||||
|
||||
{currentStatus !== "REVIEWING" && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user