After an outage on September 1, the Instructure Community is now fully available, including guides, release notes, forums, and groups. If some styling still looks unusual, clear your cache and cookies.
Found this content helpful? Log in or sign up to leave a like!
I recently had an assignment where my teacher gave me a good comment. I replied back saying "Thank You!" but I would now like to delete my comment. Is there any way to do so? Thanks in advance!
Solved! Go to Solution.
@jham18 , I did a little testing and it looks like students are not able to delete comments. If you'd really like the comment to be deleted, you can contact your Instructor and your Instructor has the ability to delete comments.
Hope this helps!
@jham18 , I did a little testing and it looks like students are not able to delete comments. If you'd really like the comment to be deleted, you can contact your Instructor and your Instructor has the ability to delete comments.
Hope this helps!
UPDATE: THIS SOLUTION NO LONGER WORKS
After some testing, it appears Canvas has revoked the right for students to delete or edit comments using the API. I've tried both PUT and DELETE for /api/v1/courses/*/assignments/*/submissions/*/comments and I've tried DELETE for the internal api /submission_comments/* that is used by speedgrader. Neither work when acting as a student. If someone wants to continue fiddling with the original solution, I'll leave it here.
OLD COMMENT
While it's true Canvas hasn't created an interface for deleting comments, students DO have the access rights to delete comments, they're just missing a button to do it. If you are a student and would like to delete a comment without reaching out to your teacher, here are the steps you should follow.
1. Open Canvas in Chrome and navigate to the submission page where you can see your comment you'd like to delete.
2. Open the Chrome console (ctrl + shift + i)
3. Paste this code into the console and run it (press enter)
$.delete = function (url, data) {
return $.ajax({
url: url,
data: data,
type: 'DELETE'
});
}
$(".comment_list div.comment").each(function() {
let el = $(this);
let id = el.attr("id");
if (id !== undefined) {
let userName = el.find(".author_name").text().trim();
if (userName == ENV.current_user.display_name.trim()) {
console.log(userName);
let commentId = id.replace("submission_comment_", "");
console.log(commentId);
el.css("position", "relative");
let button = $(`<span style="position: absolute; top: 0; right: 0; color: #888;">x</span>`);
button.click(function() {
let url = `/api/v1${window.location.pathname}/comments/${commentId}`
$.delete(url);
el.remove();
});
el.append(button);
}
}
});
4. Click the X that appears by your comment.
update 10/26/2023 - fixed an issue where it doesn't show the x on some assignments.
If it still doesn't show up, you can try this. It strips out the check to see if the comment is written by you. This means you'll get an x on every comment, but only the ones written by you will work. The rest will throw an error.
$.delete = function (url, data) {
return $.ajax({
url: url,
data: data,
type: 'DELETE'
});
}
$(".comment_list div.comment").each(function() {
let el = $(this);
let id = el.attr("id");
if (id !== undefined) {
let commentId = id.replace("submission_comment_", "");
console.log(commentId);
el.css("position", "relative");
let button = $(`<span style="position: absolute; top: 0; right: 0; color: #888;">x</span>`);
button.click(function() {
let url = `/api/v1${window.location.pathname}/comments/${commentId}`
$.delete(url);
el.remove();
});
el.append(button);
}
});
This didn't work for me, I went to Grades, Developer Tools, Console, then pasted the code but it didn't work please can you tell me if I did something wrong or double check if the code is correct please? Thank you!
Did it give you any errors in the developer tools after you ran it?
No but there was no X beside my comment I looked everywhere 😞 Please can you help me figure out what is wrong?
Take a look at your url. Does it look something like this?
school.instructure.com/courses/#/assignments/#/submissions/#
If not, you may be in the wrong spot. You mentioned you went to grades. Did you then click on the link to the individual assignment?
Yes that is the exact url I have, is there anything else that might be wrong? My issue is that when I paste the thing you posted and click enter, there is no X beside my comment and I don't know what to do. Except I just realized that there was this error but it was there before I even typed in the code ( it's for the school name icon picture) but it's just for the picture of my school name so I don't think that's the reason its not working but I linked a screenshot below of what it looks like. I know that's not the problem though because I tried this for another Canvas account with no error and it still didn't work. I usually paste the code underneath the error in the typing spot. I also linked a screenshot of what it looks like when I paste the code. Thank you so so much and I truly appreciate it!!
I hacked this together from the previous post. It works but I'm not entirely sure what it will do if there are multiple comments. It might just delete all comments that are from the logged in user. This version doesn't give you an X, it just deletes. Be aware that the comment may still be visible on the assignment screen unless you submit a new version of the assignment.
===========================================
$.delete = function (url, data) {
return $.ajax({
url: url,
data: data,
type: 'DELETE'
});
}
$(".comment_list div.comment").each(function() {
let el = $(this);
let id = el.attr("id");
if (id !== undefined) {
let userName = el.find(".author_name").text().trim();
if (userName == ENV.current_user.display_name.trim()) {
let commentId = id.replace("submission_comment_", "");
let url = `/api/v1${window.location.pathname}/comments/${commentId}`
$.delete(url);
console.log('deleted');
}
}
});
================================================
Thank you so so so much this worked for me!! I really appreciate it beyond words and cannot express how thankful I am that you put in so much time and effort to help me! May I please ask if you know if the teacher will still be able to see it from their screen? I am a student and from all my devices the comment is not there anymore but since I can only see my assignment from my student account I am not sure if the teacher will still be able to see it from their account. Thank you again and I truly appreciate it so much!!
I have no idea what the teacher sees. The configuration of Canvas is pretty flexible so it's possible the teacher was emailed the comment as well. I feel reasonably confident that the comment is not there to be seen via the web interface.
PS - I needed to delete a comment too, which is why I spent the time figuring it out. 🙂
I went and created a test course and assignment to see what happens. Once I deleted it, I could not find the comment anywhere when I looked at it as either a teacher or a student. However, it looks like the default setting for a course is to email a daily summary of submission comments. This can be configured to be immediate, daily, weekly, or off. Since the comment is deleted, it wouldn't be sent in any future notifications. However, it might have already been sent. The email does appear to contain the full text of the comment. According to what I see, "Daily notifications will be delivered around 6pm. Weekly notifications will be delivered Saturday between 7am and 9am." Looks like this is MST so adjust accordingly.
HTH!
Ohh ok thank you so much for doing all of this and letting me know what you found!! I truly appreciate all your help so much and you are so kind to do all this to help me so thank you so much! Best of wishes and I hope things work out for the best for you and you achieve all your hopes and dreams!!
Also, I just wanted to say that you are very smart to have created that code that works really well and it's really impressive that you were able to not just do that, but also figure out if and what the teacher sees from their point of view! I am so thankful that you used your skills to help me out it means so much to me!!
Have a wonderful rest of your week!
Hi there,
Sorry I tried using this code. It works for the comments of submission. However, when using this to remove comments for anonymous submissions, it does not work and the 404 error shows up.
The URL link is the following: institution/courses/#/assignments/#/anonymous_submissions/#
Does anyone know why the code would not work for this URL?
the code is based on searching for the user name. so i assume if it's anonymous there's no user name. i would be surprised if you can delete an anonymous comment.... if you could do that then anyone could delete it just by remaining anonymous. remember, the functionality to delete comments exists but it's just hidden in the instance you're looking at. so if the function were not hidden then anyone could delete anyone else's anonymous comment.
if it's anonymous it's not going to come back and bite you anyway. if it's something inappropriate, the teacher can delete it....
I don't see any way to allow anonymous submissions in my test course so I can't replicate this scenario.
but can you just change the URL so you're not viewing anonymous submissions only?
Hi,
Thank you so much for the reply. So the way apparently this works is that the "author of the assignment" is made 'anonymous" on my screen and I can see my name as the author of comment when I make a comment. However, if the individual with the assignment logs in, on their screen they would see the comment's author name as "anonymous" rather then my name.
I am not sure if this makes sense ?
I tried changing the url from anonymous_submission to submission, however I get the error of " the specific use is not in this course" .
Can the code issue be due to difference in URL? Is there anyway I can tell it to manually search for a specific URL?
Anyways thank you so much, if there's no way, its fine. I really appreciate you looked into this.
If the comment isn't anonymous then you should be able to delete it when you're logged in since it looks for comments where you're the author (based on your successful login). Remember, the delete functionality is built in to Canvas but not visible. So the protections are all there for not being able to delete comments that you didn't write. There may be some other way the submission is being tagged that would let you search for it but if I can't see it, I can't help you figure that out. Perhaps you can view the source of the page and send it to me directly?
I'm not sure what the issue is based on just the screen shot you sent. It seems it's having a problem with the comment list which leads me to believe that you're doing it from the wrong location. what is the URL you are on when trying to execute this?
I think that is my problem als,o but I don't know how to navigate to the point of the url above. I get to this url: https://templeu.instructure.com/courses/#/assignments/# , yet I can still see what I submitted and the comments which I made directly on the assignment. Is there any way you could help me?
could you contact me directly to help me figure this out?
try just changing the URL to be https://templeu.instructure.com/courses/#/assignments/#/submissions/# and then running the code
It doesn't appear I can DM you via this platform
when changing url to submissions it says access denied that I do not have access to view the resource
Did you figure it out? I’m having the same issue
Hi, the code you provided was helpful in finding the correct URL and comments ID. However, when attempting to delete a comment on a submission using the provided URL, I received a "403 Forbidden" error message:
DELETE https://canvas.nus.edu.sg/api/v1/courses/45898/assignments/78212/submissions/140689/comments/452583 403 (Forbidden)
I'm wondering if you might have any insight into why this error occurred? It seems that the user account I am using to access the Canvas API may not have the necessary permissions to delete comments on submissions.
Hi friend, did you solve this issue? I've got the exactly same warning as yours: 403 Forbidden. Thanks so much if you could reply to me.
Hi, thanks so much for your sharing. Unfortunately, I wanted to delete three comments I made under the submission of one assignment. And I was at the right website. But I kept receiving warnings as followed:
trycatch.js:220
DELETE https://canvas.*****.edu.hk/api/v1/courses/55117/assignments/241409/submissions/192823/comments/1268...403 (Forbidden)
After I expanded the warning message, it showed lines as below:
(anonymous) @ trycatch.js:220
(anonymous) @ instrument.js:266
(anonymous) @ instrument.js:248
send @ jquery.js:7487
ajax @ jquery.js:6990
$.delete @ VM1136:2
(anonymous) @ VM1136:19
each @ jquery.js:636
each @ jquery.js:271
(anonymous) @ VM1136:10
I also got reminded of these two issues as attached. Is it relate to the problem?
Did you have any idea what might go wrong? Many thanks for your time.
It worked for me after trying a few times!
how did you get it to work? I am still trying to get it to work.
Unfortunately, It does not work on my case. Could you perhaps helps me with it? It shows error on the console, and I don't know why.https://mtsac.instructure.com/courses/122979/assignments/1973211/anonymous_submissions/9tb3D
It does not seem to be working for me. Does it matter that I am on a Mac?
Hi there, thanks very much for your update. An 'X' appeared on every comment after I ran your updated codes. However, the 403 forbidden warnings still prevented me from doing the deletion. The comments I tried to delete were all made by me, so I had no idea why. Could it be set by the school that students cannot edit the comments in any way after posting?
Hi, are you still here?
I do see X but when I refresh, it's still here. How can I solve this?
I want to delete a comment that I wrote as anonymous. Can u pls help me?
Sorry, it looks like Canvas has removed this work around.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in