summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/views/player.blade.php2
-rw-r--r--routes/web.php4
-rw-r--r--src/Http/Controllers/ScormPlayerController.php18
3 files changed, 22 insertions, 2 deletions
diff --git a/resources/views/player.blade.php b/resources/views/player.blade.php
index 31836eb..7970cea 100644
--- a/resources/views/player.blade.php
+++ b/resources/views/player.blade.php
@@ -27,6 +27,6 @@
<script>
window.scorm_api_data = {{ Js::from($scorm_api_data) }};
</script>
- <script src="{{ manifest('js/scorm_player.js') }}"></script>
+ <script src="{{ $js_uri }}"></script>
</body>
</html>
diff --git a/routes/web.php b/routes/web.php
index b86d710..4570f11 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -10,6 +10,9 @@ Route::name('scorm-player.')->prefix('elearning')->middleware([
'web',
])->group(function() {
+ Route::get('scorm-player-{version}.js', [ScormPlayerController::class, 'jsSource'])
+ ->name('javascript');
+
$group = function() {
Route::get('/scorm/{sco}', 'scormLoad')->name('scorm.load');
Route::post('/scorm/{tracking}', 'scormCommit')->name('scorm.commit');
@@ -26,4 +29,5 @@ Route::name('scorm-player.')->prefix('elearning')->middleware([
}
$route->group($group);
+
});
diff --git a/src/Http/Controllers/ScormPlayerController.php b/src/Http/Controllers/ScormPlayerController.php
index 34a5967..7c801c9 100644
--- a/src/Http/Controllers/ScormPlayerController.php
+++ b/src/Http/Controllers/ScormPlayerController.php
@@ -21,6 +21,8 @@ use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
class ScormPlayerController extends Controller
{
+ private const JS_PATH = __DIR__ . '/../../../dist/js/scorm_player.js';
+
public function player(Request $request, Scorm $module)
{
$sco = $request->query('sco');
@@ -33,9 +35,14 @@ class ScormPlayerController extends Controller
],
];
+ $js_uri = route('scorm-player.javascript', [
+ 'version' => substr(md5(filemtime(self::JS_PATH)), 10, 8)
+ ]);
+
return view('scorm-player::player', compact(
'sco',
- 'scorm_api_data'
+ 'scorm_api_data',
+ 'js_uri'
));
}
@@ -101,4 +108,13 @@ class ScormPlayerController extends Controller
];
}
+ public function jsSource(Request $request)
+ {
+ return response()->file(self::JS_PATH, [
+ 'Content-Type' => 'application/javascript',
+ //'Cache-Control' => $cacheControl,
+ //'ETag' => $etag,
+ ]);
+ }
+
}