pconkie Posted April 30, 2017 Share Posted April 30, 2017 (edited) We are currently looking at how we could use assignments to better support learning. We are considering all staff using assignments in frog for some or all homework. I have been asked about the possibility of bulk assignment creation from excel or a google sheet (which is where details of homework are typically stored now). I think there are a number of steps needed to accomplish this... 1. Bring the external records into frog 2. For each record in turn a) create a site (sites.create) b) update the site (create a page to 'host' the assignment - sites.update) c) create an assignment using the site just created (assignments.create) Thanks to the tutorial on 'using firebase with frog' step 1 is done. Based on another tutorial on here: 'understanding frog api' I have made a start on step 2a. However, I believe that sites.create requires the form data to be POSTED rather than attached as a GET request. This would make it different to other Frog.model.api examples on this forum. I have been trying (unsuccessfully) variations to the code below to get the data "posted" to the end point. If this is the problem then can anyone shed any light on the correct syntax? Thanks Edited April 30, 2017 by pconkie 2 Link to comment Share on other sites More sharing options...
Chris.Smith Posted May 2, 2017 Share Posted May 2, 2017 Hi @pconkie, You are almost there! Frog.Model .api( 'sites.create', { page: [], quiet: true, name: 'test66', description: 'my description', theme: '7397AE892002C4FABE0FAFC9D06525054B7A007C5EV5C06D' }, { type: 'POST' } ).done(function(thisResponse) { var site = thisResponse.data.site; console.log(site.uuid); }); The third parameter is the options we want to send to jQuery to tell it how to send the request to the server! For more information, check out the api method's documentation here - https://froglearn.backwellschool.net/app/lib/packaging/docs/Com.Frog.Model.html Hope this helps, Chris Link to comment Share on other sites More sharing options...
pconkie Posted May 2, 2017 Author Share Posted May 2, 2017 Hi Chris Thanks for this pointer! And I think the link to the docs (that I had no ideas existed) will be extremely useful. Thanks Paul Link to comment Share on other sites More sharing options...
pconkie Posted May 2, 2017 Author Share Posted May 2, 2017 Actually - I still have no joy with this code...... It now posts the required parameters to the end point and I have what appears to be identical request headers, but the response returned is code: 1000 (An internal error has occurred). Left hand side is my code, right hand side is frog And the response (left my code, right frog).... I can't see a difference between the two. Is there another reason why code on a html widget might generate the error? Thanks Paul Link to comment Share on other sites More sharing options...
Chris.Smith Posted May 2, 2017 Share Posted May 2, 2017 Hi @pconkie, Sorry about that. It appears that your specified theme uuid is incorrect, odd that the information coming back is not entirely useful. Correct your theme uuid and it should work for you. You could also try a different method of programmatically creating sites. Unfortunately, we haven't written the documentation for this part of the system yet, so there will be an element of blind programming here. // We need the createsite component; if its not loaded, then get it // once loaded, run the function passed into .then() steal('//frogui/components/createsite/createsite.js').then(function() { var $el = $('<div />'); // Create a virtual element to "host" the component. $el.on('createsite.created', function(ev, site) { // A site is born! console.log(site.uuid); }); $el.on('createsite.error', function() { // error handling code goes here }); new Frogui.Controllers.Components.Createsite($el, { quiet: true, title: 'test45785d', launchOnCreate: false, theme: '7397AE892002C4FABE0FAFC9D06525054B7A007C5EV5C06D', description: 'my description', pages: [{ sequence: 0, name: 'Page 1', layout: 'F7B77DAF2002B37FD67E3F8F9EF9F50BFFB6EE2C088C91F6', parent_uuid: null, buckets: [] }] }); }); This approach is more complex but offers you can easy way of building the pages out. There is a lot of async code happening here, which will require a delicate hand to manage as I imagine you are gonna be looping through loads of data. If you would like more information on this approach let me know. Hope this helps ~ Chris 1 Link to comment Share on other sites More sharing options...
pconkie Posted May 3, 2017 Author Share Posted May 3, 2017 Thanks again Chris, I must have checked that theme id ten times! All working great now. I like the alternative method above as it combines step 2a and 2b from my original post (and i don't need to pass a page uuid, which seems to be needed for sites.update) I know what you mean about async issues, ta. Paul 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now