Erweiterung des Frameworks.

This commit is contained in:
Daniel Ocks
2025-07-28 10:56:30 +02:00
parent 80753596f0
commit 1f496b5a0c
3 changed files with 39 additions and 18 deletions

View File

@ -1,18 +1,23 @@
[
{
"file": "questionnaire_1_demographic_information.json"
"file": "questionnaire_1_demographic_information.json",
"showPoints": false
},
{
"file": "questionnaire_2_rhs.json"
"file": "questionnaire_2_rhs.json",
"showPoints": true
},
{
"file": "questionnaire_3_integration_index.json"
"file": "questionnaire_3_integration_index.json",
"showPoints": true
},
{
"file": "questionnaire_4_consultation_results.json"
"file": "questionnaire_4_consultation_results.json",
"showPoints": false
},
{
"file": "questionnaire_5_final_interview.json",
"showPoints": false,
"condition": {
"questionnaire": "questionnaire_4_consultation_results",
"questionId": "consultation_decision",
@ -21,6 +26,7 @@
}
},
{
"file": "questionnaire_6_follow_up_survey.json"
"file": "questionnaire_6_follow_up_survey.json",
"showPoints": false
}
]

View File

@ -73,7 +73,10 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
value = conditionObj.getString("value")
)
} else null
QuestionItem.QuestionnaireEntry(file, condition)
val showPoints = obj.optBoolean("showPoints", false)
QuestionItem.QuestionnaireEntry(file, condition, showPoints)
}
} catch (e: Exception) {
e.printStackTrace()
@ -81,7 +84,6 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
}
}
private fun createQuestionnaireButtons() {
buttonContainer.removeAllViews()
dynamicButtons.clear()
@ -204,7 +206,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
buttonPoints.clear()
for (entry in completedEntries) {
if (entry.isDone && (entry.sumPoints ?: 0) > 0) {
if (entry.isDone) {
buttonPoints[entry.questionnaireId] = entry.sumPoints ?: 0
if (entry.questionnaireId.contains("questionnaire_3_integration_index", ignoreCase = true)) {
@ -255,28 +257,40 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
private fun updateButtonTexts() {
questionnaireFiles.forEach { (button, fileName) ->
// Suche passenden QuestionnaireEntry
val entry = questionnaireEntries.firstOrNull { it.file == fileName }
val key = fileName.substringAfter("questionnaire_").substringAfter("_").removeSuffix(".json")
var buttonText = LanguageManager.getText(languageID, key)
val matchedEntry = buttonPoints.entries.firstOrNull { fileName.contains(it.key, ignoreCase = true) }
val points = matchedEntry?.value ?: 0
if (points > 0) {
val pointsAvailable = buttonPoints.entries.firstOrNull { fileName.contains(it.key, ignoreCase = true) }
val points = pointsAvailable?.value ?: 0
if (entry?.showPoints == true && pointsAvailable != null) {
buttonText += " (${points} P)"
}
button.text = buttonText
// Farbgebung je nach Punktzahl
when {
points in 1..12 -> button.setBackgroundColor(Color.parseColor("#4CAF50")) // Grün
points in 13..36 -> button.setBackgroundColor(Color.parseColor("#FFEB3B")) // Gelb
points in 37..100 -> button.setBackgroundColor(Color.parseColor("#F44336")) // Rot
else -> button.setBackgroundColor(Color.parseColor("#E0E0E0")) // Standardgrau bei 0
// Farbe setzen nur wenn Punkte angezeigt werden und Fragebogen ausgefüllt ist
if (entry?.showPoints == true && pointsAvailable != null) {
when {
points in 0..12 -> button.setBackgroundColor(Color.parseColor("#4CAF50")) // Grün
points in 13..36 -> button.setBackgroundColor(Color.parseColor("#FFEB3B")) // Gelb
points in 37..100 -> button.setBackgroundColor(Color.parseColor("#F44336")) // Rot
else -> button.setBackgroundColor(Color.parseColor("#E0E0E0")) // Grau bei 0 Punkten
}
} else {
// Standardgrau, wenn Punkte nicht angezeigt werden sollen oder Fragebogen nicht ausgefüllt ist
button.setBackgroundColor(Color.parseColor("#E0E0E0"))
}
}
buttonLoad.text = LanguageManager.getText(languageID, "load")
}
private fun setButtonsEnabled(enabledButtons: List<Button>) {
questionnaireFiles.keys.forEach { button ->
button.isEnabled = enabledButtons.contains(button)

View File

@ -108,7 +108,8 @@ sealed class QuestionItem {
data class QuestionnaireEntry(
val file: String,
val condition: Condition? = null
val condition: Condition? = null,
val showPoints: Boolean = false // neu
)
data class Condition(