diff options
Diffstat (limited to 'static/create.js')
-rw-r--r-- | static/create.js | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/static/create.js b/static/create.js deleted file mode 100644 index d34a2da..0000000 --- a/static/create.js +++ /dev/null @@ -1,62 +0,0 @@ -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.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() |