Convert a simple html file to scorm package - java

I want to host my html asset into LMS, here LMS only accept and run the SCORM Package.
How can i convert an html file (exporting from my app using jasper report) to a scorm package?
Any help?

For single pages, in fact the best approach I found was to do it mannually: based on: https://www.ispringsolutions.com/blog/how-to-convert-html-to-scorm to adapt it, just ignore the res folder and point to the index on: <resource identifier="resource_1" type="webcontent" adlcp:scormtype="sco" href="index.html">
Download a SCORM example: https://21w98o3yqgi738kmv7xrf9lj-wpengine.netdna-ssl.com/wp-content/assets/golf_examples/PIFS/ContentPackagingSingleSCO_SCORM12.zip
extract it;
in imsmanifest.xml change the title to your title;
List all the resources that your HTML page includes;
Zip the course root folder (with the manifest file).

On this page you will find software that you can use to create SCORM compatible packages. If you have created a simple project, you can unpack the resulting ZIP file and edit the content. Mostly you will find an index.html there. I know, that sounds a bit awkward at first.
https://docs.moodle.org/35/en/Creating_SCORM_Content

Related

Load HTML file from a linked java library into Android webview

I have a webview into which I'd like to load an HTML file that comes from an external java library.
That is, my project includes a java library that, besides a bunch of Java classes, also contains a bunch of HTML (and related) files inside its resource folder. I'd like to load these files into my webview.
I know how to load HTML files when they are located in the assets folder: you simply run webview.loadUrl("file:///android_asset/your-file.html").
I do not know how to write the url to access resources in the linked JAR. The docs do not help much.

Access image file inside a Jar file dynamically

I have a Java project,exported as a JAR file (Desktop Application) which generates a HTML file as output. The output html file, needs to read one image file, as the page's logo. The JAR application will be in say X folder. The target html file will be placed dynamically anywhere. How do I make the html,residing in someother location, access the image, inside the JAR file.
In short, how do I determine the path for the below code, for the above scenario.
java.net.URL url = getClass().getResource("image.jpg");
fw.write("<tr><td><b>"+csname+"</b></td><td> <img src = "+url.toString()+"'>/td></tr>");
works fine, when i run in eclipse. But not when exported as JAR
The resultant html file,in some other folder has the code
<img src="rsrc:com/demo/dirapitoword/image.jpg">
You just need to read the image as a stream from the classpath, e.g.:
InputStream in = getClass().getResourceAsStream("image.jpg");
and write the stream out as a file to a known place on disk. There are lots of ways to do this, if you're using Java 7 or above, try:
File out = new File("image.jpg");
Files.copy(in, out.toPath());
Then, your src attribute can use the relative location you chose to display this image in the HTML, without having to worry about Jar compatibility in the browser / client.
You can find that the jar: URI Scheme exist for .zip containers as described in the Wikipedia here http://en.wikipedia.org/wiki/URI_scheme
The format is:
jar:<url>!/[<entry>]
BUT it is not supported by all browsers (only Firefox actually) as described in this article: https://code.google.com/p/browsersec/wiki/Part1
Even in that case, I think it is not very nice that the output .html can be elsewhere but contains an absolute path to your resources.
I suggest to use the data: URI scheme which allows to embed the image within the HTML page.
There is a question that covers this procedure: How to display Base64 images in HTML?
And in one of the answers, there is an interesting fiddle sample here: http://jsfiddle.net/hpP45/

Applet: Loading image in jar file that is not in home directory

