cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Publishing Module Item on POST

Jump to solution

I am creating an app with PHP that puts our assignments into a specific module based on the assignment title.  I have almost completed it with one hang up. 

The script is creating the module item with these parameters:

module_item[type]=Assignment&module_item[content_id]=19683&module_item[position]=3&module_item[indent]=1&module_item[published]=true 

Everything works but the "module_item[published]=true". No matter what I do the items are unpublished in the modules, and I'm not seeing the option in Canvas live API. 

I think I know the answer to this question, but I wanted to check with this great resource of knowledge before I do all of the extra work.  Does this mean that I have to pull from the API to first POST the module assignment and then pull from it again to get all of the Module items and do a PUT to update them?  Why wouldn't they have a way to publish the module items on POST?

Labels (1)
1 Solution

Accepted Solutions

Thanks for sharing your experience jason.edington@arist.com‌, but personally I think it would be better to set the default as unpublished. First, it would be consistent with other scenarios, such as assignment, discussion, and etc. Second, if the course is published, I don't want to my students to be panic when I am "playing" with the course contents. 🙂

View solution in original post

3 Replies
Community Member

I figured it out.   I just have to use the response body to get the id from the Module Item and then update with the "[published]=true" parameter.  Just one extra step and something I should have thought of before, so not too bad. I'm still learning PHP and how the API works with it.

I am still curious why they don't have "[published]=true" parameter available on the initial Module item creation.  Why wouldn't I want it to default as published?

Thanks for sharing your experience jason.edington@arist.com‌, but personally I think it would be better to set the default as unpublished. First, it would be consistent with other scenarios, such as assignment, discussion, and etc. Second, if the course is published, I don't want to my students to be panic when I am "playing" with the course contents. 🙂

View solution in original post

That is a great point muh@udel.edu‌.  I guess I was seeing it in the perspective of a building the course out before it even started. I wrote a script that automatically adds the assignments to a module based on the assignment title.  It was built as a time saver for me to not have to add every assignment to the modules each time I built out a new course.  I can see why you would want it to be unpublished in the scenario in which you described.  While that is different than mine, it is probably a more likely scenario, and as such, Canvas would obviously default to that.  I'm still baffled, though, as to why the option to publish isn't available on the creation of the module item.  It's not a big deal though.  It was an extra couple lines of code in my script to publish it.  

Thanks for your insight! It makes perfect sense.