for (let alt in question.alternatives)
key = "alt1" value = "2"
for (let alt in question.alternatives)
key = "alt1" value = "2"
async function myQuiz () { let myQ = await window.fetch(`http://vhost3.lnu.se:20080/question/1`) let jsonQ = await myQ.json() return jsonQ.question } myQuiz().then((text) => { let qDiv = document.querySelector('#questions') let quest = document.createElement('p') quest.innerHTML = text qDiv.appendChild(quest) }) let alternatives = this.jsonQ.alternatives let answerURL = 'http://vhost3.lnu.se:20080/answer/1' let answer = {answer: 0} async function getNextQ (Q) { let question = await myQuiz(myQ) answerURL = question.nextAnswerUrl if(question.alternatives === undefined) { let fAnswer = document.createElement('input') fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm') fo.appendChild(fAnswer) } else { for (let prop in question.alternatives) { let rButton = document.createElement('input') let label = document.createElement('label') rButton.setAttribute('type', 'radio', 'value',`${prop}`) rbutton.setAttribute('id', `${prop}`, 'name', 'radioAnswer') label.setAttribute('for', `${prop}`) label.textContent = `${question.alternatives[prop]}` fo.appendChild(rButton) fo.appendChild(label) } } } async function request (URL) { const response = await window.fetch(URL) const data = await response.json() question = data.question answerURL = nextURL alternatives = data.alternatives } async function response (answerURL) { let answerR = await window.fetch(this.answerURL, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(answer) }) }
async function myQuiz () { let myQ = await window.fetch(`http://vhost3.lnu.se:20080/question/1`) let jsonQ = await myQ.json() return jsonQ.question } myQuiz().then((text) => { let qDiv = document.querySelector('#questions') let quest = document.createElement('p') quest.innerHTML = text qDiv.appendChild(quest) }) let alternatives = this.jsonQ.alternatives let answerURL = 'http://vhost3.lnu.se:20080/answer/1' let answer = {answer: 0} async function getNextQ (Q) { let question = await myQuiz(myQ) answerURL = question.nextAnswerUrl if(question.alternatives === undefined) { let fAnswer = document.createElement('input') fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm') fo.appendChild(fAnswer) } else { for (let prop in question.alternatives) { let rButton = document.createElement('input') let label = document.createElement('label') rButton.setAttribute('type', 'radio', 'value',`${prop}`) rbutton.setAttribute('id', `${prop}`, 'name', 'radioAnswer') label.setAttribute('for', `${prop}`) label.textContent = `${question.alternatives[prop]}` fo.appendChild(rButton) fo.appendChild(label) } } } async function request (URL) { const response = await window.fetch(URL) const data = await response.json() question = data.question answerURL = nextURL alternatives = data.alternatives } async function response (answerURL) { let answerR = await window.fetch(this.answerURL, { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(answer) }) }
var o = { "key1": "value1", "key2": "value2"};
for(var key in Object.keys(o){
var value = o[key];
console.log("key = " + key + "value = " + value);
}
var o = { "key1": "value1", "key2": "value2"};
for(var key in Object.keys(o){
var value = o[key];
console.log("key = " + key + "value = " + value);
}
async function myQuiz () { let myQ = await window.fetch(`http://vhost3.lnu.se:20080/question/1`) let jsonQ = await myQ.json() return jsonQ.question } myQuiz().then((text) => { let qDiv = document.querySelector('#questions') let quest = document.createElement('p') quest.innerHTML = text qDiv.appendChild(quest) })
async function myQuiz () { let myQ = await window.fetch(`http://vhost3.lnu.se:20080/question/1`) let jsonQ = await myQ.json() return jsonQ.question } myQuiz().then((text) => { let qDiv = document.querySelector('#questions') let quest = document.createElement('p') quest.innerHTML = text qDiv.appendChild(quest) })
async function getNextQ (Q) { let question = await myQuiz(myQ) answerURL = question.nextAnswerUrl if(question.alternatives === undefined) { let fAnswer = document.createElement('input') fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm') form.appendChild(fAnswer) } else { for (let prop in question.alternatives) { let rButton = document.createElement('input') let label = document.createElement('label') rButton.setAttribute('type', 'radio', 'value',`${prop}`) rbutton.setAttribute('id', `${prop}`, 'name', 'radioAnswer') label.setAttribute('for', `${prop}`) label.textContent = `${question.alternatives[prop]}` form.appendChild(rButton) form.appendChild(label) } } }
async function getNextQ (Q) { let question = await myQuiz(myQ) answerURL = question.nextAnswerUrl if(question.alternatives === undefined) { let fAnswer = document.createElement('input') fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm') form.appendChild(fAnswer) } else { for (let prop in question.alternatives) { let rButton = document.createElement('input') let label = document.createElement('label') rButton.setAttribute('type', 'radio', 'value',`${prop}`) rbutton.setAttribute('id', `${prop}`, 'name', 'radioAnswer') label.setAttribute('for', `${prop}`) label.textContent = `${question.alternatives[prop]}` form.appendChild(rButton) form.appendChild(label) } } }
if(question.alternatives === undefined) {
let fAnswer = document.createElement('input')
fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm')
form.appendChild(fAnswer)
} else {
for (let key in Object.getKeys(question.alternatives)) {
let value = questions.alternatives[key];
let rButton = document.createElement('input')
let label = document.createElement('label')
rButton.setAttribute('type', 'radio')
rButton.setAttribute('value', value)
rbutton.setAttribute('id', key )
rButton.setAttribute('name', 'radioAnswer')
label.setAttribute('for', key)
label.textContent = key;
form.appendChild(rButton)
form.appendChild(label)
}
}
async function myQuiz (URL) { let myQ = await window.fetch(`http://vhost3.lnu.se:20080/question/1`) let jsonQ = await myQ.json() return jsonQ.question } myQuiz().then((text) => { let qDiv = document.querySelector('#questions') let quest = document.createElement('p') quest.innerHTML = text qDiv.appendChild(quest) }) let answerURL = 'http://vhost3.lnu.se:20080/answer/1' let questionURL = 'http://vhost3.lnu.se:20080/question/1' let o = {'key1': 'value1', 'key2': 'value2'} async function getQuestion (answerURL) { let question = await myQuiz(myQ) let jsonQ = await myQ.json() answerURL = question.nextAURL let nextAURL = jsonQ.nextURL let alternatives = jsonQ.alternatives if (question.alternatives === undefined) { let fAnswer = document.createElement('input') fAnswer.setAttribute('text', 'type', 'id', 'answerForm', 'name', 'answerForm') form.appendChild(fAnswer) } else { for (let key in Object.getKeys(question.alternatives)) { let value = question.alternatives[key] let rButton = document.createElement('input') let label = document.createElement('label') rButton.setAttribute('type', 'radio') rButton.setAttribute('value', value) rbutton.setAttribute('id', key) rButton.setAttribute('name', 'radioAnswer') label.setAttribute('for', key) label.textContent = key form.appendChild(rButton) form.appendChild(label) } } } getQuestion()
Flashback finansieras genom donationer från våra medlemmar och besökare. Det är med hjälp av dig vi kan fortsätta erbjuda en fri samhällsdebatt. Tack för ditt stöd!
Swish: 123 536 99 96 Bankgiro: 211-4106
Flashback finansieras genom donationer från våra medlemmar och besökare. Det är med hjälp av dig vi kan fortsätta erbjuda en fri samhällsdebatt. Tack för ditt stöd!
Swish: 123 536 99 96 Bankgiro: 211-4106