Some java broke my file

Jun 03, 2019

Firstly, I know java isn't officially supported and I may be screwed but here's the deal. I've got this object that had some working bits of java in it. Mainly to print a results page but they want it to be able to be emailed. So I got some java code from a guy in my office that works in the test form he gave me. So I modified that to fill the body with what I want and put that in and it doesn't work. But also neither does the print bit now and taking out the email code still leaves the print bit broken.  

Is there anything I can do short of rebuilding the object to fix this?

Also does anyone know of any hard limits of the java system, such as character/line counts/amount of variables it can pull in etc (what i'm trying to run is 179 lines/4538 chars, mostly being get vars and some html table code for the body. I don't really know if thats alot or not but the one that does work is 32lines/1056char

32 Replies
Phil Mayor

There are missing semicolons at the end of most lines, I can see a missing bracket and I don't think calling the results variable will work. 

I have not had a look at the table formatting, but suspect there are errors in that. Try writing the code in something like Atom that will highlight any syntax errors. I would generally write in steps so I know which bit doesn't work, it is laborious to test but at least you can see where you are going wrong.

Bruce French

I have it in notepad++ and nothing that I can see looks out of place and like I say. The original code does work and that has none of the ; that are missing so i'm less inclined to think that is what stopping it and as far as I can tell my table works fine (http://learn.nwrc.ac.uk/_teldemo/Test/skillstest/tabletest.html

Bruce French

I've gone through and put the ; in and now that (. Im trying to replace the bits one at a time and see where it breaks but so far i can only get the original to work. ¯\_(ツ)_/¯

What do mean not call the results variables but set another one? At the moment the values on all the question ones default to incorrect and then change to correct if the user gets it right so i'm just trying to display that value

Phil Mayor

One thing you can try is adding an alert in and moving it down through each line in the code this way you can check which bit is working

alert("Hello! Everything above me is working, something below is broken”);

For the results variables set up some numeric variables and add a trigger to assign the value of the results variable to that new variable.

Bruce French

Oh right do you just mean for the score part? Where would it display that alert. I havnt been able to get the f12 thing to come up when im on a storyline tab. I've made a little bit of process in that i have one with two buttons on it the one with the default which is sending and one with the same but all my getvars in which isnt. http://esprima.org/demo/validate.html this page says its syntactically valid so im going to look at that results thing next.

is there a better way to test these than publishing a new thing every time?

Russell Killips

Good morning,

I took a quick look at the java_email_code.txt file.

I don't see where player is defined. You are missing:
var player = GetPlayer();

Semicolons should also be used.

I have also never been able to access Results.ScorePoints directly with JavaScript. As a work around, create your own Points Variable and use a trigger to assign ScorePoints to your own variable. Then you can access your Points Variable with Javascript.

Bruce French

PROGRESS!!!!!

I removed references to the results and added that var player line at the top. One or both of those has made my button start working. I'm thinking because the original wasn't getting anything from storyline it didn't matter that line was missing. I'm now going to to another variable to take the place of that one and see if it still works.

Thanks very much to all you for the help. It is very much appreciated.

This discussion is closed. You can start a new discussion or contact Articulate Support.