diff --git a/plugins/tps/tps/controllers/Test.php b/plugins/tps/tps/controllers/Test.php new file mode 100644 index 000000000..dbfc37e20 --- /dev/null +++ b/plugins/tps/tps/controllers/Test.php @@ -0,0 +1,18 @@ +where('test_id', $id)->get()->shuffle(); + + return $questions; + } +} diff --git a/plugins/tps/tps/controllers/test/_list_toolbar.htm b/plugins/tps/tps/controllers/test/_list_toolbar.htm new file mode 100644 index 000000000..b091f79c1 --- /dev/null +++ b/plugins/tps/tps/controllers/test/_list_toolbar.htm @@ -0,0 +1,18 @@ +
+ + +
diff --git a/plugins/tps/tps/controllers/test/config_form.yaml b/plugins/tps/tps/controllers/test/config_form.yaml new file mode 100644 index 000000000..eec82c1c1 --- /dev/null +++ b/plugins/tps/tps/controllers/test/config_form.yaml @@ -0,0 +1,10 @@ +name: Test +form: $/tps/tps/models/test/fields.yaml +modelClass: Tps\Tps\Models\Test +defaultRedirect: tps/tps/test +create: + redirect: 'tps/tps/test/update/:id' + redirectClose: tps/tps/test +update: + redirect: tps/tps/test + redirectClose: tps/tps/test diff --git a/plugins/tps/tps/controllers/test/config_list.yaml b/plugins/tps/tps/controllers/test/config_list.yaml new file mode 100644 index 000000000..db13e4603 --- /dev/null +++ b/plugins/tps/tps/controllers/test/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/tps/models/test/columns.yaml +modelClass: Tps\Tps\Models\Test +title: Test +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/tps/test/update/:id' diff --git a/plugins/tps/tps/controllers/test/create.htm b/plugins/tps/tps/controllers/test/create.htm new file mode 100644 index 000000000..a879d3747 --- /dev/null +++ b/plugins/tps/tps/controllers/test/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/controllers/test/index.htm b/plugins/tps/tps/controllers/test/index.htm new file mode 100644 index 000000000..ea43a3636 --- /dev/null +++ b/plugins/tps/tps/controllers/test/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/tps/tps/controllers/test/preview.htm b/plugins/tps/tps/controllers/test/preview.htm new file mode 100644 index 000000000..91fbcc69f --- /dev/null +++ b/plugins/tps/tps/controllers/test/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/tps/controllers/test/update.htm b/plugins/tps/tps/controllers/test/update.htm new file mode 100644 index 000000000..55625e95e --- /dev/null +++ b/plugins/tps/tps/controllers/test/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/controllers/testquestion/_list_toolbar.htm b/plugins/tps/tps/controllers/testquestion/_list_toolbar.htm new file mode 100644 index 000000000..eb9223de3 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/_list_toolbar.htm @@ -0,0 +1,18 @@ +
+ + +
diff --git a/plugins/tps/tps/controllers/testquestion/config_form.yaml b/plugins/tps/tps/controllers/testquestion/config_form.yaml new file mode 100644 index 000000000..01f6ea428 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/config_form.yaml @@ -0,0 +1,10 @@ +name: TestQuestion +form: $/tps/tps/models/testquestion/fields.yaml +modelClass: Tps\Tps\Models\TestQuestion +defaultRedirect: tps/tps/testquestion +create: + redirect: 'tps/tps/testquestion/update/:id' + redirectClose: tps/tps/testquestion +update: + redirect: tps/tps/testquestion + redirectClose: tps/tps/testquestion diff --git a/plugins/tps/tps/controllers/testquestion/config_list.yaml b/plugins/tps/tps/controllers/testquestion/config_list.yaml new file mode 100644 index 000000000..67657e1f4 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/tps/models/testquestion/columns.yaml +modelClass: Tps\Tps\Models\TestQuestion +title: TestQuestion +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/tps/testquestion/update/:id' diff --git a/plugins/tps/tps/controllers/testquestion/create.htm b/plugins/tps/tps/controllers/testquestion/create.htm new file mode 100644 index 000000000..0c661d30c --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/controllers/testquestion/index.htm b/plugins/tps/tps/controllers/testquestion/index.htm new file mode 100644 index 000000000..ea43a3636 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/tps/tps/controllers/testquestion/preview.htm b/plugins/tps/tps/controllers/testquestion/preview.htm new file mode 100644 index 000000000..ad5de6346 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/tps/controllers/testquestion/update.htm b/plugins/tps/tps/controllers/testquestion/update.htm new file mode 100644 index 000000000..9fb5cbfd4 --- /dev/null +++ b/plugins/tps/tps/controllers/testquestion/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/models/Test.php b/plugins/tps/tps/models/Test.php new file mode 100644 index 000000000..fb3851ac9 --- /dev/null +++ b/plugins/tps/tps/models/Test.php @@ -0,0 +1,43 @@ + 'System\Models\File' + ]; + + public $hasMany = [ + 'questions' => [ + 'Tps\Tps\Models\TestQuestion' + ], + ]; +} diff --git a/plugins/tps/tps/models/TestQuestion.php b/plugins/tps/tps/models/TestQuestion.php new file mode 100644 index 000000000..111a59ad8 --- /dev/null +++ b/plugins/tps/tps/models/TestQuestion.php @@ -0,0 +1,46 @@ + 'array' + ]; + + public $implement = ['RainLab.Translate.Behaviors.TranslatableModel']; + + public $translatable = ['question', 'description']; + + public $attachOne = [ + 'image' => 'System\Models\File' + ]; + + public $belongsTo = [ + 'test' => ['Tps\Tps\Models\Test'], + ]; + +} diff --git a/plugins/tps/tps/models/test/columns.yaml b/plugins/tps/tps/models/test/columns.yaml new file mode 100644 index 000000000..e1db804ab --- /dev/null +++ b/plugins/tps/tps/models/test/columns.yaml @@ -0,0 +1,10 @@ +columns: + id: + label: id + type: number + title: + label: title + type: text + description: + label: description + type: text diff --git a/plugins/tps/tps/models/test/fields.yaml b/plugins/tps/tps/models/test/fields.yaml new file mode 100644 index 000000000..238e06c5a --- /dev/null +++ b/plugins/tps/tps/models/test/fields.yaml @@ -0,0 +1,19 @@ +fields: + title: + label: Title + span: auto + type: text + description: + label: Description + span: auto + size: '' + type: textarea + image: + label: Image + mode: image + useCaption: true + thumbOptions: + mode: crop + extension: auto + span: auto + type: fileupload diff --git a/plugins/tps/tps/models/testquestion/columns.yaml b/plugins/tps/tps/models/testquestion/columns.yaml new file mode 100644 index 000000000..84326dc8c --- /dev/null +++ b/plugins/tps/tps/models/testquestion/columns.yaml @@ -0,0 +1,10 @@ +columns: + id: + label: id + type: number + test_id: + label: test + type: number + question: + label: question + type: text diff --git a/plugins/tps/tps/models/testquestion/fields.yaml b/plugins/tps/tps/models/testquestion/fields.yaml new file mode 100644 index 000000000..25dcbf289 --- /dev/null +++ b/plugins/tps/tps/models/testquestion/fields.yaml @@ -0,0 +1,50 @@ +fields: + test: + label: Test + nameFrom: title + descriptionFrom: description + span: auto + type: relation + question: + label: Question + size: '' + span: auto + type: textarea + description: + label: Description + size: '' + span: auto + type: textarea + image: + label: Image + mode: image + useCaption: true + thumbOptions: + mode: crop + extension: auto + span: auto + type: fileupload + answers: + label: Answers + prompt: 'Add new question' + style: default + span: auto + type: repeater + form: + fields: + title_tm: + label: 'Title Tm' + span: auto + type: text + title_ru: + label: 'Title Ru' + span: auto + type: text + title_en: + label: 'Title En' + span: auto + type: text + correct: + label: Correct + span: auto + type: checkbox diff --git a/plugins/tps/tps/plugin.yaml b/plugins/tps/tps/plugin.yaml index cc4845d28..7754c541a 100644 --- a/plugins/tps/tps/plugin.yaml +++ b/plugins/tps/tps/plugin.yaml @@ -22,6 +22,14 @@ navigation: label: 'Media View' url: tps/tps/mediaview icon: icon-signal + side-menu-item3: + label: Tests + url: tps/tps/test + icon: icon-sitemap + side-menu-item4: + label: 'Test questions' + url: tps/tps/testquestion + icon: icon-question permissions: media.media: tab: Media diff --git a/plugins/tps/tps/routes.php b/plugins/tps/tps/routes.php new file mode 100644 index 000000000..91249c1fb --- /dev/null +++ b/plugins/tps/tps/routes.php @@ -0,0 +1,7 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('title'); + $table->text('description'); + }); + } + + public function down() + { + Schema::dropIfExists('tps_tps_test_categories'); + } +} diff --git a/plugins/tps/tps/updates/builder_table_create_tps_tps_test_questions.php b/plugins/tps/tps/updates/builder_table_create_tps_tps_test_questions.php new file mode 100644 index 000000000..6bbe3a880 --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_create_tps_tps_test_questions.php @@ -0,0 +1,23 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('title'); + $table->text('description')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('tps_tps_test_questions'); + } +} diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_test_questions.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_test_questions.php new file mode 100644 index 000000000..40b74d9ea --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_test_questions.php @@ -0,0 +1,29 @@ +integer('test_id'); + $table->string('question'); + $table->text('answers'); + $table->dropColumn('title'); + }); + } + + public function down() + { + Schema::table('tps_tps_test_questions', function($table) + { + $table->dropColumn('test_id'); + $table->dropColumn('question'); + $table->dropColumn('answers'); + $table->string('title', 191); + }); + } +} diff --git a/plugins/tps/tps/updates/builder_table_update_tps_tps_tests.php b/plugins/tps/tps/updates/builder_table_update_tps_tps_tests.php new file mode 100644 index 000000000..56c290f0f --- /dev/null +++ b/plugins/tps/tps/updates/builder_table_update_tps_tps_tests.php @@ -0,0 +1,17 @@ +where('test_id', $this->param('id'))->get()->shuffle(); + $this['test_id'] = $this->param('id'); +} + +?> +== + + +
+
+
+ + +
+
+
+
+

