Jump to content

Bulk creation of homework's (assignments)


pconkie

Recommended Posts

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?

Capture.PNG.3090fe36a4cf04785057e12ab325c4f2.PNG

Thanks

 

 

Edited by pconkie
  • Like 2
Link to comment
Share on other sites

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

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).

590872ac29a79_mycodeheaders.PNG.ff7cfc5e5383196c9d4c6c8489b6e83c.PNG590872b02c594_frogheaders.PNG.3be92ec81c1f5339a2faac8b82415f08.PNG

Left hand side is my code, right hand side is frog

And the response (left my code, right frog)....

5908731a09fb9_mycoderesponse.PNG.16e0c16a3c3617a9fc01f4996703b315.PNG5908731c7d4af_frogresponse.PNG.8cccba5cbbebccb1ec835818fc040382.PNG

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

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

  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...