test
This commit is contained in:
parent
7a79a6365b
commit
8563bafa3e
|
|
@ -0,0 +1,18 @@
|
|||
<?php namespace Tps\Tps\Controllers;
|
||||
|
||||
use Backend\Classes\Controller;
|
||||
use BackendMenu;
|
||||
|
||||
class Test extends Controller
|
||||
{
|
||||
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController' ];
|
||||
|
||||
public $listConfig = 'config_list.yaml';
|
||||
public $formConfig = 'config_form.yaml';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
BackendMenu::setContext('Tps.Tps', 'main-menu-item', 'side-menu-item3');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Tps\Tps\Controllers;
|
||||
|
||||
use Backend\Classes\Controller;
|
||||
use BackendMenu;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use RainLab\Translate\Classes\Translator;
|
||||
use Tps\Tps\Models\TestQuestion as ModelsTestQuestion;
|
||||
|
||||
class TestQuestion extends Controller
|
||||
{
|
||||
public $implement = ['Backend\Behaviors\ListController', 'Backend\Behaviors\FormController'];
|
||||
|
||||
public $listConfig = 'config_list.yaml';
|
||||
public $formConfig = 'config_form.yaml';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
BackendMenu::setContext('Tps.Tps', 'main-menu-item', 'side-menu-item4');
|
||||
}
|
||||
|
||||
public function getQuestions($locale, $id)
|
||||
{
|
||||
$questions = ModelsTestQuestion::with('image')->where('test_id', $id)->get()->shuffle();
|
||||
|
||||
return $questions;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<div data-control="toolbar">
|
||||
<a href="<?= Backend::url('tps/tps/test/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
|
||||
<button
|
||||
class="btn btn-default oc-icon-trash-o"
|
||||
disabled="disabled"
|
||||
onclick="$(this).data('request-data', {
|
||||
checked: $('.control-list').listWidget('getChecked')
|
||||
})"
|
||||
data-request="onDelete"
|
||||
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
|
||||
data-trigger-action="enable"
|
||||
data-trigger=".control-list input[type=checkbox]"
|
||||
data-trigger-condition="checked"
|
||||
data-request-success="$(this).prop('disabled', true)"
|
||||
data-stripe-load-indicator>
|
||||
<?= e(trans('backend::lang.list.delete_selected')) ?>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -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
|
||||
|
|
@ -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'
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/test') ?>">Test</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.create')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.create_and_close')) ?>
|
||||
</button>
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/tps/test') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/tps/test') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<?= $this->listRender() ?>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/test') ?>">Test</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<div class="form-preview">
|
||||
<?= $this->formRenderPreview() ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<p>
|
||||
<a href="<?= Backend::url('tps/tps/test') ?>" class="btn btn-default oc-icon-chevron-left">
|
||||
<?= e(trans('backend::lang.form.return_to_list')) ?>
|
||||
</a>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/test') ?>">Test</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-request-data="redirect:0"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.save')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.save_and_close')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="oc-icon-trash-o btn-icon danger pull-right"
|
||||
data-request="onDelete"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
|
||||
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
|
||||
</button>
|
||||
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/tps/test') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/tps/test') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<div data-control="toolbar">
|
||||
<a href="<?= Backend::url('tps/tps/testquestion/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
|
||||
<button
|
||||
class="btn btn-default oc-icon-trash-o"
|
||||
disabled="disabled"
|
||||
onclick="$(this).data('request-data', {
|
||||
checked: $('.control-list').listWidget('getChecked')
|
||||
})"
|
||||
data-request="onDelete"
|
||||
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
|
||||
data-trigger-action="enable"
|
||||
data-trigger=".control-list input[type=checkbox]"
|
||||
data-trigger-condition="checked"
|
||||
data-request-success="$(this).prop('disabled', true)"
|
||||
data-stripe-load-indicator>
|
||||
<?= e(trans('backend::lang.list.delete_selected')) ?>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -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
|
||||
|
|
@ -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'
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/testquestion') ?>">TestQuestion</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.create')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.create_and_close')) ?>
|
||||
</button>
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/tps/testquestion') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/tps/testquestion') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<?= $this->listRender() ?>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/testquestion') ?>">TestQuestion</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<div class="form-preview">
|
||||
<?= $this->formRenderPreview() ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<p>
|
||||
<a href="<?= Backend::url('tps/tps/testquestion') ?>" class="btn btn-default oc-icon-chevron-left">
|
||||
<?= e(trans('backend::lang.form.return_to_list')) ?>
|
||||
</a>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/tps/testquestion') ?>">TestQuestion</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-request-data="redirect:0"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.save')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.save_and_close')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="oc-icon-trash-o btn-icon danger pull-right"
|
||||
data-request="onDelete"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
|
||||
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
|
||||
</button>
|
||||
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/tps/testquestion') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/tps/testquestion') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php namespace Tps\Tps\Models;
|
||||
|
||||
use Model;
|
||||
|
||||
/**
|
||||
* Model
|
||||
*/
|
||||
class Test extends Model
|
||||
{
|
||||
use \October\Rain\Database\Traits\Validation;
|
||||
|
||||
/*
|
||||
* Disable timestamps by default.
|
||||
* Remove this line if timestamps are defined in the database table.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
/**
|
||||
* @var string The database table used by the model.
|
||||
*/
|
||||
public $table = 'tps_tps_tests';
|
||||
|
||||
/**
|
||||
* @var array Validation rules
|
||||
*/
|
||||
public $rules = [
|
||||
];
|
||||
|
||||
public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
|
||||
|
||||
public $translatable = ['title', 'description'];
|
||||
|
||||
public $attachOne = [
|
||||
'image' => 'System\Models\File'
|
||||
];
|
||||
|
||||
public $hasMany = [
|
||||
'questions' => [
|
||||
'Tps\Tps\Models\TestQuestion'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php namespace Tps\Tps\Models;
|
||||
|
||||
use Model;
|
||||
|
||||
/**
|
||||
* Model
|
||||
*/
|
||||
class TestQuestion extends Model
|
||||
{
|
||||
use \October\Rain\Database\Traits\Validation;
|
||||
|
||||
/*
|
||||
* Disable timestamps by default.
|
||||
* Remove this line if timestamps are defined in the database table.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
/**
|
||||
* @var string The database table used by the model.
|
||||
*/
|
||||
public $table = 'tps_tps_test_questions';
|
||||
|
||||
/**
|
||||
* @var array Validation rules
|
||||
*/
|
||||
public $rules = [
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'answers' => 'array'
|
||||
];
|
||||
|
||||
public $implement = ['RainLab.Translate.Behaviors.TranslatableModel'];
|
||||
|
||||
public $translatable = ['question', 'description'];
|
||||
|
||||
public $attachOne = [
|
||||
'image' => 'System\Models\File'
|
||||
];
|
||||
|
||||
public $belongsTo = [
|
||||
'test' => ['Tps\Tps\Models\Test'],
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
columns:
|
||||
id:
|
||||
label: id
|
||||
type: number
|
||||
title:
|
||||
label: title
|
||||
type: text
|
||||
description:
|
||||
label: description
|
||||
type: text
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
columns:
|
||||
id:
|
||||
label: id
|
||||
type: number
|
||||
test_id:
|
||||
label: test
|
||||
type: number
|
||||
question:
|
||||
label: question
|
||||
type: text
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Tps\Tps\Controllers\TestQuestion;
|
||||
|
||||
|
||||
// Custom Routes
|
||||
Route::get('{locale}/test/questions/{id}', 'Tps\Tps\Controllers\TestQuestion@getQuestions');
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace Tps\Tps\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableCreateTpsTpsTestCategories extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tps_tps_test_categories', function($table)
|
||||
{
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id')->unsigned();
|
||||
$table->string('title');
|
||||
$table->text('description');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tps_tps_test_categories');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace Tps\Tps\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableCreateTpsTpsTestQuestions extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tps_tps_test_questions', function($table)
|
||||
{
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id')->unsigned();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tps_tps_test_questions');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php namespace Tps\Tps\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableUpdateTpsTpsTestQuestions extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('tps_tps_test_questions', function($table)
|
||||
{
|
||||
$table->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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php namespace Tps\Tps\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableUpdateTpsTpsTests extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::rename('tps_tps_test_categories', 'tps_tps_tests');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::rename('tps_tps_tests', 'tps_tps_test_categories');
|
||||
}
|
||||
}
|
||||
|
|
@ -237,10 +237,6 @@ const videoSwiper = new Swiper(".videoSwiper", {
|
|||
slidesPerView: 3,
|
||||
spaceBetween: 60,
|
||||
lazyLoading: true,
|
||||
autoplay: {
|
||||
delay: 5000,
|
||||
disableOnInteraction: false,
|
||||
},
|
||||
navigation: {
|
||||
prevEl: ".video-prev",
|
||||
nextEl: ".video-next",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
padding-top: 30px;
|
||||
}
|
||||
|
||||
|
||||
.article {
|
||||
&_desc {
|
||||
&-title {
|
||||
|
|
@ -49,21 +48,27 @@
|
|||
// justify-content: ;
|
||||
margin-top: 40px;
|
||||
|
||||
&.color-gr {
|
||||
a {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
line-height: 1.4;
|
||||
border: 1px solid transparent;
|
||||
background: #00822C;
|
||||
background: #00822c;
|
||||
color: #fff;
|
||||
display: block;
|
||||
padding: 8px 30px;
|
||||
transition: .2s linear;
|
||||
transition: 0.2s linear;
|
||||
|
||||
&:hover {
|
||||
background: transparent;
|
||||
border-color: #00822C;
|
||||
color: #00822C;
|
||||
border-color: #00822c;
|
||||
color: #00822c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +76,7 @@
|
|||
&-test {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
align-items: stretch;
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
|
|
@ -83,7 +88,7 @@
|
|||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
|
||||
width: 200px;
|
||||
max-width: 300px;
|
||||
padding: 5px 14px;
|
||||
margin-bottom: 12px;
|
||||
color: #00822c;
|
||||
|
|
@ -164,10 +169,10 @@
|
|||
}
|
||||
|
||||
.article-item {
|
||||
@include imgStyle($objFit: cover);
|
||||
@include imgStyle($objFit: contain);
|
||||
@include flex;
|
||||
align-items: flex-start;
|
||||
height: 40rem;
|
||||
height: 55rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
|
@ -235,6 +240,7 @@
|
|||
}
|
||||
|
||||
.article-bottom-head {
|
||||
|
||||
h4,
|
||||
span {
|
||||
color: $base-black;
|
||||
|
|
@ -280,11 +286,9 @@
|
|||
width: 100%;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +336,7 @@
|
|||
&-wrapper {
|
||||
width: calc(50% - 2.4rem);
|
||||
|
||||
&:nth-of-type(n+3) {
|
||||
&:nth-of-type(n + 3) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -342,8 +346,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 700px) {
|
||||
|
||||
// .article-swiper-wrapper-lower {
|
||||
// display: none;
|
||||
// }
|
||||
|
|
@ -378,7 +382,6 @@
|
|||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
|
||||
.article-aside {
|
||||
&.test-aside {
|
||||
margin-top: 50px;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
img {
|
||||
@include stretch;
|
||||
height: 24rem;
|
||||
height: 32rem;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,215 @@
|
|||
title = "Test start"
|
||||
url = "/test/start/:id"
|
||||
layout = "new/master-inside"
|
||||
is_hidden = 0
|
||||
robot_index = "index"
|
||||
robot_follow = "follow"
|
||||
==
|
||||
|
||||
<?php
|
||||
function onStart(){
|
||||
$this['questions'] = Tps\Tps\Models\TestQuestion::with('image')->where('test_id', $this->param('id'))->get()->shuffle();
|
||||
$this['test_id'] = $this->param('id');
|
||||
}
|
||||
|
||||
?>
|
||||
==
|
||||
|
||||
<!-- Test ================================== -->
|
||||
<main class="article">
|
||||
<div class="container">
|
||||
<div class="article-wrap">
|
||||
<div class="trending-head affiche-head">
|
||||
<h2>{{'test.tests'|_}}</h2>
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
<div class="article-inner">
|
||||
<div class="article-content">
|
||||
<div class="article-content-top">
|
||||
<div class="article-head">
|
||||
<h2>
|
||||
{{questions.first.test.title}}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="article-desc" id="question_container">
|
||||
<h4 class="article_desc-title" id="question_title"></h4>
|
||||
|
||||
<div class="article-test" id="question_answer"></div>
|
||||
|
||||
<div class="article-hint" id="description">
|
||||
<div class="article_desc-photo" id="question_description_image"></div>
|
||||
|
||||
<p id="question_description_text"></p>
|
||||
|
||||
<div class="article_btn color-gr">
|
||||
<a id="question_next_btn" onclick="openNewQuestion()">
|
||||
{{'test.next'|_}}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="aside article-aside test-aside">
|
||||
<h6 class="aside-ad-wrapper-title">
|
||||
{{'test.see_also'|_}}
|
||||
</h6>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/affiche.jpg" alt="" />
|
||||
</a>
|
||||
<p class="aside-ad-wrapper-txt">
|
||||
В Минфине обсудили разработку стратегии АБР для Туркменистана с новым страновым
|
||||
директором
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/affiche.jpg" alt="" />
|
||||
</a>
|
||||
<p class="aside-ad-wrapper-txt">
|
||||
В Минфине обсудили разработку стратегии АБР для Туркменистана с новым страновым
|
||||
директором
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/affiche.jpg" alt="" />
|
||||
</a>
|
||||
<p class="aside-ad-wrapper-txt">
|
||||
В Минфине обсудили разработку стратегии АБР для Туркменистана с новым страновым
|
||||
директором
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- Test end ============================== -->
|
||||
|
||||
<script>
|
||||
|
||||
let locale = '{{ activeLocale }}';
|
||||
let test_id = '{{ test_id }}';
|
||||
|
||||
let questions;
|
||||
let step = 1;
|
||||
|
||||
let correct_answers = 0;
|
||||
function getQuestions() {
|
||||
let request = new XMLHttpRequest();
|
||||
let url = `${location.protocol + '//' + location.host}/${locale}/test/questions/${test_id}`
|
||||
request.open('GET', url);
|
||||
request.send();
|
||||
|
||||
request.onload = async function () {
|
||||
questions = JSON.parse(this.response);
|
||||
|
||||
startNewQuestion();
|
||||
}
|
||||
}
|
||||
|
||||
function openNewQuestion(){
|
||||
if(step <= questions.length){
|
||||
startNewQuestion();
|
||||
}else{
|
||||
showResults();
|
||||
}
|
||||
}
|
||||
|
||||
function showResults(){
|
||||
|
||||
let question_title = document.getElementById("question_container");
|
||||
|
||||
question_title.innerHTML =
|
||||
`<h6 class="article_desc-result">
|
||||
{{'test.results'|_}}
|
||||
<br>
|
||||
${correct_answers}/${questions.length}
|
||||
</h6>`;
|
||||
}
|
||||
|
||||
function startNewQuestion(){
|
||||
|
||||
let question = questions[step-1];
|
||||
|
||||
let question_title = document.getElementById("question_title");
|
||||
question_title.innerHTML = '';
|
||||
question_title.innerHTML =
|
||||
`${question.question} <br> ${step}/${questions.length}`;
|
||||
|
||||
let description = document.getElementById("description");
|
||||
description.classList.remove("active");
|
||||
|
||||
let question_description_text = document.getElementById("question_description_text");
|
||||
question_description_text.innerHTML = '';
|
||||
question_description_text.innerHTML =
|
||||
`${question.description}`;
|
||||
|
||||
if(question.image){
|
||||
let question_description_image = document.getElementById("question_description_image");
|
||||
question_description_image.innerHTML = '';
|
||||
question_description_image.innerHTML = `<img src="${question.image.path}" alt="test-photo">`;
|
||||
}
|
||||
let question_answer = document.getElementById("question_answer");
|
||||
question_answer.innerHTML = '';
|
||||
|
||||
let answersBox = '';
|
||||
question.answers.forEach(answer => {
|
||||
let correct = answer.correct === "1" ? true : false;
|
||||
|
||||
let title = locale == 'ru' ? answer.title_ru :
|
||||
locale == 'en' ? answer.title_en : answer.title_tm;
|
||||
|
||||
answersBox +=
|
||||
`<button class="article-test-btn" onclick="checkAnswer(this, ${correct})">
|
||||
${title}
|
||||
</button>`;
|
||||
});
|
||||
question_answer.innerHTML = answersBox;
|
||||
|
||||
step++;
|
||||
refreshButtons();
|
||||
|
||||
}
|
||||
|
||||
function checkAnswer(button, correct){
|
||||
button.classList.add(correct ? "true" : "false");
|
||||
|
||||
let description = document.getElementById("description");
|
||||
description.classList.add("active");
|
||||
|
||||
if(correct){
|
||||
correct_answers++;
|
||||
}
|
||||
}
|
||||
|
||||
function refreshButtons(){
|
||||
let btn = document.querySelectorAll('.article-test-btn');
|
||||
let hint = document.querySelector('.article-hint');
|
||||
|
||||
if (btn != undefined) {
|
||||
btn.forEach(x => {
|
||||
x.addEventListener('click', function () {
|
||||
btn.forEach(p => {
|
||||
p.setAttribute("disabled", "true");
|
||||
p.classList.add('disabled');
|
||||
})
|
||||
|
||||
hint.classList.add('active');
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getQuestions();
|
||||
|
||||
</script>
|
||||
|
|
@ -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' %}
|
||||
<?php
|
||||
function onStart(){
|
||||
$this['test'] = Tps\Tps\Models\Test::where('id', $this->param('id'))->get()->first();
|
||||
}
|
||||
?>
|
||||
==
|
||||
|
||||
<!-- Test ================================== -->
|
||||
<main class="article">
|
||||
<div class="container">
|
||||
<div class="article-wrap">
|
||||
<div class="trending-head affiche-head">
|
||||
<h2>{{'test.tests'|_}}</h2>
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
<div class="article-inner">
|
||||
<div class="article-content">
|
||||
<div class="article-content-top">
|
||||
<div class="article-head">
|
||||
<h2>
|
||||
{{ test.title }}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="article-swiper-wrapper">
|
||||
<div class="swiper articleSwiper">
|
||||
<div class="swiper-wrapper">
|
||||
<div class="swiper-slide">
|
||||
<div class="article-item">
|
||||
<img src="{{ test.image.path }}" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-desc">
|
||||
<p>
|
||||
{{ test.description }}
|
||||
</p>
|
||||
|
||||
<div class="article_btn color-gr">
|
||||
<a href="{{ 'test-start'|page({ id: test.id })}}">
|
||||
{{'test.start_test'|_}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside class="aside article-aside">
|
||||
<h6 class="aside-ad-wrapper-title">
|
||||
{{'test.see_also'|_}}
|
||||
</h6>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/affiche.jpg" alt="" />
|
||||
</a>
|
||||
<p class="aside-ad-wrapper-txt">
|
||||
В Минфине обсудили разработку стратегии АБР для Туркменистана с новым страновым
|
||||
директором
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/affiche.jpg" alt="" />
|
||||
</a>
|
||||
<p class="aside-ad-wrapper-txt">
|
||||
В Минфине обсудили разработку стратегии АБР для Туркменистана с новым страновым
|
||||
директором
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- Test end ============================== -->
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
title = "tests2"
|
||||
url = "/tests2"
|
||||
layout = "new/master-inside"
|
||||
is_hidden = 0
|
||||
robot_index = "index"
|
||||
robot_follow = "follow"
|
||||
==
|
||||
<!-- Test ================================== -->
|
||||
<main class="article">
|
||||
<div class="container">
|
||||
<div class="article-wrap">
|
||||
<div class="trending-head affiche-head">
|
||||
<h2>{{'test.tests'|_}}</h2>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="article-inner">
|
||||
<div class="article-content">
|
||||
<div class="rubric-items affiche-items">
|
||||
{% for item in tests %}
|
||||
<a href="{{ 'test'|page({ id: item.id })}}" class="sub-news-left-content-item rubric-item">
|
||||
<div class="sub-news-left-content-item-img">
|
||||
<img src="{{item.image.path}}" alt="" />
|
||||
</div>
|
||||
<div class="sub-news-left-content-item-content align-center">
|
||||
<h3>
|
||||
{{item.title}}
|
||||
</h3>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<aside class="aside article-aside">
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/aside-ad.jpg" alt="" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="aside-ad-wrapper">
|
||||
<a href="#">
|
||||
<img src="../assets/images/aside-ad.jpg" alt="" />
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- Test end ============================== -->
|
||||
Loading…
Reference in New Issue