作者 zhangji

1、我的模块-我的错题列表

2、我的模块-我的答题记录
3、错题列表之重新答题
4、答题记录之答题详情
以上全写完
正在显示 35 个修改的文件 包含 1138 行增加149 行删除
... ... @@ -69,10 +69,12 @@
android:screenOrientation="portrait"
android:theme="@style/Theme.SecurityTrainMaster.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
... ... @@ -193,6 +195,8 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" />
<activity android:name=".ui.view.home.activity.course.CoursePractiseActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"/>
<activity android:name=".ui.view.bank.activity.AnswerRecordDetailsActivity" />
<activity android:name=".ui.view.bank.activity.WrongQuestionsActivity" />
</application>
... ...
... ... @@ -63,7 +63,7 @@ interface AllItemApi : ApiService {
@POST("/api/item/paper_list_detail")
fun specialPracticeDetail(
@Field("paper_id") paper_id: String
): Observable<BaseResponse<CommonDetailList<PaperListDetail>>>
): Observable<BaseResponse<CommonDataList<PaperListDetail>>>
/**
* 专项练习题目列表
... ... @@ -87,7 +87,7 @@ interface AllItemApi : ApiService {
@Field("pos_id") pos_ia: Int, // 工种id
@Field("page") page: Int, // 页数
@Field("pageNum") pageNum: Int // 每页条数
): Observable<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>>
): Observable<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>>
/**
* 开始答题
... ... @@ -135,7 +135,7 @@ interface AllItemApi : ApiService {
@Field("type") type: Int,
@Field("page") page: Int,
@Field("page_num") page_num: Int
): Observable<BaseResponse<CommonList<ErrorListItem>>>
): Observable<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>>
/**
* 错题列表
... ... @@ -153,7 +153,7 @@ interface AllItemApi : ApiService {
* @param answer 答案都好分开
*/
@FormUrlEncoded
@POST("/api/item/user_sub_error")
@POST("/api/item/item_sub_error")
fun subError(
@Field("error_id") error_id: Int,
@Field("answer") answer: String
... ... @@ -166,7 +166,7 @@ interface AllItemApi : ApiService {
* @param item_type 答题类型1=每日一练2=挑战答题3=专项练习4=模拟考试
*/
@FormUrlEncoded
@POST("/api/item/user_del_error")
@POST("/api/item/item_del_error")
fun delError(
@Field("item_id") item_id: Int,
@Field("type") type: Int,
... ... @@ -185,7 +185,7 @@ interface AllItemApi : ApiService {
@Field("type") type: Int,
@Field("page") page: Int,
@Field("page_num") page_num: Int
): Observable<BaseResponse<CommonList<AnswerRecord>>>
): Observable<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>>
/**
* 答题记录详情
... ... @@ -196,9 +196,7 @@ interface AllItemApi : ApiService {
@FormUrlEncoded
@POST("/api/item/user_item_list_detail")
fun errorSubDetail(
@Field("id") id: Int,
@Field("page") page: Int,
@Field("page_num") page_num: Int
@Field("id") id: Int
): Observable<BaseResponse<CommonList<AnswerDetail>>>
}
\ No newline at end of file
... ...
... ... @@ -172,6 +172,8 @@ interface ApiService {
fun getMineInfo(
): Observable<BaseResponse<MineInfoBean>>
//退出登录
@POST("/api/user/logout")
fun logout(
... ...
... ... @@ -11,7 +11,6 @@ open class CommonList<T>(var list: List<T>)
open class CommonReport<T>(var report: T)
open class CommonDataList<T>(var list: T)
open class CommonDetail<T>(var detail: T)
open class CommonDetailList<T>(var list: T)
open class CommonInfo<T>(var info: T)
open class CommonPage<T>(
var total: Int, // 总数
... ...
... ... @@ -3,14 +3,11 @@ package com.br_technology.securitytrain_master.base.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.ui.bean.*
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.StartItemBean
import com.br_technology.securitytrain_master.ui.view.bank.bean.SubjectData
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.ui.view.bank.bean.*
/**
* Author by YSir
... ... @@ -49,7 +46,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
//专项练习详情
fun specialPracticeDetail(
paper_id: String,
liveData: MutableLiveData<BaseResponse<CommonDetailList<PaperListDetail>>>
liveData: MutableLiveData<BaseResponse<CommonDataList<PaperListDetail>>>
) {
addRequest(itemService.specialPracticeDetail(paper_id), liveData)
}
... ... @@ -67,7 +64,7 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
pos_id: Int,
page: Int,
pageNum: Int,
liveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>>
liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>>
) {
addRequest(itemService.dayPracticeList(pos_id, page, pageNum), liveData)
}
... ... @@ -116,15 +113,6 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
addRequest(itemService.subPaper(user_item_id), liveData)
}
//错题列表
fun errorList(
type: Int,
page: Int,
page_num: Int,
liveData: MutableLiveData<BaseResponse<CommonList<ErrorListItem>>>
) {
addRequest(itemService.errorList(type, page, page_num), liveData)
}
//错题详情
fun errorDetail(id: Int, liveData: MutableLiveData<BaseResponse<ErrorDetail>>) {
... ... @@ -140,34 +128,22 @@ class ItemRepository(loadState: MutableLiveData<State>) : ApiRepository(loadStat
addRequest(itemService.subError(error_id, answer), liveData)
}
//删除错题
fun delError(
item_id: Int,
type: Int,
item_type: Int,
liveData: MutableLiveData<BaseResponse<Void>>
) {
addRequest(itemService.delError(item_id, type, item_type), liveData)
}
//答题记录
fun errorSubList(
type: Int,
page: Int,
page_num: Int,
liveData: MutableLiveData<BaseResponse<CommonList<AnswerRecord>>>
) {
addRequest(itemService.errorSubList(type, page, page_num), liveData)
}
// //答题记录
// fun errorSubList(
// type: Int,
// page: Int,
// page_num: Int,
// liveData: MutableLiveData<BaseResponse<CommonList<AnswerRecord>>>
// ) {
// addRequest(itemService.errorSubList(type, page, page_num), liveData)
// }
//答题记录详情
fun errorSubDetail(
id: Int,
page: Int,
page_num: Int,
liveData: MutableLiveData<BaseResponse<CommonList<AnswerDetail>>>
) {
addRequest(itemService.errorSubDetail(id, page, page_num), liveData)
addRequest(itemService.errorSubDetail(id), liveData)
}
/**
... ...
... ... @@ -84,6 +84,7 @@ abstract class BaseAdapter<T, VB : ViewBinding> :
notifyItemChanged(oldPosition, list.size)
}
fun addListAndPosition(t: List<T>, position: Int) {
list.addAll(position, t)
notifyItemChanged(position, list.size)
... ...
... ... @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.bean
import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
import com.br_technology.securitytrain_master.ui.view.bank.bean.PracticeBean
import com.br_technology.securitytrain_master.base.network.response.CommonDetail
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
/**
* Author by YSir
... ... @@ -94,7 +95,7 @@ open class ErrorListItem(
//错题详情
open class ErrorDetail(
var error_id: String,
var detail: CommonDetail<ErrorDetailData>
var detail: TestSubject
)
open class ErrorDetailData(
... ... @@ -129,14 +130,11 @@ open class AnswerRecord(
//答题记录详情
open class AnswerDetail(
var type: String,
var item_id: Int,
var answer: String,
var is_correct: String,
var item: AnswerDetailItem
val type: String,
val item_id: Int,
val answer: String,
val is_correct: String,
val item: TestSubject,
val paperitem: TestSubject,
)
open class AnswerDetailItem(
var title: String,
var options: String
)
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@ open class TestSubject(
var paper_id: Int,
var item_id: Int,
var title: String,
var options: String,
var type: String,
var difficulty: String,
var correct: String,
... ... @@ -75,3 +76,4 @@ data class StartItemBean(
val user_item_id: String,
var list: List<TestSubject>
)
... ...
package com.br_technology.securitytrain_master.ui.view.bank.activity
import android.app.Activity
import android.content.ClipData
import android.content.Intent
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.ActivityAnswerRecordDetailsBinding
import com.br_technology.securitytrain_master.ui.view.bank.adapter.AnswerRecordDetailsAdapter
import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
import com.br_technology.securitytrain_master.view.listener.ToolBarClickListener
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
/**
* auth: 张继
* date: 2022/1/24 13:54
* dsc:答题记录详情
* updateInfo:
*/
class AnswerRecordDetailsActivity :
BaseLifeCycleActivity<PracticeViewModel, ActivityAnswerRecordDetailsBinding>(
ActivityAnswerRecordDetailsBinding::inflate
) {
private val mPagerAdapter = AnswerRecordDetailsAdapter()
private val startForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
//页面返回值
val data = result.data?.getIntExtra("position", 0)
if (data != null) {
binding.previous.visibility = View.VISIBLE
binding.next.visibility = View.VISIBLE
if (data == 0) {
binding.previous.visibility = View.GONE
binding.next.visibility = View.VISIBLE
}
if (data == mPagerAdapter.itemCount - 1) {
binding.previous.visibility = View.VISIBLE
binding.next.visibility = View.GONE
}
if (data in 0 until mPagerAdapter.itemCount) {
binding.practicePager.currentItem = data
}
}
}
}
override fun initDataObserver() {
mViewModel.errorSubDetailLiveData.observe(this) {
mPagerAdapter.showCorrect = true
mPagerAdapter.addList(it.data.list)
}
}
override fun initData() {
super.initData()
val id = intent.getIntExtra("id", 0)
mViewModel.errorSubDetail(id)
binding.apply {
toolBar.setRightText("答题卡")
toolBar.setRightTextDrawable(
ContextCompat.getDrawable(
baseContext,
R.mipmap.answer_sheet
)
)
// 答题卡点击事件
toolBar.addRightListener(object : ToolBarClickListener {
override fun onClick(view: View) {
val intent = Intent(baseContext, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
startForResult.launch(intent)
}
})
// 隐藏交卷
finishJob.visibility = View.GONE
practicePager.isUserInputEnabled = false
// 设置适配器
practicePager.adapter = mPagerAdapter
// 上一题
previous.setOnClickListener {
val index = practicePager.currentItem
if (index >= 1) {
practicePager.currentItem = index - 1
}
next.visibility = View.VISIBLE
if (index == 1) {
previous.visibility = View.GONE
}
}
// 下一题
next.setOnClickListener {
val index = binding.practicePager.currentItem
if (index < mPagerAdapter.itemCount - 1) {
binding.practicePager.currentItem = index + 1
}
binding.previous.visibility = View.VISIBLE
if (index == mPagerAdapter.itemCount - 2) {
binding.next.visibility = View.GONE
}
}
}
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.bank.activity
import com.br_technology.securitytrain_master.databinding.ActivityWrongQuestionsBinding
import com.br_technology.securitytrain_master.ui.view.bank.adapter.PracticePaperAdapter
import com.br_technology.securitytrain_master.ui.view.bank.viewmodel.PracticeViewModel
import com.br_technology.securitytrain_master.ui.view.mine.fragment.MyErrorQuestionFragment
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
import kotlin.properties.Delegates
/**
* auth: 张继
* date: 2022/1/24 18:29
* dsc:错题列表继续答题
* updateInfo:
*/
class WrongQuestionsActivity :
BaseLifeCycleActivity<PracticeViewModel, ActivityWrongQuestionsBinding>(
ActivityWrongQuestionsBinding::inflate
) {
private var itemId: Int = 0
private var type by Delegates.notNull<Int>()
private val adapter by lazy {
PracticePaperAdapter()
}
override fun initDataObserver() {
mViewModel.errorDetail.observe(this) {
itemId = it.data.error_id.toInt()
adapter.addData(it.data.detail)
}
mViewModel.subErrorLiveData.observe(this) {
showTip("提交成功")
adapter.showCorrect = true
adapter.notifyDataSetChanged()
}
}
override fun initData() {
super.initData()
val id = intent.getIntExtra("id", 0)
type = intent.getIntExtra("type", 1)
MyErrorQuestionFragment.map[type] = true
mViewModel.errorDetail(id)
binding.apply {
errorPager.isUserInputEnabled = false
errorPager.adapter = adapter
// 交卷
finishJob.setOnClickListener {
finishJob.isClickable = false
mViewModel.subError(itemId, adapter.getAnswer()[0].answer)
}
}
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.bank.adapter
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.text.SpannableString
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.common.ConstantType
import com.br_technology.securitytrain_master.base.view.BaseAdapter
import com.br_technology.securitytrain_master.base.view.BaseViewHolder
import com.br_technology.securitytrain_master.databinding.AdapterContentPracticeItemBinding
import com.br_technology.securitytrain_master.databinding.AdapterTopicBinding
import com.br_technology.securitytrain_master.expand.dp2px
import com.br_technology.securitytrain_master.ui.bean.Answer
import com.br_technology.securitytrain_master.ui.bean.AnswerDetail
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
import com.br_technology.securitytrain_master.ui.view.bank.bean.OptionArr
import com.br_technology.securitytrain_master.ui.view.bank.bean.TestSubject
import com.br_technology.securitytrain_master.util.GlideEnginePic
import com.br_technology.securitytrain_master.view.listener.OnItemClickListener
import com.br_technology.securitytrain_master.view.listener.OnItemListener
import com.luck.picture.lib.PictureSelector
import com.luck.picture.lib.entity.LocalMedia
/**
* auth: 张继
* date: 2022/1/24 16:21
* dsc:
* updateInfo:
*/
class AnswerRecordDetailsItemAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
// 题目类型 1:单选 2:多选 3:判断
var type = 1
// 是否显示正确答案
var showCorrect = false
// 选中选项
var mSelectIndex = mutableListOf<Int>()
var mListener: OnItemListener? = null
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): AdapterTopicBinding {
return AdapterTopicBinding.inflate(from, parent, false)
}
/**
* 选中处理
*/
fun itemClick(position: Int) {
if (!mSelectIndex.contains(position)) {
mSelectIndex.add(position)
} else {
mSelectIndex.remove(position)
}
notifyDataSetChanged()
}
fun setItemClickListener(listener: OnItemListener) {
this.mListener = listener
}
/**
* 是否为选中
*/
fun isSelected(position: Int): Boolean {
return mSelectIndex.contains(position)
}
override fun onBindViewHolder(holder: BaseViewHolder<AdapterTopicBinding>, position: Int) {
super.onBindViewHolder(holder, position)
holder.itemView.isEnabled = !showCorrect
holder.itemView.setOnClickListener {
mListener?.onItemClick(position)
}
}
@SuppressLint("SetTextI18n")
override fun onBind(holder: AdapterTopicBinding, position: Int, data: OptionArr) {
holder.tvName.text = "${data.option_name}.${data.value}"
if (data.pic_arr.isNotEmpty()) {
val pictureAdapter = PictureAdapter(holder.root.context)
pictureAdapter.addList(data.pic_arr.toMutableList())
holder.ivPic.adapter = pictureAdapter
holder.ivPic.setOnTouchListener { v, event ->
holder.contentTopic.onTouchEvent(event)
false
}
pictureAdapter.addListener(object : OnItemClickListener<String> {
override fun onClick(position: Int, pic: String) {
previewPhoto(data.pic_arr, holder.root.context, position)
}
})
}
setTextDefault(holder.contentTopic, holder.tvName)
// 单选 / 判断
if (type == 1 || type == 3) {
if (mSelectIndex.isNotEmpty() && mSelectIndex[0] == position) {
if (showCorrect) {
if (data.is_correct == 1) {
setTextGreen(holder.contentTopic, holder.tvName)
} else {
setTextRed(holder.contentTopic, holder.tvName)
}
} else {
//未交卷时显示
setTextGreen(holder.contentTopic, holder.tvName)
}
} else {
if (showCorrect && data.is_correct == 1) {
// 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化
// setTextGreen(holder.contentTopic, holder.tvName)
}
}
}
// 多选
if (type == 2) {
if (isSelected(position)) {
if (showCorrect) {
if (data.is_correct == 1) {
setTextGreen(holder.contentTopic, holder.tvName)
} else {
setTextRed(holder.contentTopic, holder.tvName)
}
} else {
setTextGreen(holder.contentTopic, holder.tvName)
}
} else {
if (showCorrect && data.is_correct == 1) {
// 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化
// setTextGreen(holder.contentTopic, holder.tvName)
}
}
}
}
private fun setTextDefault(view: View, textView: TextView) {
view.setBackgroundResource(R.drawable.stroke_eb_4)
textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_32))
}
private fun setTextRed(view: View, textView: TextView) {
view.setBackgroundResource(R.drawable.topic_back_error)
textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_e9))
}
private fun setTextGreen(view: View, textView: TextView) {
view.setBackgroundResource(R.drawable.solid_0825_4)
textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_25))
}
private fun previewPhoto(data: Array<String>, context: Context, position: Int) {
val list = mutableListOf<LocalMedia>()
data.forEach {
val localMedia = LocalMedia()
localMedia.path = it
list.add(localMedia)
}
PictureSelector.create(context as Activity)
.themeStyle(R.style.picture_default_style)
.imageEngine(GlideEnginePic.createGlideEngine())
.openExternalPreview(position, list)
}
}
class AnswerRecordDetailsAdapter(private val isShowPosition: Boolean = true) :
BaseAdapter<AnswerDetail, AdapterContentPracticeItemBinding>() {
// 是否显示正确答案
var showCorrect = false
var selectResultData = HashMap<Int, List<Int>>()
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): AdapterContentPracticeItemBinding {
return AdapterContentPracticeItemBinding.inflate(from, parent, false)
}
@SuppressLint("SetTextI18n")
override fun onBind(
holder: AdapterContentPracticeItemBinding,
index: Int,
data: AnswerDetail
) {
val value = if (isShowPosition) {
"(${index + 1}/${itemCount})${data.item.title}${ConstantType.getType(data.type)}"
} else {
"${data.item.title}${ConstantType.getType(data.type)}"
}
val span = SpannableString(value)
span.setSpan(
ForegroundColorSpan(Color.parseColor("#C8C9CC")),
value.length - 4,
value.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
span.setSpan(
AbsoluteSizeSpan(14.dp2px()),
value.length - 4,
value.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
holder.topic.text = span
val adapterChild = AnswerRecordDetailsItemAdapter()
adapterChild.addList(data.item.options_arr)
holder.topicRecycler.adapter = adapterChild
holder.txtCorrect.text = "正确答案:${data.item.correct}"
holder.txtAnalysis.text = "解析:${data.item.remark}"
holder.contentAnalysis.visibility = if (showCorrect) View.VISIBLE else View.GONE
adapterChild.let {
val type = data.type.toInt()
it.type = type
it.showCorrect = showCorrect
if (type == 1 || type == 3) {
for (position in data.item.options_arr.indices) {
if (data.item.options_arr[position].option_name == data.answer) {
it.itemClick(position)
break
}
}
} else {
for (position in data.item.options_arr.indices) {
val split = data.answer.split(",")
for (j in split.indices) {
if (data.item.options_arr[position].option_name == split[j]) {
it.itemClick(index)
break
}
}
}
}
if (selectResultData.containsKey(index)) {
selectResultData[index]?.let { data ->
if (data.isNotEmpty()) {
it.mSelectIndex = data as MutableList<Int>
}
}
}
it.setItemClickListener(object : OnItemListener {
override fun onItemClick(position: Int) {
if (type == 1 || type == 3) {
if (it.mSelectIndex.isEmpty()) {
it.mSelectIndex.add(position)
} else {
it.mSelectIndex[0] = position
}
it.notifyDataSetChanged()
} else {
it.itemClick(position)
}
selectResultData[index] = it.mSelectIndex
}
})
}
}
override fun addList(t: List<AnswerDetail>) {
super.addList(t)
for (data in getData()) {
val index = getData().indexOf(data)
selectResultData[index] = listOf()
val selectIndex = mutableListOf<Int>()
if (data.type == "1" || data.type == "3") {
for (position in data.item.options_arr.indices) {
if (data.item.options_arr[position].option_name == data.answer) {
selectIndex.add(position)
selectResultData[index] = selectIndex
break
}
}
} else {
for (position in data.item.options_arr.indices) {
val split = data.answer.split(",")
for (j in split.indices) {
if (data.item.options_arr[position].option_name == split[j]) {
selectIndex.add(position)
selectResultData[index] = selectIndex
break
}
}
}
}
}
}
private fun getResultData(): ArrayList<List<Int>> {
val data = ArrayList<List<Int>>()
val result = selectResultData.keys
val dataKey = mutableListOf<Int>()
for (item in result) {
dataKey.add(item)
}
dataKey.sort()
for (index in dataKey) {
selectResultData[index]?.let {
data.add(it)
}
}
return data
}
fun getAnswer(): ArrayList<Answer> {
val data = ArrayList<Answer>()
val list = getResultData()
val listSubject = getData()
for (res in list.indices) {
val pos = list[res]
val ppp = listSubject[res]
data.add(Answer(ppp.item_id, getAnswer(ppp.item.options_arr, pos)))
}
return data
}
fun getAnswer(optionArr: List<OptionArr>, data: List<Int>): String {
var str = ""
if (data.isNotEmpty()) {
for (res in data) {
if (res < optionArr.size) {
str = str + optionArr[res].option_name + ","
}
}
}
return str.substringBeforeLast(",");
}
fun getCount(): Int {
var count = 0
for (data in selectResultData) {
if (data.value.isNotEmpty()) {
count++
}
}
return count
}
fun getArrayList(): ArrayList<String> {
val list = ArrayList<String>()
val dataList = getResultData()
for (data in getData()) {
val position = getData().indexOf(data)
if (dataList[position].isEmpty()) {
list.add("")
} else {
val element = if (isTrue(data, dataList[position], data.item.options_arr)
) "1" else "0"
list.add(element)
}
}
return list
}
private fun isTrue(
testSubject: AnswerDetail,
mSelectIndex: List<Int>,
optionArr: List<OptionArr>
): Boolean {
var bool = false
val type = testSubject.type.toInt()
if (type == 1 || type == 3) {
bool = if (mSelectIndex.isNotEmpty()) {
optionArr[mSelectIndex[0]].is_correct == 1
} else {
false
}
}
if (type == 2) {
var count = 0
var dataCount = 0
for (item in optionArr) {
val position = optionArr.indexOf(item)
if (item.is_correct == 1) {
if (mSelectIndex.contains(position)) {
count++
}
dataCount++;
}
}
bool = count == dataCount && mSelectIndex.size == count
}
return bool
}
}
... ...
... ... @@ -44,9 +44,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
// 题目类型 1:单选 2:多选 3:判断
var type = 1
// 是否时正确的答题
var isTrue: Boolean = true
// 是否显示正确答案
var showCorrect = false
... ... @@ -114,7 +111,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
})
}
setTextDefault(holder.contentTopic, holder.tvName)
// 单选 / 判断
if (type == 1 || type == 3) {
... ... @@ -185,7 +181,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
.openExternalPreview(position, list)
}
}
class PracticePaperAdapter(private val isShowPosition: Boolean = true) :
... ...
... ... @@ -3,7 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.bank.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.repository.ItemRepository
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.PaperListDetail
... ... @@ -17,7 +17,7 @@ import com.br_technology.securitytrain_master.util.sp_job_id
*/
class MockExamViewModel : BaseViewModel<ItemRepository>() {
val liveData: MutableLiveData<BaseResponse<CommonList<PracticeBean>>> = MutableLiveData()
val paperDetailLiveData: MutableLiveData<BaseResponse<CommonDetailList<PaperListDetail>>> =
val paperDetailLiveData: MutableLiveData<BaseResponse<CommonDataList<PaperListDetail>>> =
MutableLiveData()
fun specialPracticeList(
... ...
... ... @@ -30,10 +30,20 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() {
val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData()
// 每日一练列表数据
val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> =
val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> =
MutableLiveData()
// 获取挑战答题弹板信息
val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData()
val errorSubDetailLiveData: MutableLiveData<BaseResponse<CommonList<AnswerDetail>>> =
MutableLiveData()
// 错题详情
val errorDetail: MutableLiveData<BaseResponse<ErrorDetail>> = MutableLiveData()
val subErrorLiveData: MutableLiveData<BaseResponse<Void>> = MutableLiveData()
fun getTestData(id: String) {
mRepository.getTestSubject(testData, id)
}
... ... @@ -55,6 +65,13 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() {
mRepository.subAnswer(itemId, jsonArray, subAnswer)
}
/**
* 提交错题
*/
fun subError(itemId: Int, answer: String) {
mRepository.subError(itemId, answer, subErrorLiveData)
}
// 开始答题
fun itemStart(
paper_id: Int?,
... ... @@ -91,4 +108,18 @@ class PracticeViewModel : BaseViewModel<ItemRepository>() {
}
fun errorSubDetail(
id: Int
) {
mRepository.errorSubDetail(id, errorSubDetailLiveData)
}
fun errorDetail(
id: Int
) {
mRepository.errorDetail(id, errorDetail)
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@ package com.br_technology.securitytrain_master.ui.view.home.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDetailList
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.repository.TrainRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
... ... @@ -28,7 +28,7 @@ class CoursePracticeViewModel : BaseViewModel<TrainRepository>() {
val subSingleData: MutableLiveData<BaseResponse<SubSingle>> = MutableLiveData()
// 每日一练列表数据
val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDetailList<CommonPage<PaperDaily>>>> =
val dayPracticeLiveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<PaperDaily>>>> =
MutableLiveData()
// 获取挑战答题弹板信息
val challengeInfoLiveData: MutableLiveData<BaseResponse<ChallengeInfo>> = MutableLiveData()
... ...
... ... @@ -35,7 +35,11 @@ class MyErrorQuestionActivity :
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
)
val list =
mutableListOf(MyErrorQuestionFragment(), MyErrorQuestionFragment(), MyErrorQuestionFragment())
mutableListOf(
MyErrorQuestionFragment.newInstance(1),
MyErrorQuestionFragment.newInstance(2),
MyErrorQuestionFragment.newInstance(3)
)
val titles = listOf("单选题", "判断题", "多选题")
searchResultAdapter.addData(list.toMutableList())
searchResultAdapter.addTitle(titles)
... ...
... ... @@ -29,8 +29,13 @@ class QuestionRecordActivity :
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
)
val list =
mutableListOf(SpecialExercisesFragment(), MockExaminationFragment())
val titles = listOf("专项练习", "模拟考试")
mutableListOf(
SpecialExercisesFragment.newInstance(3),
SpecialExercisesFragment.newInstance(4),
SpecialExercisesFragment.newInstance(5),
SpecialExercisesFragment.newInstance(6)
)
val titles = listOf("专项练习", "培训计划考试", "培训计划联系", "模拟考试")
searchResultAdapter.addData(list.toMutableList())
searchResultAdapter.addTitle(titles)
viewPager.adapter = searchResultAdapter
... ...
... ... @@ -3,27 +3,26 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.view.BaseAdapter
import com.br_technology.securitytrain_master.databinding.ItemMyErrorQuestionBinding
import com.br_technology.securitytrain_master.ui.bean.ErrorListItem
import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
/**
* Time: 7/31/2021 16:08
* Author: Captain
* Description: 初见时你很迷人
*/
class MyErrorQuestionAdapter : BaseAdapter<VideoCourse, ItemMyErrorQuestionBinding>() {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): ItemMyErrorQuestionBinding {
return ItemMyErrorQuestionBinding.inflate(from, parent, false)
class MyErrorQuestionAdapter : BaseQuickAdapter<ErrorListItem,BaseViewHolder>(R.layout.item_my_error_question) {
init {
addChildClickViewIds(R.id.iv_del)
}
override fun onBind(holder: ItemMyErrorQuestionBinding, position: Int, data: VideoCourse) {
// 错题名称
holder.tvQuestionTitle.text = data.courseName
override fun convert(holder: BaseViewHolder, item: ErrorListItem) {
holder.setText(R.id.tv_question_title,item.title)
}
}
\ No newline at end of file
... ...
... ... @@ -3,27 +3,36 @@ package com.br_technology.securitytrain_master.ui.view.mine.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.view.BaseAdapter
import com.br_technology.securitytrain_master.databinding.ItemSpecialExercisesBinding
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
/**
* Time: 7/31/2021 17:06
* Author: Captain
* Description: 初见时你很迷人
*/
class SpecialExercisesAdapter : BaseAdapter<VideoCourse,ItemSpecialExercisesBinding>() {
override fun getViewBinding(
context: Context,
parent: ViewGroup,
viewType: Int,
from: LayoutInflater
): ItemSpecialExercisesBinding {
return ItemSpecialExercisesBinding.inflate(from, parent, false)
}
override fun onBind(holder: ItemSpecialExercisesBinding, position: Int, data: VideoCourse) {
// 题名称
holder.tvQuestionTitle.text = data.courseName
class SpecialExercisesAdapter : BaseQuickAdapter<AnswerRecord,BaseViewHolder>(R.layout.item_special_exercises) {
override fun convert(holder: BaseViewHolder, item: AnswerRecord) {
holder.setText(R.id.tv_question_title,item.title)
.setText(R.id.tv_timer,item.create_time_text)
.setText(R.id.tv_answer,"答对:${item.correct}/${item.count}")
}
// override fun getViewBinding(
// context: Context,
// parent: ViewGroup,
// viewType: Int,
// from: LayoutInflater
// ): ItemSpecialExercisesBinding {
// return ItemSpecialExercisesBinding.inflate(from, parent, false)
// }
//
// override fun onBind(holder: ItemSpecialExercisesBinding, position: Int, data: VideoCourse) {
// // 题名称
// holder.tvQuestionTitle.text = data.courseName
// }
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.fragment
import android.content.Intent
import android.os.Bundle
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.FragmentMyErrorQuestionBinding
import com.br_technology.securitytrain_master.ui.bean.ErrorListItem
import com.br_technology.securitytrain_master.ui.view.bank.activity.WrongQuestionsActivity
import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse
import com.br_technology.securitytrain_master.ui.view.mine.adapter.MyErrorQuestionAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.MyErrorQuestionFragmentViewModel
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
import kotlin.properties.Delegates
/**
* Time: 7/31/2021 15:47
... ... @@ -16,23 +21,84 @@ class MyErrorQuestionFragment :
BaseLifeCycleFragment<MyErrorQuestionFragmentViewModel, FragmentMyErrorQuestionBinding>(
FragmentMyErrorQuestionBinding::inflate
) {
override fun initDataObserver() {
private val questionAdapter: MyErrorQuestionAdapter by lazy {
MyErrorQuestionAdapter()
}
private var page = 1
private var type by Delegates.notNull<Int>()
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
map[type] = false
if (it.data.list.data.size <= 20) {
binding.smartRefresh.setNoMoreData(true)
}
if (page == 1) {
questionAdapter.setNewInstance(it.data.list.data as MutableList<ErrorListItem>)
} else {
questionAdapter.addData(it.data.list.data)
}
}
mViewModel.delErrorLiveData.observe(this) {
showTip("删除成功")
binding.smartRefresh.autoRefresh()
}
}
override fun initData() {
super.initData()
type = arguments?.getInt("type", 1) ?: 1
binding.apply {
smartRefresh.setOnRefreshListener {
page = 1
smartRefresh.setNoMoreData(false)
mViewModel.errorList(type, page)
smartRefresh.finishRefresh()
}
smartRefresh.setOnLoadMoreListener {
++page
mViewModel.errorList(type, page)
smartRefresh.finishLoadMore()
}
recyclerview.adapter = questionAdapter
// 删除
questionAdapter.setOnItemChildClickListener { adapter, view, position ->
val errorListItem = adapter.data.get(position) as ErrorListItem
mViewModel.delError(
errorListItem.item_id.toInt(),
type,
errorListItem.item_type.toInt()
)
}
// 继续答题
questionAdapter.setOnItemClickListener { adapter, view, position ->
val intent = Intent(requireActivity(), WrongQuestionsActivity::class.java)
intent.putExtra("id", questionAdapter.data[position].id)
intent.putExtra("type", type)
startActivity(intent)
}
}
}
override fun onResume() {
super.onResume()
if (map[type] == true) {
binding.recyclerview.scrollToPosition(0)
binding.smartRefresh.autoRefresh()
}
}
val myErrorQuestionAdapter = MyErrorQuestionAdapter()
val list = mutableListOf(
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
)
recyclerview.adapter = myErrorQuestionAdapter
myErrorQuestionAdapter.addList(list)
companion object {
val map = hashMapOf<Int, Boolean>()
fun newInstance(type: Int): MyErrorQuestionFragment {
map[type] = true
val fragment = MyErrorQuestionFragment()
val bundle = Bundle()
bundle.putInt("type", type)
fragment.arguments = bundle
return fragment
}
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.fragment
import android.content.Intent
import android.os.Bundle
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.databinding.FragmentSpecialExercisesBinding
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
import com.br_technology.securitytrain_master.ui.view.bank.activity.AnswerRecordDetailsActivity
import com.br_technology.securitytrain_master.ui.view.home.pojo.VideoCourse
import com.br_technology.securitytrain_master.ui.view.mine.adapter.SpecialExercisesAdapter
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.SpecialExercisesFragmentViewModel
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
import kotlin.properties.Delegates
/**
* Time: 7/31/2021 17:02
... ... @@ -17,24 +22,71 @@ class SpecialExercisesFragment
: BaseLifeCycleFragment<SpecialExercisesFragmentViewModel, FragmentSpecialExercisesBinding>(
FragmentSpecialExercisesBinding::inflate
) {
override fun initDataObserver() {
private var page = 1
private var type by Delegates.notNull<Int>()
private val exercisesAdapter: SpecialExercisesAdapter by lazy {
SpecialExercisesAdapter()
}
private val map = hashMapOf(1 to true, 2 to true, 3 to true, 4 to true)
override fun initDataObserver() {
mViewModel.liveData.observe(this) {
if (it.data.list.data.size <= 20) {
binding.smartRefresh.setNoMoreData(true)
}
if (page == 1) {
exercisesAdapter.setNewInstance(it.data.list.data as MutableList<AnswerRecord>)
} else {
exercisesAdapter.addData(it.data.list.data)
}
}
}
override fun initData() {
super.initData()
type = arguments?.getInt("type") ?: 1
binding.apply {
smartRefresh.setOnRefreshListener {
page = 1
smartRefresh.setNoMoreData(false)
mViewModel.errorSubList(type, page)
smartRefresh.finishRefresh()
}
smartRefresh.setOnLoadMoreListener {
++page
mViewModel.errorSubList(type, page)
smartRefresh.finishLoadMore()
}
recyclerview.adapter = exercisesAdapter
exercisesAdapter.setOnItemClickListener { adapter, view, position ->
val intent = Intent(requireContext(), AnswerRecordDetailsActivity::class.java)
intent.putExtra("id", exercisesAdapter.data[position].id)
startActivity(intent)
}
val specialExercisesAdapter = SpecialExercisesAdapter()
val list = mutableListOf(
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
VideoCourse(R.mipmap.banner, "01:45:00", "自动化制作课程", "1.1", "张钧-三岗职位培训班"),
)
recyclerview.adapter = specialExercisesAdapter
specialExercisesAdapter.addList(list)
}
}
override fun onResume() {
super.onResume()
if (map[type] == true) {
map[type] = false
binding.smartRefresh.autoRefresh()
}
}
companion object {
fun newInstance(type: Int): SpecialExercisesFragment {
val fragment = SpecialExercisesFragment()
val bundle = Bundle()
bundle.putInt("type", type)
fragment.arguments = bundle
return fragment
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.ui.bean.ErrorListItem
/**
* Time: 7/31/2021 15:48
... ... @@ -10,4 +15,25 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository
* Description: 初见时你很迷人
*/
class MyErrorQuestionFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
//错题列表
fun errorList(
type: Int,
page: Int,
page_num: Int,
liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>>
) {
addRequest(itemService.errorList(type, page, page_num), liveData)
}
//删除错题
fun delError(
item_id: Int,
type: Int,
item_type: Int,
liveData: MutableLiveData<BaseResponse<Void>>
) {
addRequest(itemService.delError(item_id, type, item_type), liveData)
}
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,10 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.ui.bean.ErrorListItem
/**
* Time: 7/31/2021 15:37
... ... @@ -10,4 +13,6 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository
* Description: 初见时你很迷人
*/
class MyErrorQuestionRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,11 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.ui.bean.AnswerDetail
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
/**
* Time: 7/31/2021 16:55
... ... @@ -10,4 +14,7 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository
* Description: 初见时你很迷人
*/
class QuestionRecordRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,12 @@ package com.br_technology.securitytrain_master.ui.view.mine.repository
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.common.State
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.repository.ApiRepository
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
/**
* Time: 7/31/2021 17:02
... ... @@ -10,4 +15,15 @@ import com.br_technology.securitytrain_master.base.repository.ApiRepository
* Description: 初见时你很迷人
*/
class SpecialExercisesFragmentRepository(val loadState: MutableLiveData<State>) : ApiRepository(loadState) {
//答题记录
fun errorSubList(
type: Int,
page: Int,
page_num: Int,
liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>>
) {
addRequest(itemService.errorSubList(type, page, page_num), liveData)
}
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.ErrorListItem
import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQuestionFragmentRepository
/**
... ... @@ -9,4 +15,26 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue
* Description: 初见时你很迷人
*/
class MyErrorQuestionFragmentViewModel : BaseViewModel<MyErrorQuestionFragmentRepository>() {
val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<ErrorListItem>>>> = MutableLiveData()
val delErrorLiveData: MutableLiveData<BaseResponse<Void>> = MutableLiveData()
fun errorList(
type: Int,
page: Int,
) {
mRepository.errorList(type, page, 20, liveData)
}
//删除错题
fun delError(
item_id: Int,
type: Int,
item_type: Int,
) {
mRepository.delError(item_id,type,item_type,delErrorLiveData)
}
}
\ No newline at end of file
... ...
... ... @@ -9,4 +9,5 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.MyErrorQue
* Description: 初见时你很迷人
*/
class MyErrorQuestionViewModel : BaseViewModel<MyErrorQuestionRepository>() {
}
\ No newline at end of file
... ...
package com.br_technology.securitytrain_master.ui.view.mine.viewmodel
import androidx.lifecycle.MutableLiveData
import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.network.response.CommonDataList
import com.br_technology.securitytrain_master.base.network.response.CommonPage
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.AnswerRecord
import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExercisesFragmentRepository
/**
... ... @@ -9,4 +14,15 @@ import com.br_technology.securitytrain_master.ui.view.mine.repository.SpecialExe
* Description: 初见时你很迷人
*/
class SpecialExercisesFragmentViewModel : BaseViewModel<SpecialExercisesFragmentRepository>() {
val liveData: MutableLiveData<BaseResponse<CommonDataList<CommonPage<AnswerRecord>>>> =
MutableLiveData()
//答题记录
fun errorSubList(
type: Int,
page: Int,
) {
mRepository.errorSubList(type, page, 20, liveData)
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/toolbar"
android:layout_alignBottom="@+id/tool_bar"
android:layout_centerVertical="true"
android:contentDescription="@string/logo"
android:scaleType="fitXY"
android:src="@mipmap/practice_back" />
<LinearLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/layout_tool_bar" />
</LinearLayout>
<com.br_technology.securitytrain_master.view.ViewToolBar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_below="@id/toolbar" />
</RelativeLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/practice_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/color_f7" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:drawableStart="@mipmap/previous"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="上一题"
android:textColor="@color/color_25"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableEnd="@mipmap/next"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="下一题"
android:textColor="@color/color_25"
android:textSize="14sp"
android:visibility="visible" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:id="@+id/finish_job"
android:layout_width="104dp"
android:layout_height="44dp"
android:background="@drawable/solid_25_4"
android:gravity="center"
android:text="交卷"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -18,16 +18,17 @@
android:id="@+id/tab_layout"
style="@style/SearchTab"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_height="44dp"
android:overScrollMode="never"
app:tabMode="auto"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabSelectedTextColor="@color/color_252"
app:tabTextColor="@color/color_96" />
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="@color/color_f7"></View>
android:background="@color/color_f7"/>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager"
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/toolbar"
android:layout_alignBottom="@+id/tool_bar"
android:layout_centerVertical="true"
android:contentDescription="@string/logo"
android:scaleType="fitXY"
android:src="@mipmap/practice_back" />
<LinearLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/layout_tool_bar" />
</LinearLayout>
<com.br_technology.securitytrain_master.view.ViewToolBar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_below="@id/toolbar" />
</RelativeLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/error_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/color_f7" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/finish_job"
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="@drawable/solid_25_4"
android:gravity="center"
android:text="交卷"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -6,15 +6,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:overScrollMode="never"
android:scrollbars="none"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
... ...
... ... @@ -8,9 +8,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="82dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="@mipmap/item_error_question_bg"
android:orientation="horizontal">
... ... @@ -22,7 +20,6 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="男子从国外赶回陪产,回家第二天被隔离:孩子出生了我却见不到?"
android:textColor="@color/color_32"
android:textSize="14sp" />
... ...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
... ... @@ -8,9 +9,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="83dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/solid_eff2_4"
android:orientation="vertical">
... ... @@ -26,11 +25,10 @@
android:layout_marginStart="12dp"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:drawableStart="@mipmap/item_special_exercises_icon"
android:drawablePadding="8dp"
android:text="专项练习(焊工)"
android:textColor="@color/color_32"
android:textSize="14sp" />
android:textSize="14sp"
app:drawableStartCompat="@mipmap/item_special_exercises_icon" />
<TextView
android:id="@+id/tv_timer"
... ... @@ -38,7 +36,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginEnd="12dp"
android:text="2020-09-10 12:00"
android:textColor="@color/color_96"
android:textSize="12sp" />
... ... @@ -55,7 +52,6 @@
android:paddingTop="2dp"
android:paddingEnd="8dp"
android:paddingBottom="2dp"
android:text="答对:50/100"
android:textColor="@color/color_25"
android:textSize="12sp" />
... ...