Complete answer view
This commit is contained in:
parent
e398cfe7e6
commit
0bc9e3fb44
@ -11,21 +11,21 @@ app.jinja_env.lstrip_blocks = True
|
|||||||
|
|
||||||
datafile = "data.csv"
|
datafile = "data.csv"
|
||||||
|
|
||||||
def input_check(form, field):
|
def check_input(form, field):
|
||||||
if field.data == 'default':
|
if field.data == 'default':
|
||||||
raise validators.ValidationError('Bitte wähle eine Option aus')
|
raise validators.ValidationError('Bitte wähle eine Option aus')
|
||||||
|
|
||||||
class QuestionForm(Form):
|
class QuestionForm(Form):
|
||||||
computers = [('default', 'Bitte auswählen'), ('hal', 'HAL 9000 (2001: Odyssee im Weltraum)'), ('deepthought', 'Deep Thought (Hitchhiker\'s Guide)'), ('neuromancer', 'Neuromancer (Neuromancer)'), ('samantha', 'Samatha (Her)'), ('tars', 'TARS und CASE (Interstellar)')]
|
computers = [('default', 'Bitte auswählen'), ('hal', 'HAL 9000 (2001: Odyssee im Weltraum)'), ('deepthought', 'Deep Thought (Hitchhiker\'s Guide)'), ('neuromancer', 'Neuromancer (Neuromancer)'), ('samantha', 'Samatha (Her)'), ('tars', 'TARS und CASE (Interstellar)')]
|
||||||
computer = SelectField(u'Fiktionaler Lieblingscomputer', choices=computers, validators=[validators.InputRequired(), input_check])
|
computer = SelectField(u'Fiktionaler Lieblingscomputer', choices=computers, validators=[validators.InputRequired(), check_input])
|
||||||
statuses = [('default', 'Bitte auswählen'), ('200', '200 OK'), ('300', '300 Multiple Choices'), ('301', '301 Moved Permanently'), ('402', '402 Payment Required'), ('404', '404 (Sleep) Not Found'), ('408', '408 Request Timeout'), ('418', '418 I am a teapot'), ('450', '450 Blocked by Windows Parental Controls'), ('451', '451 Unavailable For Legal Reasons'), ('502', '502 Bad Gateway (Internetkurort)')]
|
statuses = [('default', 'Bitte auswählen'), ('200', '200 OK'), ('300', '300 Multiple Choices'), ('301', '301 Moved Permanently'), ('402', '402 Payment Required'), ('404', '404 (Sleep) Not Found'), ('408', '408 Request Timeout'), ('418', '418 I am a teapot'), ('450', '450 Blocked by Windows Parental Controls'), ('451', '451 Unavailable For Legal Reasons'), ('502', '502 Bad Gateway (Internetkurort)')]
|
||||||
status = SelectField(u'Welcher HTTP-Statuscode trifft am häufigsten auf dich zu?', choices=statuses, validators=[validators.InputRequired(), input_check])
|
status = SelectField(u'Welcher HTTP-Statuscode trifft am häufigsten auf dich zu?', choices=statuses, validators=[validators.InputRequired(), check_input])
|
||||||
vegetables = [('default', 'Bitte auswählen'), ('karotte', '🥕'), ('broccoli','🥦'), ('aubergine', '🍆'), ('kartoffel', '🥔'), ('bretzel', '🥨'), ('tomate', '🍅'), ('chili', '🌶️')]
|
vegetables = [('default', 'Bitte auswählen'), ('karotte', '🥕'), ('broccoli','🥦'), ('aubergine', '🍆'), ('kartoffel', '🥔'), ('bretzel', '🥨'), ('tomate', '🍅'), ('chili', '🌶️')]
|
||||||
vegetable = SelectField(u'Lieblingsgemüse', choices=vegetables, validators=[validators.InputRequired(), input_check])
|
vegetable = SelectField(u'Lieblingsgemüse', choices=vegetables, validators=[validators.InputRequired(), check_input])
|
||||||
spirit_animals = [('default', 'Bitte auswählen'), ('feuer', 'Feuerfuchs'), ('wasser', 'Wasserhahn'), ('erde', 'Erdferkel'), ('luft', 'Luftschlange')]
|
spirit_animals = [('default', 'Bitte auswählen'), ('feuer', 'Feuerfuchs'), ('wasser', 'Wasserhahn'), ('erde', 'Erdferkel'), ('luft', 'Luftschlange')]
|
||||||
spirit_animal = SelectField(u'Spirit Animal', choices=spirit_animals, validators=[validators.InputRequired(), input_check])
|
spirit_animal = SelectField(u'Spirit Animal', choices=spirit_animals, validators=[validators.InputRequired(), check_input])
|
||||||
operating_systems = [('default', 'Bitte auswählen'), ('windows', 'Windows'), ('mac', 'Mac'), ('linux', 'Linux'), ('kaffee', 'Kaffee'), ('glados', 'GLaDOS')]
|
operating_systems = [('default', 'Bitte auswählen'), ('windows', 'Windows'), ('mac', 'Mac'), ('linux', 'Linux'), ('kaffee', 'Kaffee'), ('glados', 'GLaDOS')]
|
||||||
operating_system = SelectField(u'Bevorzugtes Betriebssystem', choices=operating_systems, validators=[validators.InputRequired(), input_check])
|
operating_system = SelectField(u'Bevorzugtes Betriebssystem', choices=operating_systems, validators=[validators.InputRequired(), check_input])
|
||||||
check = BooleanField('Bitte nicht ankreuzen')
|
check = BooleanField('Bitte nicht ankreuzen')
|
||||||
email = EmailField('Email-Adresse')
|
email = EmailField('Email-Adresse')
|
||||||
|
|
||||||
@ -40,7 +40,6 @@ def create_used_id_list():
|
|||||||
reader = csv.reader(f)
|
reader = csv.reader(f)
|
||||||
for line in reader:
|
for line in reader:
|
||||||
data.append(line[0])
|
data.append(line[0])
|
||||||
print(data)
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
class AnswerForm(Form):
|
class AnswerForm(Form):
|
||||||
@ -76,7 +75,7 @@ def questions():
|
|||||||
|
|
||||||
@app.route('/result<user_id>')
|
@app.route('/result<user_id>')
|
||||||
def result(user_id):
|
def result(user_id):
|
||||||
return render_template('result.html', hausname='Knuth', haustext='Mitglieder dieses Hauses mögen LaTeX-Anzüge und Eisbären.', id=user_id)
|
return render_template('result.html', title='Sortierhut', hausname='Knuth', haustext='Mitglieder dieses Hauses mögen LaTeX-Anzüge und Eisbären.', id=user_id)
|
||||||
|
|
||||||
@app.route('/admin')
|
@app.route('/admin')
|
||||||
def admin():
|
def admin():
|
||||||
@ -92,7 +91,14 @@ def answers():
|
|||||||
|
|
||||||
@app.route('/view_answers<user_id>')
|
@app.route('/view_answers<user_id>')
|
||||||
def view_answers(user_id):
|
def view_answers(user_id):
|
||||||
return render_template('view.html', title='Sortierhut', user_id=user_id)
|
user_row = list()
|
||||||
|
with open(datafile, "r", newline='') as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
for line in reader:
|
||||||
|
if line[0] == user_id:
|
||||||
|
user_row = line
|
||||||
|
break
|
||||||
|
return render_template('view.html', title='Sortierhut', user_id=user_id, user_row=user_row)
|
||||||
|
|
||||||
@app.route('/solution')
|
@app.route('/solution')
|
||||||
def solution():
|
def solution():
|
||||||
|
|||||||
@ -95,3 +95,8 @@ header h1 {
|
|||||||
display: inline;
|
display: inline;
|
||||||
vertical-align: center;
|
vertical-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* view answers page: highlight chosen options */
|
||||||
|
.choice {
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<p>Fiktionaler Computer<br>
|
<p>Fiktionaler Computer<br>
|
||||||
<select name="computer">
|
<select name="computer">
|
||||||
<option value="" disabled selected>Bitte auswählen</option>
|
<option value="" disabled selected>Bitte auswählen</option>
|
||||||
<option value="hal9000">HAL 9000 (2001: Odyssee im Weltraum)</option>
|
<option value="hal">HAL 9000 (2001: Odyssee im Weltraum)</option>
|
||||||
<option value="deepthought">Deep Thought (Per Anhalter durch die Galaxis)</option>
|
<option value="deepthought">Deep Thought (Per Anhalter durch die Galaxis)</option>
|
||||||
<option value="neuromancer">Neuromancer (Neuromancer)</option>
|
<option value="neuromancer">Neuromancer (Neuromancer)</option>
|
||||||
<option value="samantha">Samantha (Her)</option>
|
<option value="samantha">Samantha (Her)</option>
|
||||||
|
|||||||
@ -1,4 +1,54 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Deine Antworten, liebe*r {{ user_id }}!</h1>
|
<h1>Deine Antworten, liebe*r {{ user_id }}!</h1>
|
||||||
|
<h2>Fiktionaler Lieblingscomputer</h2>
|
||||||
|
<ul>
|
||||||
|
<li {% if user_row[1] == "hal" %} class="choice" {% endif %}>HAL 9000 (2001: Odyssee im Weltraum)</li>
|
||||||
|
<li {% if user_row[1] == "deepthought" %} class="choice" {% endif %}>Deep Thought (Per Anhalter durch die Galaxis)</li>
|
||||||
|
<li {% if user_row[1] == "neuromancer" %} class="choice" {% endif %}>Neuromancer (Neuromancer)</li>
|
||||||
|
<li {% if user_row[1] == "samantha" %} class="choice" {% endif %}>Samantha (Her)</li>
|
||||||
|
<li {% if user_row[1] == "tars" %} class="choice" {% endif %}>TARS und CASE (Interstellar)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Welcher HTTP-Status trifft am häufigsten auf dich zu?</h2>
|
||||||
|
<ul>
|
||||||
|
<li {% if user_row[2] == "200" %} class="choice" {% endif %}>200 – OK</li>
|
||||||
|
<li {% if user_row[2] == "300" %} class="choice" {% endif %}>300 – Multiple Choices</li>
|
||||||
|
<li {% if user_row[2] == "301" %} class="choice" {% endif %}>301 – Moved Permanently</li>
|
||||||
|
<li {% if user_row[2] == "402" %} class="choice" {% endif %}>402 – Payment Required</li>
|
||||||
|
<li {% if user_row[2] == "404" %} class="choice" {% endif %}>404 – (Sleep) Not Found</li>
|
||||||
|
<li {% if user_row[2] == "408" %} class="choice" {% endif %}>408 – Request Timeout</li>
|
||||||
|
<li {% if user_row[2] == "418" %} class="choice" {% endif %}>418 – I'm a Teapot</li>
|
||||||
|
<li {% if user_row[2] == "450" %} class="choice" {% endif %}>450 – Blocked by Windows Parental Controls</li>
|
||||||
|
<li {% if user_row[2] == "451" %} class="choice" {% endif %}>451 – Unavailable for Legal Reasons</li>
|
||||||
|
<li {% if user_row[2] == "502" %} class="choice" {% endif %}>502 – Bad Gateway (Internetkurort)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Lieblingsgemüse</h2>
|
||||||
|
<ul>
|
||||||
|
<li {% if user_row[3] == "karotte" %} class="choice" {% endif %}>🥕 Karotte</li>
|
||||||
|
<li {% if user_row[3] == "broccoli" %} class="choice" {% endif %}>🥦 Brokkoli</li>
|
||||||
|
<li {% if user_row[3] == "aubergine" %} class="choice" {% endif %}>🍆 Aubergine</li>
|
||||||
|
<li {% if user_row[3] == "kartoffel" %} class="choice" {% endif %}>🥔 Kartoffel</li>
|
||||||
|
<li {% if user_row[3] == "bretzel" %} class="choice" {% endif %}>🥨 Bretzel</li>
|
||||||
|
<li {% if user_row[3] == "tomate" %} class="choice" {% endif %}>🍅 Tomate</li>
|
||||||
|
<li {% if user_row[3] == "chili" %} class="choice" {% endif %}>🌶️ Chili</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Spirit Animal</h2>
|
||||||
|
<ul>
|
||||||
|
<li {% if user_row[4] == "feuer" %} class="choice" {% endif %}>Feuerfuchs</li>
|
||||||
|
<li {% if user_row[4] == "wasser" %} class="choice" {% endif %}>Wasserhahn</li>
|
||||||
|
<li {% if user_row[4] == "erde" %} class="choice" {% endif %}>Erdferkel</li>
|
||||||
|
<li {% if user_row[4] == "luft" %} class="choice" {% endif %}>Luftschlange</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Bevorzugtes Betriebssystem</h2>
|
||||||
|
<ul>
|
||||||
|
<li {% if user_row[5] == "windows" %} class="choice" {% endif %}>Windows</li>
|
||||||
|
<li {% if user_row[5] == "mac" %} class="choice" {% endif %}>Mac</li>
|
||||||
|
<li {% if user_row[5] == "linux" %} class="choice" {% endif %}>Linux</li>
|
||||||
|
<li {% if user_row[5] == "glados" %} class="choice" {% endif %}>GLaDOS</li>
|
||||||
|
<li {% if user_row[5] == "kaffee" %} class="choice" {% endif %}>Kaffee</li>
|
||||||
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user