Updated questions #68
@ -7,7 +7,7 @@ const app = express();
|
|||||||
const server = require('http').createServer(app);
|
const server = require('http').createServer(app);
|
||||||
const {Server} = require("socket.io");
|
const {Server} = require("socket.io");
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
let cards = JSON.parse(fs.readFileSync(__dirname + '/../data/fragen_10_06_21_final_new_format.json'));
|
let cards = JSON.parse(fs.readFileSync(__dirname + '/../data/fragen_12_07_21_new_format.json'));
|
||||||
|
|
||||||
let game = {};
|
let game = {};
|
||||||
|
|
||||||
|
1052
data/fragen_12_07_21.json
Normal file
1052
data/fragen_12_07_21.json
Normal file
File diff suppressed because it is too large
Load Diff
2417
data/fragen_12_07_21_new_format.json
Normal file
2417
data/fragen_12_07_21_new_format.json
Normal file
File diff suppressed because it is too large
Load Diff
56
data/main.py
56
data/main.py
@ -1,59 +1,19 @@
|
|||||||
import json
|
import json
|
||||||
|
import io
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
array = []
|
array = []
|
||||||
with open('fragen_10_06_21_final.json') as file:
|
with io.open('fragen_12_07_21.json', 'r', encoding='utf-8-sig') as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
|
|
||||||
length_q = 0
|
|
||||||
id_q = 0
|
|
||||||
length = 0
|
|
||||||
id = 0
|
|
||||||
for i in range(0, len(data)):
|
for i in range(0, len(data)):
|
||||||
new = {'id': int(data[i]['id']), 'difficulty': int(data[i]['difficulty']), 'question': data[i]['question'],
|
new = { 'id': int(data[i]['ID']), 'difficulty': int(data[i]['Schwierigkeit']), 'question': data[i]['Frage'], 'answers': [] }
|
||||||
'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']
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if(length_q < len(data[i]['question'])):
|
|
||||||
length_q = len(data[i]['question'])
|
|
||||||
|
|
||||||
|
|
||||||
if(length < len(data[i]['A'])):
|
|
||||||
length = len(data[i]['A'])
|
|
||||||
if(length < len(data[i]['B'])):
|
|
||||||
length = len(data[i]['B'])
|
|
||||||
if(length < len(data[i]['C'])):
|
|
||||||
length = len(data[i]['C'])
|
|
||||||
if(length < len(data[i]['D'])):
|
|
||||||
length = len(data[i]['D'])
|
|
||||||
|
|
||||||
|
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)
|
array.append(new)
|
||||||
|
|
||||||
print("Längste Frage: " + str(length))
|
with open('fragen_12_07_21_new_format.json', 'w', encoding='utf8') as file:
|
||||||
print("Längste Antwort: " + str(length_q))
|
|
||||||
|
|
||||||
with open('fragen_10_06_21_final.json') as file:
|
|
||||||
data = json.load(file)
|
|
||||||
|
|
||||||
for i in range(0, len(data)):
|
|
||||||
if(length_q == len(data[i]['question'])):
|
|
||||||
print("Längste Frage ID: " + str(data[i]['id']))
|
|
||||||
|
|
||||||
if(length == len(data[i]['A']) or length == len(data[i]['B']) or length == len(data[i]['C']) or length == len(data[i]['D'])):
|
|
||||||
print("Längste Antwort ID: " + str(data[i]['id']))
|
|
||||||
|
|
||||||
with open('fragen_10_06_21_final_new_format.json', 'w', encoding='utf8') as file:
|
|
||||||
json.dump(array, file, ensure_ascii=False)
|
json.dump(array, file, ensure_ascii=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user