Your Community is getting an upgrade!
Read about our partnership with Higher Logic and how we will build the next generation of the Instructure Community.
Found this content helpful? Log in or sign up to leave a like!
I copy courses from sandboxes every semester and I use a batch of date-specific announcements every time. Reminders like: "Don't forget your papers are due by Friday night" and such.
It really bothers me that all the copied announcements look like I didn't make them because my authorship is stripped when the course is copied.
Since I'm working on this google doc to batch edit the announcement dates (which is pretty much done, BTW), I thought maybe I could update the author on each announcement as well. I logged the input from an announcement and there is an author object, so I have created the same object going back but it doesn't seem to update.
Has anyone tried this before? Should I keep trying or is it something that Canvas blocks on the incoming PUT?
The discussion post object as it comes in:
{
"id":151151,
"title":"Test Announcement",
"last_reply_at":"2017-11-14T21:10:31Z",
"delayed_post_at":"2018-01-07T13:00:00Z",
"posted_at":"2017-11-14T21:10:31Z",
"assignment_id":null,
"root_topic_id":null,
"position":32,
"podcast_has_student_posts":false,
"discussion_type":"side_comment",
"lock_at":null,
"allow_rating":false,
"only_graders_can_rate":false,
"sort_by_rating":false,
"user_name":"Donald Bryn",
"discussion_subentry_count":0,
"permissions":{"attach":true,"update":true,"reply":true,"delete":true},"
require_initial_post":null,
"user_can_see_posts":true,
"podcast_url":null,
"read_state":"read",
"unread_count":0,
"subscribed":false,
"topic_children":[],
"attachments":[],
"published":true,
"can_unpublish":false,
"locked":true,
"can_lock":true,
"comments_disabled":true,
"author":{
"id":5054,
"display_name":"Donald Bryn",
"avatar_image_url":"https://scf.instructure.com/images/thumbnails/2936451/<removed>",
"html_url":"https://scf.instructure.com/courses/20565/users/5054"},
"html_url":"https://scf.instructure.com/courses/20565/discussion_topics/151151",
"url":"https://scf.instructure.com/courses/20565/discussion_topics/151151",
"pinned":false,
"group_category_id":null,
"can_group":false,
"locked_for_user":false,
"message":"\u003cp style=\"font-size: 8pt; margin-top: -3px; margin-bottom: 3px;\"\u003eSession 1\u003c/p\u003e\r\n\u003cp\u003etest\u003c/p\u003e\u003cscript src=\"https://instructure-uploads.s3.amazonaws.com/account_21940000000000001/attachments/1625201/scf-app.j...\"\u003e\u003c/script\u003e",
"subscription_hold":"topic_is_announcement"
}
These are my parameters going out:
{
:id=148633.0,author={
avatar_image_url=https://scf.instructure.com/images/thumbnails/2936451/<removed>,
html_url=https://scf.instructure.com/courses/20565/users/5054,
id=5054.0,
display_name=Donald Bryn
},
:course_id=20565,
type=discussion,
delayed_post_at=2018-01-08T13:00:00Z
}
The delayed_post_at, ID, course_id, and type appear to function, but not the author. It could just be something I'm not getting about formatting the object correctly. I'm really just a hack at this. But it looks like the format changes from incoming to outgoing are the same for delayed_post-at and author.
And I did try also sending the user_name, but didn't make a difference.
If Canvas did support an author, it would be of the form user_id and a single number, not an object. It would not accept anything other than the Canvas user ID for it since it will go lookup that information based on the user ID.
However, announcements are an area that doesn't have a lot of API support. I had a Canvancement all ready to go, even wrote up documentation on it, to find out that it wouldn't work right once pagination was involved. This was on the global announcement side, but it helps show the lack of programming features for the discussions.
That said, Canvas would not need to ask for the user_id when creating an announcement because it would use the user_id of the person making the API call or there are already provisions for masquerading as a specific user in the API. Nothing I see in any of the discussion API allows for writing or setting the user / author, just for reading it.
Updating or changing the author is not a common scenario, although there have been some requests for the ability to do this so that the instructional designer's name doesn't show up as the author of the discussion topic when the instructor wants there name to be this. The suggested solution in that case is to create the discussion in a sandbox and then copy it into the real course through an import. That is, the solution that is recommended for most people who have asked about this in the past is the exact opposite of what you want. You want it to carry over the author of an announcement when the content is copied rather than stripping it.
All that leads me to think that you won't be able to set the author unless you create an announcement and not with an update. The only solution I see to getting your name in there as the author is to load an announcement, copy everything that you need in your JavaScript and use it to create a new announcement with the information. Then delete the old announcement that didn't have you as the author.
That's kind of a pain and it might be worth considering whether just adding your name to the end of the announcement as a signature would suffice.
Thanks, James,
That is really helpful. I don't think it would be too difficult to bring in the announcements and simply change dates and author and send the command to create new announcements (and probably delete old ones), BUT since there is nothing mentioned in the API at all about topic authors (only entry authors), I'm still not guaranteed it will work. So I will drop it for now. I was hoping since it wasn't mentioned in the API but still shows up in the incoming data that it might work.
You might try one to make sure, but I imagine that any author that exists for announcements comes from the user who created the announcement. But I agree the dropping it is definitely the easier route.
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