R-Quiz

R-Quiz is a software component that can convert suitable contents into interactive quizzes (Demo).

Version and Download

Current Version: 3.0 (2017/05/01) - rquiz-3.0.zip (184.2 KB)

Changes in comparison to previous versions: CHANGES

Features

R-Quiz is available under the GNU Lesser General Public License (LGPL) which makes it free software. You can use R-Quiz for all your intents and purposes as long as you don't directly sell it. However you can create quiz contents and sell these bundled with R-Quiz which itself remains free of charge. You can also use R-Quiz to offer contents behind a paywall.

Quiz Types

R-Quiz currently supports these quiz types:

  1. matching quiz (drag&drop - either with pairs or categories)
  2. gapfill quiz (with both drag&drop and text input fields)
    With this quiz type you can create regular gapfill exercises as well as a sorting quiz and even a picture puzzle.
  3. memory quiz
  4. multiple choice quiz
  5. wordjumble quiz (with text input fields)
  6. crossword quiz
  7. wordsearch quiz
  8. wordguess quiz (hangman)

With the exception of the wordguess quiz type all quizzes can be printed on paper and used non-interactively. Use the browser's native printing functionality for this.

Internationalization

R-Quiz supports button texts and help texts in the following languages:

  1. Deutsch (Demo)
  2. English (Demo)
  3. Français
  4. Italiano
  5. Latein
  6. Español
  7. Polaco

Integration

R-Quiz consists basically of two files, a JavaScript file rquiz.js and a corresponding CSS file rquiz.css. The class names in the CSS file have been prefixed in order to avoid complications with the web page's environment.

You can embed an additional JavaScript file like the provided rquiz-uploader.js which should illustrate how to connect to your server-side logic. An example PHP script rquiz-response.php is also provided. As response you can either send a simple number which will be interpreted as the last number of attempts, or you can send any custom message which will be displayed unmodified.

Script Loader

If you load R-Quiz using a script loader like in a WikiMedia environment, R-Quiz might not initialize any quizzes at first. For this case R-Quiz exposes the window.rQuizInit() method, which needs to be called by the script loader. This has to do with the DOMContentLoaded event which might already have fired in a script loader-based environment.

Make sure the script loader also loads the corresponding CSS file because R-Quiz might fail to do so in such a situation.

How To

After initialization R-Quiz searches for elements that carry certain class names. When it finds a suitable one it tries to convert this element's contents into a quiz. If this element carries a lang attribute, R-Quiz tries to use the attribute value as language setting for the quiz. For backwards compatibility reasons the default language setting is "de" (German). This is what the source code should look like:

Matching Quiz

<div class="rquiz-matching" lang="en">
  <p>Possible instructions here...</p>
  <table>
    <tr>
      <td>bee</td>
      <td><img src="bee.jpg" alt="bee"></td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter

Possible instructions here...

beeBiene

Possible instructions here...

beeBiene

If you add more rows to the table, the quiz will have more than a single pair. Using more than two cells per row results in the Quiz operating in "categories mode" in which it uses the first cell's contents as category indicator:

<div class="rquiz-matching" lang="en">
  <p>Possible instructions here...</p>
  <table>
    <tr>
      <td>Insects</td>
      <td>ant</td>
      <td><img src="biene.jpg" alt="bee"></td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter

Possible instructions here...

Insectsantbee

Possible instructions here...

Insectsantbee

Gapfill Quiz

<div class="rquiz-gapfill" lang="en">
  <p>The early <strong>bird</strong> catches the <em>worm</em>.</p>
  <p>A <b>bee | bumble bee | fly (<img src="bee.jpg" alt="bee">)</b> is an insect.</p>
  <p>5 + 6 * 2 - 12 = <i>5()</i></p>
</div>

This is what the above code looks like on the page:
beforeafter

The early bird catches the worm.

A bee | bumble bee | fly (bee) is an insect.

5 + 6 * 2 - 12 = 5()

The early bird catches the worm.

A bee | bumble bee | fly (bee) is an insect.

5 + 6 * 2 - 12 = 5()

