-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reset evaluation after it started #2136
base: main
Are you sure you want to change the base?
reset evaluation after it started #2136
Conversation
c353503
to
5ee1e27
Compare
cb79677
to
909c5a7
Compare
Two Unit Tests are missing. I do not have any idea on how to practically test for ui popups without selenium tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started reviewing your changes and I find it a bit tricky to separate the "revert -> reset" and "make State an IntEnum" changes. Do you think you could split these changes into two PRs? If not, we will have to see how we manage :D
The extra PR would also be a good place to discuss the motivation for the move to IntEnum
- it sounds like a good idea, but it's hard to see the benefits when they are mixed in with the other changes here
I don't think it is possible with our current setup. However, since the javascript deciding whether or not to show the modal is pretty clear, I think we don't urgently need a test for that |
909c5a7
to
f3670fb
Compare
6c0cf01
to
8eabcbe
Compare
@fekoch some TODO's:
|
8eabcbe
to
2e67d03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Forgot to specify before: It should not be possible to reset single results. They should be removed from the selection and the operation should not be
applicable_to
them. - Submitting other operations (e.g., start evaluation, publish, unpublish) is not possible anymore. The submit button does not send a request in these cases (
document.getElementById("delete-previous-answers")
fails).
cecbc89
to
5d9d71e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, I have some final remarks below.
Since all reviews are green now, but you still may want to change something, just write a quick comment once you are okay with merging
allowed_sources = [ | ||
Evaluation.State.PREPARED, | ||
Evaluation.State.EDITOR_APPROVED, | ||
Evaluation.State.APPROVED, | ||
Evaluation.State.IN_EVALUATION, | ||
Evaluation.State.EVALUATED, | ||
Evaluation.State.REVIEWED, | ||
] | ||
return self.state in allowed_sources and not self.is_single_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to prefer this over the following?
allowed_sources = [ | |
Evaluation.State.PREPARED, | |
Evaluation.State.EDITOR_APPROVED, | |
Evaluation.State.APPROVED, | |
Evaluation.State.IN_EVALUATION, | |
Evaluation.State.EVALUATED, | |
Evaluation.State.REVIEWED, | |
] | |
return self.state in allowed_sources and not self.is_single_result | |
return Evaluation.State.NEW < self.state < Evaluation.State.PUBLISHED and not self.is_single_result |
def reset_to_new(self, *, delete_previous_answers: bool): | ||
if delete_previous_answers: | ||
for answer_class in Answer.__subclasses__(): | ||
answer_class._default_manager.filter(contribution__evaluation_id=self.id).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the following also work?
answer_class._default_manager.filter(contribution__evaluation_id=self.id).delete() | |
answer_class._default_manager.filter(contribution__evaluation=self).delete() |
if request.POST.get("delete-previous-answers") == "on": | ||
delete_previous_answers = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we do delete_previous_answers = request.POST.get("delete-previous-answers") == "on"
from the start? I think this would also fix the bool | None
"issue", although I don't care so much about that
{% comment %} | ||
The modal needs an element in the slot, otherwise it throws an error. | ||
No button is needed, as the modal is conditionally shown via JS. | ||
{% endcomment %} | ||
<span slot="show-button"></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, we should change the modal so that this is not needed, you or me can fix it in a follow up :)
const data = new FormData(submitEvent.target); | ||
if (data.get("delete-previous-answers") === "on" && !submitEvent.submitter?.hasAttribute("data-confirm-answer-deletion")) { | ||
submitEvent.preventDefault() | ||
submitEvent.target.querySelector("confirmation-modal[data-allow-answer-deletion]").dialog.showModal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the following, we can get rid of the data-allow-answer-deletion
on the modal:
submitEvent.target.querySelector("confirmation-modal[data-allow-answer-deletion]").dialog.showModal(); | |
submitEvent.target.querySelector("confirmation-modal:has([data-confirm-answer-deletion])").dialog.showModal(); |
You can decide which version you prefer, I think both are fine
Closes #1991
Replaces the
revert_to_new
evaluation operation withreset_to_new
. It now allows resetting from any State exceptNEW
andPUBLISHED
. It also allows deleting all previously received answers.Also, it makes
Evaluation.State
anIntEnum
.