Picture of Aleksey Klimenko
Insert pre-made html in component "body"
by Aleksey Klimenko - Thursday, 20 August 2015, 8:41 AM
 

Hi all!

The question is - what should I do to to load html text to component body from an external html file?

I don't use the Authoring tool and it's a bit difficult to edit all the component html bodies in the same components.json file.

Thanks,

Aleksey

 

Picture of Gareth Walker
Re: Insert pre-made html in component "body"
by Gareth Walker - Thursday, 20 August 2015, 8:23 PM
 

As in you want to show/embed a block of html? If so, the iFrame plugin could help: https://github.com/LearningPool/adapt-contrib-responsiveIframe

But I've possibly misunderstood the question!

Picture of Aleksey Klimenko
Re: Insert pre-made html in component "body"
by Aleksey Klimenko - Thursday, 20 August 2015, 10:07 PM
 

Hi, Gareth. Thanks for reply!

I want put my course components' content in separate folders, for example:

assets/c-25/, assets/c-26/...

So i just want to put my component bodies' with formatted html text "<p><b>Lorem</b> ipsum</p>" into separate html files instead of write them in components.json file.

For example: assets/c-25/body.html, assets/c-26/body.html...

I think it can help to edit this content in future. That's why I'm looking for a right way to do it.

 

 

Picture of Oliver Foster
Re: Insert pre-made html in component "body"
by Oliver Foster - Friday, 21 August 2015, 5:11 PM
 

There are a few ways to do this.

 

1. You'll need to make an extension to populate the JSON models with the HTML when the course starts up. It'll make a separate request for each component, so this could really slow down your course. To write the extension you'll need to know how Adapt loads the course data and do some client side javascripting.

2. You could make amends to the grunt file to pick up the HTML and insert it into the relevant place in the components.json. that means you won't be making any extra requests from the client side. But you will have to do a bit of extreme coding in node.

3. Find a better way of naming / editing / spacing your component.json so that you don't have to go down this route. It'll be a lot of effort unless you can make a case for decent reward.

 4. Make a little prebuilding utility in javascript that populates the components.json from you HTML files. Then use adapt as normal. 

I hope that helps somewhat?

 

Ollie

Picture of Gareth Walker
Re: Insert pre-made html in component "body"
by Gareth Walker - Saturday, 22 August 2015, 7:34 PM
 

I guess an extension of option 4 might be to use any language you're comfortable with (e.g. Ruby/Perl/Python) to create a set of scripts that would process and output your course JSON from a HTML source. 

How tricky that is could depend on how consistent or otherwise your components were likely to be. But before too long you could be talking a kind of command line authoring tool....

Picture of Aleksey Klimenko
Re: Insert pre-made html in component "body"
by Aleksey Klimenko - Saturday, 22 August 2015, 11:56 PM
 

Oliver,

Thanks for that list of option. I've already done a kind of option 1, but it seems that option 4 is a more clear way so I'll try to make a utility for my needs. 

Thank you for good ideas!

Aleksey

Picture of Oliver Foster
Re: Insert pre-made html in component "body"
by Oliver Foster - Sunday, 23 August 2015, 5:53 PM
 

Cool! let use know if you solve it. :)