Skip to content

Commit

Permalink
added quick answer
Browse files Browse the repository at this point in the history
  • Loading branch information
tafakkur committed Sep 18, 2021
1 parent b4256bf commit 9a75df1
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Scratch/*
Scratch
*/wip*
.history/*
wip/
.history
wip/
.vscode
23 changes: 23 additions & 0 deletions JavaScript Files/Quick answer reminder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Qualtrics.SurveyEngine.addOnReady(function () {
let quest = this,
all_inputs = quest.questionContainer.querySelectorAll("[type='radio'],[type='checkbox']");
all_inputs.forEach((ip) => {
ip.oninput = function (e) {
setTimeout(() => {
// Change the question here
let check = confirm("Yes or no");
if (!check) {
quest.getSelectedChoices().forEach((ch) => {
quest.setChoiceValue(ch, false);
});
}
}, 100);
};
});
setTimeout(() => {
all_inputs.forEach((ip) => {
ip.oninput = function (e) {};
});
// Change this to the delay in ms
}, 6000);
});
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The PDFs are a good starting point for someone who has never worked with Qualtri

Some points to note:

* I'm not well versed with JS _\(read as lookup function at stackoverflow\)_ and therefore some of the code may be inelegant and inefficient. Please let me know if you know how a better solution.
* I'm not well versed with JS _\(read as lookup function at stackoverflow\)_ and therefore some of the code may be inelegant and inefficient. Please let me know if you know have a better solution.
* All code uploaded is working on the day it was uploaded. If it doesn't work for you, please let me know, and we'll check if it's an issue in your implementation or an update from Qualtrics.

[Examples](examples.md)
Expand Down
2 changes: 1 addition & 1 deletion examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
6. If they choose option 2, the question text changes, giving them an option to re-consider.
7. If they choose option 3, they are automatically redirected to the next page.

![](.gitbook/assets/external-website-error.gif)
![](../../images/external-website-error.gif)

2 changes: 1 addition & 1 deletion functions/Add header rows to matrix.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add Header Row to Matrix

This function allow one to add the matrix header row at a custom location in the matrix. While Qualtrics allows repeating the header row within the table, it only does so after 5 or so rows. By using this function, one can ensure the options are visible at all times. The script below is for adding the header as the 2th row, but multiple rows can be added with slight modification.
This function allows one to add the matrix header row at a custom location in the matrix. While Qualtrics allows repeating the header row within the table, it only does so after 5 or so rows. By using this function, one can ensure the options are visible at all times. The script below is for adding the header as the 2nd row, but multiple rows can be added with slight modification.

[_Link to Working Demo_](https://iima.au1.qualtrics.com/jfe/preview/SV_2rCRZYIQqNq0nzv/BL_9Hnthujr7TA2LvD?Q_SurveyVersionID=current)
Hold down Ctrl or ⌘ Cmd to open the link in a new tab
Expand Down
32 changes: 32 additions & 0 deletions functions/Speedy Answer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Check for fast answers

This function allows you to reconfirm the respondents answer if they were too fast. The idea here is to allow the respondent to slowdown a bit, helping improve data quality.

If the respondent answers too quickly, the code below asks them to confirm their choice, if they say no, the choices are cleared.

```js
Qualtrics.SurveyEngine.addOnReady(function () {
// Change this value to increase/decrease the time. It is in ms.
let check_time = 6000;
let quest = this,
all_inputs = quest.questionContainer.querySelectorAll("[type='radio'],[type='checkbox']");
all_inputs.forEach((ip) => {
ip.oninput = function (e) {
setTimeout(() => {
// Change the question here
let check = confirm("Yes or no");
if (!check) {
quest.getSelectedChoices().forEach((ch) => {
quest.setChoiceValue(ch, false);
});
}
}, 100);
};
});
setTimeout(() => {
all_inputs.forEach((ip) => {
ip.oninput = function (e) {};
});
}, check_time);
});
```

0 comments on commit 9a75df1

Please sign in to comment.