Commit c4f16f68 authored by Antonia Wüst's avatar Antonia Wüst

hide explanation button when no explanation is given

parent 2a6bbdec
......@@ -12,6 +12,7 @@ import kotlinx.android.synthetic.main.fragment_continue_duel.*
class ContinueDuelFragment : Fragment() {
lateinit var onContinueDuelHandler: OnContinueDuelHandler
lateinit var presenter: QuestionContract.Presenter
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
......@@ -23,8 +24,16 @@ class ContinueDuelFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
button_continue_without_explanation.setOnClickListener {onContinueDuelHandler.onContinueWithoutExplanationClicked() }
button_continue_with_explanation.setOnClickListener { onContinueDuelHandler.onContinueWithExplanationClicked() }
presenter = (activity as QuestionContract.View).presenter
// Explanation button
if (presenter.isExplanationThere()) {
button_continue_with_explanation.setOnClickListener { onContinueDuelHandler.onContinueWithExplanationClicked() }
} else {
button_continue_with_explanation.visibility = View.GONE
}
button_continue_without_explanation.setOnClickListener { onContinueDuelHandler.onContinueWithoutExplanationClicked() }
}
override fun onAttach(context: Context) {
......
......@@ -64,6 +64,8 @@ interface QuestionContract {
fun submitUserOptionAnswer(selectedAnswerItemIds: IntArray)
/** Finds the correct answerItem **/
fun getCorrectAnswerItem(answer: MultipleChoiceAnswer) : MultipleChoiceAnswerItem
/** Return true if an explanation is given **/
fun isExplanationThere(): Boolean
}
}
\ No newline at end of file
......@@ -7,7 +7,10 @@ import de.akamu.tudarmstadt.model.*
import de.akamu.tudarmstadt.util.Constants
class QuestionPresenter(private val interactor: DuelInteractor, private var view: QuestionContract.View?) :
class QuestionPresenter(
private val interactor: DuelInteractor,
private var view: QuestionContract.View?
) :
QuestionContract.Presenter {
/**
......@@ -73,16 +76,19 @@ class QuestionPresenter(private val interactor: DuelInteractor, private var view
}
override fun sendQuestionReport(feedbackText: String) {
interactor.reportQuestion(currentQuestion.id, feedbackText, object : DuelDataSource.ReportQuestionCallback {
override fun onReportQuestionSuccess() {
view?.showReportQuestionSuccess()
}
interactor.reportQuestion(
currentQuestion.id,
feedbackText,
object : DuelDataSource.ReportQuestionCallback {
override fun onReportQuestionSuccess() {
view?.showReportQuestionSuccess()
}
override fun onReportQuestionFailed(reason: String) {
view?.showReportQuestionFailed(reason)
}
override fun onReportQuestionFailed(reason: String) {
view?.showReportQuestionFailed(reason)
}
})
})
}
override fun next() {
......@@ -165,6 +171,10 @@ class QuestionPresenter(private val interactor: DuelInteractor, private var view
throw AkamuAPIException(1002, "Logical internal error: Question has no correct answer.")
}
override fun isExplanationThere(): Boolean {
return currentQuestion.explanation.text != null && currentQuestion.explanation.text != ""
}
override fun stop() {
view = null
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment