1.13.1 • Published 3 years ago

questionare-generator-core v1.13.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

questionare-generator-core

问卷设计器的核心校验模块,提供完整的对JSON SCHEMA的校验功能


安装

使用npm进行安装

npm i questionare-generator-core

使用yarn进行安装

yarn add questionare-generator-core

引入

完整引入

完整引入提供全部题型和问卷的整体校验功能

import { jsonSchemaValidateError } from 'questionare-generator-core'

按需引入

按需引入可以使用qgc对象对单独的题目类型进行校验,在没有使用大量题目类型时有绝对的性能优势

import { qgc } from 'questionare-generator-core'

使用

完整引入的校验方式

import { jsonSchemaValidateError } from 'questionare-generator-core'

const testData = {
  questionImage: '',
  questionTitle: '问卷标题',
  questionRemark: '感谢您能抽出几分钟时间来参加本次答题,现在我们就马上开始吧!',
  isQuestionNumber: true,
  isQuestionType: true,
  data: [
    {
      id: 1,
      title: '请选择一个选项',
      type: 'single-choice',
      must: true,
      options: [{ label: '选项名称', value: 1 }, { label: '选项名称', value: 2 }]
    },
    {
      id: 2,
      title: '请选择一个或多个选项',
      type: 'multiple-choice',
      must: true,
      options: [{ label: '选项名称', value: 1 }, { label: '选项名称', value: 2 }]
    },
    {
      id: 3,
      title: '请选择一个或多个选项',
      type: 'multiple-choice',
      must: true,
      options: [{ label: '选项名称', value: 1 }, { label: '选项名称', value: 2 }]
    },
    {
      id: 4,
      title: '请填写本项内容',
      type: 'blanks-filling',
      must: true
    },
    {
      id: 5,
      title: '请给本项打分',
      type: 'scoring',
      must: true,
      fractionType: 5
    },
    {
      id: 6,
      title: '请给以下选项排序',
      type: 'ranking',
      must: false,
      options: [{ label: '选项名称', value: 1 }, { label: '选项名称', value: 2 }]
    }
  ]
}

const validate = () => {
  testData.data.forEach((item: any) => {
    jsonSchemaValidateError(item.type, [item])
  })
}

按需引入校验方式

import { qgc } from 'questionare-generator-core'

// 校验单选题
qgc.topicSingleChoiceValidate([{
  id: 3,
  title: '请选择一个或多个选项',
  type: 'multiple-choice',
  must: true,
  options: [{ label: '选项名称', value: 1 }, { label: '选项名称', value: 2 }]
}])

题型分类

分类名称题型名称参数名称
选择题单选题single-choice
选择题多选题multiple-choice
填空题填空题blanks-filling
打分题打分题scoring
排序题排序题ranking
比重题比重题proportion

问卷参数配置

名称类型说明是否必传默认值可选值
questionTitlestring问卷标题true--
questionRemarkstring问卷备注true--
questionImagestring问卷头部主题图片true--
dataarray问卷题目数据true--
isQuestionNumberboolean是否显示题号true-true、false
isQuestionTypeboolean是否现实题型true-true、false

题型基础参数配置

基础参数配置

名称类型说明是否必传默认值可选值选项参数
titlestring题目true---
mustboolean是否必答(排序题和比重题只能传递false,因为排序题和比重题存在使用默认排序和比重为0的情况)true-true、false-
topicNumnumber题号false---
idnumber题目idfalse---
typestring题型true---

单选题和多选题特有参数配置

名称类型说明是否必传默认值可选值选项参数
optionsarray选项true--{ label: 'first-option', value: 1 }, { label: 'second-option', value: 2 }

排序题特有参数配置

名称类型说明是否必传默认值可选值选项参数
optionsarray选项true--{ label: 'first-option', value: 1, order: 1 }, { label: 'second-option', value: 2, order: 2 }

打分题特有参数配置

名称类型说明是否必传默认值可选值
fractionTypenumber分数制true510
1.13.1

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.14

3 years ago

1.11.12

3 years ago

1.11.13

3 years ago

1.11.10

3 years ago

1.11.11

3 years ago

1.11.0

3 years ago

1.11.4

3 years ago

1.11.3

3 years ago

1.11.2

3 years ago

1.11.1

3 years ago

1.11.8

3 years ago

1.11.7

3 years ago

1.11.6

3 years ago

1.11.5

3 years ago

1.11.9

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.0

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.2.1

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago