Commit 22ba6ba7 authored by Kateřina Sloupová's avatar Kateřina Sloupová
Browse files

fix textareas in html

parent 45064bc4
......@@ -45,57 +45,55 @@ class ConvertForm(FlaskForm):
def compare():
student_form = TaskForm(prefix='student_form')
teacher_form = TypeForm(prefix='teacher_form')
student_area = ""
teacher_area = ""
if request.method == 'POST' and 'submit_button' in request.form:
teacher_type = teacher_form.make.data
teacher_string = request.form['teacher_string']
student_type = student_form.make.data
student_string = request.form['student_string']
student_area = student_string
teacher_area = teacher_string
checker = WebChecker(student_string=student_string, task=student_type)
task_solved = checker.compare(teacher_string=teacher_string, teacher_type=teacher_type)
if not isinstance(task_solved, str):
return render_template('parsing_error.html', error=task_solved)
neq = not checker.ok and checker.eq is not None
extra_word_ce = checker.eq.left_counterexample if neq else None
missing_word_ce = checker.eq.right_counterexample if neq else None
inf = checker.eq.inf if neq else None
if task_solved == "":
task_solved = "Odpověď splňuje požadovaný formalismus."
teacher = Language(string=teacher_string, task=teacher_type)
student = Language(string=student_string, task=student_type)
is_task = teacher.gen_is_task(task=student_type)
return render_template('result_compare.html', compare=True, ok=checker.ok,
inf=inf, task_solved=task_solved,
result = checker.compare(teacher_string=teacher_string, teacher_type=teacher_type)
if not isinstance(result, bool):
return render_template('parsing_error.html', error=result)
extra_word_ce, missing_word_ce, inf = None, None, None
if not result and checker.eq is not None:
extra_word_ce = checker.eq.left_counterexample
missing_word_ce = checker.eq.right_counterexample
inf = checker.eq.inf
return render_template('result_compare.html', compare=True, ok=result,
inf=inf, task_solved=checker.task_solved, alphabets=checker.alphabets,
extra_word_ce=extra_word_ce, missing_word_ce=missing_word_ce,
is_task=is_task, teacher=teacher, student=student)
#flash(error)
is_task=checker.is_task, img_src=checker.img_src,
teacher=checker.teacher, student=checker.student)
student_example = ""
teacher_example = ""
if request.method == 'POST' and 'example_button' in request.form:
teacher_type = teacher_form.make.data
student_type = student_form.make.data
if (teacher_type, student_type) in examples:
teacher_example, student_example = examples[(teacher_type, student_type)]
#return redirect(url_for('eval.compare'))
teacher_area, student_area = examples[(teacher_type, student_type)]
return render_template('compare.html', student_form=student_form, teacher_form=teacher_form,
student_example=student_example, teacher_example=teacher_example)
student_area=student_area, teacher_area=teacher_area)
@bp.route('/convert', methods=('GET', 'POST'))
def convert():
student_form = TypeForm(prefix='student_form')
task_form = ConvertForm(prefix='task_form')
student_area = ""
if request.method == 'POST' and 'submit_button' in request.form:
student_string = request.form['student_string']
student_type = student_form.make.data
task = task_form.make.data
student_area = student_string
checker = WebChecker(student_string=student_string, task=task)
output = checker.convert(student_type=student_type)
......@@ -105,16 +103,13 @@ def convert():
return render_template('result_convert.html', compare=False, student_string=student_string,
student_type=types[student_type], task=tasks[task], output=output, is_task=is_task)
#flash(error)
example = ""
if request.method == 'POST' and 'example_button' in request.form:
student_type = student_form.make.data
if student_type in convert_examples:
example = convert_examples[student_type]
#return redirect(url_for('eval.convert'))
student_area = convert_examples[student_type]
return render_template('convert.html', student_form=student_form, task_form=task_form, example=example)
return render_template('convert.html', student_form=student_form, task_form=task_form, student_area=student_area)
@bp.route('/userref')
......
......@@ -12,7 +12,7 @@
<label for="teacher_string">Zadání</label>
<div>
<div style="width:400px; float:right;">
<textarea style="width:400px;" name="teacher_string" id="teacher_string">{{ teacher_example }}{{ request.form['teacher_string'] }}</textarea></div>
<textarea style="width:400px;" name="teacher_string" id="teacher_string">{{ teacher_area }}</textarea></div>
{{ teacher_form.hidden_tag() }}
<div style="float:left;">{{ teacher_form.make }}</div>
</div>
......@@ -20,7 +20,7 @@
<label for="student_string">Moje řešení</label><br>
<div>
<div style="width:400px; float:right;">
<textarea style="width:400px;" name="student_string" id="student_string">{{ student_example }}{{ request.form['student_string'] }}</textarea></div>
<textarea style="width:400px;" name="student_string" id="student_string">{{ student_area }}</textarea></div>
{{ student_form.hidden_tag() }}
<div style="float:left;">{{ student_form.make }}</div>
</div>
......
......@@ -12,7 +12,7 @@
<label for="student_string">Můj vstup typu</label><br>
<div>
<div style="width:400px; float:right;">
<textarea style="width:400px;" name="student_string" id="student_string">{{ example }}{{ request.form['student_string'] }}</textarea></div>
<textarea style="width:400px;" name="student_string" id="student_string">{{ student_area }}</textarea></div>
{{ student_form.hidden_tag() }}
<div style="float:left;">{{ student_form.make }}</div>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment