Skip to content

Commit

Permalink
Merge branch 'master' into rs-app-2147
Browse files Browse the repository at this point in the history
  • Loading branch information
valerydluski authored Nov 1, 2023
2 parents 249a2d5 + 987c03a commit 30a1d61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/src/pages/course/student/auto-test/task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -27,12 +28,20 @@ export const getServerSideProps: GetServerSideProps<AutoTestTaskProps> = 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 },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 30a1d61

Please sign in to comment.