Commit 736c5265 authored by Kateřina Sloupová's avatar Kateřina Sloupová
Browse files

pre-support of formalism examples providing

parent 2a742b78
......@@ -4,6 +4,7 @@ from wtforms import RadioField
import sys
sys.path.append('~/eval')
from evalweb.web_checker import WebChecker
from evalweb.examples import examples, convert_examples
bp = Blueprint('eval', __name__, url_prefix='/')
......@@ -35,7 +36,7 @@ def compare():
student_form = TaskForm(prefix='student_form')
teacher_form = TypeForm(prefix='teacher_form')
if request.method == 'POST':
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
......@@ -59,13 +60,25 @@ def compare():
extra_word_ce=extra_word_ce, missing_word_ce=missing_word_ce)
flash(error)
return render_template('compare.html', student_form=student_form, teacher_form=teacher_form)
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'))
return render_template('compare.html', student_form=student_form, teacher_form=teacher_form,
student_example=student_example, teacher_example=teacher_example)
@bp.route('/convert', methods=('GET', 'POST'))
def convert():
student_form = TypeForm(prefix='student_form')
task_form = TaskForm(prefix='task_form')
if request.method == 'POST':
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
......@@ -77,7 +90,14 @@ def convert():
student_type=types[student_type], task=tasks[task], output=output)
flash(error)
return render_template('convert.html', student_form=student_form, task_form=task_form)
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'))
return render_template('convert.html', student_form=student_form, task_form=task_form, example=example)
@bp.route('/userref')
......
from typing import Dict, Tuple
from lib.parsing.parser import Parser
parser = Parser()
examples: Dict[Tuple[str, str], Tuple[str, str]] = {}
convert_examples: Dict[str, str] = {}
teacher_dfa = "(0,a)=1 (1,b)=0 final={0}"
student_dfa = "(A,a)=B (B,b)=C (C,a)=B final={A,C}"
teacher_dfa_total = parser.dfa_to_str(parser.str_to_dfa(teacher_dfa).total())
teacher_efa = "(A,a)={B} (A,\e)={D} (B,b)={A} final={A,D}"
student_nfa = parser.nfa_to_str(parser.str_to_nfa(teacher_efa).eliminate_epsilon())
student_gra = "S -> aS' | \e\nS' -> bA | b\nA -> aS'"
student_reg = "(ab)^*"
student_efa = "(A,a)={B} (A,\e)={D} (B,b)={C} (C,a)={B} final={C,D}"
examples[('DFA', 'DFA')] = (teacher_dfa, student_dfa)
examples[('DFA', 'TOT')] = (teacher_dfa, teacher_dfa_total)
examples[('DFA', 'MIN')] = (teacher_dfa, teacher_dfa_total)
examples[('DFA', 'EFA')] = (teacher_dfa, student_efa)
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[('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[('REG', 'DFA')] = (student_reg, student_dfa)
examples[('REG', 'TOT')] = (student_reg, teacher_dfa_total)
examples[('REG', 'MIN')] = (student_reg, teacher_dfa_total)
examples[('REG', 'EFA')] = (student_reg, student_efa)
examples[('REG', 'NFA')] = (student_reg, student_nfa)
examples[('REG', 'GRA')] = (student_reg, student_gra)
examples[('REG', 'REG')] = (student_reg, student_reg)
convert_examples['DFA'] = teacher_dfa
convert_examples['EFA'] = student_nfa
convert_examples['GRA'] = student_gra
convert_examples['REG'] = student_reg
\ No newline at end of file
......@@ -6,11 +6,13 @@
{% block content %}
<form method="post">
<input type="submit" name="example_button" value="Vlož příklady ke zvoleným typům">
<label for="teacher_string">Zadání</label>
<div>
<div style="width:400px; float:right;">
<textarea style="width:400px;" name="teacher_string" id="teacher_string">{{ request.form['teacher_string'] }}</textarea></div>
<textarea style="width:400px;" name="teacher_string" id="teacher_string">{{ teacher_example }}{{ request.form['teacher_string'] }}</textarea></div>
{{ teacher_form.hidden_tag() }}
<div style="float:left;">{{ teacher_form.make }}</div>
</div>
......@@ -18,12 +20,12 @@
<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">{{ request.form['student_string'] }}</textarea></div>
<textarea style="width:400px;" name="student_string" id="student_string">{{ student_example }}{{ request.form['student_string'] }}</textarea></div>
{{ student_form.hidden_tag() }}
<div style="float:left;">{{ student_form.make }}</div>
</div>
<input type="submit" value="Porovnej">
<input type="submit" name="submit_button" value="Porovnej">
</form>
Tento mód simuluje vyhodnocení odpovědníku v IS MU. Máte-li k dispozici správné řešení úlohy, můžete jej porovnat s vaším výsledkem.
......
......@@ -8,10 +8,11 @@
{% block content %}
<form method="post">
<input type="submit" name="example_button" value="Vlož příklad zvoleného typu">
<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">{{ request.form['student_string'] }}</textarea></div>
<textarea style="width:400px;" name="student_string" id="student_string">{{ example }}{{ request.form['student_string'] }}</textarea></div>
{{ student_form.hidden_tag() }}
<div style="float:left;">{{ student_form.make }}</div>
</div>
......@@ -19,7 +20,8 @@
<label>Převeď na typ</label><br>
{{ task_form.hidden_tag() }}
{{ task_form.make }}
<input type="submit" value="Převeď">
<input type="submit" name="submit_button" value="Převeď">
</form>
{% endblock %}
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