For example, when logged in as sgao, after selecting Wiki Textbook 2011, Others' Work, Chapter 5; chapter 4a is assigned.
This isn't actually a bug in the code, but an inconsistency in the database due to a manual change made about a month ago.
The problem is due to a DB design issue. When an assignment is a team assignment, the topic_id is stored on every participant, and not the team itself. This leads to redundant data and it may cause ambiguities like in this case.
The following query proves my point (the result should be empty, but it shows a team with 2 different topics):
select a.team_id from
(select distinct tu.team_id, p.topic_id
from participants p, teams_users tu, teams t
where p.type = 'AssignmentParticipant'
and p.parent_id = 320 and tu.user_id = p.user_id
and t.id = tu.team_id and t.type = 'AssignmentTeam' and t.parent_id = 320) as a
group by a.team_id
having count(a.topic_id) > 1;
| team_id |
| 3047 |
I will change the DB to make it consistent again.