Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
fja
eval
Commits
9a7200e2
Commit
9a7200e2
authored
Jul 06, 2020
by
Kateřina Sloupová
Browse files
add support for more detailed feedback on web
parent
cb1746ce
Changes
6
Hide whitespace changes
Inline
Side-by-side
evalweb/evalweb.py
View file @
9a7200e2
...
...
@@ -3,7 +3,7 @@ from flask_wtf import FlaskForm
from
wtforms
import
RadioField
import
sys
sys
.
path
.
append
(
'~/eval'
)
from
evalweb.web_checker
import
WebChecker
from
evalweb.web_checker
import
WebChecker
,
Language
from
evalweb.examples
import
examples
,
convert_examples
...
...
evalweb/templates/parsing_error.html
0 → 100644
View file @
9a7200e2
{% extends 'base.html' %}
{% block header %}
<h1>
{% block title %}
Výsledek
{% endblock %}
</h1>
{% endblock %}
{% block content %}
<br>
Vstupní formalismus nebyl správně zadán, nastala chyba při parsování.
<br><br>
{{ error }}
{% endblock %}
\ No newline at end of file
evalweb/templates/result.html
deleted
100644 → 0
View file @
cb1746ce
{% extends 'base.html' %}
{% block header %}
<h1>
{% block title %}
{% if compare %}Výsledek porovnání
{% else %}Výsledek převodu
{% endif %}
{% endblock %}
</h1>
{% endblock %}
{% block content %}
<br>
{% if compare %}
<label
for=
"teacher_string"
>
Zadání
</label><br>
<textarea
style=
"width:400px;"
name=
"teacher_string"
id=
"teacher_string"
>
{{ teacher_string }}
</textarea>
{{ teacher_type }}
{% endif %}
<br><label
for=
"student_string"
>
Můj vstup
</label><br>
<textarea
style=
"width:400px;"
name=
"student_string"
id=
"student_string"
>
{{ student_string }}
</textarea>
{{ student_type }}
{% if not compare %}
, převod na
{{ task }}
{% endif %}
<br><br>
{% if compare %}
{% if ok %}
Správné řešení, jazyky popisované oběma formalismy jsou ekvivalentní.
{% else %}
Špatné řešení. {{ task_solved }}
<br>
{% if extra_word_ce or missing_word_ce %}
Jazyky popisované oběma formalismy nejsou ekvivalentní.
<br>
{% if extra_word_ce %}
Příklad slova, které je ve studentově řešení a není v zadaném jazyce: {{ extra_word_ce }}
{% else %}
Studentovo řešení je podmnožinou zadaného jazyka.
{% endif %}
<br>
{% if missing_word_ce %}
Příklad slova, které chybí ve studentově řešení a je v zadaném jazyce: {{ missing_word_ce }}
{% else %}
Studentovo řešení je nadmnožinou zadaného jazyka.
{% endif %}
<br>
{% if inf %}
Rozdíl porovnávaných jazyků je nekonečný.
{% else %}
Rozdíl porovnávaných jazyků je konečný.
{% endif %}
{% endif %}
{% endif %}
{% else %}
<label
for=
"output"
>
Výsledek
</label><br>
<textarea
style=
"width:400px;"
name=
"output"
id=
"output"
>
{{ output }}
</textarea>
{% endif %}
{% endblock %}
\ No newline at end of file
evalweb/templates/result_compare.html
0 → 100644
View file @
9a7200e2
{% extends 'base.html' %}
{% block header %}
<h1>
{% block title %}
Výsledek porovnání
{% endblock %}
</h1>
{% endblock %}
{% block content %}
<br>
<div
style=
"text-align:center"
><h2>
Celkový výsledek:
{% if ok %} správné řešení.
{% else %} nesprávné řešení.
{% endif %}
</h2><br>
{{ task_solved }}
<br>
{% if ok %} Jazyky popisované oběma formalismy jsou ekvivalentní.
{% else %} {% if extra_word_ce or missing_word_ce %}
Jazyky popisované oběma formalismy nejsou ekvivalentní.
{% endif %}
{% endif %}
</div><br>
<div>
<div
style=
"float:left;"
><label
for=
"teacher_string"
><h3
style=
"text-align:center"
>
Jazyk zadání
</h3></label>
<div
style=
"width:400px;"
name=
"teacher_string"
id=
"teacher_string"
>
<b>
Charakteristika:
</b>
{{ teacher.inf }}
<br><br>
<b>
Příklad slova z jazyka:
</b>
{{ teacher.example }}
<br><br>
<b>
Původní popis:
</b>
<br>
{{ teacher.task }}: {{ teacher.string }}
<br><br>
<b>
Popis pomocí minimálního DFA:
</b>
<br>
{{ teacher.minimal }}
<br>
</div><br>
</div>
<div
style=
"float:right;"
><label
for=
"student_string"
><h3
style=
"text-align:center"
>
Jazyk mého řešení
</h3></label>
<div
style=
"width:400px;"
name=
"student_string"
id=
"student_string"
>
<b>
Charakteristika:
</b>
{{ student.inf }}
<br><br>
<b>
Příklad slova z jazyka:
</b>
{{ student.example }}
<br><br>
<b>
Původní popis:
</b>
<br>
{{ student.task }}: {{ student.string }}
<br><br>
<b>
Popis pomocí minimálního DFA:
</b>
<br>
{{ student.minimal }}
<br>
</div><br>
</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><hr>
<p>
<h3>
Porovnání jazyků
</h3>
{% if not ok and (extra_word_ce or missing_word_ce) %}
{% if extra_word_ce %}
Příklad slova, které je ve studentově řešení a není v zadaném jazyce: {{ extra_word_ce }}
{% else %}
Studentovo řešení je podmnožinou zadaného jazyka.
{% endif %}
<br>
{% if missing_word_ce %}
Příklad slova, které chybí ve studentově řešení a je v zadaném jazyce: {{ missing_word_ce }}
{% else %}
Studentovo řešení je nadmnožinou zadaného jazyka.
{% endif %}
<br>
{% if inf %}Rozdíl porovnávaných jazyků je nekonečný.
{% else %}Rozdíl porovnávaných jazyků je konečný.
{% endif %}
{% else %}
{% if ok %}
Jazyky jsou ekvivalentní.
{% endif %}
{% endif %}
</p>
<br><br>
<h3>
Vygenerovaný řetězec pro odpovědník
</h3>
{{ is_task }}
{% endblock %}
\ No newline at end of file
evalweb/templates/result_convert.html
0 → 100644
View file @
9a7200e2
{% extends 'base.html' %}
{% block header %}
<h1>
{% block title %}
Výsledek převodu
{% endblock %}
</h1>
{% endblock %}
{% block content %}
<br><label
for=
"student_string"
>
Můj vstup
</label><br>
<textarea
style=
"width:400px;"
name=
"student_string"
id=
"student_string"
>
{{ student_string }}
</textarea>
{{ student_type }}, převod na {{ task }}
<br><br>
<label
for=
"output"
>
Výsledek
</label><br>
<textarea
style=
"width:400px;"
name=
"output"
id=
"output"
>
{{ output }}
</textarea>
<br><br>
<h3>
Vygenerovaný řetězec pro odpovědník
</h3>
{{ is_task }}
{% endblock %}
\ No newline at end of file
evalweb/web_checker.py
View file @
9a7200e2
...
...
@@ -3,6 +3,32 @@ from lib.parsing.parser import Parser, ParsingError
import
signal
from
lib.checker
import
transform
,
dfa_transform
,
nfa_transform
,
check_task
,
check_alphabets
,
check_empty
class
Language
():
def
__init__
(
self
,
string
:
str
,
task
:
str
):
self
.
string
=
string
self
.
task
=
task
self
.
dfa
=
None
self
.
minimal
=
None
self
.
inf
=
"prázdný"
self
.
example
=
""
self
.
gen_lang_html
()
def
gen_lang_html
(
self
):
parser
=
Parser
()
dfa
=
dfa_transform
(
self
.
string
,
self
.
task
)
self
.
minimal
=
parser
.
dfa_to_str
(
dfa
.
minimize
().
canonize
())
empty
=
dfa
.
is_empty
()
if
empty
.
inf
is
not
None
:
self
.
inf
=
"nekonečný"
if
empty
.
inf
else
"konečný"
self
.
example
=
empty
.
counterexample
self
.
dfa
=
parser
.
dfa_to_str
(
dfa
.
canonize
())
def
gen_is_task
(
self
,
task
:
str
)
->
str
:
teacher
=
"NFA"
if
self
.
task
==
"EFA"
else
self
.
task
return
f
"
{
teacher
}
-
{
task
}
-N:
{
self
.
dfa
}
"
class
WebChecker
():
def
__init__
(
self
,
student_string
:
str
,
task
:
str
):
...
...
@@ -18,20 +44,23 @@ class WebChecker():
teacher_dfa
=
dfa_transform
(
teacher_string
,
teacher_type
)
except
ParsingError
as
ex
:
return
(
"Chyba při parsování."
)
return
(
ex
.
args
)
task_solved
=
""
if
isinstance
(
student_solution
,
reg
.
DFA
)
or
isinstance
(
student_solution
,
reg
.
NFA
):
task_solved
=
check_task
(
student_solution
,
task
)
check_empty
(
student_solution
=
student_dfa
,
teacher_solution
=
teacher_dfa
)
if
teacher_dfa
.
is_empty
()
and
student_dfa
.
is_empty
():
self
.
ok
=
True
return
""
alphabets
=
check_alphabets
(
student_alpha
=
student_dfa
.
characters
,
teacher_alpha
=
teacher_dfa
.
characters
,
task
=
task
)
# TODO return alphabets
if
alphabets
!=
""
:
return
alphabets
task_solved
=
""
if
isinstance
(
student_solution
,
reg
.
DFA
)
or
isinstance
(
student_solution
,
reg
.
NFA
):
task_solved
=
check_task
(
student_solution
,
task
)
self
.
eq
=
reg
.
DFA
.
is_equivalent
(
student_dfa
,
teacher_dfa
)
if
task_solved
==
""
and
self
.
eq
:
self
.
ok
=
True
...
...
@@ -61,7 +90,7 @@ class WebChecker():
if
self
.
task
==
"TOT"
:
return
parser
.
dfa_to_str
(
dfa
.
total
())
if
self
.
task
==
"MIN"
:
return
parser
.
dfa_to_str
(
dfa
.
minimize
())
return
parser
.
dfa_to_str
(
dfa
.
minimize
()
.
canonize
()
)
#if canonize: TODO checkbox
# return parser.dfa_to_str(automaton.canonize())
...
...
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