Laravel package for integrating with Saudi NELC xAPI.
Before you begin, navigate to the directory where your Laravel project is located. Use the following command to change into your project directory:
cd path/to/your/laravel-project
You can install this library using Composer. Run the following command:
composer require lamoud/laravel-nelc-xapi-integration
Register the NelcXapiServiceProvider
in your Laravel project. Open the config/app.php
file and add the following line to the providers
array:
// config/app.php
'providers' => ServiceProvider::defaultProviders()->merge([
/*
* Package Service Providers...
*/
// Other providers...
Lamoud\LaravelNelcXapiIntegration\NelcXapiServiceProvider::class,
])->toArray(),
After registering the ServiceProvider, run the following command to re-generate Composer's autoloader files:
composer dump-autoload
To publish the configuration files provided by this package, run the following Artisan command:
php artisan vendor:publish --provider="Lamoud\LaravelNelcXapiIntegration\NelcXapiServiceProvider"
This will deploy asset
files inside the public folder with the name lamoud-nelc-xapi
and the file lamoud-nelc-xapi.php
inside the config
folder.
To start using this package, follow these steps to configure the basic settings and connect with NELC XAPI:
Open the lamoud-nelc-xapi.php
file inside the config
folder. Adjust the basic settings according to your requirements. Make sure to set up any necessary enpoint
, authentication (key, secret)
details, and other configuration options.
// config/lamoud-nelc-xapi.php
return [
'endpoint' => 'https://lrs.nelc.gov.sa/staging-lrs/xapi/statements', // Replace with endpoint.
'middleware' => ['web'], // Middleware to display the demo page, ['web', 'auth', ...]
'key' => 'userName',
'secret' => 'pasword',
'platform_in_arabic' => '', // Platform name in Arabic
'platform_in_english' => '', // Platform name in English
'base_route' => 'nelcxapi/test', // Demo Page Link
];
Now, you can go to the demo page and start testing statement submissions using the following link:
https://your-site.com/nelcxapi/test
or through the route('lamoud-nelc-xapi.base_route')
.
Once the package is installed and the ServiceProvider is registered, you can use it in your Laravel project. Here's a simple examples:
Indicates the actor is officially enrolled or inducted in an activity.
use Lamoud\LaravelNelcXapiIntegration\XapiIntegration;
// ...
$xapi = new XapiIntegration();
$response = $xapi->Registered(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course', // Course Title
'New Course description', // Course description
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID
Indicates the activity provider has determined that the actor successfully started an activity.
use Lamoud\LaravelNelcXapiIntegration\XapiIntegration;
// ...
$xapi = new XapiIntegration();
$response = $xapi->Initialized(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course', // Course Title
'New Course description', // Course description
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID
Indicates 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.
use Lamoud\LaravelNelcXapiIntegration\XapiIntegration;
// ...
$xapi = new XapiIntegration();
$response = $xapi->Watched(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/url/to/lesson', // Lesson Or object URL
'Lesson title', // Object title
'Lesson description', // Object description
true, // The status indicating whether it has been fully watched (boolean).
'PT15M', // The duration of the watching session in `ISO 8601` format.
'123', // Course Id OR url Or slug
'New Course', // Course Title
'New Course description', // Course description
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID
Indicates the actor finished or concluded the activity normally.
use Lamoud\LaravelNelcXapiIntegration\XapiIntegration;
// ...
$xapi = new XapiIntegration();
$response = $xapi->CompletedLesson(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/url/to/lesson', // Lesson URL
'Lesson title',
'Lesson description',
'123', // Course Id OR url Or slug
'New Course', // Course Title
'New Course description', // Course description
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID