Skip to content

Commit

Permalink
feat(h5p-react): added xAPI collector to player
Browse files Browse the repository at this point in the history
Also now includes REST example
  • Loading branch information
sr258 authored Feb 24, 2021
1 parent 070da95 commit 5802e6f
Show file tree
Hide file tree
Showing 58 changed files with 21,962 additions and 839 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ There are two example implementations that illustrate how the packages can be
used:

| Example type | Tech stack | Location |
|---|---|---|
| server-side-rendering | server: Express with JS template rendering<br/>client: static HTML, some React for library management | `/packages/h5p-examples` |
| Single Page Application | server: Express with REST endpoints<br/>client: React | `/packages/h5p-rest-example-server`<br/>`/packages/h5p-rest-example-client`|
| :--- | :--- | :--- |
| server-side-rendering | server: Express with JS template rendering client: static HTML, some React for library management | `/packages/h5p-examples` |
| [Single Page Application](examples/rest/README.md) | server: Express with REST endpoints client: React | `/packages/h5p-rest-example-server` `/packages/h5p-rest-example-client` |

## Trying out the demo

Expand Down
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [h5p-react](packages/h5p-react.md)
- Development
* [Getting started](development/getting-started.md)
* [REST Example](examples/rest/README.md)
* [Testing & code quality](development/testing-quality.md)
* [Core updates](development/core-updates.md)
* [Project Status](development/status.md)
68 changes: 68 additions & 0 deletions docs/examples/rest/Client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# h5p-rest-example:client

This repository demonstrates how h5p-nodejs-library can be used in a SPA with a
REST endpoint.

This project was bootstrapped with [Create React
App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br /> Open
[http://127.0.0.1:3000](http://127.0.1:3000) to view it in the browser.

**IMPORTANT**: DO NOT use http://localhost:3000 on Windows as the proxy to the
server is very slow when you use localhost. The reason is that the IPv6 IP
resolution seems to be slow when using localhost.

The page will reload if you make edits.<br /> You will also see any lint errors
in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br /> See the section
about [running
tests](https://facebook.github.io/create-react-app/docs/running-tests) for more
information.

### `npm run build`

Builds the app for production to the `build` folder.<br /> It correctly bundles
React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br /> Your app is
ready to be deployed!

See the section about
[deployment](https://facebook.github.io/create-react-app/docs/deployment) for
more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can
`eject` at any time. This command will remove the single build dependency from
your project.

Instead, it will copy all the configuration files and the transitive
dependencies (webpack, Babel, ESLint, etc) right into your project so you have
full control over them. All of the commands except `eject` will still work, but
they will point to the copied scripts so you can tweak them. At this point
you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for
small and middle deployments, and you shouldn’t feel obligated to use this
feature. However we understand that this tool wouldn’t be useful if you couldn’t
customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App
documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
63 changes: 63 additions & 0 deletions docs/examples/rest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# H5P Single Page Application example using a REST API

This repository illustrates how to use the the packages of
[h5p-nodejs-library](https://github.com/lumieducation/h5p-nodejs-library) in a
Single Page Application with a REST backend in TypeScript.

Naturally the application is separated into a **client**, which uses React as a
framework. The **server** implements the `@lumieducation/h5p-server` using
Express. You are not bound to using React or Express in your own application, as
`@lumieducation/h5p-server` is framework agnostic.

Check out the architecture overview that describes which parts of the
application are provided by which package:

![Architecture overview](./architecture.svg)

- This repository contains all the components in **purple** boxes.
- The **green** parts come from one of the server-side packages of
`h5p-nodejs-library`. While `@lumieducation/h5p-server` is also a dev
dependency of the client, this is only the case to use the TypeScript
interface definitions exported by it. The dependency (which can be rather
large) is only required at build time and not at runtime.
- The **red** parts are React components that can be found in the package
`@lumieducation/h5p-react`. The React components wrap around the web
components from `@lumieducation/h5p-webcomponents`, which in turn wrap the
actual core h5p player and editor JavaScript and simplify instantiation,
loading, saving and event handling.
- The **blue** parts is comprised of JavaScript and CSS files that make up the
core H5P player and editor. They are part of the original PHP repositories
and are downloaded from GitHub in the server with the script
[`download-core.sh`](../../../packages/h5p-examples/download-core.sh). They
must be served as static files by the server and are added to the page by
the web components as needed.

## Trying it out

1. Clone the repository
2. Run `npm install` **in the root**. This will install all dependencies of the
example packages and internally link the packages inside the monorepo with
symlinks (lerna).
3. Run `npm start` for the server. (Must be up and running before you start the
client!)
4. Run `npm start` for the client (**the server must still be running**).
5. A browser should open on http://localhost:3000. If there is an error, you
have to reload the the page, as the server might not be fully initialized
yet.

## Client

The client was bootstrapped with [Create React
App](https://github.com/facebook/create-react-app). For more information see
[client](./Client.md)

## Support

This work obtained financial support for development from the German
BMBF-sponsored research project "lea.online -" (FKN: 41200147).

Read more about them at the following websites:

- lea.online Blog (German) - blogs.uni-bremen.de/leaonline
- University of Bremen - https://www.uni-bremen.de/en.html
- BMBF - https://www.bmbf.de/en/index.html
3 changes: 3 additions & 0 deletions docs/examples/rest/architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/examples/rest/architecture.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2021-02-24T13:45:51.315Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.1.8 Chrome/87.0.4280.88 Electron/11.1.1 Safari/537.36" etag="dmSVfdojfXUlji14qWAQ" version="14.1.8" type="device"><diagram id="91866775-811a-ca55-16df-98d47c250f2a" name="Page-1">7Vxbk5u4Ev41rpM82MUd/OiZ8SSbTXZdmWydPY8YZJsEWxyBZ8b59SuBhNEFG4/ly2R2qlIxQgip++uLulv07Nvl8wcUZosvMAZpzzLi555917Ms0wg8/B9p2VQtgUEb5iiJaadtw0PyE7Anaes6iUHOdSw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