diff --git a/client/src/pages/course/student/auto-test/task.tsx b/client/src/pages/course/student/auto-test/task.tsx index 839b1f72e3..505d4f4f02 100644 --- a/client/src/pages/course/student/auto-test/task.tsx +++ b/client/src/pages/course/student/auto-test/task.tsx @@ -5,6 +5,7 @@ import { GetServerSideProps } from 'next'; import { CoursesTasksApi } from 'api'; import { getApiConfiguration } from 'utils/axios'; import { getTokenFromContext } from 'utils/server'; +import dayjs from 'dayjs'; function Page(props: AutoTestTaskProps) { return ( @@ -27,12 +28,20 @@ export const getServerSideProps: GetServerSideProps = async c try { const course = result.props.course; + if (course) { const { data: task } = await new CoursesTasksApi(getApiConfiguration(token)).getCourseTask( course.id, Number(courseTaskId), ); + const now = dayjs(); + const startDate = dayjs(task.studentStartDate); + + if (startDate > now) { + return noAccessResponse; + } + return { props: { course, task }, }; diff --git a/nestjs/src/courses/task-verifications/task-verifications.service.ts b/nestjs/src/courses/task-verifications/task-verifications.service.ts index 896a189af1..76acdb3caa 100644 --- a/nestjs/src/courses/task-verifications/task-verifications.service.ts +++ b/nestjs/src/courses/task-verifications/task-verifications.service.ts @@ -109,6 +109,10 @@ export class TaskVerificationsService { throw new BadRequestException(`Course task does not belong to the student's course`); } + if (courseTask.studentStartDate && courseTask.studentStartDate > new Date()) { + throw new BadRequestException(`Task Verification ${courseTask.task.name} not started`); + } + const existing = await this.taskVerificationsRepository.findOne({ where: { status: 'pending',