Skip to content

Commit

Permalink
feat: 그래프가 없더라도 상황에 맞는 ref값을 제공한다
Browse files Browse the repository at this point in the history
- 초기화 상태인지 검사하는 함수 추가
- 초기화 할때 ref값도 같이 초기화한다
- 초기화 상태가 아니라면 세션에 있는 ref값을 제공한다

[#290]
  • Loading branch information
LuizyHub authored and flydog98 committed Dec 13, 2023
1 parent 7d67ad3 commit fbc49de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/backend/src/quizzes/quizzes.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class QuizzesController {
ref: defaultRef,
};
}
if (!graph) {
if (await this.sessionService.isReseted(sessionId, id)) {
return {
...defaultGraph,
ref: defaultRef,
Expand Down
9 changes: 9 additions & 0 deletions packages/backend/src/session/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class SessionService {
session.problems.get(problemId).status = 'solving';
session.problems.get(problemId).graph = '';
session.problems.get(problemId).containerId = '';
session.problems.get(problemId).ref = '';
}

private async getSessionById(id: string): Promise<Session> {
Expand Down Expand Up @@ -235,4 +236,12 @@ export class SessionService {
}
return;
}

async isReseted(sessionId: string, problemId: number): Promise<boolean> {
const session = await this.getSessionById(sessionId);
if (!session.problems.get(problemId)) {
throw new Error('problem not found');
}
return session.problems.get(problemId).logs.length === 0;
}
}

0 comments on commit fbc49de

Please sign in to comment.