Commit 51304081 authored by Niklas Fix's avatar Niklas Fix 🎓

Merge remote-tracking branch 'origin/dev' into dev

parents d42961fc d0237931
......@@ -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
}
......
......@@ -86,8 +86,8 @@
android:layout_width="match_parent"
android:layout_height="93dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:clickable="true"
android:focusable="true"
android:lineSpacingExtra="2sp"
......@@ -98,10 +98,10 @@
android:textAlignment="viewStart"
android:textColor="@color/textLight"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dse_page1_decline_button" />
<Button
android:id="@+id/dse_page1_decline_button"
......@@ -109,15 +109,15 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="24dp"
android:padding="0dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/dse_page1_decline_button"
app:layout_constraintBottom_toTopOf="@+id/dse_page1_consent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dse_page1_crashlytics" />
<Button
android:id="@+id/dse_page1_skip_buttom"
......
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