作者 zhangji

根据需求修改原有答题卡显示图标问题

根据需求修改原有答题解析显示背景色
... ... @@ -46,5 +46,10 @@
<option name="name" value="maven" />
<option name="url" value="https://maven.aliyun.com/repository/apache-snapshots" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://oss.sonatype.org/content/groups/public" />
</remote-repository>
</component>
</project>
\ No newline at end of file
... ...
... ... @@ -26,7 +26,7 @@ open class OptionArr(
var value: String,
var pic: String,
var is_correct: Int,
var pic_arr: Array<String>
var pic_arr: Array<String>,
)
/**
... ...
... ... @@ -25,6 +25,7 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
override fun initData() {
super.initData()
val dataResult = intent.getStringArrayListExtra("resultData")
val showCorrect = intent.getBooleanExtra("showCorrect", false)
binding.apply {
// 答题卡
sheet.addItemDecoration(object : RecyclerView.ItemDecoration() {
... ... @@ -45,6 +46,7 @@ class AnswerSheetActivity : BaseLifeCycleActivity<AnswerSheetViewModel, Activity
})
// 答题卡适配器
val answerSheetAdapter = AnswerSheetAdapter()
answerSheetAdapter.showCorrect=showCorrect
val list = dataResult?.toList() as List<String>
sheet.adapter = answerSheetAdapter
answerSheetAdapter.addList(list)
... ...
... ... @@ -57,6 +57,7 @@ class ChallengeActivity :
override fun onClick(view: View) {
val intent = Intent(baseContext, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
startForResult.launch(intent)
}
})
... ...
... ... @@ -83,6 +83,7 @@ class ExamDetailActivity :
override fun onClick(view: View) {
val intent = Intent(baseContext, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
startForResult.launch(intent)
}
})
... ...
... ... @@ -80,6 +80,7 @@ class PracticeActivity :
override fun onClick(view: View) {
val intent = Intent(this@PracticeActivity, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
startForResult.launch(intent)
}
})
... ...
... ... @@ -81,6 +81,7 @@ class QuestionsActivity :
override fun onClick(view: View) {
val intent = Intent(this@QuestionsActivity, AnswerSheetActivity::class.java)
.putStringArrayListExtra("resultData", mPagerAdapter.getArrayList())
.putExtra("showCorrect", mPagerAdapter.showCorrect)
startForResult.launch(intent)
}
})
... ...
... ... @@ -15,6 +15,7 @@ import com.br_technology.securitytrain_master.databinding.AdapterAnswerSheetBind
* des:
*/
class AnswerSheetAdapter : BaseAdapter<String, AdapterAnswerSheetBinding>() {
var showCorrect: Boolean = false
override fun getViewBinding(
context: Context,
parent: ViewGroup,
... ... @@ -28,10 +29,14 @@ class AnswerSheetAdapter : BaseAdapter<String, AdapterAnswerSheetBinding>() {
override fun onBind(holder: AdapterAnswerSheetBinding, position: Int, data: String) {
holder.txtIndex.text = "${position + 1}"
holder.iconError.setImageResource(
if (data == "1") {
if (!showCorrect) {
R.mipmap.success
} else {
R.mipmap.error
}else{
if (data == "1") {
R.mipmap.success
} else {
R.mipmap.error
}
}
)
holder.iconError.visibility = if (data == "") View.GONE else View.VISIBLE
... ...
... ... @@ -8,6 +8,7 @@ import android.text.SpannableString
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
... ... @@ -43,6 +44,9 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
// 题目类型 1:单选 2:多选 3:判断
var type = 1
// 是否时正确的答题
var isTrue: Boolean = true
// 是否显示正确答案
var showCorrect = false
... ... @@ -111,8 +115,6 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
}
setTextDefault(holder.contentTopic, holder.tvName)
// 单选 / 判断
if (type == 1 || type == 3) {
... ... @@ -124,11 +126,13 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
setTextRed(holder.contentTopic, holder.tvName)
}
} else {
//未交卷时显示
setTextGreen(holder.contentTopic, holder.tvName)
}
} else {
if (showCorrect && data.is_correct == 1) {
setTextGreen(holder.contentTopic, holder.tvName)
// 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化
// setTextGreen(holder.contentTopic, holder.tvName)
}
}
}
... ... @@ -146,7 +150,8 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
}
} else {
if (showCorrect && data.is_correct == 1) {
setTextGreen(holder.contentTopic, holder.tvName)
// 正确答背景应变绿色--需求修改成当有错题时正确答案背景色没变化
// setTextGreen(holder.contentTopic, holder.tvName)
}
}
}
... ... @@ -163,8 +168,8 @@ class TopicAdapter : BaseAdapter<OptionArr, AdapterTopicBinding>() {
}
private fun setTextGreen(view: View, textView: TextView) {
view.setBackgroundResource(R.drawable.solid_a2_4_08a2)
textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_e8))
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) {
... ... @@ -328,10 +333,9 @@ class PracticePaperAdapter(private val isShowPosition: Boolean = true) :
if (dataList[position].isEmpty()) {
list.add("")
} else {
list.add(
if (isTrue(data, dataList[position], data.options_arr)
) "1" else "0"
)
val element = if (isTrue(data, dataList[position], data.options_arr)
) "1" else "0"
list.add(element)
}
}
return list
... ...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:color="#257cff"
android:width="1dp" />
<solid android:color="#10257CFF" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
... ...
... ... @@ -44,9 +44,11 @@
<TextView
android:id="@+id/txt_correct"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingHorizontal="12dp"
android:paddingVertical="7dp"
android:background="@drawable/solid_a2_4_08a2"
android:text="正确答案:B"
android:textColor="@color/color_e8"
... ...