Works posted by a user fulfilling one of at least two open assignments that have the same recipient has all assignments checked by default on posting and editing form

Description

This problem presents itself only if a user has two open (unfulfilled) assignments, both with the same recipient.

To test:

1. Get two challenge assignments on two different challenges with the same recipient.
2. Select the button to fulfill one of them.

The form will have both assignments checked (as if the work were fulfilling both), and both collections added.

Unchecking one of the assignments allows the user to post properly fulfilling only one of the assignments. (Provided they notice.)

If the user doesn't notice the second checked box and posts the work fulfilling both assignments, the second assignment can be removed from the work by editing the work (edit the work, uncheck the unwanted assignment, remove the unwanted collection, post with or without preview).

As long as the second assignment stays open, the form defaults to checking both whenever the work is edited, forcing the user to keep unchecking the second assignment.

The problem stops once there are posted works for both assignments, and posting the second work doesn't present the problem at all (because the first assignment is already fulfilled at the time).

Activity

Show:
Nary Rising
April 13, 2018, 1:10 AM

Also, if you follow these steps you will also run into a variation of this bug:

1. Post a work fulfilling an assignment for Recipient A.
2. Receive another assignment, also for Recipient A (could be in another challenge).
3. Edit the first work, for instance to correct a typo.
4. Hit Post.
5. Work will now be marked as fulfilling both assignments, and be part of both challenge collections (and may become unrevealed/anon even if it was already revealed, depending on the settings of the second collection.)

ticking instant
February 3, 2019, 6:23 PM

This happens as a result of the definition of the ChallengeAssignment comparison function (<=>), which only checks the bylines and doesn't look at the ID. And the include Comparable statement ensures that <=> is called when checking equality with ==.

So if two assignments have exactly the same offer_byline and request_byline, they're treated as being "equal" even if they're from different collections and have different IDs. (And this extends to when the view is trying to determine which checkboxes should be checked by default.)

One way to fix this would be to add on an extra comparison at the end involving IDs. However, I don't believe that comparison function is actually used to sort anything. (ChallengeAssignments generally seem to be sorted in the SQL query, not by calling sort. The function counts as covered according to codecov.io, but only because it's called when checking equality.) So a simpler alternative would be to just delete the comparison function and stop including Comparable.

Sarken
November 12, 2019, 8:45 AM
Edited

From Nary:
I'll test the assignment one while I'm at it. since I feel a particular grudge against that bug
it looks good!
just checked on editing the work too, and it all stays as it should be (other assignments aren't ticked)

Sarken
November 13, 2019, 3:37 AM

I have three assignments for testy, and when I press Fulfill now, only the correct one is selected on the posting form. If I post the work and then edit it, same thing: only the correct option is selected.

Bonus: correct assignment remained checked when the initial posting errored because I forgot to put in a language.

Looks good!

DeployedToBeta

Assignee

ticking instant

Reporter

hele.br

Roadmap

Challenges
Works

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9
Configure