|
@@ -57,12 +57,15 @@ class VerifyAnswersFragment : BaseFragment<FragmentVerifyAnswersBinding>() {
|
|
|
}
|
|
|
btnNext.setOnSingleClickListener {
|
|
|
if (judge()) {
|
|
|
- val controller = Navigation.findNavController(it)
|
|
|
- val bundle = bundleOf("questionId" to 41)
|
|
|
- controller.navigate(
|
|
|
- R.id.action_verifyAnswersFragment_to_identifyPictureFragment,
|
|
|
- bundle
|
|
|
- )
|
|
|
+ binding.rvChoice.post {
|
|
|
+ updateStatus()
|
|
|
+ val controller = Navigation.findNavController(it)
|
|
|
+ val bundle = bundleOf("questionId" to 41)
|
|
|
+ controller.navigate(
|
|
|
+ R.id.action_verifyAnswersFragment_to_identifyPictureFragment,
|
|
|
+ bundle
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -117,4 +120,37 @@ class VerifyAnswersFragment : BaseFragment<FragmentVerifyAnswersBinding>() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断答案是否全部正确
|
|
|
+ */
|
|
|
+ private fun updateStatus() {
|
|
|
+ var isAllCorrect = true
|
|
|
+ if (choiceItemList.isNullOrEmpty().not()) {
|
|
|
+ choiceItemList.forEach {
|
|
|
+ if (it.correct == "0") {
|
|
|
+ isAllCorrect = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isAllCorrect.not()) {
|
|
|
+ choiceItemList.forEach {
|
|
|
+ it.reviewId = it.id
|
|
|
+ it.score = "0"
|
|
|
+ it.correct = "0"
|
|
|
+ if (dao != null) {
|
|
|
+ dao?.update(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ choiceItemList.forEach {
|
|
|
+ it.reviewId = it.id
|
|
|
+ it.score = it.reviewScore
|
|
|
+ it.correct = "1"
|
|
|
+ if (dao != null) {
|
|
|
+ dao?.update(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|