Skip to content

Commit

Permalink
Merge pull request #766 from rage/no-accept-reject-buttons-for-non-pe…
Browse files Browse the repository at this point in the history
…er-review-questions

No accept reject buttons for non peer review questions
  • Loading branch information
nygrenh authored May 17, 2021
2 parents 7a0d1bc + e844c47 commit bca2515
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/backendv2/src/models/quiz_answer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ class QuizAnswer extends mixin(BaseModel, [
.whereIn("deleted", deleteConditions)
.orderBy([{ column: "created_at", order: order }])
.page(page, pageSize)
.withGraphFetched("quiz.[peerReviewCollections]")
.withGraphFetched("userQuizState")
.withGraphFetched("itemAnswers.[optionAnswers]")
.withGraphFetched("itemAnswers.[quizItem, optionAnswers]")
.withGraphFetched("peerReviews.[answers.[question.[texts]]]")
} else {
paginated = await this.query()
Expand All @@ -223,8 +224,9 @@ class QuizAnswer extends mixin(BaseModel, [
.whereIn("status", filters)
.orderBy([{ column: "created_at", order: order }])
.page(page, pageSize)
.withGraphFetched("quiz.[peerReviewCollections]")
.withGraphFetched("userQuizState")
.withGraphFetched("itemAnswers.[optionAnswers]")
.withGraphFetched("itemAnswers.[quizItem, optionAnswers]")
.withGraphFetched("peerReviews.[answers.[question.[texts]]]")
}

Expand Down
13 changes: 12 additions & 1 deletion packages/backendv2/src/models/quiz_item_answer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import BaseModel from "./base_model"
import QuizAnswer from "./quiz_answer"
import QuizItem from "./quiz_item"
import QuizOptionAnswer from "./quiz_option_answer"

class QuizItemAnswer extends BaseModel {
id!: string
quizAnswer!: QuizAnswer
quizItemId!: string
quizItem!: QuizItem
textData!: string
correct!: boolean
optionAnswers!: QuizOptionAnswer[]
Expand All @@ -16,7 +19,7 @@ class QuizItemAnswer extends BaseModel {

static relationMappings = {
quizAnswer: {
relation: BaseModel.BelongsToOneRelation,
relation: BaseModel.HasOneRelation,
modelClass: QuizAnswer,
join: {
from: "quiz_item_answer.quiz_answer_id",
Expand All @@ -31,6 +34,14 @@ class QuizItemAnswer extends BaseModel {
to: "quiz_option_answer.quiz_item_answer_id",
},
},
quizItem: {
relation: BaseModel.HasOneRelation,
modelClass: QuizItem,
join: {
from: "quiz_item_answer.quiz_item_id",
to: "quiz_item.id",
},
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ export const AnswerContent = ({ answer }: AnswerContentProps) => {
</>
)}
</StatButtonWrapper>
{editableAnswerStates.includes(answer.status) && (
<ManualReviewField answer={answer} />
)}
{editableAnswerStates.includes(answer.status) &&
answer.quiz.peerReviewCollections.length > 0 && (
<ManualReviewField answer={answer} />
)}
</>
)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/quizzes-dashboard/types/Answer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Quiz } from "./Quiz"

export interface Answer {
id: string
quizId: string
Expand All @@ -9,6 +11,7 @@ export interface Answer {
userQuizState: UserQuizState
itemAnswers: ItemAnswer[]
peerReviews: PeerReview[]
quiz: Quiz
deleted: boolean
}

Expand Down

0 comments on commit bca2515

Please sign in to comment.