Every text structuring element like <b>, <i>, <em> or <strong> will become a drag&drop element. If R-Quiz finds parenthesis within such an element, this element won't become a drag&drop element but a text input field. Within the parenthesis you can place a hint. Multiple valid solutions can be separated using the pipe symbol.

Gapfill Quiz As Picture Puzzle

<div class="rquiz-gapfill">
  <table class="puzzle">
    <tr>
      <td><em><img alt="" src="...path/to/tile/image1-1..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image1-2..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image1-3..."></em></td>
    </tr>
  </table>
    <tr>
      <td><em><img alt="" src="...path/to/tile/image2-1..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image2-2..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image2-3..."></em></td>
    </tr>
  </table>
    <tr>
      <td><em><img alt="" src="...path/to/tile/image3-1..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image3-2..."></em></td>
      <td><em><img alt="" src="...path/to/tile/image3-3..."></em></td>
    </tr>
  </table>
</div>

This is what the above code looks like on the page:
beforeafter

Memo Quiz

<div class="rquiz-memo" lang="en">
  <table>
    <tr>
      <td>bee</td>
      <td><img src="bee.jpg" alt="bee"></td>

    </tr>
    <tr>
      <td>pear</td>
      <td><img src="pear.jpg" alt="pear"></td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter
beebee
pearpear
beebee
pearpear

Again R-Quiz extracts the contents for this quiz type from a table element. If the table has two columns, the quiz will create sets with two cards per set. A table with three columns means sets with triplets and so on.

Multiple Choice Quiz

<div class="rquiz-multichoice" lang="en">
  <p>Which animal is a mammal?(!Shark)(Whale)(Kangaroo)(!Nightingale)(Mouse)(!Bee)</p>
</div>

This is what the above code looks like on the page:
beforeafter

Which animal is a mammal? (!Shark)(Whale)(Kangaroo)(!Nightingale)(Mouse)(!Bee)

Which animal is a mammal? (!Shark)(Whale)(Kangaroo)(!Nightingale)(Mouse)(!Bee)

R-Quiz looks for any element in which it finds text with parentheses. The part before the first parenthesis will be interpreted as question and displayed unmodified. However the contents inside the parentheses get transformed into buttons that can be pressed and released (select and unselect). An exclamation mark at the beginning of such contents marks the contents as an incorrect option.

Word Jumble Quiz

<div class="rquiz-wordjumble" lang="en">
  <p>The <strong>early</strong> bird <strong>catches</strong> the worm.</p>
</div>

This is what the above code looks like on the page:
beforeafter

The early bird catches the worm.

The early bird catches the worm.

Every text structuring element like <b>, <i>, <em> or <strong> will become a text input field followed by parenthesis containing a hint in form of the expected word but in a jumbled form.

Crossword Quiz

<div class="rquiz-crossword" lang="en">
  <table>
    <tr>
      <td>bear</td>
      <td>carnivorous mammal of the family Ursidae</td>

    </tr>
    <tr>
      <td>beer</td>
      <td>the world's oldest and most widely consumed alcoholic drink</td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter
bearcarnivorous mammal of the family Ursidae
beerthe world's oldest and most widely consumed alcoholic drink
bearcarnivorous mammal of the family Ursidae
beerthe world's oldest and most widely consumed alcoholic drink

Again R-Quiz extracts the contents for this quiz type from a table element. The text contents of the first cell of a row will be the solution, the text contents of the second the corresponding hint.

Wordsearch Quiz

<div class="rquiz-wordsearch" lang="en">
  <table>
    <tr>
      <td>beer</td>
      <td>bear</td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter
beerbear
beerbear

Again R-Quiz extracts the text contents for this quiz type from any cell of a table element.

Wörterraten (Hangman)

<div class="rquiz-wordguess" lang="en">
  <table>
    <tr>
      <td>Bee</td>
      <td>Honey</td>

    </tr>
  </table>

</div>

This is what the above code looks like on the page:
beforeafter
BeeHoney
BeeHoney

Again R-Quiz extracts the text contents for this quiz type from any cell of a table element.

Feedback

I'm happy when my script is useful to someone. Emails about this are always welcome. I'm also open to suggestions for improvement, as I'm always learning and like to make my scripts better and more secure.