Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #44 - 질문지 문제 풀기 API 구현 #46

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

choiyoubin
Copy link
Collaborator

🩵 Issue

close #44


💙 변경된 내용

  • QuestionData 수정하여, 질문지 불러올때 questionId, [questions] 불러올 수 있도록 수정
  • score 채점 후, didSet이용하여 데이터 동기화

🅿️ PR Point

private func postSolvedAnswer(questionId: Int, answerList: [Int], completion: @escaping(Result<Int, FTError>) -> Void) {
        Providers.questionProvider.request(.solveQuestionnaire(questionId: questionId, answerList: answerList)) { result in
            switch result {
            case .success(let response):
                do {
                    let answerCountResponse = try response.map(BaseResponse<Int>.self)
                    
                    if answerCountResponse.status == 200 {
                        if let count = answerCountResponse.data {
                            print("채점이 성공했습니다.. 맞은 개수: \(count)")
                            completion(.success(count))
                        } else {
                            completion(.failure(.networkFail))
                            print("응답에서 초대 코드를 찾을 수 없습니다.")
                        }
                    } else {
                        completion(.failure(.networkFail))
                        print("질문지 생성 실패: \(answerCountResponse.message)")
                    }
                } catch {
                    completion(.failure(.networkFail))
                    print("Decoding error: \(error)")
                }
            case .failure(let error):
                completion(.failure(.networkFail))
                print("Network error: \(error)")
                
            }
        }
    }

📘 ScreenShot

Simulator Screen Recording - iPhone 16 Pro - 2024-12-23 at 01 38 22


수정 필요 사항

  • 질무문지 생성 후 홈화면 재진입시 네비게이션바 등장
  • 코드 컨벤션 수정

Copy link
Collaborator

@cirtuare cirtuare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

레전드개발자 ;; ☃️

Comment on lines 91 to 94
} else {
completion(.failure(.networkFail))
print("응답에서 초대 코드를 찾을 수 없습니다.")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분을 따로 분기처리해준 이유가 있나요?
아마 200인데 count 데이터가 없을 경우를 처리해준 것 같은데, networkFail는 아니라 noData 등으로 처리해주면 어떨까요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

구조를 그대로 들고오다보니까 신경쓰지 못했어요!! 다시 확인 후 수정해보겠습니다

Comment on lines 87 to 98
if answerCountResponse.status == 200 {
if let count = answerCountResponse.data {
print("채점이 성공했습니다.. 맞은 개수: \(count)")
completion(.success(count))
} else {
completion(.failure(.networkFail))
print("응답에서 초대 코드를 찾을 수 없습니다.")
}
} else {
completion(.failure(.networkFail))
print("질문지 생성 실패: \(answerCountResponse.message)")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 말한 91-94줄의 분기처리가 필요없다면 이 전체를 guard let으로 퉁치면 될 것 같아요

guard answerCountResponse.status == 200, 
     let count = answerCountResponse.data else {
    print("질문지 생성 실패: \(answerCountResponse.message)")
    completion(.failure(.networkFail))
    return
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 천재개발자

} catch {
completion(.failure(.networkFail))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것도 .decodingErr 만들어서 처리해주면 좋을 것 같습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했어용~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 질문지 문제 풀기 API 구현
2 participants