GET STARTED / FIRST INTEGRATION
Quick start
Try the simplest integration first: a package .p2lrn, the Player loaded from CDN and an HTML page. You do not need to install packages in the project to complete this walkthrough.
1. Download an example package
Save the example to a working folder. The rest of this guide assumes that the file is called questionnaire-standard.p2lrn.
2. Create an HTML page
Save this file as index.html in the same folder as the package. The first script load Player from CDN and the element <p2lrn-player> open the local course from that folder.
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>P2LRN</title>
<script src="https://p2lrn.org/player/current/dist/p2lrn.js"></script>
</head>
<body>
<p2lrn-player src="./questionnaire-standard.p2lrn"></p2lrn-player>
</body>
</html>3. Open the folder in your editor and serve it over HTTP
Open the example folder in your usual text or code editor. So that the browser can load the package and its resources correctly, open the page from a local HTTP server instead of opening index.html directamente mediante file://.
- Locate
index.htmland confirm thatquestionnaire-standard.p2lrnIt is in the same folder. - Use your editor's preview or local server option, or any static HTTP server you prefer.
- Open the local address provided by that server in your browser, usually based on
localhostor127.0.0.1.
You don't need a specific editor or extension; The important thing is to serve the folder over HTTP.
4. Check the result
The page should display the quiz within the Player. If it appears, you have already checked the essential path: loading the component, opening a package and running its contents from a web application.
The Player has been loaded from CDN; the course is still a file .p2lrn independent. From here you can decide how you want to maintain that integration in your project.
5. Continue with the installation
The next step is Installation. The documentation first introduces CDN—the natural continuation of this example—and then NPM for projects that manage their dependencies through packages.