PHPackages                             msaaq/nelc-xapi-php-sdk - 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. [API Development](/categories/api)
4. /
5. msaaq/nelc-xapi-php-sdk

ActiveLibrary[API Development](/categories/api)

msaaq/nelc-xapi-php-sdk
=======================

xAPI Integration with Saudi NELC (National Center for e-Learning)

v1.4(1mo ago)412.9k—3.8%11MITPHPPHP ^8.1

Since Sep 14Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/msaaqcom/nelc-xapi-php-sdk)[ Packagist](https://packagist.org/packages/msaaq/nelc-xapi-php-sdk)[ Docs](https://github.com/msaaqcom/nelc-xapi-php-sdk)[ RSS](/packages/msaaq-nelc-xapi-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (10)Used By (1)

xAPI Integration with Saudi NELC (National Center for e-Learning)
=================================================================

[](#xapi-integration-with-saudi-nelc-national-center-for-e-learning)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7c7e25bc6f98f77a19647ca6119ff16ef46b28886d51a830d517ccd52fb7ec2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d736161712f6e656c632d786170692d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msaaq/nelc-xapi-php-sdk)[![GitHub Tests Action Status](https://camo.githubusercontent.com/430fc0c41dc9c2520f1c8804d4f5226e69bbf0b89e3e0b52aec3346ab76422a8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d736161712f6e656c632d786170692d7068702d73646b2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/msaaq/nelc-xapi-php-sdk/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3d41f26a8b5240be39354da8cde141b3facef6c1fafa364ec91c897aa8663e4d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d736161712f6e656c632d786170692d7068702d73646b2f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/msaaq/nelc-xapi-php-sdk/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/26c3632a1d1f67c6a0491c6ce85ccbe358bc933c2acc8b41fee16be2c9d80442/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d736161712f6e656c632d786170692d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/msaaq/nelc-xapi-php-sdk)

The base concept of this package is to provide a simple way to send xAPI statements to Saudi NELC (National Center for e-Learning) LRS (Learning Record Store).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require msaaq/nelc-xapi-php-sdk
```

Usage
-----

[](#usage)

1. Create Api Client.
---------------------

[](#1-create-api-client)

The first step to use the SDK is to create an instance of the `ApiClient`. The `ApiClient` is the main entry point to the SDK. It is responsible for creating the other objects and for sending the requests to the API.

The `ApiClient` required the following credentials:

- Key
- Secret
- Platform Name

> You need to contact NELC to provide you with your integration credentials.

```
use Msaaq\Nelc\ApiClient;

$client = new ApiClient(
    key: 'username', // required
    secret: 'password', // required
    isSandbox: true, // optional, default is false
);

$platform = new \Msaaq\Nelc\Common\Platform($identifier = 'platform-identifier', $name = 'platform-name', $language = \Msaaq\Nelc\Enums\Language::ARABIC); // required
```

After we created our client, we can use it to send statements to the NELC LRS.

2. Send Statement
-----------------

[](#2-send-statement)

To send a statement to the NELC LRS, we need to create an instance of the `StatementClient` class.

The `StatementClient` required an instance of the `ApiClient` that we've created in the previous step, and the `$platform`.

```
use Msaaq\Nelc\StatementClient;

$statementClient = StatementClient::setClient($client)->setPlatform($platform);
```

Now we are almost ready to send our first statement to the NELC LRS, we just need to create an instance of the `Statement` that we are going to send, but first let's understand the `Statement` classes structure.

### Statement Structure

[](#statement-structure)

You can think of the `Statement` as an event that happened in your application, and we have 8 types of statements for each case:

NameDescriptionClassregisteredIndicates the actor is officially enrolled or inducted in an activity.`RegisteredStatement`initializedIndicates the activity provider has determined that the actor successfully started an activity.`InitializedStatement`watchedIndicates that the actor has watched the object. This verb is typically applicable only when the object represents dynamic, visible content such as a movie, a television show or a public performance. This verb is a more specific form of the verbs experience, play and consume.`WatchedStatement`completedIndicates the actor finished or concluded the activity normally.`CompletedStatement`progressedIndicates a value of how much of an actor has advanced or moved through an activity.`ProgressedStatement`ratedAction of giving a rating to an object. Should only be used when the action is the rating itself, as opposed to another action such as "reading" where a rating can be applied to the object as part of that action. In general the rating should be included in the Result with a Score object.`RatedStatement`earnedIndicates that the actor has earned or has been awarded the object.`EarnedStatement`attemptedIndicates the actor made an effort to access the object. An attempt statement without additional activities could be considered incomplete in some cases.`AttemptedStatement`Every statement requires the following:

- `Actor` which is the user that performed the action (Student).
    - It has the following properties:
        - `national_id` which is the user national id.
        - `email` which is the user email.
- `Instructor` which is the course or module instructor (Teacher).
    - It has the following properties:
        - `name` which is the instructor name.
        - `email` which is the instructor email.
- `Module` which is the course or module that the student is enrolled in.
    - It has the following properties:
        - `url`\* which is the module url.
        - `name`\* which is the module name.
        - `description`\* which is the module description.
        - `language`\* which is the module language, and it must be an instance of `Language`.
        - `activityType`\* which is the module type.
            - It can be one of the following:
                - `ActivityType::COURSE`
                - `ActivityType::LESSON`
                - `ActivityType::VIDEO`
                - `ActivityType::MODULE`
                - `ActivityType::UNIT_TEST`
                - `ActivityType::CERTIFICATE`
        - `duration` which is the module duration in seconds (this is only when the `activityType`is `ActivityType::VIDEO`).
        - `score` which is the module score (this is only when the `activityType` is `ActivityType::UNIT_TEST`).
    - `language` is an enum that has the following values:
        - `Language::ARABIC`
        - `Language::ENGLISH`
    - `timestamp` The date/time, following the ISO 8601 format such as `2022-09-14T10:33:43+03:00`.
        - If you don't provide a timestamp, the current date/time will be used.

> For the `timestamp` you can use [Carbon](https://carbon.nesbot.com/docs/), you can use the `toIso8601String()` method to get the correct format.

Let's prepare the `Actor` and `Instructor` objects, as we are going to use them with all of our statements.

```
use Msaaq\Nelc\Common\Actor;
use Msaaq\Nelc\Common\Instructor;

$actor = new Actor();
$actor->national_id = '123456789';
$actor->email = 'student@msaaq.com';

$instructor = new Instructor();
$instructor->email = 'instructor@msaaq.com';
$instructor->name = 'Instructor Name';
```

Now we are ready to create our first statement:

### Registered Statement

[](#registered-statement)

The `RegisteredStatement` is used to indicate that the student is officially enrolled or inducted in an activity.

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\RegisteredStatement;

$statement = new RegisteredStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course';
$statement->module->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::COURSE;

var_dump($statementClient->send($statement));
```

### Initialized Statement

[](#initialized-statement)

The `InitializedStatement` is used to indicate that the actor (student) has successfully started the course.

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\InitializedStatement;

$statement = new InitializedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course';
$statement->module->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::COURSE;

var_dump($statementClient->send($statement));
```

### Watched Statement

[](#watched-statement)

The `WatchedStatement` is used to indicate that the actor (student) has watched the object (video).

This statement requires more properties than the previous statements, as it has the following properties:

- `parent` which is an instance `Module` which is the course in our case.
- `completed` which is a boolean value that indicates if the video is completed or not.
- `browserInformation`
    - `family` which is the browser family (Mozilla, Google, ex..).
    - `name` which is the browser name (Firefox, Chrome, ex..).
    - `version` which is the browser version.

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Common\BrowserInformation;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\WatchedStatement;

$statement = new WatchedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$browserInformation = new BrowserInformation();
$browserInformation->family = 'Mozilla';
$browserInformation->name = 'Firefox';
$browserInformation->version = '92.0';

$statement->browserInformation = $browserInformation;

$statement->actor = $actor;
$statement->instructor = $instructor;

// Our parent module is the course
$parent = new Module();
$parent->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$parent->title = 'How to create professional course';
$parent->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$parent->language = $statement->language;
$parent->activityType = ActivityType::COURSE;

$statement->parent = $parent;

// Our module is the video
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course/contents/11919';
$statement->module->title = 'Introduction to creating training courses';
$statement->module->description = 'In this video, we will talk about the importance of creating training courses and the benefits of doing so.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::VIDEO;
// Duration in seconds, required when the activity type is VIDEO
$statement->module->duration = 630; // 10:30 minutes

$statement->completed = true;

var_dump($statementClient->send($statement));
```

### Attempted Statement

[](#attempted-statement)

The `AttemptedStatement` is used to indicate that the actor (student) has attempted the object (quiz).

This statement requires more properties than the previous statements, as it has the following properties:

- `parent`
- `completed`
- `browserInformation`
- `succeeded` which is a boolean value that indicates if the quiz is succeeded or not.
- `attemptId` which is a unique identifier for the attempt.

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Common\Score;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\AttemptedStatement;

$statement = new AttemptedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->browserInformation = $browserInformation;

$statement->actor = $actor;
$statement->instructor = $instructor;

// Our parent module is the course
$statement->parent = $parent;

// Our module is the video
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course/contents/11919';
$statement->module->title = 'Quiz title';
$statement->module->description = 'Quiz description';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::UNIT_TEST;
// score required when the activity type is UNIT_TEST
$statement->module->score = new Score(); // 10:30 minutes
$statement->module->score->min = 0;
$statement->module->score->max = 100;
$statement->module->score->score = 70; // 70% student score

$statement->completed = true;
$statement->succeeded = true;

var_dump($statementClient->send($statement));
```

### Completed Statement (Module, Chapter or Unit)

[](#completed-statement-module-chapter-or-unit)

The `CompletedStatement` is used to indicate that the actor (student) has completed the object (module).

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\CompletedStatement;

$statement = new CompletedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->browserInformation = $browserInformation;

$statement->actor = $actor;
$statement->instructor = $instructor;

// Our parent module is the course
$statement->parent = $parent;

// Our module is the video
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course/contents/11919';
$statement->module->title = 'Unit title';
$statement->module->description = 'Unit description';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::MODULE;

var_dump($statementClient->send($statement));
```

### Progressed Statement

[](#progressed-statement)

The `ProgressedStatement` is used to indicate that the actor (student) has progressed the object (module/course).

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\ProgressedStatement;

$statement = new ProgressedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

// Our module is the course
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course';
$statement->module->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::COURSE;

$score = new \Msaaq\Nelc\Common\Score();
$score->score = 15; // the student has progressed 15% of the course

$statement->module->score = $score;

$statement->completed = false;

var_dump($statementClient->send($statement));
```

### Completed Statement (Course)

[](#completed-statement-course)

The `CompletedStatement` is used to indicate that the actor (student) has completed the object (course).

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\CompletedStatement;

$statement = new CompletedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

// Our module is the course
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course';
$statement->module->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::COURSE;

var_dump($statementClient->send($statement));
```

### Rated Statement

[](#rated-statement)

The `RatedStatement` is used to indicate that the actor (student) has rated the object (course).

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Common\Score;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\RatedStatement;

$statement = new RatedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

// The course that student rated
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course';
$statement->module->description = 'This series will cover the most important principles of course making, marketing and content preparation.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::COURSE;

$statement->rate = new Score();
$statement->rate->min = 1;
$statement->rate->max = 5;
$statement->rate->score = 3; // 3 stars out of 5

$statement->rateContent = 'This course is very good.';

var_dump($statementClient->send($statement));
```

### Earned Statement

[](#earned-statement)

The `EarnedStatement` is used to indicate that the actor (student) has earned the object (certificate).

```
use Msaaq\Nelc\Common\Module;
use Msaaq\Nelc\Common\Score;
use Msaaq\Nelc\Enums\ActivityType;
use Msaaq\Nelc\Enums\Language;
use Msaaq\Nelc\Statements\EarnedStatement;

$statement = new EarnedStatement();
$statement->language = Language::ENGLISH;
$statement->timestamp = '2022-09-14T10:33:43+03:00';

$statement->actor = $actor;
$statement->instructor = $instructor;

// The course that student earned the certificate
$statement->parent = $parent;

// The certificate that student earned
$statement->module = new Module();
$statement->module->url = 'https://academy.msaaq.com/courses/how-to-create-professional-course';
$statement->module->title = 'How to create professional course certificate';
$statement->module->description = 'This certificate is awarded to students who completed the course.';
$statement->module->language = $statement->language;
$statement->module->activityType = ActivityType::CERTIFICATE;

$statement->certificateUrl = 'path to download the certificate';

var_dump($statementClient->send($statement));
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

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 ~183 days

Recently: every ~313 days

Total

8

Last Release

55d ago

PHP version history (2 changes)v1.0PHP ^8.1

v1.3PHP ^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/93d2a416b2b04dcc7a6d8acd2415198756694f68043494cc84e4983152a58397?d=identicon)[Hussam3bd](/maintainers/Hussam3bd)

---

Top Contributors

[![Hussam3bd](https://avatars.githubusercontent.com/u/8091592?v=4)](https://github.com/Hussam3bd "Hussam3bd (24 commits)")[![maherelgamil](https://avatars.githubusercontent.com/u/6294478?v=4)](https://github.com/maherelgamil "maherelgamil (3 commits)")[![sezohessen](https://avatars.githubusercontent.com/u/29412443?v=4)](https://github.com/sezohessen "sezohessen (1 commits)")

---

Tags

lrslrs-scorenelcsaudi-nelcxapimsaaqcomxapi-statementsnelc-xapi-php-sdk

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/msaaq-nelc-xapi-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/msaaq-nelc-xapi-php-sdk/health.svg)](https://phpackages.com/packages/msaaq-nelc-xapi-php-sdk)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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