|
@@ -1,11 +1,13 @@
|
|
|
package com.yingyangfly.evaluation.questionlist
|
|
package com.yingyangfly.evaluation.questionlist
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
|
|
+import android.text.TextUtils
|
|
|
import android.view.MotionEvent
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.yingyangfly.baselib.db.QuestionOptionBean
|
|
import com.yingyangfly.baselib.db.QuestionOptionBean
|
|
|
import com.yingyangfly.baselib.db.QuestionRecordsBean
|
|
import com.yingyangfly.baselib.db.QuestionRecordsBean
|
|
|
|
|
+import com.yingyangfly.baselib.dialog.AnswerJudgmentFragment
|
|
|
import com.yingyangfly.baselib.dialog.TipsDialog
|
|
import com.yingyangfly.baselib.dialog.TipsDialog
|
|
|
import com.yingyangfly.baselib.ext.getEndAnimation
|
|
import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
@@ -47,10 +49,14 @@ class QuestionListActivity : BaseMVVMActivity<ActivityQuestionListBinding, Quest
|
|
|
rvSelectedItem.adapter = questionListAdapter
|
|
rvSelectedItem.adapter = questionListAdapter
|
|
|
}
|
|
}
|
|
|
questionListAdapter.onClickListener = {
|
|
questionListAdapter.onClickListener = {
|
|
|
- if (questionRecordsBean != null && questionRecordsDao != null) {
|
|
|
|
|
- questionRecordsBean?.selectedItemId = it.id
|
|
|
|
|
- questionRecordsBean?.questionOptionName = it.optionVal
|
|
|
|
|
- questionRecordsDao?.update(questionRecordsBean!!)
|
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
|
+ if (questionRecordsBean != null) {
|
|
|
|
|
+ if (TextUtils.equals("0", questionRecordsBean?.manualHelp)) {
|
|
|
|
|
+ showAnswerJudgmentDialog(it)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ saveAnswer(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -147,7 +153,6 @@ class QuestionListActivity : BaseMVVMActivity<ActivityQuestionListBinding, Quest
|
|
|
runOnUiThread {
|
|
runOnUiThread {
|
|
|
//底部按钮展示逻辑
|
|
//底部按钮展示逻辑
|
|
|
binding {
|
|
binding {
|
|
|
-
|
|
|
|
|
btnPrevious.visibility = if (questionIndex > 0) {
|
|
btnPrevious.visibility = if (questionIndex > 0) {
|
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
|
} else {
|
|
} else {
|
|
@@ -178,34 +183,68 @@ class QuestionListActivity : BaseMVVMActivity<ActivityQuestionListBinding, Quest
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 展示人工判断弹窗
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun showAnswerJudgmentDialog(bean: QuestionOptionBean) {
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
|
+ val answerJudgmentFragment = AnswerJudgmentFragment()
|
|
|
|
|
+ answerJudgmentFragment.onDialogClickListener = {
|
|
|
|
|
+ if (questionRecordsDao != null) {
|
|
|
|
|
+ questionRecordsBean?.isCorrect = it
|
|
|
|
|
+ questionRecordsBean?.selectedItemId = bean.id
|
|
|
|
|
+ questionRecordsBean?.questionOptionName = bean.optionVal
|
|
|
|
|
+ questionRecordsDao?.update(questionRecordsBean!!)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ answerJudgmentFragment.show(supportFragmentManager, "answerJudgmentFragment")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存答案
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun saveAnswer(bean: QuestionOptionBean) {
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
|
+ if (questionRecordsDao != null) {
|
|
|
|
|
+ questionRecordsBean?.selectedItemId = bean.id
|
|
|
|
|
+ questionRecordsBean?.questionOptionName = bean.optionVal
|
|
|
|
|
+ questionRecordsDao?.update(questionRecordsBean!!)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 提交数据
|
|
* 提交数据
|
|
|
*/
|
|
*/
|
|
|
private fun saveData() {
|
|
private fun saveData() {
|
|
|
- if (questionRecordsBeans.isNullOrEmpty().not()) {
|
|
|
|
|
- val saveAnswerRecordBean = mutableListOf<SaveAnswerRecordBean>()
|
|
|
|
|
- questionRecordsBeans.forEach {
|
|
|
|
|
- val saveAnswerRecord = SaveAnswerRecordBean().apply {
|
|
|
|
|
- correctOptionId = it.selectedItemId
|
|
|
|
|
- id = it.id
|
|
|
|
|
- score = it.score
|
|
|
|
|
- correctOptionName = it.questionOptionName
|
|
|
|
|
- title = it.title
|
|
|
|
|
- usedTime = time.toString()
|
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
|
+ if (questionRecordsBeans.isNullOrEmpty().not()) {
|
|
|
|
|
+ val saveAnswerRecordBean = mutableListOf<SaveAnswerRecordBean>()
|
|
|
|
|
+ questionRecordsBeans.forEach {
|
|
|
|
|
+ val saveAnswerRecord = SaveAnswerRecordBean().apply {
|
|
|
|
|
+ correctOptionId = it.selectedItemId
|
|
|
|
|
+ id = it.id
|
|
|
|
|
+ score = it.score
|
|
|
|
|
+ correctOptionName = it.questionOptionName
|
|
|
|
|
+ title = it.title
|
|
|
|
|
+ usedTime = time.toString()
|
|
|
|
|
+ isCorrect = it.isCorrect
|
|
|
|
|
+ }
|
|
|
|
|
+ id = it.id.toString()
|
|
|
|
|
+ saveAnswerRecord.examinationId = examinationId
|
|
|
|
|
+ saveAnswerRecord.examinationTitle = examinationTitle
|
|
|
|
|
+ saveAnswerRecordBean.add(saveAnswerRecord)
|
|
|
}
|
|
}
|
|
|
- id = it.id.toString()
|
|
|
|
|
- saveAnswerRecord.examinationId = examinationId
|
|
|
|
|
- saveAnswerRecord.examinationTitle = examinationTitle
|
|
|
|
|
- saveAnswerRecordBean.add(saveAnswerRecord)
|
|
|
|
|
|
|
+ viewModel.saveAnswerRecord(saveAnswerRecordBean, fail = {
|
|
|
|
|
+ it.toast()
|
|
|
|
|
+ }, success = {
|
|
|
|
|
+ JumpUtil.jumpActivityWithUrl(
|
|
|
|
|
+ RouterUrlCommon.evaluationHistory, "other", mContext
|
|
|
|
|
+ )
|
|
|
|
|
+ finish()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- viewModel.saveAnswerRecord(saveAnswerRecordBean, fail = {
|
|
|
|
|
- it.toast()
|
|
|
|
|
- }, success = {
|
|
|
|
|
- JumpUtil.jumpActivityWithUrl(
|
|
|
|
|
- RouterUrlCommon.evaluationHistory, "other", mContext
|
|
|
|
|
- )
|
|
|
|
|
- finish()
|
|
|
|
|
- })
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|