-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Qualtrics.SurveyEngine.addOnReady(function() | ||
{ | ||
choice_table = this.getChoiceContainer(); | ||
//Numbering starts from 0. So the header is the 0th row, the first statement row 1 etc. | ||
//This will create an empty row above statement 4. YOu can change it accordingly. | ||
new_row = choice_table.insertRow(4); | ||
|
||
//rows[0] refersto the header. | ||
// So this takes the header row fills up the empty row just created. | ||
new_row.innerHTML = choice_table.rows[0].innerHTML; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Qualtrics.SurveyEngine.addOnReady(function () { | ||
|
||
const qid = this.questionId; | ||
const all_choices = Qualtrics.SurveyEngine.registry[qid].getChoices(); | ||
const base_colours = [ | ||
"rgba(238, 50, 70, 0.3)", | ||
"rgba(245, 150, 30, 0.3)", | ||
"rgba(255, 203, 8, 0.3)", | ||
"rgba(178, 210, 53, 0.3", | ||
"rgba(0, 165, 81, 0.3)", | ||
]; | ||
|
||
// Sets the desired colours initially | ||
all_choices.forEach((item,index) => { | ||
document.querySelector("#" + qid + "-" + item + "-label").style.background = base_colours[index]; | ||
document.querySelector("#" + qid + "-" + item + "-label").style.color = "#525252"; | ||
}); | ||
|
||
|
||
// Check if anyone clicks on the question | ||
this.questionclick = function(){ | ||
// Get the currently selected choices | ||
var selected_choices = this.getSelectedChoices(); | ||
|
||
// Restore all the colours to their original state | ||
// This is done, so that the options appear the same in case someone unselects a choice | ||
all_choices.forEach((item,index) => { | ||
document.querySelector("#" + qid + "-" + item + "-label").style.background = base_colours[index]; | ||
document.querySelector("#" + qid + "-" + item + "-label").style.color = "#525252"; | ||
}); | ||
|
||
// Give a different colour to the selected choices | ||
// background is for the Box and color is for the text | ||
// Change as desired | ||
selected_choices.forEach((item) => { | ||
document.querySelector("#" + qid + "-" + item + "-label").style.background = "DarkBlue"; | ||
document.querySelector("#" + qid + "-" + item + "-label").style.color = "Yellow"; | ||
}); | ||
} | ||
}); |