Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion H5P/laravel-h5p/src/LaravelH5p/Eloquents/H5pContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;;
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/Api/V1/H5pController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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.');
}
Expand All @@ -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) {
Expand All @@ -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 === '') {
Expand All @@ -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;
Expand Down Expand Up @@ -226,7 +229,7 @@ public function store(Request $request)
], 422);
}
}

if ($return_id) {
return response([
'success' => trans('laravel-h5p.content.created'),
Expand Down Expand Up @@ -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);

Expand Down
Loading