diff --git a/client/views/Exam.jsx b/client/views/Exam.jsx index 8c89effb52a83285154dc99e30d17b88604becfc..593cf78e0e77632e37dc50ab714b74e5977d6959 100644 --- a/client/views/Exam.jsx +++ b/client/views/Exam.jsx @@ -63,15 +63,15 @@ class Exams extends React.Component { previewing: false } } - if(prevState.problemIdToEditFeedbackOf && !prevState.editActive) { - if(prevState.waitForNextRender) { + if (prevState.problemIdToEditFeedbackOf && !prevState.editActive) { + if (prevState.waitForNextRender) { var problem = newProps.exam.problems.find(w => { - return w.widget.id == prevState.problemIdToEditFeedbackOf + return w.widget.id === prevState.problemIdToEditFeedbackOf }) prevState.widgets[problem.widget.id].problem.feedback = problem.feedback prevState.waitForNextRender = false - if(!prevState.editActive) prevState.problemIdToEditFeedbackOf = null - } else prevState.waitForNextRender = true + if (!prevState.editActive) prevState.problemIdToEditFeedbackOf = null + } else prevState.waitForNextRender = true } return prevState } @@ -85,7 +85,7 @@ class Exams extends React.Component { if (prevState.selectedWidgetId !== this.state.selectedWidgetId) { this.saveProblemName() this.setState({ - editActive:false, + editActive: false, problemIdToEditFeedbackOf: false }) } @@ -343,19 +343,19 @@ class Exams extends React.Component { props.saveProblemName(e.target.value) }} /> </div> - <br/> + <br /> {!this.state.editActive && <label className='label'>Feedback options</label>} </React.Fragment> )} </div> </div> {this.isProblemWidget(selectedWidgetId) && (this.state.editActive - ? <EditPanel problemID={props.problem.id} feedback={this.state.feedbackToEdit} - goBack={this.backToFeedback} /> - : <FeedbackPanel examID={this.props.examID} problem={props.problem} - editFeedback={this.editFeedback} showTooltips={this.state.showTooltips} - grading={false} - />)} + ? <EditPanel problemID={props.problem.id} feedback={this.state.feedbackToEdit} + goBack={this.backToFeedback} /> + : <FeedbackPanel examID={this.props.examID} problem={props.problem} + editFeedback={this.editFeedback} showTooltips={this.state.showTooltips} + grading={false} + />)} <div className='panel-block'> <button disabled={props.disabledDelete} diff --git a/tests/test_database.py b/tests/test_database.py index c7b99fc983cb80834c95eaf1496708658f80c851..c890a1880b17706ca7d80f152ba80ab788cab21c 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -13,11 +13,11 @@ def test_exam_generate_token_length_uppercase(duplicate_count, monkeypatch): self.duplicates = duplicate_count + 1 def filter(self, *args): - return self + return self def first(self): - self.duplicates -= 1 - return None if self.duplicates else True + self.duplicates -= 1 + return None if self.duplicates else True app = Flask(__name__, static_folder=None) app.config.update( diff --git a/zesje/api/emails.py b/zesje/api/emails.py index 60039da236d84a9727f4c8d39fb9e61dc156753b..408657ad7f8e2537b61f158b9ab65132a8b9d44b 100644 --- a/zesje/api/emails.py +++ b/zesje/api/emails.py @@ -57,27 +57,27 @@ def render_email(exam_id, student_id, template): def build_email(exam_id, student_id, template, attach, from_address, copy_to=None): - student = Student.query.get(student_id) - if student is None: - abort( - 404, - message=f"Student #{student_id} does not exist" - ) - if not student.email: - abort( - 409, - message=f'Student #{student_id} has no email address' - ) - - return emails.build( - student.email, - render_email(exam_id, student_id, template), - emails.build_solution_attachment(exam_id, student_id) - if attach - else None, - copy_to=copy_to, - email_from=from_address, + student = Student.query.get(student_id) + if student is None: + abort( + 404, + message=f"Student #{student_id} does not exist" ) + if not student.email: + abort( + 409, + message=f'Student #{student_id} has no email address' + ) + + return emails.build( + student.email, + render_email(exam_id, student_id, template), + emails.build_solution_attachment(exam_id, student_id) + if attach + else None, + copy_to=copy_to, + email_from=from_address, + ) class EmailTemplate(Resource): diff --git a/zesje/emails.py b/zesje/emails.py index 212952086b4a4c002537e123942c4033ee74eb21..8e3571608e501a0476cfcb357104d3cf2674184c 100644 --- a/zesje/emails.py +++ b/zesje/emails.py @@ -103,7 +103,7 @@ def send( server_type = smtplib.SMTP_SSL if use_ssl else smtplib.SMTP with server_type(server, port) as s: if user and password: - s.login(user, password) + s.login(user, password) for identifier, message in messages.items(): recipients = [ *message['To'].split(','),