Commit f46777e7 authored by Adrià Labay's avatar Adrià Labay
Browse files

disable anonymous grading after sending emails

parent f84a2c56
......@@ -160,6 +160,23 @@ class EmailEveryoneControls extends React.Component {
sending: false
}
disableAnonymousMode = () => {
api.put(`exams/${this.props.examID}`, {grade_anonymous: false}).then(resp => {
if (resp.changed) {
Notification.info(
<div>
<p>
'Turned off anonymous grading for this exam'
</p>
<a onClick={() => api.put(`exams/${this.props.examID}`, {grade_anonymous: true})}>
(undo)
</a>
</div>
)
}
})
}
sendEmail = async () => {
this.setState({ sending: true })
try {
......@@ -212,6 +229,7 @@ class EmailEveryoneControls extends React.Component {
}
} finally {
this.setState({ sending: false })
this.disableAnonymousMode()
}
}
......
......@@ -280,9 +280,10 @@ class Exams(Resource):
return dict(status=403, message='Exam can not be unfinalized'), 403
if args['grade_anonymous'] is not None:
changed = exam.grade_anonymous != args['grade_anonymous']
exam.grade_anonymous = args['grade_anonymous']
db.session.commit()
return dict(status=200, message="ok"), 200
return dict(status=200, message="ok", changed=changed), 200
return dict(status=400, message='One of finalized or anonymous must be present'), 400
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment