blob: d64073fc06133af35a01fdbff6a048c1115ef67c (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
var questions = {}
createQuestionDiv = ( question ) => {
const questionDiv = document.createElement('div')
questionDiv.className = 'kysQuestion'
const qDiv = document.createElement('div')
qDiv.appendChild( document.createTextNode( question.q ) )
qDiv.className = 'kysText'
questionDiv.appendChild( qDiv )
const npDiv = document.createElement('div')
npDiv.className = 'kysScale'
const nDiv = document.createElement('div')
nDiv.appendChild( document.createTextNode( question.n ) )
nDiv.className = 'kysNegative'
npDiv.appendChild( nDiv )
const sDiv = document.createElement('div')
sDiv.className = 'kysScaleSpacer'
npDiv.appendChild( sDiv )
const pDiv = document.createElement('div')
pDiv.appendChild( document.createTextNode( question.p ) )
pDiv.className = 'kysPositive'
npDiv.appendChild( pDiv )
questionDiv.appendChild( npDiv )
const aDiv = document.createElement('input')
aDiv.appendChild( document.createTextNode( question.a ) )
aDiv.className = 'kysAnswer'
aDiv.type = 'range'
aDiv.min = 0
aDiv.max = 999
aDiv.disabled = true
aDiv.value = question.a
questionDiv.appendChild( aDiv )
return questionDiv
}
createQuestions = () => {
const questionsDiv = document.getElementById('questions')
questionsDiv.className = 'kysQuestions'
Object.keys(questions).forEach(k => {
questionsDiv.appendChild( createQuestionDiv( questions[k] ) )
})
}
loadQuestions = async() => {
await fetch( 'get/quiz_creator' )
.then( response => response.json() )
.then( json => questions = json )
.catch( error => {
alert("dkd")
} )
createQuestions()
}
loadQuestions()
|