Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
fja
eval
Commits
6202b25d
Commit
6202b25d
authored
Jul 06, 2020
by
Kateřina Sloupová
Browse files
add examples of chosen tasks
parent
9a7200e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
evalweb/evalweb.py
View file @
6202b25d
...
...
@@ -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
=
Task
Form
(
prefix
=
'task_form'
)
task_form
=
Convert
Form
(
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
web
checker
=
WebChecker
(
student_string
=
student_string
,
task
=
task
)
output
=
web
checker
.
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
)
...
...
evalweb/examples.py
View file @
6202b25d
...
...
@@ -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_gr
a
,
student_dfa
)
examples
[(
'EFA'
,
'TOT'
)]
=
(
student_gr
a
,
teacher_dfa_total
)
examples
[(
'EFA'
,
'MIN'
)]
=
(
student_gr
a
,
teacher_dfa_total
)
examples
[(
'EFA'
,
'EFA'
)]
=
(
student_gr
a
,
student_efa
)
examples
[(
'EFA'
,
'NFA'
)]
=
(
student_gr
a
,
student_nfa
)
examples
[(
'EFA'
,
'GRA'
)]
=
(
student_gr
a
,
student_gra
)
examples
[(
'EFA'
,
'REG'
)]
=
(
student_gr
a
,
student_reg
)
examples
[(
'EFA'
,
'DFA'
)]
=
(
teacher_ef
a
,
student_dfa
)
examples
[(
'EFA'
,
'TOT'
)]
=
(
teacher_ef
a
,
teacher_dfa_total
)
examples
[(
'EFA'
,
'MIN'
)]
=
(
teacher_ef
a
,
teacher_dfa_total
)
examples
[(
'EFA'
,
'EFA'
)]
=
(
teacher_ef
a
,
student_efa
)
examples
[(
'EFA'
,
'NFA'
)]
=
(
teacher_ef
a
,
student_nfa
)
examples
[(
'EFA'
,
'GRA'
)]
=
(
teacher_ef
a
,
student_gra
)
examples
[(
'EFA'
,
'REG'
)]
=
(
teacher_ef
a
,
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment