Skip to content

Commit bca2515

Browse files
authored
Merge pull request #766 from rage/no-accept-reject-buttons-for-non-peer-review-questions
No accept reject buttons for non peer review questions
2 parents 7a0d1bc + e844c47 commit bca2515

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

packages/backendv2/src/models/quiz_answer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ class QuizAnswer extends mixin(BaseModel, [
213213
.whereIn("deleted", deleteConditions)
214214
.orderBy([{ column: "created_at", order: order }])
215215
.page(page, pageSize)
216+
.withGraphFetched("quiz.[peerReviewCollections]")
216217
.withGraphFetched("userQuizState")
217-
.withGraphFetched("itemAnswers.[optionAnswers]")
218+
.withGraphFetched("itemAnswers.[quizItem, optionAnswers]")
218219
.withGraphFetched("peerReviews.[answers.[question.[texts]]]")
219220
} else {
220221
paginated = await this.query()
@@ -223,8 +224,9 @@ class QuizAnswer extends mixin(BaseModel, [
223224
.whereIn("status", filters)
224225
.orderBy([{ column: "created_at", order: order }])
225226
.page(page, pageSize)
227+
.withGraphFetched("quiz.[peerReviewCollections]")
226228
.withGraphFetched("userQuizState")
227-
.withGraphFetched("itemAnswers.[optionAnswers]")
229+
.withGraphFetched("itemAnswers.[quizItem, optionAnswers]")
228230
.withGraphFetched("peerReviews.[answers.[question.[texts]]]")
229231
}
230232

packages/backendv2/src/models/quiz_item_answer.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import BaseModel from "./base_model"
22
import QuizAnswer from "./quiz_answer"
3+
import QuizItem from "./quiz_item"
34
import QuizOptionAnswer from "./quiz_option_answer"
45

56
class QuizItemAnswer extends BaseModel {
67
id!: string
8+
quizAnswer!: QuizAnswer
79
quizItemId!: string
10+
quizItem!: QuizItem
811
textData!: string
912
correct!: boolean
1013
optionAnswers!: QuizOptionAnswer[]
@@ -16,7 +19,7 @@ class QuizItemAnswer extends BaseModel {
1619

1720
static relationMappings = {
1821
quizAnswer: {
19-
relation: BaseModel.BelongsToOneRelation,
22+
relation: BaseModel.HasOneRelation,
2023
modelClass: QuizAnswer,
2124
join: {
2225
from: "quiz_item_answer.quiz_answer_id",
@@ -31,6 +34,14 @@ class QuizItemAnswer extends BaseModel {
3134
to: "quiz_option_answer.quiz_item_answer_id",
3235
},
3336
},
37+
quizItem: {
38+
relation: BaseModel.HasOneRelation,
39+
modelClass: QuizItem,
40+
join: {
41+
from: "quiz_item_answer.quiz_item_id",
42+
to: "quiz_item.id",
43+
},
44+
},
3445
}
3546
}
3647

packages/quizzes-dashboard/components/Answer/CardContent/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ export const AnswerContent = ({ answer }: AnswerContentProps) => {
204204
</>
205205
)}
206206
</StatButtonWrapper>
207-
{editableAnswerStates.includes(answer.status) && (
208-
<ManualReviewField answer={answer} />
209-
)}
207+
{editableAnswerStates.includes(answer.status) &&
208+
answer.quiz.peerReviewCollections.length > 0 && (
209+
<ManualReviewField answer={answer} />
210+
)}
210211
</>
211212
)
212213
}

packages/quizzes-dashboard/types/Answer.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Quiz } from "./Quiz"
2+
13
export interface Answer {
24
id: string
35
quizId: string
@@ -9,6 +11,7 @@ export interface Answer {
911
userQuizState: UserQuizState
1012
itemAnswers: ItemAnswer[]
1113
peerReviews: PeerReview[]
14+
quiz: Quiz
1215
deleted: boolean
1316
}
1417

0 commit comments

Comments
 (0)