Git Product home page Git Product logo

laravel-scorm's Introduction

Laravel Scorm Handler

Design for Laravel LMS

N|Solid

Laravel Scorm Handler is a laravel package that simplify scorm package contents (zip file) into laravel storage.

Highlight of this package:

  • Zipfile handler with auto extract and store sco into database
  • Store user CMI data into database
  • Get user last learning data

Things you must know before you install:

  1. You have a domain/subdomain to serve scorm content
  2. Scorm content folder/path must be outside from laravel application (Security issue).
  3. Virtual host to point domain/subdomain to scorm content directory (E.g: /scorm/hashed_folder_name/)
  4. Uploaded file should have the right permission to extract scorm files into scorm content directory
  5. This package will handle folder creation into scorm content directory (E.g: /scorm/{auto_generated_hashname}/imsmanifest.xml)

Step 1:

Install from composer (For flysystem v1)

composer require devianl2/laravel-scorm:"^3.0"

Install from composer (For flysystem v2/v3)

composer require devianl2/laravel-scorm

Step 2:

Run vendor publish for migration and config file

php artisan vendor:publish --provider="Peopleaps\Scorm\ScormServiceProvider"

Step 3:

Run config cache for update cached configuration

php artisan config:cache

Step 4:

Migrate file to database

php artisan migrate

Step 5 (Optional):

Update SCORM config under config/scorm

  • update scorm table names.
  • update SCORM disk and configure disk @see config/filesystems.php
    'disk'  =>  'scorm-local',
    'disk'  =>  'scorm-s3',

 // @see config/filesystems.php
     'disks' => [
         .....
         'scorm-local' => [
            'driver'     => 'local',
            'root'       =>  env('SCORM_ROOT_DIR'), // set root dir
            'visibility' => 'public',
        ],

        's3-scorm' => [
            'driver' => 's3',
            'root'   => env('SCORM_ROOT_DIR'), // set root dir
            'key'    => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_SCORM_BUCKET'),
        ],
        .....
     ]

Update SCORM translations under resources/lang/en-US/scorm.php

  • SCORM runtime errors exceptions handler, (Check next example)
  • Copy and translate error msg with key for other locale as you wish.

After finishing don't forget to run php artisan config:cache

Step 6 (Optional):

Usage

class ScormController extends BaseController
{
    /** @var ScormManager $scormManager */
    private $scormManager;
    /**
     * ScormController constructor.
     * @param ScormManager $scormManager
     */
    public function __construct(ScormManager $scormManager)
    {
        $this->scormManager = $scormManager;
    }

    public function show($id)
    {
        $item = ScormModel::with('scos')->findOrFail($id);
        // response helper function from base controller reponse json.
        return $this->respond($item);
    }

    public function store(ScormRequest $request)
    {
        try {
            $scorm = $this->scormManager->uploadScormArchive($request->file('file'));
            // handle scorm runtime error msg
        } catch (InvalidScormArchiveException | StorageNotFoundException $ex) {
            return $this->respondCouldNotCreateResource(trans('scorm.' .  $ex->getMessage()));
        }

        // response helper function from base controller reponse json.
        return $this->respond(ScormModel::with('scos')->whereUuid($scorm['uuid'])->first());
    }

    public function saveProgress(Request $request)
    {
        // TODO save user progress...
    }
}

Upgrade from version 2 to 3: Update your Scorm table:

  • Add entry_url (varchar 191 / nullable)
  • Change hash_name to title
  • Remove origin_file_mime field

Upgrade from version 3 to 4: Update your Scorm table:

  • Add identifier (varchar 191)

laravel-scorm's People

Contributors

cthomas87 avatar devianl2 avatar khaledlela avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.