To start off with a page that everyone might find useful is this one:
http://confluence.concord.org/display/CSP/OTrunk+HowTo
Any general info about OTrunk that other developers might find useful
should go here.
You can also create individual pages for more lengthy pieces of info,
for example:
http://confluence.concord.org/display/CSP/OTrunk+Script+Example
At some point the HowTo page will be reorganized, so it isn't one giant
page.
I answered your specific questions below.
Geoffrey Kwan wrote:
> Hi,
>
> I am trying to implement the getReportForLearner() function in OTrunkStep.
>
> We found where it creates the xhtml in OTMLToXHTMLConverter.java. The
> bodyText contains the xhtml in the code below.
>
> OTJComponentView objView =
> getOTJComponentView(topLevelOTObject, mode);
>
> OTXHTMLView xhtmlView = null;
> String bodyText = "";
> if(objView instanceof OTXHTMLView) {
> xhtmlView = (OTXHTMLView) objView;
> bodyText = xhtmlView.getXHTMLText(topLevelOTObject);
> }
> //System.out.println(bodyText);
>
> We are wondering how to obtain the OTJComponentView from within an
> OTrunkStep.
I think you should be able to use the OTMLToXHTMLConverter to do the
work. So you don't need to worry about getting the OTJComponentView
yourself. If not then we/you should fix it so you can use it. All you
have to worry about (I think) is calling the correct constructor for
OTMLToXHTMLConverter, calling setXHTMLParams, and then calling the run
method.
I think the right constructor is probably:
public OTMLToXHTMLConverter(OTViewFactory viewFactory, OTObject otObject)
you should be able to get the correct viewFactory and root object, out
of the viewerHelper used by OTrunkStep.
>
> We are also wondering how to obtain topLevelOTObject which is a
> DefaultOTObject from within an OTrunkStep. Is it possible to obtain a
> DefaultOTObject from the getComponent() method within OTrunkStep?
>
> Does any of the code below relate to how we could obtain the
> DefaultOTObject? (this code is from within getComponent())
>
> OTViewContainerPanel otPanel =
> viewerHelper.createViewContainerPanel();
> panel.setLayout(new BorderLayout());
>
> panel.add(otPanel, BorderLayout.CENTER);
>
> OTObject root = viewerHelper.getRootObject();
This shouldn't be necessary if you follow the approach above.
The OTMLToXHTMLConvert code has a few bugs that are mentioned here:
http://jira.concord.org/browse/ALL-38
Hopefully you won't run into these problems with the draw tool.
Scott
Sam, can you verify that these changes don't break how you are using it
in UDL?
If they do break it can you send me instructions how I should test it,
so I can do that as I make changes?
Geoff, if you are using this with the OTrunkStep you are probably
getting the classes from a otrunk jar in your local maven repository.
If you want to test you code with these latest changes you'll need to
add the otrunk project to your launcher classpath infront of the maven
dependencies. Once this OTMLToXHTMLConverter code is stabilized you can
probably go back to using the otrunk jar in your local maven repository.
Scott
Geoffrey Kwan wrote:
> I am trying to invoke the constructor
>
> public OTMLToXHTMLConverter(OTViewFactory viewFactory, DefaultOTObject
> otObject)
>
> from within OTrunkStep.java
>
>
> Is there a way to obtain a DefaultOTObject from within the OTrunkStep.
> I can only obtain an OTObject from viewerHelper.getRootObject() but
> need a DefaultOTObject. I have tried casting the
> viewerHelper.getRootObject() to a DefaultOTObject but I receive a
> ClassCastException.
>
> Thanks,
> Geoff
>
> On Jan 23, 2008 11:31 AM, Scott Cytacki <scyt...@fastmail.fm
The OTMLToXHTMLConverter extends the Thread class. With the Thread
class if you call the start method it creates a new thread of execution
and then calls the run method in this new thread.
Scott
Geoffrey Kwan wrote:
> When I try to call oTMLToXHTMLConverter.run(); I receive an exception.
> Is there any way to resolve this?
>
> Here's my code below
>
> OTMLToXHTMLConverter oTMLToXHTMLConverter = null;
> File outputFile = new File("output.txt");
> OTObject otObject = null;
> try {
> otObject = viewerHelper.getRootObject();
> oTMLToXHTMLConverter = new
> OTMLToXHTMLConverter(viewerHelper.getViewFactory(), otObject);
> oTMLToXHTMLConverter.setXHTMLParams(outputFile, 200, 200);
> *oTMLToXHTMLConverter.run();*
Have you tried debugging it? I find debugging something is good way to
learn how it works. If you find some code that you can't figure out let
us know and we can help. We could talk about this more at our meeting
today.
> If I try to Show All Work, I then receive this output in the console
> in Eclipse
>
> Loaded objects in:
> jar:podar:dddddddd-0002-0002-0000-000982454303!/drawing.otml
> error reading property "template-id" it is not defined for type:
> org.concord.graph.util.state.OTDrawingTool
> Loaded objects in: unknown_name
>
> and the image is blank in Show All Work.
the template-id error is not a problem. I think the "unknown_name" is
not a problem either. Usually that would be the url for the file the
students work is loaded from, but since it is coming from a sockEntry it
has an "unknown_name".
>
> Do you guys know why it doesn't save all the time when the "Save"
> button is clicked?
It will only save if it thinks the drawing has been changed. When you
say it doesn't save is that because you are debugging it and can tell
the data isn't going into a sock entry? Or is it that you are not
seeing your drawing?
>
> Another issue is that the dimension of the image that is captured has
> a max of width = 550, and height = 225 which is set in the
> OTDrawingToolView.java in the function getPrintDimention(int
> containerDisplayWidth, int containerDisplayHeight). This may cause the
> drawing to be cropped since some students may have their VLE window
> set to a larger size. Are the dimensions set to 550, and 225 for a
> reason or can I increase it in OTDrawingToolView.java?
Yeah that is a problem. OTDrawingToolView should calculate the best
dimension in the getPrintDimension method. The best solution would be this:
First it looks at the width of the background image, and it then looks
at the bounding box of all the objects that drawn. It should take the
larger of the two in each direction. Just that would get us pretty far.
Second it should compare this to the containerDisplay* params. If its
calculate size is larger then it needs to store some scale factor, and
when the getComponent method is called this scale factored should be
used to shrink the drawing down to size.
Can you try adding the first part of the calculation to OTDrawingToolView?
>
>
> Thanks for all your help Scott,
No problem, keep it coming. :)
Scott