王鹏鹏 2 лет назад
Родитель
Сommit
8833a673dc

+ 48 - 0
baselib/src/main/java/com/yingyangfly/baselib/bean/QuestionRecordsListBean.kt

@@ -0,0 +1,48 @@
+package com.yingyangfly.baselib.bean
+
+data class QuestionRecordsListBean(
+    val countId: Any,
+    val current: Int,
+    val maxLimit: Any,
+    val optimizeCountSql: Boolean,
+    val orders: List<Any>,
+    val pages: Int,
+    val records: List<QuestionRecordsBean>,
+    val searchCount: Boolean,
+    val size: Int,
+    val total: Int
+)
+
+data class QuestionRecordsBean(
+    val correctOptionId: Any,
+    val correctOptionName: Any,
+    val createBy: String,
+    val createTime: String,
+    val examinationId: String,
+    val examinationTitle: Any,
+    val id: String,
+    val limit: Int,
+    val manualHelp: String,
+    val orgCode: String,
+    val orgName: String,
+    val page: Int,
+    val questionOptions: List<QuestionOption>,
+    val score: Int,
+    val status: String,
+    val title: String,
+    val updateBy: String,
+    val updateTime: String,
+    val usedTime: Any
+)
+
+data class QuestionOption(
+    val correctOption: String,
+    val createBy: String,
+    val createTime: String,
+    val id: String,
+    val optionKey: Any,
+    val optionVal: String,
+    val questionId: String,
+    val updateBy: String,
+    val updateTime: String
+)

+ 11 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/entity/GetQuestionListBean.kt

@@ -0,0 +1,11 @@
+package com.yingyangfly.evaluation.entity
+
+/**
+ * 获取试题内容
+ */
+class GetQuestionListBean {
+
+    var examinationId = ""
+    var page : Int = 1
+    var limit = ""
+}

+ 7 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/net/EvaluationApiService.kt

@@ -1,5 +1,6 @@
 package com.yingyangfly.evaluation.net
 
+import com.yingyangfly.baselib.bean.QuestionRecordsListBean
 import com.yingyangfly.baselib.bean.UserInfoBean
 import com.yingyangfly.baselib.db.QuestionsBean
 import com.yingyangfly.baselib.net.BaseResp
@@ -59,4 +60,10 @@ interface EvaluationApiService {
     @POST("questionRecord/examinationList")
     suspend fun getExaminationList(@Body requestBody: RequestBody): BaseResp<ExaminationListBean>
 
+    /**
+     * 获取试题库内容
+     */
+    @POST("questionRecord/questionList")
+    suspend fun getQuestionList(@Body requestBody: RequestBody): BaseResp<QuestionRecordsListBean>
+
 }

+ 15 - 2
evaluation/src/main/java/com/yingyangfly/evaluation/otherevaluation/OtherEvaluationActivity.kt

@@ -39,7 +39,6 @@ class OtherEvaluationActivity :
     private var evaluationList = mutableListOf<ExaminationRecord>()
     private val examinationAdapter by lazy { ExaminationAdapter() }
 
-
     override fun initViews() {
         binding {
             swipeEvaluation.setEnableLoadMore(true)
@@ -55,7 +54,7 @@ class OtherEvaluationActivity :
 
             rvEvaluation.adapter = examinationAdapter
             examinationAdapter.onClickListener = {
-                JumpUtil.jumpActivity(RouterUrlCommon.questionList, mContext)
+                getQuestionList(it.examinationId)
             }
         }
     }
@@ -158,4 +157,18 @@ class OtherEvaluationActivity :
         }
         return true
     }
+
+
+    /**
+     * 获取测评试题内容列表
+     */
+    private fun getQuestionList(examinationId: String) {
+        viewModel.getQuestionList(examinationId, fail = {
+            it.toast()
+        }, success = {
+            if (it != null && it.records.isNullOrEmpty().not()) {
+                JumpUtil.jumpActivity(RouterUrlCommon.questionList, mContext)
+            }
+        })
+    }
 }

+ 21 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/otherevaluation/OtherEvaluationViewModel.kt

@@ -1,11 +1,13 @@
 package com.yingyangfly.evaluation.otherevaluation
 
+import com.yingyangfly.baselib.bean.QuestionRecordsListBean
 import com.yingyangfly.baselib.mvvm.BaseViewModel
 import com.yingyangfly.baselib.net.XUtils
 import com.yingyangfly.baselib.utils.GsonUtil
 import com.yingyangfly.evaluation.entity.EvaluationTypeBean
 import com.yingyangfly.evaluation.entity.ExaminationListBean
 import com.yingyangfly.evaluation.entity.GetExaminationListBean
+import com.yingyangfly.evaluation.entity.GetQuestionListBean
 import com.yingyangfly.evaluation.net.EVALUATION_API
 
 /**
@@ -47,4 +49,23 @@ class OtherEvaluationViewModel : BaseViewModel() {
         success, fail
     )
 
+    /**
+     * 获取试题库列表
+     */
+    fun getQuestionList(
+        id: String,
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: QuestionRecordsListBean?) -> Unit)? = null,
+    ) = launchFlow(true) {
+        val requestBean = GetQuestionListBean().apply {
+            limit = "99999"
+            page = 1
+            examinationId = id
+        }
+        val body = XUtils.createJson(GsonUtil.GsonString(requestBean))
+        EVALUATION_API.getQuestionList(body)
+    }.runUI(
+        success, fail
+    )
+
 }