diff --git a/H5P/laravel-h5p/src/LaravelH5p/Eloquents/H5pContent.php b/H5P/laravel-h5p/src/LaravelH5p/Eloquents/H5pContent.php
index 936337b16..3a2b15b46 100644
--- a/H5P/laravel-h5p/src/LaravelH5p/Eloquents/H5pContent.php
+++ b/H5P/laravel-h5p/src/LaravelH5p/Eloquents/H5pContent.php
@@ -2,8 +2,10 @@
namespace Djoudi\LaravelH5p\Eloquents;
-use Illuminate\Database\Eloquent\Model;
+use id;
use Illuminate\Support\Facades\DB;
+use App\Models\IndependentActivity;
+use Illuminate\Database\Eloquent\Model;
class H5pContent extends Model
{
@@ -50,4 +52,9 @@ public function library()
return $this->belongsTo(H5pLibrary::class, 'library_id');
}
+ public function independentActivity()
+ {
+ return $this->hasOne(IndependentActivity::class, 'h5p_content_id', 'id');
+ }
+
}
diff --git a/H5P/laravel-h5p/src/LaravelH5p/Repositories/LaravelH5pRepository.php b/H5P/laravel-h5p/src/LaravelH5p/Repositories/LaravelH5pRepository.php
index f2d498136..11e189a65 100644
--- a/H5P/laravel-h5p/src/LaravelH5p/Repositories/LaravelH5pRepository.php
+++ b/H5P/laravel-h5p/src/LaravelH5p/Repositories/LaravelH5pRepository.php
@@ -435,7 +435,6 @@ public function updateContent($content, $contentMainId = NULL)
'filtered' => '',
'disable' => $content['disable']
));
-
if (!isset($content['id'])) {
// Insert new content
$data['created_at'] = $current_date;;
diff --git a/app/Http/Controllers/Api/V1/H5pController.php b/app/Http/Controllers/Api/V1/H5pController.php
index 395f5a740..c5689b914 100644
--- a/app/Http/Controllers/Api/V1/H5pController.php
+++ b/app/Http/Controllers/Api/V1/H5pController.php
@@ -90,6 +90,7 @@ public function create(Request $request)
// Prepare form
$library = 0;
+
if ($request->get('machineName') && $request->get('majorVersion') && $request->get('minorVersion')) {
$library = $request->get('machineName') . ' ' . $request->get('majorVersion') . '.' . $request->get('minorVersion');
}
@@ -145,6 +146,7 @@ public function store(Request $request)
try {
if ($request->get('action') === 'create') {
$content['library'] = $core->libraryFromString($request->get('library'));
+
if (!$content['library']) {
throw new H5PException('Invalid library.');
}
@@ -161,6 +163,7 @@ public function store(Request $request)
$content['params'] = $request->get('parameters');
$params = json_decode($content['params']);
+
// $content['title'] = $params->metadata->title;
if ($params === NULL) {
@@ -169,7 +172,7 @@ public function store(Request $request)
$content['params'] = json_encode($params->params);
$content['metadata'] = $params->metadata;
-
+
// Trim title and check length
$trimmed_title = empty($content['metadata']->title) ? '' : trim($content['metadata']->title);
if ($trimmed_title === '') {
@@ -185,7 +188,7 @@ public function store(Request $request)
// Save new content
$content['id'] = $core->saveContent($content);
-
+
// for Brightcove Interactive Videos
if ($content['library']['machineName'] === 'H5P.BrightcoveInteractiveVideo') {
$brightCoveVideoData['brightcove_video_id'] = $params->params->interactiveVideo->video->brightcoveVideoID;
@@ -226,7 +229,7 @@ public function store(Request $request)
], 422);
}
}
-
+
if ($return_id) {
return response([
'success' => trans('laravel-h5p.content.created'),
@@ -499,6 +502,8 @@ public function update(Request $request, $id)
// Save new content
$core->saveContent($content);
+
+
// Move images and find all content dependencies
$editor->processParameters($content['id'], $content['library'], $params->params, $oldLibrary, $oldParams);
diff --git a/app/Http/Controllers/Api/V1/IndependentActivityController.php b/app/Http/Controllers/Api/V1/IndependentActivityController.php
index 6eb4cc816..293288498 100644
--- a/app/Http/Controllers/Api/V1/IndependentActivityController.php
+++ b/app/Http/Controllers/Api/V1/IndependentActivityController.php
@@ -32,6 +32,11 @@
use App\Jobs\ExportIndependentActivity;
use App\Jobs\ImportIndependentActivity;
use App\Http\Requests\V1\IndependentActivityUploadImportRequest;
+use Illuminate\Support\Facades\File;
+use ZipArchive;
+use RecursiveIteratorIterator;
+use RecursiveDirectoryIterator;
+use Djoudi\LaravelH5p\Eloquents\H5pContent;
/**
* @group 5. Independent Activity
@@ -644,265 +649,325 @@ public function h5p(IndependentActivity $independent_activity)
], 200);
}
- /**
- * Get H5P Resource Settings
- *
- * Get H5P Resource Settings for an independent activity
- *
- * @urlParam independent_activity required The Id of an independent activity Example: 1
- *
- * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
- *
- * @response 500 {
- * "errors": [
- * "Independent Activity doesn't belong to this user."
- * ]
- * }
- *
- * @param IndependentActivity $independent_activity
- * @return Response
- */
- public function getH5pResourceSettings(IndependentActivity $independent_activity)
- {
- $this->authorize('view', $independent_activity);
+ //download inpendent activity
+ public function h5pActivity(Request $request){
- if ($independent_activity->type === 'h5p') {
- $h5p = App::make('LaravelH5p');
- $core = $h5p::$core;
- $editor = $h5p::$h5peditor;
- $content = $h5p->load_content($independent_activity->h5p_content_id);
- }
+ $h5pcontent = H5pContent::find($request->id);
+ $independent_activity = $h5pcontent->independentActivity;
+ $this->authorize('view', $independent_activity);
+ $zip = new ZipArchive;
- return response([
- 'h5p' => $content,
- 'independent-activity' => new IndependentActivityResource($independent_activity)
- ], 200);
- }
-
- /**
- * Get H5P Resource Settings (Shared)
- *
- * Get H5P Resource Settings for a shared independent activity
- *
- * @urlParam independent_activity required The Id of an independent activity
- *
- * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
- *
- * @response 400 {
- * "errors": [
- * "Independent Activity not found."
- * ]
- * }
- *
- * @param IndependentActivity $independent_activity
- * @return Response
- */
- public function getH5pResourceSettingsShared(IndependentActivity $independent_activity)
- {
- // 3 is for indexing approved - see IndependentActivity Model @indexing property
- if ($independent_activity->shared || ($independent_activity->indexing === (int)config('constants.indexing-approved'))) {
$h5p = App::make('LaravelH5p');
$core = $h5p::$core;
- $settings = $h5p::get_editor();
+ $settings = $h5p::get_editor($content = null, 'preview');
$content = $h5p->load_content($independent_activity->h5p_content_id);
$content['disable'] = config('laravel-h5p.h5p_preview_flag');
$embed = $h5p->get_embed($content, $settings);
$embed_code = $embed['embed'];
$settings = $embed['settings'];
- $user_data = null;
+ $user = Auth::user();
+
+ // create event dispatch
+ event(new H5pEvent(
+ 'content',
+ NULL,
+ $content['id'],
+ $content['title'],
+ $content['library']['name'],
+ $content['library']['majorVersion'] . '.' . $content['library']['minorVersion']
+ ));
+ $user_data = $user->only(['id', 'name', 'email']);
$h5p_data = ['settings' => $settings, 'user' => $user_data, 'embed_code' => $embed_code];
+ $data[] = $h5p_data;
+ $data[] = $independent_activity;
+ Storage::disk('public')->put('/exports/'.$request->id.'/'.$request->id.'-h5p.json', json_encode($data));
+
+ $rootPath = storage_path('app/public/exports/'.$request->id);
+ $zipFileName = $request->id.'.zip';
+
+ $zip->open(storage_path('app/public/exports/'.$request->id.'.zip'), ZipArchive::CREATE );
+ $files = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($rootPath),
+ RecursiveIteratorIterator::LEAVES_ONLY
+ );
+
+ foreach ($files as $name => $file)
+ {
+ // Skip directories (they would be added automatically)
+ if (!$file->isDir())
+ {
+ // Get real and relative path for current file
+ $filePath = $file->getRealPath();
+ $relativePath = substr($filePath, strlen($rootPath) + 1);
+
+ // Add current file to archive
+ $zip->addFile($filePath, $relativePath);
+ }
+ }
+ $zip->close();
+ return url('storage/exports/'.$zipFileName);
+
+ }
+
+ /**
+ * Get H5P Resource Settings
+ *
+ * Get H5P Resource Settings for an independent activity
+ *
+ * @urlParam independent_activity required The Id of an independent activity Example: 1
+ *
+ * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
+ *
+ * @response 500 {
+ * "errors": [
+ * "Independent Activity doesn't belong to this user."
+ * ]
+ * }
+ *
+ * @param IndependentActivity $independent_activity
+ * @return Response
+ */
+ public function getH5pResourceSettings(IndependentActivity $independent_activity)
+ {
+ $this->authorize('view', $independent_activity);
+
+ if ($independent_activity->type === 'h5p') {
+ $h5p = App::make('LaravelH5p');
+ $core = $h5p::$core;
+ $editor = $h5p::$h5peditor;
+ $content = $h5p->load_content($independent_activity->h5p_content_id);
+ }
return response([
- 'h5p' => $h5p_data,
+ 'h5p' => $content,
'independent-activity' => new IndependentActivityResource($independent_activity)
], 200);
}
- return response([
- 'errors' => ['Independent Activity not found.']
- ], 400);
- }
-
- /**
- * @uses One time script to populate all missing order number
- */
- public function populateOrderNumber()
- {
- $this->activityRepository->populateOrderNumber();
- }
+ /**
+ * Get H5P Resource Settings (Shared)
+ *
+ * Get H5P Resource Settings for a shared independent activity
+ *
+ * @urlParam independent_activity required The Id of an independent activity
+ *
+ * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
+ *
+ * @response 400 {
+ * "errors": [
+ * "Independent Activity not found."
+ * ]
+ * }
+ *
+ * @param IndependentActivity $independent_activity
+ * @return Response
+ */
+ public function getH5pResourceSettingsShared(IndependentActivity $independent_activity)
+ {
+ // 3 is for indexing approved - see IndependentActivity Model @indexing property
+ if ($independent_activity->shared || ($independent_activity->indexing === (int)config('constants.indexing-approved'))) {
+ $h5p = App::make('LaravelH5p');
+ $core = $h5p::$core;
+ $settings = $h5p::get_editor();
+ $content = $h5p->load_content($independent_activity->h5p_content_id);
+ $content['disable'] = config('laravel-h5p.h5p_preview_flag');
+ $embed = $h5p->get_embed($content, $settings);
+ $embed_code = $embed['embed'];
+ $settings = $embed['settings'];
+ $user_data = null;
+ $h5p_data = ['settings' => $settings, 'user' => $user_data, 'embed_code' => $embed_code];
- /**
- * Get Independent Activity Search Preview
- *
- * Get the specified independent activity search preview.
- *
- * @urlParam suborganization required The Id of a suborganization Example: 1
- * @urlParam independent_activity required The Id of an independent activity Example: 1
- *
- * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
- *
- * @param Organization $suborganization
- * @param IndependentActivity $independent_activity
- * @return Response
- */
- public function searchPreview(Organization $suborganization, IndependentActivity $independent_activity)
- {
- $this->authorize('searchPreview', [$independent_activity, $suborganization]);
+ return response([
+ 'h5p' => $h5p_data,
+ 'independent-activity' => new IndependentActivityResource($independent_activity)
+ ], 200);
+ }
- $h5p = App::make('LaravelH5p');
- $core = $h5p::$core;
- $settings = $h5p::get_editor();
- $content = $h5p->load_content($independent_activity->h5p_content_id);
- $content['disable'] = config('laravel-h5p.h5p_preview_flag');
- $embed = $h5p->get_embed($content, $settings);
- $embed_code = $embed['embed'];
- $settings = $embed['settings'];
- $user_data = null;
- $h5p_data = ['settings' => $settings, 'user' => $user_data, 'embed_code' => $embed_code];
+ return response([
+ 'errors' => ['Independent Activity not found.']
+ ], 400);
+ }
- return response([
- 'h5p' => $h5p_data,
- 'activity' => new IndependentActivityResource($independent_activity),
- ], 200);
- }
+ /**
+ * @uses One time script to populate all missing order number
+ */
+ public function populateOrderNumber()
+ {
+ $this->activityRepository->populateOrderNumber();
+ }
- /**
- * Download XApi File
- *
- * This is an API for to download the XAPI zip for the attempted independent activity
- *
- * @urlParam independent_activity required id, title, slug of an independent_activity
- *
- * @return download file download for the independent activity XAPI zip download
- */
- public function getXAPIFileForIndepActivity(Request $request, IndependentActivity $independent_activity) {
- return Storage::download($this->lms->getXAPIFileForIndepActivity($independent_activity));
- }
+ /**
+ * Get Independent Activity Search Preview
+ *
+ * Get the specified independent activity search preview.
+ *
+ * @urlParam suborganization required The Id of a suborganization Example: 1
+ * @urlParam independent_activity required The Id of an independent activity Example: 1
+ *
+ * @responseFile responses/h5p/independent-h5p-resource-settings-open.json
+ *
+ * @param Organization $suborganization
+ * @param IndependentActivity $independent_activity
+ * @return Response
+ */
+ public function searchPreview(Organization $suborganization, IndependentActivity $independent_activity)
+ {
+ $this->authorize('searchPreview', [$independent_activity, $suborganization]);
- /**
- * Export Independent Activity
- *
- * Export the specified activity of a user.
- *
- * @urlParam suborganization required The Id of a suborganization Example: 1
- * @urlParam independent_activity required The Id of a independent_activity Example: 1
- *
- * @response {
- * "message": "Your request to export independent Activity [title] has been received and is being processed."
- * }
- *
- * @param Request $request
- * @param Organization $suborganization
- * @param IndependentActivity $independent_activity
- * @return Response
- */
- public function exportIndependentActivity(Request $request, Organization $suborganization, IndependentActivity $independent_activity)
- {
- $this->authorize('export', $independent_activity);
- // pushed cloning of activity in background
- ExportIndependentActivity::dispatch(auth()->user(), $independent_activity, $suborganization)->delay(now()->addSecond());
+ $h5p = App::make('LaravelH5p');
+ $core = $h5p::$core;
+ $settings = $h5p::get_editor();
+ $content = $h5p->load_content($independent_activity->h5p_content_id);
+ $content['disable'] = config('laravel-h5p.h5p_preview_flag');
+ $embed = $h5p->get_embed($content, $settings);
+ $embed_code = $embed['embed'];
+ $settings = $embed['settings'];
+ $user_data = null;
+ $h5p_data = ['settings' => $settings, 'user' => $user_data, 'embed_code' => $embed_code];
- return response([
- 'message' => "Your request to export independent Activity [$independent_activity->title] has been received and is being processed.
- You will be alerted in the notification section in the title bar when complete.",
- ], 200);
- }
+ return response([
+ 'h5p' => $h5p_data,
+ 'activity' => new IndependentActivityResource($independent_activity),
+ ], 200);
+ }
- /**
- * Import Independent Activity
- *
- * Import the specified independent activity of a user.
- *
- * @urlParam suborganization required The Id of a suborganization Example: 1
- * @param independent_activity
- * @response {
- * "message": "Your request to import independent activity has been received and is being processed."
- * }
- *
- * @return Response
- */
+ /**
+ * Download XApi File
+ *
+ * This is an API for to download the XAPI zip for the attempted independent activity
+ *
+ * @urlParam independent_activity required id, title, slug of an independent_activity
+ *
+ * @return download file download for the independent activity XAPI zip download
+ */
+ public function getXAPIFileForIndepActivity(Request $request, IndependentActivity $independent_activity) {
+ return Storage::download($this->lms->getXAPIFileForIndepActivity($independent_activity));
+ }
- public function importIndependentActivity(IndependentActivityUploadImportRequest $IndependentActivityUploadImportRequest, Organization $suborganization)
- {
- $this->authorize('import', [IndependentActivity::class, $suborganization]);
+ /**
+ * Export Independent Activity
+ *
+ * Export the specified activity of a user.
+ *
+ * @urlParam suborganization required The Id of a suborganization Example: 1
+ * @urlParam independent_activity required The Id of a independent_activity Example: 1
+ *
+ * @response {
+ * "message": "Your request to export independent Activity [title] has been received and is being processed."
+ * }
+ *
+ * @param Request $request
+ * @param Organization $suborganization
+ * @param IndependentActivity $independent_activity
+ * @return Response
+ */
+ public function exportIndependentActivity(Request $request, Organization $suborganization, IndependentActivity $independent_activity)
+ {
+ $this->authorize('export', $independent_activity);
+ // pushed cloning of activity in background
+ ExportIndependentActivity::dispatch(auth()->user(), $independent_activity, $suborganization)->delay(now()->addSecond());
- $IndependentActivityUploadImportRequest->validated();
- $path = $IndependentActivityUploadImportRequest->file('independent_activity')->store('public/imports');
+ return response([
+ 'message' => "Your request to export independent Activity [$independent_activity->title] has been received and is being processed.
+ You will be alerted in the notification section in the title bar when complete.",
+ ], 200);
+ }
- ImportIndependentActivity::dispatch(auth()->user(), Storage::url($path), $suborganization->id)->delay(now()->addSecond());
+ /**
+ * Import Independent Activity
+ *
+ * Import the specified independent activity of a user.
+ *
+ * @urlParam suborganization required The Id of a suborganization Example: 1
+ * @param independent_activity
+ * @response {
+ * "message": "Your request to import independent activity has been received and is being processed."
+ * }
+ *
+ * @return Response
+ */
+
+ public function importIndependentActivity(IndependentActivityUploadImportRequest $IndependentActivityUploadImportRequest, Organization $suborganization)
+ {
+ $this->authorize('import', [IndependentActivity::class, $suborganization]);
+
+ $IndependentActivityUploadImportRequest->validated();
+ $path = $IndependentActivityUploadImportRequest->file('independent_activity')->store('public/imports');
+
+ ImportIndependentActivity::dispatch(auth()->user(), Storage::url($path), $suborganization->id)->delay(now()->addSecond());
- return response([
- 'message' => "Your request to import independent activity has been received and is being processed.
- You will be alerted in the notification section in the title bar when complete.",
- ], 200);
- }
+ return response([
+ 'message' => "Your request to import independent activity has been received and is being processed.
+ You will be alerted in the notification section in the title bar when complete.",
+ ], 200);
+ }
- /**
- * Independent Activity Indexing
- *
- * Modify the index value of an independent activity.
- *
- * @urlParam independent_activity required The Id of a independent_activity Example: 1
- * @urlParam index required New Integer Index Value, 1 => 'REQUESTED', 2 => 'NOT APPROVED', 3 => 'APPROVED'. Example: 3
- *
- * @response {
- * "message": "Library status changed successfully!",
- * }
- *
- * @response 500 {
- * "errors": [
- * "Invalid index value provided."
- * ]
- * }
- *
- * @param IndependentActivity $independent_activity
- * @param $index
- * @return Application|ResponseFactory|Response
- * @throws GeneralException
- */
- public function updateIndex(IndependentActivity $independent_activity, $index)
- {
- return response(['message' => $this->independentActivityRepository->updateIndex($independent_activity, $index)], 200);
- }
+ /**
+ * Independent Activity Indexing
+ *
+ * Modify the index value of an independent activity.
+ *
+ * @urlParam independent_activity required The Id of a independent_activity Example: 1
+ * @urlParam index required New Integer Index Value, 1 => 'REQUESTED', 2 => 'NOT APPROVED', 3 => 'APPROVED'. Example: 3
+ *
+ * @response {
+ * "message": "Library status changed successfully!",
+ * }
+ *
+ * @response 500 {
+ * "errors": [
+ * "Invalid index value provided."
+ * ]
+ * }
+ *
+ * @param IndependentActivity $independent_activity
+ * @param $index
+ * @return Application|ResponseFactory|Response
+ * @throws GeneralException
+ */
+ public function updateIndex(IndependentActivity $independent_activity, $index)
+ {
+ return response(['message' => $this->independentActivityRepository->updateIndex($independent_activity, $index)], 200);
+ }
- /**
- * Copy Independent Activity into Playlist
- *
- * Clone the specified independent activity of an suborganization and link with a playlist.
- *
- * @urlParam suborganization required The Id of a suborganization Example: 1
- * @urlParam independent_activity required The Id of a independent activity Example: 1
- * @urlParam playlist required The Id of a playlist Example: 1
- *
- * @response {
- * "message": "Independent Activity is being copied in background!"
- * }
- *
- * @response 400 {
- * "errors": [
- * "Not a Public Independent Activity."
- * ]
- * }
- *
- * @response 500 {
- * "errors": [
- * "Failed to copy independent activity."
- * ]
- * }
- *
- * @param Request $request
- * @param Organization $suborganization
- * @param IndependentActivity $independent_activity
- * @param Playlist $playlist
- * @return Response
- */
- public function copyIndependentActivityIntoPlaylist(Request $request, Organization $suborganization, IndependentActivity $independent_activity, Playlist $playlist)
- {
- CopyIndependentActivityIntoPlaylist::dispatch($suborganization, $independent_activity, $playlist, $request->bearerToken())->delay(now()->addSecond());
+ /**
+ * Copy Independent Activity into Playlist
+ *
+ * Clone the specified independent activity of an suborganization and link with a playlist.
+ *
+ * @urlParam suborganization required The Id of a suborganization Example: 1
+ * @urlParam independent_activity required The Id of a independent activity Example: 1
+ * @urlParam playlist required The Id of a playlist Example: 1
+ *
+ * @response {
+ * "message": "Independent Activity is being copied in background!"
+ * }
+ *
+ * @response 400 {
+ * "errors": [
+ * "Not a Public Independent Activity."
+ * ]
+ * }
+ *
+ * @response 500 {
+ * "errors": [
+ * "Failed to copy independent activity."
+ * ]
+ * }
+ *
+ * @param Request $request
+ * @param Organization $suborganization
+ * @param IndependentActivity $independent_activity
+ * @param Playlist $playlist
+ * @return Response
+ */
+ public function copyIndependentActivityIntoPlaylist(Request $request, Organization $suborganization, IndependentActivity $independent_activity, Playlist $playlist)
+ {
+ CopyIndependentActivityIntoPlaylist::dispatch($suborganization, $independent_activity, $playlist, $request->bearerToken())->delay(now()->addSecond());
- return response([
- "message" => "Your request to add independent activity [$independent_activity->title] into playlist [$playlist->title] has been
- received and is being processed.
You will be alerted in the notification section in the title bar when complete.",
- ], 200);
+ return response([
+ "message" => "Your request to add independent activity [$independent_activity->title] into playlist [$playlist->title] has been
+ received and is being processed.
You will be alerted in the notification section in the title bar when complete.",
+ ], 200);
+ }
}
-}
diff --git a/database/migrations/2022_06_17_891806_add_mark_the_words_h5p_library.php b/database/migrations/2022_06_17_891806_add_mark_the_words_h5p_library.php
deleted file mode 100644
index f5e9ab075..000000000
--- a/database/migrations/2022_06_17_891806_add_mark_the_words_h5p_library.php
+++ /dev/null
@@ -1,29 +0,0 @@
- H5PAddMarkTheWordsLibrarySeeder::class,
- '--force' => true
- ]);
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- //
- }
-}
diff --git a/database/migrations/2022_06_20_095042_update_libraries_semantic.php b/database/migrations/2022_07_14_080831_change-behaviour-word.php
similarity index 81%
rename from database/migrations/2022_06_20_095042_update_libraries_semantic.php
rename to database/migrations/2022_07_14_080831_change-behaviour-word.php
index bfeb8cc1c..95c156812 100644
--- a/database/migrations/2022_06_20_095042_update_libraries_semantic.php
+++ b/database/migrations/2022_07_14_080831_change-behaviour-word.php
@@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-class UpdateLibrariesSemantic extends Migration
+class ChangeBehaviourWord extends Migration
{
/**
* Run the migrations.
@@ -15,7 +15,7 @@ public function up()
{
//
\Artisan::call('db:seed', [
- '--class' => UpdateLibrariesSemantics::class,
+ '--class' => changeBehaviourKeyword::class,
'--force' => true
]);
}
diff --git a/database/seeds/changeBehaviourKeyword.php b/database/seeds/changeBehaviourKeyword.php
new file mode 100644
index 000000000..bfd54dca8
--- /dev/null
+++ b/database/seeds/changeBehaviourKeyword.php
@@ -0,0 +1,1664 @@
+ "H5P.DragText", "major_version" =>1, "minor_version" => 8];
+ $h5pDragTextLib = DB::table('h5p_libraries')->where($h5pDragTextLibParams)->first();
+
+ if ($h5pDragTextLib) {
+ DB::table('h5p_libraries')->where($h5pDragTextLibParams)->update([
+ 'semantics' => $this->updatedDragTextSemantics(),
+ ]);
+ }
+
+ //H5P.DragQuestion-1.14
+ $h5pDragQuestionLibParams = ['name' => "H5P.DragQuestion", "major_version" =>1, "minor_version" => 14];
+ $h5pDragQuestionLib = DB::table('h5p_libraries')->where($h5pDragQuestionLibParams)->first();
+
+ if ($h5pDragQuestionLib) {
+ DB::table('h5p_libraries')->where($h5pDragQuestionLibParams)->update([
+ 'semantics' => $this->updatedDragQuestionSemantics(),
+ ]);
+ }
+
+ //H5P.AdvancedBlanks-1.0
+ $h5pAdvancedBlanksLibParams = ['name' => "H5P.AdvancedBlanks", "major_version" =>1, "minor_version" => 0];
+ $h5pAdvancedBlanksLib = DB::table('h5p_libraries')->where($h5pAdvancedBlanksLibParams)->first();
+
+ if ($h5pAdvancedBlanksLib) {
+ DB::table('h5p_libraries')->where($h5pAdvancedBlanksLibParams)->update([
+ 'semantics' => $this->updatedAdvancedBlanksSemantics(),
+ ]);
+ }
+ }
+
+ //H5P.DragText-1.8
+ private function updatedDragTextSemantics() {
+ return '[
+ {
+ "label": "Task description",
+ "importance": "high",
+ "name": "taskDescription",
+ "type": "text",
+ "widget": "html",
+ "description": "Describe how the user should solve the task.",
+ "default": "Drag the words into the correct boxes",
+ "enterMode": "p",
+ "tags": [
+ "strong",
+ "em",
+ "u",
+ "a",
+ "ul",
+ "ol",
+ "h2",
+ "h3",
+ "hr",
+ "pre",
+ "code"
+ ]
+ },
+ {
+ "label": "Text",
+ "importance": "high",
+ "name": "textField",
+ "type": "text",
+ "widget": "textarea",
+ "placeholder": "*Oslo* is the capital of Norway, *Stockholm* is the capital of Sweden and *Copenhagen* is the capital of Denmark. All cities are located in the *Scandinavian:Northern Part of Europe* peninsula.",
+ "description": "",
+ "important": {
+ "description": "