Skip to content

[Backend] - Separate query to get assignments for a teacher - #511

Merged
thomasdejaeghere merged 3 commits into
developmentfrom
502-get-assignments-teacher
May 14, 2025
Merged

[Backend] - Separate query to get assignments for a teacher#511
thomasdejaeghere merged 3 commits into
developmentfrom
502-get-assignments-teacher

Conversation

@brieromb

@brieromb brieromb commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

I wrote a separate query to get assignments for a teacher.

@brieromb brieromb added bug Something isn't working backend labels Apr 24, 2025
@brieromb brieromb added this to the Milestone 2 milestone Apr 24, 2025
@brieromb
brieromb requested a review from bramcomyn April 24, 2025 17:58
@brieromb brieromb self-assigned this Apr 24, 2025
Comment on lines 78 to 91
const assignmentsJoinResult = await datasource
.getRepository(StudentOfGroupTypeORM)
.createQueryBuilder()
.where("StudentOfGroupTypeORM.student = :id", { id: userId })
.where("StudentOfGroupTypeORM.student = :id", { id: studentOrTeacherId })
// Join StudentOfGroup
.leftJoinAndSelect("StudentOfGroupTypeORM.group", "group") // Last one is alias
// Join Group to AssignmentGroup
.leftJoinAndSelect("group.assignment", "assignment")
// Join Assignment to Class
.leftJoinAndSelect("assignment.class", "class")
.getMany();

return assignmentsJoinResult.map(assignmentJoinResult => {
return assignmentJoinResult.group.assignment.toAssignmentEntity();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this in an else, but ok.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally did that but the linter was complaining about it...

@brieromb
brieromb marked this pull request as ready for review April 24, 2025 18:42
@brieromb brieromb linked an issue Apr 24, 2025 that may be closed by this pull request
1 task
@brieromb

brieromb commented Apr 24, 2025

Copy link
Copy Markdown
Contributor Author

I tested it out by logging in as a teacher and going to my assignments on our application, and it worked.
All the teacher's assignments were there.

@rvdkeere rvdkeere left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works

@brieromb
brieromb marked this pull request as draft April 29, 2025 12:48
@thomasdejaeghere
thomasdejaeghere merged commit 5206974 into development May 14, 2025
@thomasdejaeghere
thomasdejaeghere deleted the 502-get-assignments-teacher branch May 19, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] - Getting assignments for a teacher

5 participants