Skip to content

A Javascript library to add Word Search Tasks to online and offline experiments. Adapted from Robert J. Calin-Jageman's version

Notifications You must be signed in to change notification settings

fagan2888/WordSearchJS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordSearchJS

A Javascript library to add Word Search Tasks to online and offline experiments. Adapted from Robert J. Calin-Jageman's word search task, with added functionality to facilitate Qualtrics integration.

You can preview it on CodePen here:

https://codepen.io/QuentinAndre/full/rQLejK/

Using WordSearchJS in Qualtrics

Setup

  1. Navigate to the "Look and Feel" section of your survey, and click on the "Advanced" tab
  2. Edit the "Header" section, and add the following lines to load the library script:
<script src="https://cdn.jsdelivr.net/gh/QuentinAndre/WordSearchJS/lib/wordsearch.min.js"></script>
  1. Create a "Text" question, and add the following HTML code:
<div id="mysearchtask"></div>
  1. Edit the "Custom JS" of the question, and add the following Javascript code in the Qualtrics.SurveyEngine.addOnReady section:
var mygrid = [
    ['.', '.', '.', '.', '.', '.'],
    ['.', 'T', 'E', 'S', 'T', '.'],
    ['.', '.', '.', '.', '.', '.']
    ];

var mywords = ["TEST"];

ws = new WordSearch({
        "grid": mygrid, // Your grid to search
        "words": mywords, // The list of words to find
        "parentId": "mysearchtask",
        "onFindWord": function() {console.log("A word was found")} // What to do when a word is found 
    });

That's it! You have added a word search task to Qualtrics!

Accessing and storing participants' behavior

You can access three useful statistics from WordSearchJS at any time:

  • WordSearch.getScore() returns the number of words found so far.
  • WordSearch.getRemaining() returns the number of words not found yet.
  • WordSearch.getTiming() returns a list of length words, containing at the index of each word a -1 (if the word has not been found yet) or an integer (corresponding to the time in seconds when the word was found).

Combined with the onFindWord argument, you can use those methods to store useful information in Qualtrics:

var mygrid = [
    ['.', '.', '.', '.', '.', '.'],
    ['.', 'T', 'E', 'S', 'T', '.'],
    ['.', '.', '.', '.', '.', '.']
    ];

var mywords = ["TEST"];

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);
}

ws = new WordSearch({
        "grid": mygrid,
        "words": mywords,
        "parentId": "mysearchtask",
        "onFindWord": storeScoreAndTimingInQualtrics; // No parenthesis! Will call this function when a word is found.
    });

Version history

v0.5.0

  • First release of the library.

About

A Javascript library to add Word Search Tasks to online and offline experiments. Adapted from Robert J. Calin-Jageman's version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 60.6%
  • TypeScript 36.0%
  • CSS 3.4%