package com.dlc.exam.ui.score

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.dlc.exam.common.TopicType
import com.rc.httpcore.vo.response.ExamTopic
import com.rc.httpcore.vo.response.HandPaperBean
import com.rc.httpcore.vo.response.HandPractiseBean

/**
 * info
 *
 * @author ReiChin_
 */
class PaperQuViewModel : ViewModel() {

    private val mutablePaperQuData = MutableLiveData<ExamTopic.ElPaperQu>()
    val paperQuData: LiveData<ExamTopic.ElPaperQu> get() = mutablePaperQuData

    fun setPaperQu(data: ExamTopic.ElPaperQu?) {
        mutablePaperQuData.value = data
    }

    private val mutableGroupInfoData = MutableLiveData<TopicGroupInfo>()
    val groupInfoData: LiveData<TopicGroupInfo> get() = mutableGroupInfoData

    fun setTopicGroupInfo(data: TopicGroupInfo) {
        mutableGroupInfoData.value = data
    }

    private val mutableHandPractiseData = MutableLiveData<HandPractiseBean>()
    val handPractiseData: LiveData<HandPractiseBean> get() = mutableHandPractiseData

    fun setHandPractise(data: HandPractiseBean) {
        mutableHandPractiseData.value = data
    }

    private val mutableExamTopicData = MutableLiveData<ExamTopic>()
    val examTopicData: LiveData<ExamTopic> get() = mutableExamTopicData

    fun setExamTopic(data: ExamTopic) {
        mutableExamTopicData.value = data
    }

    private val mutableExamAnswerData = MutableLiveData<ExamAnswer>()
    val examExamAnswerData: LiveData<ExamAnswer> get() = mutableExamAnswerData

    fun setExamAnswer(data: ExamAnswer) {
        mutableExamAnswerData.value = data
    }

    private val mutableHandPaperData = MutableLiveData<HandPaperBean>()
    val examHandPaperData: LiveData<HandPaperBean> get() = mutableHandPaperData

    fun setHandPaper(data: HandPaperBean) {
        mutableHandPaperData.value = data
    }

    private val mutableRemainingTimeData = MutableLiveData<String>()
    val remainingTimeData: LiveData<String> get() = mutableRemainingTimeData

    fun setRemainingTime(data: String) {
        mutableRemainingTimeData.value = data
    }

    private val mutableRetestData = MutableLiveData<Boolean>()
    val retestData: LiveData<Boolean> get() = mutableRetestData

    fun setRetest(data: Boolean) {
        mutableRetestData.value = data
    }

}

data class TopicGroupInfo(
    val topicType: TopicType, // 当前题目类型，单选/多选/判断
    val topicCount: Int = 0, // 当前题目类型组共有多少题目
    val currentNum: Int = 0 // 当前题目编号，从1开始
)

data class ExamAnswer(
    val sheetInx: Int, // 答题卡编号，从0开始
    val nextIdx: Int, // 下一题，从0开始
    val answeredCnt: Int, // 已作答题目数
    val answered: Boolean = true, // 是否需要更新答题卡
    val right: Boolean = false // 是否回答正确，在answered=true时有效
)