PHP code example of al-saloul / laravel-nelc-xapi-integration

1. Go to this page and download the library: Download al-saloul/laravel-nelc-xapi-integration library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

al-saloul / laravel-nelc-xapi-integration example snippets


// config/app.php

'providers' => ServiceProvider::defaultProviders()->merge([
    /*
        * Package Service Providers...
    */
    // Other providers...
    Nelc\LaravelNelcXapiIntegration\NelcXapiServiceProvider::class,
])->toArray(),

// config/lrs-nelc-xapi.php
return [
    'endpoint'      => env('LRS_ENDPOINT'),
    'middleware'      => ['web'], // Middleware to display the demo page, ['web', 'auth', ...]
    'key'    => env('LRS_USERNAME'),
    'secret'    => env('LRS_PASSWORD'),
    'platform_in_arabic'    => '', // Platform name in Arabic
    'platform_in_english'    => '', // Platform name in English
    'base_route'    => 'nelcxapi/test', // Demo Page Link
];

use Nelc\LaravelNelcXapiIntegration\XapiIntegration;
// ...

$xapi = new XapiIntegration();
$response = $xapi->Registered(
    '123456789', // Student National ID
    '[email protected]', // Student Email
    '123', // Course Id OR url Or slug
    'New Course', // Course Title
    'New Course description', // Course description
    'MR Hassan', // instructor Name
    '[email protected]',  // instructor Email
);

// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID

use Nelc\LaravelNelcXapiIntegration\XapiIntegration;
// ...

$xapi = new XapiIntegration();
$response = $xapi->Initialized(
    '123456789', // Student National ID
    '[email protected]', // Student Email
    '123', // Course Id OR url Or slug
    'New Course', // Course Title
    'New Course description', // Course description
    'MR Hassan', // instructor Name
    '[email protected]',  // instructor Email
);

// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID

use Nelc\LaravelNelcXapiIntegration\XapiIntegration;
// ...

$xapi = new XapiIntegration();
$response = $xapi->Watched(
    '123456789', // Student National ID
    '[email protected]', // 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
    '[email protected]',  // instructor Email

);

// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID

use Nelc\LaravelNelcXapiIntegration\XapiIntegration;
// ...

$xapi = new XapiIntegration();
$response = $xapi->CompletedLesson(
    '123456789', // Student National ID
    '[email protected]', // 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
    '[email protected]',  // instructor Email
);

// dd( $response['status'] ); return 200
// dd( $response['message'] ); return ok
// dd( $response['body'] ); return UUID
bash
composer dump-autoload
bash
php artisan vendor:publish --provider="Nelc\LaravelNelcXapiIntegration\NelcXapiServiceProvider"