forked from Alheimsins/b5-johnson-120-ipip-neo-pi-r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (24 loc) · 803 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { knuthShuffle } = require('knuth-shuffle')
const languages = require('./data/languages.json')
module.exports.getItems = (lang = 'en', shuffle = false) => {
let choices, questions
try {
questions = require(`./data/${lang}/questions.json`)
choices = require(`./data/${lang}/choices`)
} catch (error) {
throw new Error('Inventory not found. Try another language input.')
}
const inventory = shuffle === true ? knuthShuffle(questions) : questions
return inventory.map((question, i) => Object.assign(question, { num: ++i, choices: choices[question.keyed] }))
}
module.exports.getInfo = () => (
{
name: `Johnson's IPIP NEO-PI-R`,
id: 'johnson-120-ipip-neo-pi-r',
shortId: 'b5-120',
time: 10,
questions: 120,
note: 'Recommended',
languages
}
)