uccser/cs-field-guide

View on GitHub
csfieldguide/templates/interactives/clicking-with-shaking.html

Summary

Maintainability
Test Coverage
{% extends interactive_mode_template %}

{% load i18n %}
{% load static %}

{% block interactive_html %}
<div class="container">
  <h3 class="text-center mb-2">{% trans "Clicking With Shaking" %}</h3>

  <div class="alert alert-danger text-center">
    {% trans "WARNING: DO NOT PRESS PLAY IF YOU GET MOTION SICKNESS!" %}
  </div>

  <div>
    <p>
      {% trans "Before proceeding, note that this interactive has sound." %}
      {% trans "If you do not want sound, click the Mute button in the top-right of the interactive below." %}
    </p>

    <p>
      {% trans "In this interactive, a green button will appear, which you must click." %}
      {% trans "However, the button also vibrates vertically and horizontally to simulate using an interface in a rocky environment, such as on a plane with high turbulence. " %}
      {% trans "Clicking the button awards you one point, while missing it deducts a point." %}
      {% trans "Your goal is to reach five points." %}
      {% trans "Afterwards, you will proceed to the next set where the button will be smaller." %}
      {% trans "There are four sets in total." %}
      {% trans "In the fourth set, the button will move to different parts of the game area as well." %}
      {% trans "Try to complete all sets as fast as you can." %}
      {% trans "Once you are done, a table will appear below showing your results." %}
      {% trans "Clicking the 'Give Up' button at the bottom right will skip the remaining sets." %}
    </p>

    <p>
      {% trans "What aspects of Fitts' Law are relevant here?" %}
      {% trans "How could this interface be redesigned to be easier to use in an environment that shakes?" %}
    </p>
  </div>

  <div id="game-view" class="mt-4 border">
    <div class="row w-100 no-gutters mt-2">
      <div class="col ml-2">
        <strong class="stat align-self-end">Time Elapsed: <span id="time">0</span> seconds</strong>
      </div>

      <div class="col text-center">
        <strong class="stat">Set: <span id="set">0</span>/4</strong>
      </div>

      <div class="col mr-2">
        <button type="button" class="btn btn-outline-secondary float-right" id="mute">Mute</button>
      </div>
    </div>

    <div id="game-view-main-area" class="align-items-center justify-content-center position-relative">
      <button type="button" class="btn-success" id="target" hidden>OK</button>
      <button type="button" id="play" class="btn btn-primary position-absolute">Play</button>
    </div>

    <div class="row w-100 no-gutters mb-2">
      <div class="col mr-2">
        <button type="button" class="btn btn-outline-danger float-right" id="give-up">Give Up</button>
      </div>
    </div>

    <div class="row w-100 no-gutters mb-2">
      <div class="col ml-2 mr-2">
        <div class="progress">
          <div id="game-progress" class="progress-bar bg-primary progress-bar-striped progress-bar-animated"
               role="progressbar" style="width: 0" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
            0/10
          </div>
        </div>
      </div>
    </div>
  </div>

  <div id="results-view" class="mt-4 mb-4">
    <table id="results-table" class="table table-striped table-hover table-responsive-sm">
      <thead class="thead-dark">
      <tr>
        <th scope="col">Set</th>
        <th scope="col">Button size (w x h)</th>
        <th scope="col">No. hits</th>
        <th scope="col">No. misses</th>
        <th scope="col">Accuracy (%)</th>
        <th scope="col">Total time (ms)</th>
        <th scope="col">Average time per hit (ms)</th>
      </tr>
      </thead>
      <tbody id="results-table-body"></tbody>
    </table>
    <button id="download-table-csv" class="btn btn-primary" hidden>
        {% trans "Download table as CSV" %}
    </button>
  </div>
</div>
{% endblock interactive_html %}

{% block interactive_css %}
<link rel="stylesheet" href="{% static 'interactives/clicking-with-shaking/css/clicking-with-shaking.css' %}">
<link href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" rel="stylesheet">
{% endblock interactive_css %}

{% block interactive_js %}
<script src="//code.jquery.com/ui/1.13.0/jquery-ui.js"></script>

<script>
  const hitSoundURL = "{% static 'interactives/clicking-with-shaking/sfx/hit.wav' %}";
  const missSoundURL = "{% static 'interactives/clicking-with-shaking/sfx/miss.ogg' %}";
</script>

<script type="text/javascript" src="{% static 'interactives/clicking-with-shaking/js/clicking-with-shaking.js' %}">
</script>
<script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/2.0.1/js/buttons.html5.min.js"></script>
{% endblock interactive_js %}