Questionaire xAPI statements

Questionaire is throw tons of statements out, especially with the open ended response. It's polling and seemingly sending every other character typed on the keyboard. :)


answers to questions also aren't coming across (multi-choice). And it appears to be trying to write to a database but that part seems pretty Drupal specific.

thomasmars's picture

This is by design:

  • Open Ended Question sends an "interacted" event every time an input is given/it is interacted with (i.e. a character is typed)
  • Simple Multiple Choice sends an "interacted" event every time an alternative changes
  • Questionnaire sends "completed" event when pressing the "submit" button
  • Questionnaire sends "progressed" event when moving to a different question/page

The events are not saved anywhere, you must have an LRS or similar in order to pick up these events and make use of them.

Do you think that any of these events are incorrect or should be sent/handled differently ?

wie's picture

Hi, is it possible to switch to another activity within a questionnaire based on the result?

Example: I read out the result of a multiple question and the user answers with "does not apply", which makes the answering of the next five questions obsolete. I work with xAPI-data.statements and as I understand from the documentation, it would be nice to do something like (in pseudocode):

repeat five times:

object = this.object;




Is there a syntax that allows to skip tasks, depending on user action?

Thank you very much.


thomasmars's picture

Hi, there is no functionality for swapping out an H5P in the iFrame, but the other functionality is possible.
You can for instance listen for xAPI events, if the xAPI that you catch fulfills certain criterias you can navigate them to a new page that has a different H5P. 

We're also currently working on a content type called "Branching Scenario" that is designed to fulfill exactly these types of use-cases, allowing you to guide students to different H5Ps depending on their answer. This content type will not require any technical knowledge or working with the xAPI statements, it will all be handled for you.

Best regards, Thomas

wie's picture

<pre class="jscript:lang">

(function($) {
      $(function() {
          echo("var workspaceLink = '/bibliothek/webroot/h5p/".$h5p->name."';") ?>
            id: 1,
          frameJs: '/bibliothek/webroot/h5p/dist/js/h5p-standalone-frame.min.js',
          frameCss: '/bibliothek/webroot/h5p/dist/styles/h5p.css',
          h5pContent: workspaceLink
    var answer = {};
    var result = {};
    var id = '';
    var textarea = '';
    var objectId = '';
    var eventListe = [];
    H5P.externalDispatcher.on('xAPI', function (event) {
    result =;
    id = this.subContentId; //questionnaire containing subContentIds F1 to F4
    if (typeof result != 'undefined' && typeof id != 'undefined') {
        if (result['response'].length > 10) {
            if (id == "F1") {
                textarea = this.parent.questionnaireElement.lastElementChild.childNodes[1].childNodes[0];
                textarea['maxLength'] = '10'; alert('Nur zehn Zeichen');
        if (id == "F2") {
                //somehow trigger skipping of F3, loading event F4
    if(event.getVerb()==='completed') {console.log(answer);console.log(eventListe);}