Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
67c13517
Commit
67c13517
authored
Oct 11, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display proper status indication after validation for each input line
parent
3a59c04e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
15 deletions
+37
-15
src/backend/backend.py
src/backend/backend.py
+8
-3
src/frontend/css/editor.css
src/frontend/css/editor.css
+4
-0
src/frontend/js/editor.js
src/frontend/js/editor.js
+24
-9
src/validation.py
src/validation.py
+1
-3
static/img/error.png
static/img/error.png
+0
-0
No files found.
src/backend/backend.py
View file @
67c13517
...
...
@@ -16,7 +16,7 @@ from tornado.web import RequestHandler, Application
from
src.parser
import
Parser
from
tests.parser
import
ParserWrapper
from
src.validation
import
validate
as
validate_expression
from
src.validation
import
validate
as
validate_expression
,
VALIDATE_SUCCESS
import
sys
import
traceback
...
...
@@ -134,6 +134,8 @@ class Validate(RequestHandler):
break
status
=
[]
# Validate each none empty line with the following none empty line.
for
i
in
range
(
i
+
1
,
len
(
lines
)):
line
=
lines
[
i
].
strip
()
...
...
@@ -142,13 +144,16 @@ class Validate(RequestHandler):
skipped
+=
1
continue
if
not
validate_expression
(
last_line
,
line
):
last_status
=
validate_expression
(
last_line
,
line
)
status
.
append
(
last_status
)
if
not
last_status
:
i
-=
1
break
last_line
=
line
self
.
write
({
'validated'
:
i
-
skipped
})
self
.
write
({
'validated'
:
i
-
skipped
,
'status'
:
status
})
except
Exception
as
e
:
i
-=
1
self
.
write
(
format_exception
(
e
)
+
{
'validated'
:
i
-
skipped
})
...
...
src/frontend/css/editor.css
View file @
67c13517
...
...
@@ -77,6 +77,10 @@ body {
background-image
:
url(/static/img/cross.png)
;
}
#math
.box.no-progress
{
background-image
:
url(/static/img/error.png)
;
}
#math
.hint
{
padding
:
10px
15px
0
40px
;
background
:
url(/static/img/info.png)
no-repeat
scroll
15px
13px
transparent
;
...
...
src/frontend/js/editor.js
View file @
67c13517
...
...
@@ -260,18 +260,33 @@
var
i
=
0
;
// Mark every line as correct (and remove previous class names).
for
(;
i
<
math_lines
.
length
&&
i
<=
response
.
validated
;
i
++
)
$
(
math_lines
[
i
]).
removeClass
(
'
wrong
'
).
addClass
(
'
correct
'
);
// Remove the status indicator from all remaining lines.
for
(;
i
<
math_lines
.
length
;
i
++
)
{
$
(
math_lines
[
i
])
.
removeClass
(
'
correct
'
)
.
removeClass
(
'
wrong
'
)
.
removeClass
(
'
no-progress
'
);
}
i
=
0
;
// Check if the first line has a correct syntax, since there is
// nothing to validate here.
if
(
i
<
math_lines
.
length
&&
i
<=
response
.
validated
)
{
$
(
math_lines
[
i
]).
addClass
(
'
correct
'
);
i
++
;
}
// Mark every line as {wrong,no-progress,correct,error}.
for
(;
i
<
math_lines
.
length
&&
i
<=
response
.
validated
;
i
++
)
{
status_classes
=
[
'
wrong
'
,
'
no-progress
'
,
'
correct
'
,
'
error
'
];
status_class
=
status_classes
[
response
.
status
[
i
-
1
]];
$
(
math_lines
[
i
]).
addClass
(
status_class
);
}
if
(
i
<
math_lines
.
length
)
{
// Mark the current line as wrong.
$
(
math_lines
[
i
]).
removeClass
(
'
correct
'
).
addClass
(
'
wrong
'
);
// Remove the status indicator from the remaining lines.
for
(
i
+=
1
;
i
<
math_lines
.
length
;
i
++
)
$
(
math_lines
[
i
]).
removeClass
(
'
correct
'
)
.
removeClass
(
'
wrong
'
);
$
(
math_lines
[
i
]).
addClass
(
'
wrong
'
);
}
hide_loader
();
...
...
src/validation.py
View file @
67c13517
...
...
@@ -13,8 +13,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with TRS. If not, see <http://www.gnu.org/licenses/>.
from
parser
import
Parser
,
MAXIMUM_REWRITE_STEPS
from
possibilities
import
apply_suggestion
from
strategy
import
find_possibilities
from
tests.parser
import
ParserWrapper
...
...
@@ -35,7 +33,7 @@ def validate(a, b):
b
=
parser
.
run
([
b
])
if
a
.
equals
(
b
):
return
VALIDAT
ION
_NOPROGRESS
return
VALIDAT
E
_NOPROGRESS
# Evaluate a and b, counting the number of steps
# Optimization: if b is encountered while evaluating a, return
...
...
static/img/error.png
0 → 100644
View file @
67c13517
666 Bytes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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