Hello again! I’d recommend hiding the Next button until the desired ‘words found’ score is reached. Code is updated below so that the Next button only displays when all 19 words are found:
this.hideNextButton();
var countrygrid = y
'A', 'I', 'V', 'T', 'A', 'L', 'N', 'I', 'E', 'T', 'S', 'G', 'A', 'T', 'H', 'C', 'E', 'I', 'L'],
r'G', 'A', 'C', 'H', 'I', 'E', 'V', 'E', 'A', 'N', 'D', 'S', 'N', 'T', 'V', 'A', 'A', 'P', 'W'],
r'A', 'C', 'C', 'O', 'M', 'P', 'L', 'I', 'S', 'H', 'S', 'R', 'O', 'R', 'I', 'I', 'O', 'C', 'I'],
r'S', 'T', 'E', 'J', 'V', 'U', 'E', 'T', 'Y', 'C', 'N', 'L', 'E', 'I', 'A', 'R', 'I', 'D', 'N'],
r'O', 'U', 'P', 'M', 'J', 'J', 'L', 'C', 'O', 'B', 'A', 'A', 'T', 'U', 'T', 'P', 'N', 'E', 'N'],
r'B', 'E', 'C', 'I', 'V', 'E', 'S', 'C', 'N', 'N', 'T', 'N', 'U', 'M', 'E', 'A', 'S', 'V', 'E'],
r'M', 'A', 'E', 'C', 'K', 'A', 'L', 'L', 'E', 'A', 'U', 'W', 'G', 'P', 'L', 'E', 'X', 'C', 'R'],
r'E', 'G', 'J', 'N', 'E', 'A', 'T', 'V', 'O', 'A', 'R', 'A', 'B', 'H', 'T', 'B', 'R', 'Z', 'W'],
r'X', 'E', 'J', 'W', 'N', 'S', 'S', 'L', 'S', 'V', 'L', 'F', 'S', 'C', 'O', 'R', 'E', 'G', 'R'],
r'U', 'Y', 'P', 'D', 'I', 'V', 'S', 'S', 'A', 'S', 'A', 'Z', 'L', 'L', 'R', 'L', 'L', 'S', 'O'],
r'L', 'R', 'R', 'M', 'A', 'C', 'T', 'P', 'S', 'M', 'T', 'K', 'G', 'T', 'N', 'V', 'P', 'N', 'N'],
r'I', 'A', 'C', 'H', 'A', 'M', 'P', 'I', 'O', 'N', 'Y', 'A', 'I', 'J', 'N', 'S', 'K', 'D', 'J'],
r'V', 'G', 'N', 'I', 'N', 'O', 'O', 'K', 'W', 'R', 'R', 'H', 'U', 'A', 'E', 'D', 'R', 'N', 'D'],
r'I', 'N', 'I', 'I', 'T', 'R', 'E', 'P', 'R', 'E', 'V', 'A', 'I', 'L', 'J', 'N', 'A', 'A', 'J'],
r'C', 'U', 'A', 'V', 'K', 'A', 'A', 'T', 'A', 'G', 'P', 'C', 'A', 'O', 'H', 'I', 'M', 'L', 'F'],
r'T', 'H', 'Z', 'U', 'V', 'J', 'O', 'G', 'O', 'V', 'E', 'R', 'C', 'O', 'M', 'E', 'N', 'G', 'O'],
r'O', 'E', 'D', 'E', 'C', 'S', 'B', 'R', 'N', 'N', 'U', 'V', 'J', 'Z', 'T', 'E', 'E', 'N', 'R'],
r'R', 'S', 'U', 'R', 'A', 'L', 'E', 'B', 'C', 'T', 'I', 'I', 'G', 'I', 'C', 'B', 'E', 'S', 'T'],
r'Y', 'N', 'A', 'I', 'T', 'I', 'F', 'A', 'T', 'T', 'A', 'I', 'N', 'Y', 'W', 'I', 'M', 'E', 'I']];
var countrynames = n'ACCOMPLISH', 'ACHIEVE', 'ATTAIN', 'BEST', 'CHAMPION', 'OVERCOME', 'PREVAIL', 'SCORE', 'SUCCESS',
'TRIUMPH', 'CAN', 'VICTORY', 'WINNER', 'ON', 'HIM', 'NOOK', 'IT', 'TAG',
'FOR'];
function getRandom(arr, n) {
var result = new Array(n),
len = arr.length,
taken = new Array(len);
if (n > len)
throw new RangeError("getRandom: more elements taken than available");
while (n--) {
var x = Math.floor(Math.random() * len);
result n] = arrnx in taken ? taken x] : x];
taken x] = --len in taken ? taken len] : len;
}
return result;
}
var wordnames = getRandom(countrynames, 19)
function storeScoreAndTimingInQualtrics() {
var score = this.getScore();
var timing = this.getTiming();
var timing_str = timing.join(",") // Convert the timings separated by commas to a string
Qualtrics.SurveyEngine.setEmbeddedData("wordsFound", score);
Qualtrics.SurveyEngine.setEmbeddedData("timingWordsFound", timing_str);
if(score == 19) {
jQuery("#NextButton").show();
}
}
ws = new WordSearch({
"grid": countrygrid, // Your grid to search
"words": wordnames, // The list of words to find
"parentId": "mysearchtask",
"onFindWord": storeScoreAndTimingInQualtrics // When a word is found...
});
The survey doesn’t actually require participants to find all of the words and only what they are able to in the time provided. Therefore, by using the code to hide the next button until all words are found, will it cause issues?