this title may sound confusing so I'll explain my problem.
I am converting my java application to an applet, and it works fine in Eclipse and when I make a html file with tags. But when I upload my applet to google sites and execute it via a html file, the program itself loads fine, but it tries to load its images from my own hard disk instead of from the JAR file. How can I change that?
HTML:
<applet
archive="https://sites.google.com/site/projectteagame/tea.jar"
code="ymte.core.Loader"
width=300
height=300> </applet>
Edit:
I keep all my files in the jar, for speed and ease. My code to obtain the images is:
img = ImageIO.read(Loader.class.getResourceAsStream("/res/object/ball.bmp"));
This works in my IDE, but not in the online use
You can provide your code to tell us how you obtain the image, but I suppose it is not bundled in the jar. A way to do that is to put the jar in your packages and obtain it like this:
Class.getResourceAsStream("foo");
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)
This is kinda gimmicky, however. A preferred way would be to put your image into a directory in your project that is outside your sources, something like images or resources and then bundle it in the jar of the applet. Use your favorite build tool (ant, maven, ivy) to include the image in the jar. Directory structure can be like this:
project
-src
-resources
-<yourImage>
Then you would access your image as a URL or File using a relative path. If you provide more code, maybe you can receive further help.
EDIT:
SInce your resource is in your applet, you can put it in one of your packages. Then, further in your code you can do
Class.getResourceAsStream
and that is how you can get your image, since it is guaranteed to be in your classpath.
Basically, if you have a package structure like this:
project src
com.foo.bar
com.foo.bar.stuff
com.foo.bar.resources
-yourImage
-otherStuff
-ResourceGetter.java
You can do the following in your ResourceGetter
Class.getResourceAsStream("yourImage");
Which will give you a handle to your image and you can load it as you would do normally.

How to create CHM file using java?

I am planning to write a utility for me which will accept a directory having html files and then based on those html files it will create a CHM [Microsoft Compiled HTML Help] file.
So is there any free library to create CHM file ? If not then please mention some tutorial or links for basic understanding on how to create CHM file.
The "easiest" way to create a CHM file is to use the "HTML Workshop" from Microsoft.
Basically "HTML Workshop" is an .exe (hhc.exe) file, that compiles a given folder structure of HTML, CSS and JS into a single .chm file that is not editable anymore.
So in your case where you want to build the .chm file within java, you need to save your HTML, JS and CSS sources into the correct structure for the hhc.exe (see the "HTML Workshop" documentation on about how that structure has to look like).
Once that is done, copy the hhc.exe from it's installation directory into your HTML source folder and run it. This can be achieved by calling a batch script from your java application, what can be achieved using the following code:
Process p = Runtime.getRuntime().exec("host call mySuperCoolBatchScript.bat);
p.waitFor();
Once the compiling process is done, delete the previously copied hhc.exe file from your HTML source folder and done.
I hope that helps a bit, let me know if you have any questions.
From the reference of javadoc in chm format, Franck Allimant's site, there seems to exist two scripts for generating chm from javadoc :
A Python script
A Windows executable
Although I'm not fond of the snake, I would advice you to use the Python script, as it may be more easy to insert in a build process (read in maven or ant)

Image not showing in src tag

Can anybody tell me how do i give absolute path of the img tag's src attribute?
The following doesn't work
<img alt="NO IMAGE" src="/home/administrator/tiger-info0[1].gif"/>
I am working On Ubuntu and i am very sure that image exists on this path.
This is probably happening because the image is located outside the web server's document root.
Your web server will not be able to serve anything from outside the document root. One possible workaround is to use a scripting language that has access to the file system, and route the images through the script. For example, you may want to check out the following implementation in php:
Serving Images Outside Document Root Via PHP
You can also create a symbolic link of /home/administrator/ into the document root:
ln -s /www/yoursite /home/administrator
hmm why don't you copy the image to your web directory and give it the relative path? you server (apache?) may not be able to access the file to serve the browser.
if you are making a local html page you can use that path but if you are creating a website you have to use the absolute path to the document root. And make sure the image path is correct (use firebug)
Give your path correctly with domain or use ../ or ./ is for to represent correct relative path.
You cannot access files that are not in your document root. Get Java application server to not delete your folder. You can probably do this by having one folder into which your users can upload files, and add that folder to your project. You can let users create subfolders inside that main folder, and since the main folder is a part of your project, cleaning the build will not automatically delete it or its subfolders.

Categories