What went wrong
Courses in the LMS have discussionsLMS · The platformDiscussionsQuestions and answers on each course. Instructors moderate them, but never a thread they posted as a learner.See it in the LMS build, made of threads and replies. An instructor can moderate the discussions on courses they are assigned to. Moderating means managing other people’s posts. The same person can also take part as a learner. An instructor is not allowed to moderate a thread they posted as a learner. Replying and changing a thread’s status followed that rule. Deleting a thread or a reply did not. The May development record shows both deletes going through. The server answered 200, its code for success.
Why it happened
The two delete actions checked that the instructor was assigned to the course, and stopped there. That check cannot tell two cases apart. One is an instructor managing someone else’s discussion. The other is a learner acting on their own thread.
What I changed
The reply and status actions already had a check for that. It stops anyone moderating their own posts. Both delete actions now use the same check. It runs after the thread or reply is found, and before anything is changed. It is added to the course check, not used instead of it.
How I know it works
The delete tests expect the server to refuse, with code 422. Then they check that the thread or reply is still there. That second step matters. An error answer alone does not prove the delete never happened. Another test covers the course check itself. It sends the ID of a real lesson from a different course. It expects the answer “not found”, which is code 404. The May record shows these checks passing after the fix.