npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

questionare-generator-core

v1.13.1

Published

问卷调查核心校验模块

Downloads

16

Readme

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|


问卷参数配置

|名称|类型|说明|是否必传|默认值|可选值| |:----|:----|:----|:----|:----|:----| |questionTitle|string|问卷标题|true|-|-| |questionRemark|string|问卷备注|true|-|-| |questionImage|string|问卷头部主题图片|true|-|-| |data|array|问卷题目数据|true|-|-| |isQuestionNumber|boolean|是否显示题号|true|-|true、false| |isQuestionType|boolean|是否现实题型|true|-|true、false|


题型基础参数配置

基础参数配置

|名称|类型|说明|是否必传|默认值|可选值|选项参数| |:----|:----|:----|:----|:----|:----|:----| |title|string|题目|true|-|-|-| |must|boolean|是否必答(排序题和比重题只能传递false,因为排序题和比重题存在使用默认排序和比重为0的情况)|true|-|true、false|-| |topicNum|number|题号|false|-|-|-| |id|number|题目id|false|-|-|-| |type|string|题型|true|-|-|-|

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

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

排序题特有参数配置

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

打分题特有参数配置

|名称|类型|说明|是否必传|默认值|可选值| |:----|:----|:----|:----|:----|:----| |fractionType|number|分数制|true|5|10|