+ {{questions.first.test.title}} +

+
+ +
+

+ +
+ +
+
+ +

+ +
+ + {{'test.next'|_}} + +
+ +
+
+
+
+ + +
+
+
+
+ + + \ No newline at end of file diff --git a/themes/modern2/pages/test.htm b/themes/modern2/pages/test.htm index 286b27dee..1d2260b2a 100644 --- a/themes/modern2/pages/test.htm +++ b/themes/modern2/pages/test.htm @@ -1,8 +1,89 @@ -title = "test" -url = "/test" -layout = "new/master" +title = "Test" +url = "/test/:id" +layout = "new/master-inside" is_hidden = 0 robot_index = "index" robot_follow = "follow" == -{% partial 'newHome/main-popular' %} \ No newline at end of file +param('id'))->get()->first(); +} +?> +== + + +
+
+
+ + +
+
+
+
+

+ {{ test.title }} +

+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+

+ {{ test.description }} +

+ +
+ + {{'test.start_test'|_}} + +
+
+
+
+ + +
+
+
+
+ \ No newline at end of file diff --git a/themes/modern2/pages/tests.htm b/themes/modern2/pages/tests.htm new file mode 100644 index 000000000..e5ca75c75 --- /dev/null +++ b/themes/modern2/pages/tests.htm @@ -0,0 +1,50 @@ +title = "tests2" +url = "/tests2" +layout = "new/master-inside" +is_hidden = 0 +robot_index = "index" +robot_follow = "follow" +== + +
+
+
+ +
+
+
+ {% for item in tests %} + +
+ +
+
+

+ {{item.title}} +

+
+
+ {% endfor %} +
+
+ +
+
+
+
+ \ No newline at end of file