Erweiterung des Frameworks.
This commit is contained in:
@ -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",
|
"file": "questionnaire_5_final_interview.json",
|
||||||
|
"showPoints": false,
|
||||||
"condition": {
|
"condition": {
|
||||||
"questionnaire": "questionnaire_4_consultation_results",
|
"questionnaire": "questionnaire_4_consultation_results",
|
||||||
"questionId": "consultation_decision",
|
"questionId": "consultation_decision",
|
||||||
@ -21,6 +26,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "questionnaire_6_follow_up_survey.json"
|
"file": "questionnaire_6_follow_up_survey.json",
|
||||||
|
"showPoints": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -73,7 +73,10 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
|||||||
value = conditionObj.getString("value")
|
value = conditionObj.getString("value")
|
||||||
)
|
)
|
||||||
} else null
|
} else null
|
||||||
QuestionItem.QuestionnaireEntry(file, condition)
|
|
||||||
|
val showPoints = obj.optBoolean("showPoints", false)
|
||||||
|
|
||||||
|
QuestionItem.QuestionnaireEntry(file, condition, showPoints)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@ -81,7 +84,6 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun createQuestionnaireButtons() {
|
private fun createQuestionnaireButtons() {
|
||||||
buttonContainer.removeAllViews()
|
buttonContainer.removeAllViews()
|
||||||
dynamicButtons.clear()
|
dynamicButtons.clear()
|
||||||
@ -204,7 +206,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
|||||||
|
|
||||||
buttonPoints.clear()
|
buttonPoints.clear()
|
||||||
for (entry in completedEntries) {
|
for (entry in completedEntries) {
|
||||||
if (entry.isDone && (entry.sumPoints ?: 0) > 0) {
|
if (entry.isDone) {
|
||||||
buttonPoints[entry.questionnaireId] = entry.sumPoints ?: 0
|
buttonPoints[entry.questionnaireId] = entry.sumPoints ?: 0
|
||||||
|
|
||||||
if (entry.questionnaireId.contains("questionnaire_3_integration_index", ignoreCase = true)) {
|
if (entry.questionnaireId.contains("questionnaire_3_integration_index", ignoreCase = true)) {
|
||||||
@ -255,28 +257,40 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
|||||||
|
|
||||||
private fun updateButtonTexts() {
|
private fun updateButtonTexts() {
|
||||||
questionnaireFiles.forEach { (button, fileName) ->
|
questionnaireFiles.forEach { (button, fileName) ->
|
||||||
|
|
||||||
|
// Suche passenden QuestionnaireEntry
|
||||||
|
val entry = questionnaireEntries.firstOrNull { it.file == fileName }
|
||||||
|
|
||||||
val key = fileName.substringAfter("questionnaire_").substringAfter("_").removeSuffix(".json")
|
val key = fileName.substringAfter("questionnaire_").substringAfter("_").removeSuffix(".json")
|
||||||
var buttonText = LanguageManager.getText(languageID, key)
|
var buttonText = LanguageManager.getText(languageID, key)
|
||||||
|
|
||||||
val matchedEntry = buttonPoints.entries.firstOrNull { fileName.contains(it.key, ignoreCase = true) }
|
val pointsAvailable = buttonPoints.entries.firstOrNull { fileName.contains(it.key, ignoreCase = true) }
|
||||||
val points = matchedEntry?.value ?: 0
|
val points = pointsAvailable?.value ?: 0
|
||||||
if (points > 0) {
|
|
||||||
|
if (entry?.showPoints == true && pointsAvailable != null) {
|
||||||
buttonText += " (${points} P)"
|
buttonText += " (${points} P)"
|
||||||
}
|
}
|
||||||
|
|
||||||
button.text = buttonText
|
button.text = buttonText
|
||||||
|
|
||||||
// Farbgebung je nach Punktzahl
|
// Farbe setzen nur wenn Punkte angezeigt werden und Fragebogen ausgefüllt ist
|
||||||
when {
|
if (entry?.showPoints == true && pointsAvailable != null) {
|
||||||
points in 1..12 -> button.setBackgroundColor(Color.parseColor("#4CAF50")) // Grün
|
when {
|
||||||
points in 13..36 -> button.setBackgroundColor(Color.parseColor("#FFEB3B")) // Gelb
|
points in 0..12 -> button.setBackgroundColor(Color.parseColor("#4CAF50")) // Grün
|
||||||
points in 37..100 -> button.setBackgroundColor(Color.parseColor("#F44336")) // Rot
|
points in 13..36 -> button.setBackgroundColor(Color.parseColor("#FFEB3B")) // Gelb
|
||||||
else -> button.setBackgroundColor(Color.parseColor("#E0E0E0")) // Standardgrau bei 0
|
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")
|
buttonLoad.text = LanguageManager.getText(languageID, "load")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun setButtonsEnabled(enabledButtons: List<Button>) {
|
private fun setButtonsEnabled(enabledButtons: List<Button>) {
|
||||||
questionnaireFiles.keys.forEach { button ->
|
questionnaireFiles.keys.forEach { button ->
|
||||||
button.isEnabled = enabledButtons.contains(button)
|
button.isEnabled = enabledButtons.contains(button)
|
||||||
|
|||||||
@ -108,7 +108,8 @@ sealed class QuestionItem {
|
|||||||
|
|
||||||
data class QuestionnaireEntry(
|
data class QuestionnaireEntry(
|
||||||
val file: String,
|
val file: String,
|
||||||
val condition: Condition? = null
|
val condition: Condition? = null,
|
||||||
|
val showPoints: Boolean = false // neu
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Condition(
|
data class Condition(
|
||||||
|
|||||||
Reference in New Issue
Block a user