项目作者: onmotion

项目描述 :
The page assessment/polls module for Yii2 framework
高级语言: Vue
项目地址: git://github.com/onmotion/yii2-page-assessments.git
创建时间: 2018-09-07T14:53:46Z
项目社区:https://github.com/onmotion/yii2-page-assessments

开源协议:

下载


Yii2 page assessment/polls extension

The page assessment (polls) module for Yii2 framework based on Vue2.

Language: English, Русский

Latest Stable Version
Total Downloads
Monthly Downloads
License

Fluent view:

fluent

Static (embeded in a page) view:

static

Installation

Just run:

  1. composer require onmotion/yii2-page-assessments

or add

  1. "onmotion/yii2-page-assessments": "*"

to the require section of your composer.json file.

apply migration:

  1. php yii migrate --migrationPath=@vendor/onmotion/yii2-page-assessments/migrations

Usage

You must add to your config:

  1. 'modules' => [
  2. //...
  3. 'assessments' => [
  4. 'class' => 'onmotion\assessments\Module',
  5. ],
  6. //...
  7. ],

Then you can use the widget somewhere on the page:

Example:

  1. echo \onmotion\assessments\widget\AssessmentWidget::widget([
  2. 'fluent' => false, // static or fluent view
  3. // 'timeout' => 1500 // timeout bafore appearance.
  4. 'questions' => [
  5. 'Is this page helpful?', // simple question
  6. [
  7. 'title' => 'What do you think about it?',
  8. 'maxValue' => 6,
  9. // 'allowComment' => true // allow optional comment
  10. 'allowComment' => [1, 2, 3], // allow comment only if value is 1, 2 or 3.
  11. // 'model' => (new SomeActiveRecordModel),
  12. // 'repeat' => true, // whether to force repeat the question
  13. // 'afterVoteText' => [ // show comment after got a vote (string || array)
  14. // 1 => 'It\'s ok! 👌',
  15. // 2 => 'Could be better 😎',
  16. // 3 => 'So so...',
  17. // 4 => 'Very good!',
  18. // 5 => 'Perfect!',
  19. // ]
  20. ]
  21. ]
  22. ]);

Options

option type default description
fluent bool false fluent or static view
questions string \ \ array see example
timeout integer 1500 timeout bafore appearance
model (optional) ActiveRecord null Attach Model::class info with primary key
icons array [] custom icons

Events

assessment.show - when an assessment item appears.

assessment.end - when all questions are completed.

  1. document.addEventListener('assessment.show', function (e) {
  2. console.log(e.detail);
  3. }, false);

You can change icons as you want, for example:

  1. echo \onmotion\assessments\widget\AssessmentWidget::widget([
  2. 'fluent' => true,
  3. 'questions' => $questions,
  4. 'icons' => [
  5. 1 => '<span class="assessment-icon"><span class="assessment-icon__angry"></span></span>',
  6. 2 => '<span class="assessment-icon"><span class="assessment-icon__sad"></span></span>',
  7. 3 => '<span class="assessment-icon"><span class="assessment-icon__thinking"></span></span>',
  8. 4 => '<span class="assessment-icon"><span class="assessment-icon__happy"></span></span>',
  9. 5 => '<span class="assessment-icon"><span class="assessment-icon__in-love"></span></span>',
  10. ]
  11. ]);

icons