Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added survey for AI hints #102

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[ML4SE-591] Added checkbox type, fixed borders in html. Deleted index…
… from the database for survey table
  • Loading branch information
mikrise2 committed Apr 5, 2024
commit 2baff3afceec5818bfc044b7fddcfac29fbf336b
Original file line number Diff line number Diff line change
@@ -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<RadioInfo>
@SerialName("info") val infos: List<ValueInfo>
) : 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<ValueInfo>
) : HtmlQuestion() {
override fun toHtml(): String = buildString {
append(htmlText())
infos.forEach { (id, value) ->
append("<label for=\"$id\"><input type=\"checkbox\" id=\"$id\" ${elementId.asParameter("name")} ")
append("value=\"$value\" ${isRequiredString()}>")
append("$value</label><br>")
}
}
}

@Serializable
@SerialName("Textarea")
data class TextAreaHtmlQuestion(
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
surveys:
- id: default
htmlQuestions:
- !<Textarea>
text: 1.How helpful was the hint in solving the problem?
- !<Radio>
text: 1.How helpful was the hint in solving the problem? Where 1 - not helpful at all, 5 - very helpful.
elementId: helpfulHint
required: true
rows: 5
cols: 50
- !<Radio>
info:
- id: helpfulHint1
value: 1
- id: helpfulHint2
value: 2
- id: helpfulHint3
value: 3
- id: helpfulHint4
value: 4
- id: helpfulHint5
value: 5
- !<Checkbox>
text: 2.Why did you decide to ask for a hint?
mikrise2 marked this conversation as resolved.
Show resolved Hide resolved
elementId: hintAsk
required: true
@@ -27,7 +36,7 @@ surveys:
elementId: hintAskOptional
rows: 5
cols: 50
- !<Radio>
- !<Checkbox>
text: 3.Which option did you prefer?
elementId: optionPrefer
required: true
@@ -49,7 +58,7 @@ surveys:
elementId: optionPreferOptional
rows: 5
cols: 50
- !<Radio>
- !<Checkbox>
text: 4.Have you ever used hints to quickly complete a task and move on?
elementId: quickComplete
required: true
@@ -69,7 +78,7 @@ surveys:
elementId: quickCompleteOptional
rows: 5
cols: 50
- !<Radio>
- !<Checkbox>
text: 5.Have there ever been situations when you didn't understand a hint? If yes what did you do?
elementId: understandHint
required: true
@@ -95,7 +104,7 @@ surveys:
elementId: understandHintOptional
rows: 5
cols: 50
- !<Radio>
- !<Checkbox>
text: 6.Would you like to continue using hints?
elementId: continueUse
required: true
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
let fields = document.getElementsByName(fieldTemp.name);
fields.forEach(function (field) {
field.onclick = function () {
if (field.type === "radio") {
if (field.type === "radio" || field.type === "checkbox") {
defaultBorder(field.name)
} else {
defaultBorder(field.id)
@@ -22,10 +22,7 @@
function checkAllInputs() {
let checker = true
requiredFields.forEach(function (field) {
if (field.type === "checkbox" && !field.checked) {
redBorder(field.id)
checker = false
} else if (field.type === "radio") {
if (field.type === "radio" || field.type === "checkbox") {
let checked = document.querySelector(`input[name = ${field.name}]:checked`);
if (checked == null) {
redBorder(field.name)
Loading