bterone / training-course

An online training course website coded in ruby!
0 stars 0 forks source link

BUG: User already in group not showing in unassigned list #9

Open bterone opened 5 years ago

bterone commented 5 years ago

Users already in groups from another course not shown in unassigned list of courses currently followed. So a user in multiple courses won't appear in the unassigned list.

bterone commented 5 years ago

The current SQL queries being called from the server

SELECT users.id, users.fname, users.lname, groups.groupname 
FROM "users" 
LEFT OUTER JOIN "course_users" ON "course_users"."user_id" = "users"."id" 
LEFT OUTER JOIN "courses" ON "courses"."id" = "course_users"."course_id" 
LEFT OUTER JOIN "group_users" ON "group_users"."user_id" = "users"."id" 
LEFT OUTER JOIN "groups" ON "groups"."id" = "group_users"."group_id" 
WHERE "course_users"."course_id" = 1

which displays the users groups regardless of course ID. Example: Horace Knightly is in Group 1 (Course 1) and Group 4 (Course 2). His name appears twice one for each group.

bterone commented 5 years ago
SELECT users.id, users.fname, users.lname
FROM "users" 
LEFT OUTER JOIN "course_users" ON "course_users"."user_id" = "users"."id"  
WHERE "course_users"."course_id" = 1

This code shows the users who are enrolled to only course 1