handleProblemNavigation(id)}
- className="cursor-pointer border-t border-border hover:bg-background-50"
+ onClick={() => isAvailable && handleProblemNavigation(id)}
+ className={classNames(
+ 'border-t border-border hover:bg-background-50',
+ {'cursor-not-allowed': !isAvailable },
+ {'cursor-pointer': isAvailable },
+ )}
>
- {title} |
+
+
+ {!isAvailable && renderLock()}
+ {title}
+
+ |
{Difficulty[difficulty]}
diff --git a/client/src/modules/Problem/components/Submission/index.tsx b/client/src/modules/Problem/components/Submission/index.tsx
index 39b0426..9652cb0 100644
--- a/client/src/modules/Problem/components/Submission/index.tsx
+++ b/client/src/modules/Problem/components/Submission/index.tsx
@@ -42,11 +42,8 @@ const Submission: FC = ({ problemId, code, language }) => {
};
const loading = runLoading || submissionLoading;
- const accepted = result?.status == SubmissionStatus.Accepted;
- const isSubmission = result?.type == SubmissionTypes.Submission;
const showResult = activeTab == SubmissionTabs.Result && result && !loading;
const showTestcase = activeTab == SubmissionTabs.Testcase && !loading;
- const showComplete = accepted && isSubmission;
return (
diff --git a/server/src/core/data/entities/problem.entity.ts b/server/src/core/data/entities/problem.entity.ts
index a021c0f..d39c1af 100644
--- a/server/src/core/data/entities/problem.entity.ts
+++ b/server/src/core/data/entities/problem.entity.ts
@@ -4,6 +4,7 @@ export class ProblemEntity {
content: string;
difficulty: number;
defaultCodes: DefaultCodes[];
+ isAvailable: boolean;
}
export type DefaultCodes = {
diff --git a/server/src/modules/auth/models/constants.ts b/server/src/modules/auth/models/constants.ts
index 15ee747..1e40272 100644
--- a/server/src/modules/auth/models/constants.ts
+++ b/server/src/modules/auth/models/constants.ts
@@ -1,4 +1,4 @@
-export const ACCESS_TOKEN = 'access_token';
+export const ACCESS_TOKEN = 'codex_access_token';
export const ACCESS_HEADER = 'x-access-token';
export const Roles = {
diff --git a/server/src/modules/challenge/challenge.service.ts b/server/src/modules/challenge/challenge.service.ts
index 17f0a0a..b4c0012 100644
--- a/server/src/modules/challenge/challenge.service.ts
+++ b/server/src/modules/challenge/challenge.service.ts
@@ -73,6 +73,12 @@ export class ChallengeService {
await this.dataService.challenges.update(challengeId, {
activeParticipants: activeParticipants?.map((ap) => ap.id),
});
+
+ const challenge = await this.dataService.challenges.findById(challengeId);
+ const problem = await this.dataService.problems.findById(challenge.problemId);
+
+ await this.dataService.problems.update(problem.id, { isAvailable: true });
+
await this.teamService.setupTeams(challengeId, activeParticipants);
this.lobbyService.changeStatus(challengeId, Status.ongoing);
}
diff --git a/server/src/modules/problem/dtos/create-problem.dto.ts b/server/src/modules/problem/dtos/create-problem.dto.ts
index 9e9b793..7305470 100644
--- a/server/src/modules/problem/dtos/create-problem.dto.ts
+++ b/server/src/modules/problem/dtos/create-problem.dto.ts
@@ -1,6 +1,6 @@
import { DefaultCodes } from '@core/data/entities/problem.entity';
import { ApiProperty } from '@nestjs/swagger';
-import { IsArray, IsNumber, IsString } from 'class-validator';
+import { IsArray, IsBoolean, IsNumber, IsString } from 'class-validator';
import { Difficulty } from '../models/enums';
@@ -21,4 +21,7 @@ export class CreateProblemDto {
@IsArray()
readonly defaultCodes: DefaultCodes[];
+ @ApiProperty()
+ @IsBoolean()
+ readonly isAvailable: boolean;
}
diff --git a/server/src/modules/problem/problem.service.ts b/server/src/modules/problem/problem.service.ts
index 8df5fe0..1888875 100644
--- a/server/src/modules/problem/problem.service.ts
+++ b/server/src/modules/problem/problem.service.ts
@@ -5,7 +5,7 @@ import { CreateProblemDto } from './dtos/create-problem.dto';
@Injectable()
export class ProblemService {
- constructor(private readonly dataService: IDataService) {}
+ constructor(private readonly dataService: IDataService) { }
async findAll(userId?: string) {
if (userId) return await this.dataService.queries.findProblems(userId);
@@ -14,7 +14,8 @@ export class ProblemService {
async findById(id: string) {
const problem = await this.dataService.problems.findById(id);
- return problem;
+
+ if(problem.isAvailable) return problem;
}
async create(createProblemDto: CreateProblemDto) {
diff --git a/server/src/modules/providers/ottoman/schemas/problem.schema.ts b/server/src/modules/providers/ottoman/schemas/problem.schema.ts
index 0bfc144..6a0aae1 100644
--- a/server/src/modules/providers/ottoman/schemas/problem.schema.ts
+++ b/server/src/modules/providers/ottoman/schemas/problem.schema.ts
@@ -4,5 +4,6 @@ export const problemSchema = new Schema({
title: String,
content: String,
difficulty: Number,
+ isAvailable: Boolean,
defaultCodes: [{ type: Object }],
});
|