Commit 6202b25d authored by Kateřina Sloupová's avatar Kateřina Sloupová
Browse files

add examples of chosen tasks

parent 9a7200e2
......@@ -44,30 +44,34 @@ def compare():
checker = WebChecker(student_string=student_string, task=student_type)
task_solved = checker.compare(teacher_string=teacher_string, teacher_type=teacher_type)
if not checker.ok and checker.eq is not None: # TODO don't know wtf was bad
extra_word_ce = checker.eq.left_counterexample
missing_word_ce = checker.eq.right_counterexample
inf = checker.eq.inf
else:
extra_word_ce = None
missing_word_ce = None
inf = None
return render_template('result.html', compare=True, ok=checker.ok, inf=inf, task_solved=task_solved,
student_string=student_string, student_type=tasks[student_type],
teacher_string=teacher_string, teacher_type=types[teacher_type],
extra_word_ce=extra_word_ce, missing_word_ce=missing_word_ce)
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,
extra_word_ce=extra_word_ce, missing_word_ce=missing_word_ce,
is_task=is_task, teacher=teacher, student=student)
#flash(error)
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'))
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'))
return render_template('compare.html', student_form=student_form, teacher_form=teacher_form,
student_example=student_example, teacher_example=teacher_example)
......@@ -76,26 +80,29 @@ def compare():
@bp.route('/convert', methods=('GET', 'POST'))
def convert():
student_form = TypeForm(prefix='student_form')
task_form = TaskForm(prefix='task_form')
task_form = ConvertForm(prefix='task_form')
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
webchecker = WebChecker(student_string=student_string, task=task)
output = webchecker.convert(student_type=student_type)
checker = WebChecker(student_string=student_string, task=task)
output = checker.convert(student_type=student_type)
return render_template('result.html', compare=False, student_string=student_string,
student_type=types[student_type], task=tasks[task], output=output)
student = Language(string=student_string, task=student_type)
is_task = student.gen_is_task(task=task)
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'))
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'))
return render_template('convert.html', student_form=student_form, task_form=task_form, example=example)
......
......@@ -22,21 +22,21 @@ examples[('DFA', 'NFA')] = (teacher_dfa, student_nfa)
examples[('DFA', 'GRA')] = (teacher_dfa, student_gra)
examples[('DFA', 'REG')] = (teacher_dfa, student_reg)
examples[('EFA', 'DFA')] = (student_gra, student_dfa)
examples[('EFA', 'TOT')] = (student_gra, teacher_dfa_total)
examples[('EFA', 'MIN')] = (student_gra, teacher_dfa_total)
examples[('EFA', 'EFA')] = (student_gra, student_efa)
examples[('EFA', 'NFA')] = (student_gra, student_nfa)
examples[('EFA', 'GRA')] = (student_gra, student_gra)
examples[('EFA', 'REG')] = (student_gra, student_reg)
examples[('EFA', 'DFA')] = (teacher_efa, student_dfa)
examples[('EFA', 'TOT')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'MIN')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'EFA')] = (teacher_efa, student_efa)
examples[('EFA', 'NFA')] = (teacher_efa, student_nfa)
examples[('EFA', 'GRA')] = (teacher_efa, student_gra)
examples[('EFA', 'REG')] = (teacher_efa, student_reg)
examples[('GRA', 'DFA')] = (student_reg, student_dfa)
examples[('GRA', 'TOT')] = (student_reg, teacher_dfa_total)
examples[('GRA', 'MIN')] = (student_reg, teacher_dfa_total)
examples[('GRA', 'EFA')] = (student_reg, student_efa)
examples[('GRA', 'NFA')] = (student_reg, student_nfa)
examples[('GRA', 'GRA')] = (student_reg, student_gra)
examples[('GRA', 'REG')] = (student_reg, student_reg)
examples[('GRA', 'DFA')] = (student_gra, student_dfa)
examples[('GRA', 'TOT')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'MIN')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'EFA')] = (student_gra, student_efa)
examples[('GRA', 'NFA')] = (student_gra, student_nfa)
examples[('GRA', 'GRA')] = (student_gra, student_gra)
examples[('GRA', 'REG')] = (student_gra, student_reg)
examples[('REG', 'DFA')] = (student_reg, student_dfa)
examples[('REG', 'TOT')] = (student_reg, teacher_dfa_total)
......
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