Git Product home page Git Product logo

wordsearchjs's Introduction

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.

wordsearchjs's People

Contributors

quentinandre avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.