PHPackages                             haggag/h5p-report - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. haggag/h5p-report

ActiveLibrary

haggag/h5p-report
=================

H5P Report functionality in PHP

v1.0.3(1y ago)016GPL-3.0PHPPHP &gt;=5.3.0

Since Aug 6Pushed 1y agoCompare

[ Source](https://github.com/MahmoudSaidHaggag/h5p-report)[ Packagist](https://packagist.org/packages/haggag/h5p-report)[ Docs](https://h5p.org)[ RSS](/packages/haggag-h5p-report/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

H5P-PHP-Report
==============

[](#h5p-php-report)

A generic library for rendering H5P reports for content types based on their xAPI statements.

Usage
-----

[](#usage)

1. To start with we need xAPI data from the content we will render, covered in [Content type requirements](#content-type-requirements).
2. We can then call `H5PReport->generateReport` with the content statement and an optional parent ID. Parent ID is provided if the content type is the parent of other content. This can be determined from its children.
3. Returned is HTML for the complete report.

### Generate report

[](#generate-report)

Generate report expect a special format of the xAPI data, an object with the several properties. Following is a simple example:

```
(object) array(
  'interaction_type' => 'choice',
  'description' => 'Do you like cake ?',
  'correct_responses_pattern' => '[0]',
  'response': '2',
  'extras': '{"choices":[{"id":0,"description":{"en-US":"Of course, who doesn't ?"}},{"id":1,"description":{"en-US":"No"}},{"id":2,"description":{"en-US":"What is a cake ?"}}},'
)
```

Note that `correct_responses_pattern` and `extras` should be json encoded.

Content type requirements
-------------------------

[](#content-type-requirements)

The plugin requires content types to implement the `getXAPIData` [contract](https://h5p.org/documentation/developers/contracts#guides-header-6)in order to get the proper reports with a `statement` object and an optional `children` array:

```
getXAPIData = function () {
  return {
    statement: {},
    children: []
  }
}
```

### Statement

[](#statement)

The statement object is a standard xAPI statement, which should adhere to the [xAPI specification](https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#table-of-contents). You can see an example for how this looks for [True False question](https://h5p.org/true-false) in [Appendix A](#appendix-a).

### Children

[](#children)

The children array is a collection of statements for the children of the content. An Interactive Video with "Summary" and "Mark The Words" content inside of it would have its own statement and two children items with their own statements. Children may also have children, so you can follow the chain all the way down to the lowest level. A complete example of [Single Choice Set](https://h5p.org/single-choice-set) can be found in [Appendix B](#appendix-b).

Appendix A
----------

[](#appendix-a)

An example of an xAPI statement from [True False question](https://h5p.org/true-false).

```
{
  "actor":{
    "name":"user",
    "mbox":"mailto:user@mail.com",
    "objectType":"Agent"
  },
  "verb":{
    "id":"http://adlnet.gov/expapi/verbs/answered",
    "display":{
      "en-US":"answered"
    }
  },
  "object":{
    "id":"https://h5p.org/true-false",
    "objectType":"Activity",
    "definition":{
      "extensions":{
        "http://h5p.org/x-api/h5p-local-content-id":34806
      },
      "name":{
        "en-US":"True/False Question"
      },
      "interactionType":"true-false",
      "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
      "description":{
        "en-US":"Oslo is the capital of Norway.\n"
      },
      "correctResponsesPattern":[
        "True"
      ]
    }
  },
  "context":{
    "contextActivities":{
      "category":[
        {
          "id":"http://h5p.org/libraries/H5P.TrueFalse-1.0",
          "objectType":"Activity"
        }
      ]
    }
  },
  "result":{
    "score":{
      "min":0,
      "max":1,
      "raw":0,
      "scaled":0
    },
    "completion":true,
    "success":false,
    "duration":"PT4.92S",
    "response":""
  }
}
```

Appendix B
----------

[](#appendix-b)

An example of a complete `getXAPIData` call to [Single Choice Set](https://h5p.org/single-choice-set).

```
{
  "statement":{
    "actor":{
      "name":"user",
      "mbox":"mailto:user@mail.com",
      "objectType":"Agent"
    },
    "verb":{
      "id":"http://adlnet.gov/expapi/verbs/answered",
      "display":{
        "en-US":"answered"
      }
    },
    "object":{
      "id":"https://h5p.org/single-choice-set",
      "objectType":"Activity",
      "definition":{
        "interactionType":"compound",
        "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
        "extensions":{
          "http://h5p.org/x-api/h5p-local-content-id":1515
        }
      }
    },
    "result":{
      "duration":"PT0S",
      "score":{
        "raw":0,
        "min":0,
        "max":3,
        "scaled":0
      }
    }
  },
  "children":[
    {
      "statement":{
        "actor":{
          "name":"user",
          "mbox":"mailto:user@mail.com",
          "objectType":"Agent"
        },
        "verb":{
          "id":"http://adlnet.gov/expapi/verbs/answered",
          "display":{
            "en-US":"answered"
          }
        },
        "context":{
          "contextActivities":{
            "parent":[
              {
                "id":"https://h5p.org/single-choice-set",
                "objectType":"Activity"
              }
            ]
          }
        },
        "object":{
          "id":"https://h5p.org/single-choice-set?subContentId=51445ea9-9c98-437a-8981-72d46d6e86c4",
          "objectType":"Activity",
          "definition":{
            "description":{
              "en-US":"Goji berries are also known as ..."
            },
            "interactionType":"choice",
            "correctResponsesPattern":[
              "0"
            ],
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
            "choices":[
              {
                "id":"0",
                "description":{
                  "en-US":"Wolfberries"
                }
              },
              {
                "id":"1",
                "description":{
                  "en-US":"Catberries"
                }
              },
              {
                "id":"2",
                "description":{
                  "en-US":"Bearberries"
                }
              }
            ],
            "extensions":{
              "http://h5p.org/x-api/h5p-local-content-id":1515,
              "http://h5p.org/x-api/h5p-subContentId":"51445ea9-9c98-437a-8981-72d46d6e86c4"
            }
          }
        },
        "result":{
          "response":"",
          "duration":"PT0S",
          "score":{
            "raw":0,
            "min":0,
            "max":1,
            "scaled":0
          }
        }
      }
    },
    {
      "statement":{
        "actor":{
          "name":"user",
          "mbox":"mailto:user@mail.com",
          "objectType":"Agent"
        },
        "verb":{
          "id":"http://adlnet.gov/expapi/verbs/answered",
          "display":{
            "en-US":"answered"
          }
        },
        "context":{
          "contextActivities":{
            "parent":[
              {
                "id":"https://h5p.org/single-choice-set",
                "objectType":"Activity"
              }
            ]
          }
        },
        "object":{
          "id":"https://h5p.org/single-choice-set?subContentId=95b60491-e203-4bc5-956c-89e966b1005d",
          "objectType":"Activity",
          "definition":{
            "description":{
              "en-US":"Goji berries are native to ..."
            },
            "interactionType":"choice",
            "correctResponsesPattern":[
              "0"
            ],
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
            "choices":[
              {
                "id":"0",
                "description":{
                  "en-US":"Asia"
                }
              },
              {
                "id":"1",
                "description":{
                  "en-US":"Africa"
                }
              },
              {
                "id":"2",
                "description":{
                  "en-US":"Europe"
                }
              }
            ],
            "extensions":{
              "http://h5p.org/x-api/h5p-local-content-id":1515,
              "http://h5p.org/x-api/h5p-subContentId":"95b60491-e203-4bc5-956c-89e966b1005d"
            }
          }
        },
        "result":{
          "response":"",
          "duration":"PT0S",
          "score":{
            "raw":0,
            "min":0,
            "max":1,
            "scaled":0
          }
        }
      }
    },
    {
      "statement":{
        "actor":{
          "name":"user",
          "mbox":"mailto:user@mail.com",
          "objectType":"Agent"
        },
        "verb":{
          "id":"http://adlnet.gov/expapi/verbs/answered",
          "display":{
            "en-US":"answered"
          }
        },
        "context":{
          "contextActivities":{
            "parent":[
              {
                "id":"https://h5p.org/single-choice-set",
                "objectType":"Activity"
              }
            ]
          }
        },
        "object":{
          "id":"https://h5p.org/single-choice-set?subContentId=aa694288-df4d-4ed3-8f81-f47fa3d27fe4",
          "objectType":"Activity",
          "definition":{
            "description":{
              "en-US":"Goji berries are usually sold ..."
            },
            "interactionType":"choice",
            "correctResponsesPattern":[
              "0"
            ],
            "type":"http://adlnet.gov/expapi/activities/cmi.interaction",
            "choices":[
              {
                "id":"0",
                "description":{
                  "en-US":"Dried"
                }
              },
              {
                "id":"1",
                "description":{
                  "en-US":"Pickled"
                }
              },
              {
                "id":"2",
                "description":{
                  "en-US":"Frozen"
                }
              }
            ],
            "extensions":{
              "http://h5p.org/x-api/h5p-local-content-id":1515,
              "http://h5p.org/x-api/h5p-subContentId":"aa694288-df4d-4ed3-8f81-f47fa3d27fe4"
            }
          }
        },
        "result":{
          "response":"",
          "duration":"PT0S",
          "score":{
            "raw":0,
            "min":0,
            "max":1,
            "scaled":0
          }
        }
      }
    }
  ]
}
```

License
-------

[](#license)

(The MIT License)

Copyright (c) 2016 Joubel AS

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

639d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8878cb195a9c7ab67015ad3df7ecadefad07ec8ccb33992abd038d296298fd0?d=identicon)[haggag](/maintainers/haggag)

---

Top Contributors

[![timothyylim](https://avatars.githubusercontent.com/u/6047346?v=4)](https://github.com/timothyylim "timothyylim (20 commits)")[![icc](https://avatars.githubusercontent.com/u/186580?v=4)](https://github.com/icc "icc (18 commits)")[![otacke](https://avatars.githubusercontent.com/u/16688047?v=4)](https://github.com/otacke "otacke (9 commits)")[![thomasmars](https://avatars.githubusercontent.com/u/1640201?v=4)](https://github.com/thomasmars "thomasmars (9 commits)")[![mahmoudhaggag641](https://avatars.githubusercontent.com/u/17066788?v=4)](https://github.com/mahmoudhaggag641 "mahmoudhaggag641 (4 commits)")[![jwalits](https://avatars.githubusercontent.com/u/56375964?v=4)](https://github.com/jwalits "jwalits (2 commits)")[![Gwenillia](https://avatars.githubusercontent.com/u/55385809?v=4)](https://github.com/Gwenillia "Gwenillia (2 commits)")[![fnoks](https://avatars.githubusercontent.com/u/2578572?v=4)](https://github.com/fnoks "fnoks (1 commits)")

---

Tags

contentinteractivequizh5phvp

### Embed Badge

![Health badge](/badges/haggag-h5p-report/health.svg)

```
[![Health](https://phpackages.com/badges/haggag-h5p-report/health.svg)](https://phpackages.com/packages/haggag-h5p-report)
```

###  Alternatives

[h5p/h5p-core

H5P Core functionality in PHP

1401.5M29](/packages/h5p-h5p-core)[h5p/h5p-editor

H5P Editor functionality in PHP

761.5M26](/packages/h5p-h5p-editor)[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M713](/packages/psy-psysh)[willdurand/negotiation

Content Negotiation tools for PHP provided as a standalone library.

1.4k122.0M156](/packages/willdurand-negotiation)[jorisdugue/h5p-bundle

H5P Bundle for Symfony 5, 6 and Symfony 7

1131.7k](/packages/jorisdugue-h5p-bundle)[coldtrick/thewire_tools

Extend the functionality of The Wire

133.2k](/packages/coldtrick-thewire-tools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
