Repository: Cloud-CV/EvalAI
Issue: Apply checks on map participant team to challenge api to maintain data integrity
GitHub labels: bug

hard-to-fix

backend

Api `add_participant_team_to_challenge` maps a particular challenge with a participant team. At db level, this case is already handled by enforcing uniqueness of challenge_id, participant_team_id.

The same check needs to be handled in the view also. For the first time respond when creating the mapping, respond with `HTTP_201_CREATED`. From next time, respond with `HTTP_200_OK` and response containing challenge_id and participant_team_id

Can I try this, if it's unassigned

Sorry I forgot to assign it to myself. I am almost done with the fix. You can try any other issue

One more such case of check can be

When a challenge host is mapping his participant team to a challenge created by him only. Consider a case where there are three persons named __A__, __B__ and __C__.

__A__ - creates a _ChallengeHostTeam_ and then along with __B__ creates a _Challenge_ named __C1__. So __A__ and __B__ are both _ChallengeHost_ for _Challenge_ __C1__.

Now __B__ along with __C__ creates a _ParticipantTeam_ __P1__. Everything is fine till here. But now __C__ innocently(as he is not aware of the fact that __B__ is a _Challenge Host_ for __C1__) attempts to map _Challenge_ __C1__. The current code base will allow such a blunder to happen.

This can be handled by enforcing a check in `add_participant_team_to_challenge`. 


In the future, we can add a `simulation mode` where in a ChallengeHost can participate in his own challenge in simulation mode, so that he can check the whole functionality and other details pertaining to his challenge.

Simulation mode actually needs some more thought. definitely a big NO for v1. @deshraj 

How are we solving the case "Prevent a challenge host from participating in its own challenge"

From the given challenge id, find its creator i.e. ChallengeHostTeam object. From ChallengeHostTeam, we can get ChallengeHost and eventually user ids from it. Consider this as set __A__.

For participant, we can get user ids from participant through participant team object. Consider this as set __B__.

If the set __A__ and __B__ intersects, then it means there is(are) user(s) which are both challenge host as well participant for the concerned team. Hence they should not be allowed to participate.



One more case of check can be

Host cannot be invited to teams which are participating to his own challenge

Inviting a member to a team can happen in following cases

- One when the team has not registered to participate in the challenge

    For this case we should not disallow anyone from being invited since there is no guarantee that this team will participate in a challenge which has been created by one of its member. So here invite should be allowed

- One when the team has registered to participate in the challenge

    This one is interesting. Interesting since we are allowing to add participants once the team has entered a competition. Check is required here.

@TroJan Is someone working on this??

Host cannot be invited to teams which are participating to his own challenge

This check is dropped due to lack of required data in the concerned api. While inviting a participant to a team, the only thing that is known at that time is team id and email id of the user being invited. There is no challenge id used. Hence at time of inviting a user, it is actually not clear that this team will participate in which challenge. So dropping this check as of now.

@deshraj : FYI