diff --git a/client/views/grade/FeedbackPanel.jsx b/client/views/grade/FeedbackPanel.jsx index 57ae6aee543c17bcccf32e6a8a788ea9f23415a6..ee5266e6f25447fdb6dcbc3040666bb411f09e98 100644 --- a/client/views/grade/FeedbackPanel.jsx +++ b/client/views/grade/FeedbackPanel.jsx @@ -69,6 +69,7 @@ class FeedbackPanel extends React.Component { } saveRemark = () => { + if (!this.props.solution.graded_at && this.state.remark.replace(/\s/g, '').length === 0) return api.post('solution/' + this.props.examID + '/' + this.props.submissionID + '/' + this.props.problem.id, { remark: this.state.remark, graderID: this.props.graderID diff --git a/zesje/api/solutions.py b/zesje/api/solutions.py index bc5449bf12209816ed012c2acc3e8402396ff897..bd71281de80861212f5d27c96d2e2ef891aaa067 100644 --- a/zesje/api/solutions.py +++ b/zesje/api/solutions.py @@ -78,9 +78,15 @@ class Solutions(Resource): if not solution: raise orm.core.ObjectNotFound(Solution) - solution.graded_at = datetime.now() + graded = len(solution.feedback) + len(args.remark) + solution.remarks = args.remark - solution.graded_by = grader + if graded: + solution.graded_at = datetime.now() + solution.graded_by = grader + else: + solution.graded_at = None + solution.graded_by = None return True @@ -126,7 +132,9 @@ class Solutions(Resource): solution.feedback.add(fb) state = True - if len(solution.feedback): + graded = len(solution.feedback) + len(solution.remarks) + + if graded: solution.graded_at = datetime.now() solution.graded_by = grader else: