File tree Expand file tree Collapse file tree
components/Answer/CardContent Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11import BaseModel from "./base_model"
22import QuizAnswer from "./quiz_answer"
3+ import QuizItem from "./quiz_item"
34import QuizOptionAnswer from "./quiz_option_answer"
45
56class 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
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 1+ import { Quiz } from "./Quiz"
2+
13export 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
You can’t perform that action at this time.
0 commit comments