Skip to content

Commit 0aff248

Browse files
authored
CUR-4122 column layout upgrade (#1319)
* [CUR-4122] Added seeder and migration * Upgraded Guess the answer,Question Set and Essay and Column layout
1 parent cae5ba9 commit 0aff248

8 files changed

+1977
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
5+
class AddGuessTheAnswer extends Migration
6+
{
7+
/**
8+
* Run the migrations.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
\Artisan::call('db:seed', [
15+
'--class' => AddGuessTheAnswerSemanticsSeeder::class,
16+
'--force' => true
17+
]);
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
//
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
5+
class AddQuestionSetOneTwenty extends Migration
6+
{
7+
/**
8+
* Run the migrations.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
\Artisan::call('db:seed', [
15+
'--class' => AddQuestionSetOneTwentySemanticsSeeder::class,
16+
'--force' => true
17+
]);
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
//
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
5+
class AddEssayFifteenSemantics extends Migration
6+
{
7+
/**
8+
* Run the migrations.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
\Artisan::call('db:seed', [
15+
'--class' => AddEssayFifteenSemanticsSeeder::class,
16+
'--force' => true
17+
]);
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*
23+
* @return void
24+
*/
25+
public function down()
26+
{
27+
//
28+
}
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class AddColumnLayoutSemantics extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
\Artisan::call('db:seed', [
17+
'--class' => AddColumnLayoutSemanticsSeeder::class,
18+
'--force' => true
19+
]);
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
//
30+
}
31+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<?php
2+
3+
use Illuminate\Database\Seeder;
4+
5+
class AddColumnLayoutSemanticsSeeder extends Seeder
6+
{
7+
/**
8+
* Run the database seeds.
9+
*
10+
* @return void
11+
*/
12+
public function run()
13+
{
14+
$h5pFibLibParams = ['name' => "H5P.Column", "major_version" => 1, "minor_version" => 15];
15+
$h5pFibLib = DB::table('h5p_libraries')->where($h5pFibLibParams)->first();
16+
17+
if (empty($h5pFibLib)) {
18+
$h5pFibLibId = DB::table('h5p_libraries')->insertGetId([
19+
'name' => 'H5P.Column',
20+
'title' => 'Column',
21+
'major_version' => 1,
22+
'minor_version' => 15,
23+
'patch_version' => 2,
24+
'embed_types' => 'iframe',
25+
'runnable' => 1,
26+
'restricted' => 0,
27+
'fullscreen' => 0,
28+
'preloaded_js' => 'scripts/h5p-column.js',
29+
'preloaded_css' => 'styles/h5p-column.css,styles/custom-column-layout.css',
30+
'drop_library_css' => '',
31+
'semantics' => $this->getSemantics(),
32+
'tutorial_url' => ' ',
33+
'has_icon' => 1
34+
]);
35+
// insert libraries languages
36+
$this->insertLibrariesLanguages($h5pFibLibId);
37+
}
38+
}
39+
40+
/**
41+
* Insert Library Language Semantics
42+
* @param $h5pFibLibId
43+
*/
44+
private function insertLibrariesLanguages($h5pFibLibId)
45+
{
46+
// en.json
47+
DB::table('h5p_libraries_languages')->insert([
48+
'library_id' => $h5pFibLibId,
49+
'language_code' => 'en',
50+
'translation' => json_encode(json_decode('{
51+
"semantics": [
52+
{
53+
"label": "List of Column Content",
54+
"entity": "content",
55+
"field": {
56+
"fields": [
57+
{
58+
"label": "Content"
59+
},
60+
{
61+
"label": "Separate content with a horizontal ruler",
62+
"options": [
63+
{
64+
"label": "Automatic (default)"
65+
},
66+
{
67+
"label": "Never use ruler above"
68+
},
69+
{
70+
"label": "Always use ruler above"
71+
}
72+
]
73+
}
74+
]
75+
}
76+
}
77+
]
78+
}
79+
'), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE)
80+
]);
81+
}
82+
83+
private function getSemantics() {
84+
return '[
85+
{
86+
"name": "content",
87+
"label": "List of Column Content",
88+
"importance": "high",
89+
"type": "list",
90+
"min": 1,
91+
"entity": "content",
92+
"field": {
93+
"name": "content",
94+
"type": "group",
95+
"fields": [
96+
{
97+
"name": "content",
98+
"type": "library",
99+
"importance": "high",
100+
"label": "Content",
101+
"options": [
102+
"H5P.Accordion 1.0",
103+
"H5P.Agamotto 1.5",
104+
"H5P.Audio 1.5",
105+
"H5P.AudioRecorder 1.0",
106+
"H5P.Blanks 1.14",
107+
"H5P.Chart 1.2",
108+
"H5P.Collage 0.3",
109+
"H5P.CoursePresentation 1.24",
110+
"H5P.Dialogcards 1.9",
111+
"H5P.DocumentationTool 1.8",
112+
"H5P.DragQuestion 1.14",
113+
"H5P.DragText 1.10",
114+
"H5P.Essay 1.5",
115+
"H5P.GuessTheAnswer 1.5",
116+
"H5P.Table 1.1",
117+
"H5P.AdvancedText 1.1",
118+
"H5P.IFrameEmbed 1.0",
119+
"H5P.Image 1.1",
120+
"H5P.ImageHotspots 1.10",
121+
"H5P.ImageHotspotQuestion 1.8",
122+
"H5P.ImageSlider 1.1",
123+
"H5P.InteractiveVideo 1.24",
124+
"H5P.Link 1.3",
125+
"H5P.MarkTheWords 1.11",
126+
"H5P.MemoryGame 1.3",
127+
"H5P.MultiChoice 1.16",
128+
"H5P.Questionnaire 1.3",
129+
"H5P.QuestionSet 1.20",
130+
"H5P.SingleChoiceSet 1.11",
131+
"H5P.Summary 1.10",
132+
"H5P.Timeline 1.1",
133+
"H5P.TrueFalse 1.8",
134+
"H5P.Video 1.6"
135+
]
136+
},
137+
{
138+
"name": "useSeparator",
139+
"type": "select",
140+
"importance": "low",
141+
"label": "Separate content with a horizontal ruler",
142+
"default": "auto",
143+
"options": [
144+
{
145+
"value": "auto",
146+
"label": "Automatic (default)"
147+
},
148+
{
149+
"value": "disabled",
150+
"label": "Never use ruler above"
151+
},
152+
{
153+
"value": "enabled",
154+
"label": "Always use ruler above"
155+
}
156+
]
157+
}
158+
]
159+
}
160+
}
161+
]';
162+
}
163+
}

0 commit comments

Comments
 (0)