Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Réouven ASSOULY
zesje
Commits
a76d6c0a
Commit
a76d6c0a
authored
Apr 05, 2018
by
Thomas Roos
Browse files
Patrial solutions api and integration, will sqaush this commit
parent
cce8d073
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/views/grade/FeedbackBlock.jsx
View file @
a76d6c0a
...
...
@@ -16,6 +16,10 @@ class FeedbackBlock extends React.Component {
})
}
componentDidMount
=
()
=>
{
console
.
log
(
'
mounting!
'
+
this
.
props
.
feedback
.
id
)
}
render
()
{
const
score
=
this
.
props
.
feedback
.
score
;
...
...
@@ -29,10 +33,13 @@ class FeedbackBlock extends React.Component {
{
this
.
props
.
feedback
.
name
}
</
span
>
<
div
className
=
"field is-grouped"
>
<
div
className
=
"control"
onMouseEnter
=
{
this
.
enter
}
onMouseLeave
=
{
this
.
leave
}
>
<
div
className
=
"control"
>
<
div
className
=
"tags has-addons"
>
{
score
?
<
span
className
=
"tag is-link"
>
{
this
.
props
.
feedback
.
score
}
</
span
>
:
null
}
<
span
className
=
{
"
tag
"
+
(
this
.
state
.
hover
?
"
is-white
"
:
""
)
}
onClick
=
{
()
=>
console
.
log
(
'
pencil click
'
)
}
>
<
i
className
=
"fa fa-pencil"
></
i
></
span
>
<
span
className
=
{
"
tag
"
+
(
this
.
state
.
hover
?
"
is-white
"
:
""
)
}
onMouseEnter
=
{
this
.
enter
}
onMouseLeave
=
{
this
.
leave
}
onClick
=
{
()
=>
console
.
log
(
'
pencil click
'
)
}
>
<
i
className
=
"fa fa-pencil"
></
i
>
</
span
>
</
div
>
</
div
>
</
div
>
...
...
client/views/grade/FeedbackPanel.jsx
View file @
a76d6c0a
...
...
@@ -32,6 +32,15 @@ class FeedbackPanel extends React.Component {
}
}
shouldComponentUpdate
=
(
nextProps
,
nextState
)
=>
{
if
(
this
.
props
.
problem
!==
nextProps
.
problem
||
this
.
state
.
feedback
!=
nextState
.
feedback
)
{
return
true
;
}
else
{
console
.
log
(
'
halting re-render
'
)
return
false
;
}
}
render
()
{
return
(
...
...
zesje/api.py
View file @
a76d6c0a
...
...
@@ -12,6 +12,7 @@ from .resources import summary_plot
from
.resources
import
export
from
.resources.problems
import
Problems
from
.resources.feedback
import
Feedback
from
.resources.solutions
import
Solutions
api_bp
=
Blueprint
(
__name__
,
__name__
)
...
...
@@ -34,6 +35,7 @@ api.add_resource(Submissions,
'/submissions/<int:exam_id>/<int:submission_id>'
)
api
.
add_resource
(
Problems
,
'/problems/<int:exam_id>'
)
api
.
add_resource
(
Feedback
,
'/feedback/<int:problem_id>'
)
api
.
add_resource
(
Solutions
,
'/solution/<int:exam_id>/<int:submission_id>/<int:problem_id>'
)
# Other resources that don't return JSON
...
...
@@ -48,7 +50,7 @@ api_bp.add_url_rule(
)
api_bp
.
add_url_rule
(
'/images/solutions/<int:exam_id>/<int:problem_id>/<int:submission_id>'
,
'solution'
,
'solution
_image
'
,
images
.
get
,
)
api_bp
.
add_url_rule
(
...
...
zesje/resources/solutions.py
0 → 100644
View file @
a76d6c0a
""" REST api for solutions """
from
flask_restful
import
Resource
,
reqparse
from
datetime
import
datetime
from
pony
import
orm
from
..models
import
Exam
,
Submission
,
Problem
,
Solution
,
FeedbackOption
class
Solutions
(
Resource
):
""" Solution provided on a specific problem and exam """
@
orm
.
db_session
def
get
(
self
,
exam_id
,
submission_id
,
problem_id
):
"""get solution to problem
Returns
-------
feedback: list of int (IDs of FeedbackOption)
gradedBy: grader
gradedAt: datetime
imagePath: string (url)
remarks: string
"""
problem
=
Problem
[
problem_id
]
exam
=
Exam
[
exam_id
]
sub
=
Submission
.
get
(
exam
=
exam
,
copy_number
=
submission_id
)
if
not
sub
:
raise
orm
.
core
.
ObjectNotFound
(
Submission
)
solution
=
Solution
.
get
(
submission
=
sub
,
problem
=
problem
)
if
not
solution
:
raise
orm
.
core
.
ObjectNotFound
(
Solution
)
return
{
'feedback'
:
[
fb
.
id
for
fb
in
solution
.
feedback
],
'gradedBy'
:
solution
.
graded_by
,
'gradedAt'
:
solution
.
graded_at
.
isoformat
(),
'imagePath'
:
solution
.
image_path
,
'remarks'
:
solution
.
remarks
}
put_parser
=
reqparse
.
RequestParser
()
put_parser
.
add_argument
(
'id'
,
type
=
int
,
required
=
True
)
@
orm
.
db_session
def
put
(
self
,
exam_id
,
submission_id
,
problem_id
):
"""Toggles an existing feedback option
Parameters
----------
id: int
Returns
-------
state: boolean
"""
problem
=
Problem
[
problem_id
]
exam
=
Exam
[
exam_id
]
sub
=
Submission
.
get
(
exam
=
exam
,
copy_number
=
submission_id
)
if
not
sub
:
raise
orm
.
core
.
ObjectNotFound
(
Submission
)
solution
=
Solution
.
get
(
submission
=
sub
,
problem
=
problem
)
if
not
solution
:
raise
orm
.
core
.
ObjectNotFound
(
Solution
)
args
=
self
.
put_parser
.
parse_args
()
fb
=
FeedbackOption
.
get
(
id
=
args
.
id
)
if
not
fb
:
raise
orm
.
core
.
ObjectNotFound
(
FeedbackOption
)
solution
.
graded_at
=
datetime
.
now
()
if
fb
in
solution
.
feedback
:
solution
.
feedback
.
remove
(
fb
)
return
{
'state'
:
False
}
else
:
solution
.
feedback
.
add
(
fb
)
return
{
'state'
:
True
}
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