How do I delete a comment I made on an assignment in response to my teacher? I am a student.

Jump to solution
jham18
Community Novice

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!

0 Likes
2 Solutions
kona
Community Coach
Community Coach

 @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!

View solution in original post

jhveem
Community Explorer

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);
}
});

 

View solution in original post