Skip to content
Snippets Groups Projects
Commit 9d8745d8 authored by Thomas Roos's avatar Thomas Roos
Browse files

Add fish virtualenv file to gitignore

Patrial solutions api and integration, will sqaush this commit
parent cce8d073
No related branches found
No related tags found
No related merge requests found
......@@ -77,5 +77,8 @@ __pycache__/
# vscode folder
.vscode
# Fish Virtualenv
.venv
# development data
data-dev
......@@ -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>
......
......@@ -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 (
......
......@@ -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(
......
""" 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 }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment