From 2baff3afceec5818bfc044b7fddcfac29fbf336b Mon Sep 17 00:00:00 2001 From: mikrise2 Date: Fri, 5 Apr 2024 17:27:16 +0200 Subject: [PATCH] [ML4SE-591] Added checkbox type, fixed borders in html. Deleted index from the database for survey table --- .../tasktracker/config/survey/HtmlQuestion.kt | 24 +++++++++++++++-- .../tasktracker/util/survey/SurveyParser.kt | 4 +++ .../tasktracker/config/survey_default.yaml | 27 ++++++++++++------- .../ui/main/panel/template/survey.html | 7 ++--- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/survey/HtmlQuestion.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/survey/HtmlQuestion.kt index c5cea04f..1b1483ce 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/survey/HtmlQuestion.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/config/survey/HtmlQuestion.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.Transient * Radio button id and value */ @Serializable -data class RadioInfo(val id: String, val value: String) +data class ValueInfo(val id: String, val value: String) /** * This is a class that constructs an input field of a specified type in HTML. @@ -102,7 +102,7 @@ data class RadioHtmlQuestion( * **ElementId** here is radio button **name**!!!. */ override val elementId: String, - @SerialName("info") val infos: List + @SerialName("info") val infos: List ) : HtmlQuestion() { override fun toHtml(): String = buildString { append(htmlText()) @@ -114,6 +114,26 @@ data class RadioHtmlQuestion( } } +@Serializable +@SerialName("Checkbox") +data class CheckboxHtmlQuestion( + override val text: String, + /** + * **ElementId** here is checkbox button **name**!!!. + */ + override val elementId: String, + @SerialName("info") val infos: List +) : HtmlQuestion() { + override fun toHtml(): String = buildString { + append(htmlText()) + infos.forEach { (id, value) -> + append("
") + } + } +} + @Serializable @SerialName("Textarea") data class TextAreaHtmlQuestion( diff --git a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/survey/SurveyParser.kt b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/survey/SurveyParser.kt index 3c1694b2..2ff8fad0 100644 --- a/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/survey/SurveyParser.kt +++ b/ij-plugin/src/main/kotlin/org/jetbrains/research/tasktracker/util/survey/SurveyParser.kt @@ -33,6 +33,10 @@ class SurveyParser(private val mainWindow: MainPluginWindow, project: Project) : is HtmlQuestionContainer -> item.subQuestions.forEach { parseAndLog(it, id) } + is CheckboxHtmlQuestion -> item.infos.forEach { info -> + val result = mainWindow.checkIfRadioButtonChecked(info.id).await() + surveyLogger.log(item.text, result.toString(), option = info.id, questionId = id) + } } } diff --git a/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/survey_default.yaml b/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/survey_default.yaml index 0d0f5529..75b28344 100644 --- a/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/survey_default.yaml +++ b/ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/survey_default.yaml @@ -1,13 +1,22 @@ surveys: - id: default htmlQuestions: - - !