fragen und Antworten aus CSV
This commit is contained in:
1 parent
f8d0dc43c5
commit
c101a51593
7 files changed
+461
-5
No files matched your search
Executable → Regular
+1
-2
@@ -5,8 +5,7 @@ import random
|
||||
|
||||
# Liste mit Fragen und zugehörigen Antworten erstellen
|
||||
fragen_und_antworten = [
|
||||
{"frage": "Wie heißt die Hauptstadt von Frankreich?",
|
||||
"antwort": "Paris"},
|
||||
{"frage": "Wie heißt die Hauptstadt von Frankreich?", "antwort": "Paris"},
|
||||
{"frage": "Was ist die Hauptfarbe des Himmels an einem klaren Tag?",
|
||||
"antwort": "Blau"},
|
||||
{"frage": "Wie viele Planeten gibt es in unserem Sonnensystem?",
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../.data/style/forms.css">
|
||||
<link rel="stylesheet" href="../.data/style/main.css">
|
||||
<title>Login</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100dvh;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(315deg, rgb(134, 65, 163) 0%, rgb(196, 99, 238) 100%);
|
||||
}
|
||||
|
||||
form {
|
||||
background-color: rgb(255, 255, 255);
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
width: 300px;
|
||||
box-sizing: border-box;
|
||||
transition: box-shadow 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
form:hover {
|
||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: rgb(102, 51, 153);
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 16px;
|
||||
background-color: transparent !important;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 0.25);
|
||||
outline: none;
|
||||
transition: border-bottom 0.3s ease-in-out;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
input:hover {
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 1);
|
||||
}
|
||||
|
||||
input+label {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
color: #8E44AD;
|
||||
transition: top 0.3s ease-in-out, font-size 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
input:focus+label,
|
||||
input:not(:placeholder-shown)+label {
|
||||
top: -14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: rgb(106, 90, 205);
|
||||
color: rgb(255, 255, 255);
|
||||
padding: 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
transition: background-color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: rgb(72, 61, 139);
|
||||
}
|
||||
|
||||
p {
|
||||
color: rgb(106, 90, 205);
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
p.q-amount {
|
||||
font-size: small;
|
||||
color: rgb(180, 180, 180);
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(106, 90, 205);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
li a {text-decoration : none; color : #2d2f31;}
|
||||
|
||||
nav {
|
||||
width : input;
|
||||
background: #d9d9d9;
|
||||
margin : 40px auto;
|
||||
}
|
||||
|
||||
span {
|
||||
padding : 30px;
|
||||
background : #2d2f31;
|
||||
color : white;
|
||||
font-size : 1.2em;
|
||||
font-variant : small-caps;
|
||||
cursor : pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
span::after {
|
||||
float: right;
|
||||
right: 10%;
|
||||
content: "+";
|
||||
}
|
||||
|
||||
.slide {
|
||||
clear:both;
|
||||
width:100%;
|
||||
height:0px;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
transition: height .4s ease;
|
||||
}
|
||||
|
||||
.slide li {
|
||||
padding : 30px;
|
||||
}
|
||||
|
||||
#touch {
|
||||
position: absolute; opacity: 0; height: 0px;
|
||||
}
|
||||
|
||||
#touch:checked +
|
||||
.slide {
|
||||
height: 300px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form method="post" action="">
|
||||
<p>Wähle eine Kategorie:</p>
|
||||
<button type="submit">Wählen</button>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,119 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../.data/style/forms.css">
|
||||
<link rel="stylesheet" href="../.data/style/main.css">
|
||||
<title>Login</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100dvh;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(315deg, rgb(134, 65, 163) 0%, rgb(196, 99, 238) 100%);
|
||||
}
|
||||
|
||||
form {
|
||||
background-color: rgb(255, 255, 255);
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
width: 300px;
|
||||
box-sizing: border-box;
|
||||
transition: box-shadow 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
form:hover {
|
||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: rgb(102, 51, 153);
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 16px;
|
||||
background-color: transparent !important;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 0.25);
|
||||
outline: none;
|
||||
transition: border-bottom 0.3s ease-in-out;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
input:hover {
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 1);
|
||||
}
|
||||
|
||||
input+label {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
color: #8E44AD;
|
||||
transition: top 0.3s ease-in-out, font-size 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
input:focus+label,
|
||||
input:not(:placeholder-shown)+label {
|
||||
top: -14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: rgb(106, 90, 205);
|
||||
color: rgb(255, 255, 255);
|
||||
padding: 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
transition: background-color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: rgb(72, 61, 139);
|
||||
}
|
||||
|
||||
p {
|
||||
color: rgb(106, 90, 205);
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
p.q-amount {
|
||||
font-size: small;
|
||||
color: rgb(180, 180, 180);
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(106, 90, 205);
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form>
|
||||
<p><strong>Richtig!</strong><br>Dein BonBon ist unterwegs</p>
|
||||
<p class="q-amount">N/A von N/A beantwortet!</p>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
import csv # CSV handling
|
||||
import random
|
||||
import os
|
||||
|
||||
#file = "C:/Users/bruno/Documents/__CODING__/0-git (Group)/robotik-wise23/robo/fragen1.csv"
|
||||
#file = os.getcwd() + "fragen1.csv"
|
||||
#file = os.path.join(os.getcwd(), "robo", "fragen1.csv") # Windows Entwicklung
|
||||
file = os.path.join(os.getcwd(), "fragen1.csv") # Raspi
|
||||
|
||||
#with open(file, newline="", encoding="utf-8") as csvfile: #
|
||||
with open(file, newline="", encoding="cp1252") as csvfile: # Code wird als Excel Windows-1252 Input CSV gelesen
|
||||
database = csv.reader(csvfile, delimiter=";") # Validating the "csvfile" into "database" with the delimiter "," (Comma Seperated Values)
|
||||
|
||||
q_a = [] # Empty list for all questions and answers
|
||||
|
||||
for row in database: # alle Zeilen in der Datenbank durchlaufen
|
||||
index = int(row[0]) # Laufende Nummer
|
||||
question = str(row[1]) # Frage (ist der erste Teil)
|
||||
answer = str(row[2]) # Antwort (3. Spalte in der CSV Datenbank)
|
||||
q_a.append({"index": index,"question": question, "answer": answer}) # Eine Liste bauen
|
||||
|
||||
# for i in q_a: # For every element in "q_a"
|
||||
# print("[" + str(i["index"]) + "] Frage: " + i["question"] + "\n[" + str(i["index"]) + "] Antwort: " + i["answer"] + "\n") # Print "question", "answer" and "index" for current element
|
||||
|
||||
|
||||
while True:
|
||||
# Zufällig eine Frage auswählen
|
||||
zufallige_frage = random.choice(q_a)
|
||||
ID = zufallige_frage["index"]
|
||||
frage = zufallige_frage["question"]
|
||||
antwort = zufallige_frage["answer"]
|
||||
|
||||
#print(f"wir sindin {os.getcwd()}")
|
||||
|
||||
# Frage und Antwort ausgeben
|
||||
print(f"Frage:\t({ID})\t{frage}")
|
||||
print(f"Antwort:\t{antwort}")
|
||||
|
||||
# Auf Eingabe warten
|
||||
input("Drücke Enter für die nächste Frage...")
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
1;Was ist die Hauptstadt von Frankreich?;Paris
|
||||
2;Wie viele Kontinente gibt es auf der Erde?;7
|
||||
3;Was ist die Hauptzutat in Spaghetti Bolognese?;Hackfleisch
|
||||
4;Wie lautet die Formel für die Fläche eines Rechtecks?;a*b
|
||||
5;"Welches Element hat das chemische Symbol ""H""?";Wasserstoff
|
||||
6;Wie viele Planeten gibt es in unserem Sonnensystem?;8
|
||||
7;Was ist die Hauptfarbe des Himmels bei Tag?;Blau
|
||||
8;Welches Jahr wurde die Unabhängigkeit der USA erklärt?;1776
|
||||
9;Welches ist das größte Säugetier der Welt?;Blauwal
|
||||
10;Wie viele Sekunden hat eine Minute?;60
|
||||
|
+121
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../.data/style/forms.css">
|
||||
<link rel="stylesheet" href="../.data/style/main.css">
|
||||
<title>Login</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100dvh;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(315deg, rgb(134, 65, 163) 0%, rgb(196, 99, 238) 100%);
|
||||
}
|
||||
|
||||
form {
|
||||
background-color: rgb(255, 255, 255);
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
width: 300px;
|
||||
box-sizing: border-box;
|
||||
transition: box-shadow 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
form:hover {
|
||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: rgb(102, 51, 153);
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
margin-bottom: 16px;
|
||||
background-color: transparent !important;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 0.25);
|
||||
outline: none;
|
||||
transition: border-bottom 0.3s ease-in-out;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
input:hover {
|
||||
border-bottom: 1px solid rgb(142, 68, 173, 1);
|
||||
}
|
||||
|
||||
input+label {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
color: #8E44AD;
|
||||
transition: top 0.3s ease-in-out, font-size 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
input:focus+label,
|
||||
input:not(:placeholder-shown)+label {
|
||||
top: -14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: rgb(106, 90, 205);
|
||||
color: rgb(255, 255, 255);
|
||||
padding: 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
transition: background-color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: rgb(72, 61, 139);
|
||||
}
|
||||
|
||||
p {
|
||||
color: rgb(106, 90, 205);
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
p.q-amount {
|
||||
font-size: small;
|
||||
color: rgb(180, 180, 180);
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgb(106, 90, 205);
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form method="post" action="">
|
||||
<p name="question">N/A?</p>
|
||||
<input type="text" name="answer" placeholder="Antwort eingeben..." required>
|
||||
<button type="submit">Eingeben</button>
|
||||
<p class="q-amount">N/A von N/A beantwortet!</p>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -3,7 +3,8 @@
|
||||
# + Updatefunktion
|
||||
|
||||
#GITDIR=~/git/robotSoSe2022
|
||||
GITDIR=~/git/robotik-wise23
|
||||
#GITDIR=~/git/robotik-wise23
|
||||
GITDIR=./
|
||||
|
||||
Choice=$( whiptail --title "Hausaufgabenrobo Start und Update" --radiolist \
|
||||
"Bitte wählen" 20 78 4 \
|
||||
@@ -14,8 +15,8 @@ if [ $ExitVAL = 0 ] ;then # OK
|
||||
case $Choice in
|
||||
"START")
|
||||
echo starte nun robot
|
||||
cd $GITDIR
|
||||
./robostart.sh
|
||||
cd $GITDIR/robo
|
||||
python3 csv-read.py
|
||||
;;
|
||||
"UPDATE")
|
||||
cd $GITDIR
|
||||
|
||||
Reference in new issue
Block a user