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

add examples of chosen tasks

parent 9a7200e2
Loading
Loading
Loading
Loading
+37 −30
Original line number Original line Diff line number Diff line
@@ -44,30 +44,34 @@ def compare():


        checker = WebChecker(student_string=student_string, task=student_type)
        checker = WebChecker(student_string=student_string, task=student_type)
        task_solved = checker.compare(teacher_string=teacher_string, teacher_type=teacher_type)
        task_solved = checker.compare(teacher_string=teacher_string, teacher_type=teacher_type)

        if not isinstance(task_solved, str):
        if not checker.ok and checker.eq is not None: # TODO don't know wtf was bad
            return render_template('parsing_error.html', error=task_solved)
            extra_word_ce = checker.eq.left_counterexample

            missing_word_ce = checker.eq.right_counterexample
        neq = not checker.ok and checker.eq is not None
            inf = checker.eq.inf
        extra_word_ce = checker.eq.left_counterexample if neq else None
        else:
        missing_word_ce = checker.eq.right_counterexample if neq else None
            extra_word_ce = None
        inf = checker.eq.inf if neq else None
            missing_word_ce = None
        if task_solved == "":
            inf = None
            task_solved = "Odpověď splňuje požadovaný formalismus."


        return render_template('result.html', compare=True, ok=checker.ok, inf=inf, task_solved=task_solved,
        teacher = Language(string=teacher_string, task=teacher_type)
                               student_string=student_string, student_type=tasks[student_type],
        student = Language(string=student_string, task=student_type)
                               teacher_string=teacher_string, teacher_type=types[teacher_type],
        is_task = teacher.gen_is_task(task=student_type)
                               extra_word_ce=extra_word_ce, missing_word_ce=missing_word_ce)

        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)
        #flash(error)


    student_example = ""
    student_example = ""
    teacher_example = ""
    teacher_example = ""
    # if request.method == 'POST' and 'example_button' in request.form:
    if request.method == 'POST' and 'example_button' in request.form:
    #     teacher_type = teacher_form.make.data
        teacher_type = teacher_form.make.data
    #     student_type = student_form.make.data
        student_type = student_form.make.data
    #     if (teacher_type, student_type) in examples:
        if (teacher_type, student_type) in examples:
    #         teacher_example, student_example = examples[(teacher_type, student_type)]
            teacher_example, student_example = examples[(teacher_type, student_type)]
    #     #return redirect(url_for('eval.compare'))
        #return redirect(url_for('eval.compare'))


    return render_template('compare.html', student_form=student_form, teacher_form=teacher_form,
    return render_template('compare.html', student_form=student_form, teacher_form=teacher_form,
                           student_example=student_example, teacher_example=teacher_example)
                           student_example=student_example, teacher_example=teacher_example)
@@ -76,26 +80,29 @@ def compare():
@bp.route('/convert', methods=('GET', 'POST'))
@bp.route('/convert', methods=('GET', 'POST'))
def convert():
def convert():
    student_form = TypeForm(prefix='student_form')
    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:
    if request.method == 'POST' and 'submit_button' in request.form:
        student_string = request.form['student_string']
        student_string = request.form['student_string']
        student_type = student_form.make.data
        student_type = student_form.make.data
        task = task_form.make.data
        task = task_form.make.data


        webchecker = WebChecker(student_string=student_string, task=task)
        checker = WebChecker(student_string=student_string, task=task)
        output = webchecker.convert(student_type=student_type)
        output = checker.convert(student_type=student_type)


        return render_template('result.html', compare=False, student_string=student_string,
        student = Language(string=student_string, task=student_type)
                               student_type=types[student_type], task=tasks[task], output=output)
        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)
        #flash(error)


    example = ""
    example = ""
    # if request.method == 'POST' and 'example_button' in request.form:
    if request.method == 'POST' and 'example_button' in request.form:
    #     student_type = student_form.make.data
        student_type = student_form.make.data
    #     if student_type in convert_examples:
        if student_type in convert_examples:
    #         example = convert_examples[student_type]
            example = convert_examples[student_type]
    #     #return redirect(url_for('eval.convert'))
        #return redirect(url_for('eval.convert'))


    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, example=example)


+14 −14
Original line number Original line Diff line number Diff line
@@ -22,21 +22,21 @@ examples[('DFA', 'NFA')] = (teacher_dfa, student_nfa)
examples[('DFA', 'GRA')] = (teacher_dfa, student_gra)
examples[('DFA', 'GRA')] = (teacher_dfa, student_gra)
examples[('DFA', 'REG')] = (teacher_dfa, student_reg)
examples[('DFA', 'REG')] = (teacher_dfa, student_reg)


examples[('EFA', 'DFA')] = (student_gra, student_dfa)
examples[('EFA', 'DFA')] = (teacher_efa, student_dfa)
examples[('EFA', 'TOT')] = (student_gra, teacher_dfa_total)
examples[('EFA', 'TOT')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'MIN')] = (student_gra, teacher_dfa_total)
examples[('EFA', 'MIN')] = (teacher_efa, teacher_dfa_total)
examples[('EFA', 'EFA')] = (student_gra, student_efa)
examples[('EFA', 'EFA')] = (teacher_efa, student_efa)
examples[('EFA', 'NFA')] = (student_gra, student_nfa)
examples[('EFA', 'NFA')] = (teacher_efa, student_nfa)
examples[('EFA', 'GRA')] = (student_gra, student_gra)
examples[('EFA', 'GRA')] = (teacher_efa, student_gra)
examples[('EFA', 'REG')] = (student_gra, student_reg)
examples[('EFA', 'REG')] = (teacher_efa, student_reg)


examples[('GRA', 'DFA')] = (student_reg, student_dfa)
examples[('GRA', 'DFA')] = (student_gra, student_dfa)
examples[('GRA', 'TOT')] = (student_reg, teacher_dfa_total)
examples[('GRA', 'TOT')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'MIN')] = (student_reg, teacher_dfa_total)
examples[('GRA', 'MIN')] = (student_gra, teacher_dfa_total)
examples[('GRA', 'EFA')] = (student_reg, student_efa)
examples[('GRA', 'EFA')] = (student_gra, student_efa)
examples[('GRA', 'NFA')] = (student_reg, student_nfa)
examples[('GRA', 'NFA')] = (student_gra, student_nfa)
examples[('GRA', 'GRA')] = (student_reg, student_gra)
examples[('GRA', 'GRA')] = (student_gra, student_gra)
examples[('GRA', 'REG')] = (student_reg, student_reg)
examples[('GRA', 'REG')] = (student_gra, student_reg)


examples[('REG', 'DFA')] = (student_reg, student_dfa)
examples[('REG', 'DFA')] = (student_reg, student_dfa)
examples[('REG', 'TOT')] = (student_reg, teacher_dfa_total)
examples[('REG', 'TOT')] = (student_reg, teacher_dfa_total)