- Use real questions now
- Convert JSON to other format
This commit is contained in:
parent
d47ca1be66
commit
0a55ef7db8
@ -4,7 +4,7 @@ let app = express();
|
||||
let server = require('http').createServer(app);
|
||||
let {Server} = require("socket.io");
|
||||
let io = new Server(server);
|
||||
let cards = JSON.parse(fs.readFileSync(__dirname + '/../data/cards.json'));
|
||||
let cards = JSON.parse(fs.readFileSync(__dirname + '/../data/fragen_10_06_21_final_new_format.json'));
|
||||
|
||||
let port = 5000;
|
||||
server.listen(port, function () {
|
||||
@ -100,7 +100,6 @@ function getRandomCard(difficulty) {
|
||||
let filtered_cards = cards.filter(card => {
|
||||
return card.difficulty === difficulty;
|
||||
});
|
||||
|
||||
return shuffleAnswers(filtered_cards[Math.floor(Math.random() * filtered_cards.length)]);
|
||||
}
|
||||
|
||||
|
@ -1,71 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"difficulty": 1,
|
||||
"question": "Was?",
|
||||
"answers": [
|
||||
{
|
||||
"text": "A",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"status": true
|
||||
},
|
||||
{
|
||||
"text": "C",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "D",
|
||||
"status": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"difficulty": 2,
|
||||
"question": "Wie?",
|
||||
"answers": [
|
||||
{
|
||||
"text": "A",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"status": true
|
||||
},
|
||||
{
|
||||
"text": "C",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "D",
|
||||
"status": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"difficulty": 3,
|
||||
"question": "Wo?",
|
||||
"answers": [
|
||||
{
|
||||
"text": "A",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"status": true
|
||||
},
|
||||
{
|
||||
"text": "C",
|
||||
"status": false
|
||||
},
|
||||
{
|
||||
"text": "D",
|
||||
"status": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
1052
data/fragen_10_06_21_final.json
Normal file
1052
data/fragen_10_06_21_final.json
Normal file
File diff suppressed because it is too large
Load Diff
2417
data/fragen_10_06_21_final_new_format.json
Normal file
2417
data/fragen_10_06_21_final_new_format.json
Normal file
File diff suppressed because it is too large
Load Diff
30
data/main.py
Normal file
30
data/main.py
Normal file
@ -0,0 +1,30 @@
|
||||
import json
|
||||
|
||||
if __name__ == '__main__':
|
||||
array = []
|
||||
with open('fragen_10_06_21_final.json') as file:
|
||||
data = json.load(file)
|
||||
print(len(data))
|
||||
|
||||
for i in range(0, len(data)):
|
||||
new = {'id': int(data[i]['id']), 'difficulty': int(data[i]['difficulty']), 'question': data[i]['question'],
|
||||
'answers': []}
|
||||
|
||||
new['answers'].append({"text": data[i]['A'],
|
||||
"status": 'A' == data[i]['key']
|
||||
})
|
||||
new['answers'].append({"text": data[i]['B'],
|
||||
"status": 'B' == data[i]['key']
|
||||
})
|
||||
new['answers'].append({"text": data[i]['C'],
|
||||
"status": 'C' == data[i]['key']
|
||||
})
|
||||
new['answers'].append({"text": data[i]['D'],
|
||||
"status": 'D' == data[i]['key']
|
||||
})
|
||||
|
||||
array.append(new)
|
||||
|
||||
with open('fragen_10_06_21_final_new_format.json', 'w', encoding='utf8') as file:
|
||||
json.dump(array, file, ensure_ascii=False)
|
||||
print(len(data))
|
Loading…
Reference in New Issue
Block a user