cancel
Showing results for 
Search instead for 
Did you mean: 
michael_mcgarr1
Surveyor

Create a Sandbox Course via Web Application/API?

Jump to solution

Hi Canvas gurus,

I've got a bit of a dreamscape project that I'm looking to build and am wondering if anyone has done anything similar or is able to help me think through how to best develop it. What I'm wanting to build is a webpage on our university's site that would allow a faculty member to create a sandbox course on their own as opposed to emailing our team to do it for them. 

The simplest way to achieve this would be to enable faculty to create courses within Canvas, however, I'd like to make a more controlled process that automatically adds the course to the correct subaccount, and also has a prefix appended to the reference ID.

So here's the ideal solution: a webpage where a faculty member signs in, they click a "Create Sandbox Course" button that asks what they'd like the name of the course to be, and then that course gets created and with them enrolled as the instructor. Any ideas of how to achieve this or is this too simplistic in the reality of what needs to happen?

I appreciate any and all recommendations.


Thanks!
- Michael

54 Replies

I don't know what the API's threshold for harassment is but...

I think I wrote most of the sub account tray menu against production, simply because it was faster. :smileyblush: 

Tolerance must be high.

Are you working on production, test or beta?

What roles do you get from?

// console

ENV.current_user_roles

What roles do you have set on line 50?

// the roles allowed to create a workroom
roles: ['teacher']

How are you disabling course creation?

/README.md#removing-the-course-button 

278623_course-button.png

If you can share your source somewhere, I'll see I get the same error.

Are you working on production, test or beta?

Working in beta

 

What roles do you get from?

// console

ENV.current_user_roles

For this, masquerading as a user who is hitting the error, I get the following:

console results

And when I run it logged in as myself, where I'm able to create the workroom successfully, I get this:

console results

 

What roles do you have set on line 50?

// the roles allowed to create a workroom
roles: ['teacher']

I've left this as is, set to 'teacher'

 

How are you disabling course creation?

/README.md#removing-the-course-button

I believe that we simply have this disabled within our Permissions at the account level for anyone who is not an administrator.

Hopefully this helps. Thanks! 

So those users don't have the + Course button anywhere because a permission removes it?

I'm looking for that permission but I don't see it. What's it called?

I'm pretty sure we don't disable any permissions for creating courses, we adjusted the UI to hide the button, and using this script define HOW they create a course.

It's not really a permission, it's a setting in the account settings:

278754_pastedImage_1.png

Thanks  @MattHanes . Yes, carroll-ccsd, that's where it is. I couldn't remember where that setting was but I knew I had disabled it back when we first adopted.

Thanks  @MattHanes !

Definitely looking in the wrong place (and honestly, still brushing up on just how Aaron set this up)

 @michael_mcgarry , here's what we have set... should fix those errors.

278752_Screen Shot 2018-06-06 at 9.48.43 AM.png

You'll need to apply that snippet to remove the +Course button, between line 35-41 of the gist.

Now, this may fall back to the Implementation & Deployment part of the readme. All staff in our district have the teacher role because we auto generate their first Workroom and their teacher enrollment for the workroom via SIS Import. If you have staff who don't have teacher enrollment yet, they will probably still get a permissions error.

Thanks carroll-ccsd, that seems to have done it! Except now I'm getting the error as an admin...but I'm thinking this is more a timeout issue. For my own testing purposes (excuse the super n00b question here), what would be the correct syntax so that both the 'teacher' role and the 'admin' role were permitted in line 50?

 @michael_mcgarry ,

Everybody was a noob sometime, some days I'm not sure I'm any further along. :smileygrin:

Try ['teacher','admin','root_admin']

If you to paste your code somewhere like JSFiddle , I'll try it out on test and see if I can spot anything. Remember, I'm kinda working through this too because a previous employee wrote and implemented it, so I could be missing steps. Positive that the entire setup happens within Canvas and the UI, so nothing too technical. Just have to work our way through it.

Hmmm...I had tried that too. The weird thing is it's almost like adding those roles bricks the entire thing as I no longer see the + Workroom button when I upload that version.

no button

I went ahead and created a Fiddle for you take a look at. Thanks for taking the time to work this out with me! It's much appreciated. This has been a little pet project for me that I've been wanting to get done for a while, so you're helping me and our campus out a ton with this.

Try removing the comma on line 70 :smileygrin:

.toLocaleDateString('en-US', {
    month: 'short',
    day: '2-digit',
    year: '2-digit', // this comma, this must go
})‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Doing so, gave me the button when I pasted it into the console. I used my own term and sub account, and got this...

278837_Screen Shot 2018-06-07 at 10.49.27 AM.png