Converting Wise 2.0 projects to a Wise 3.0 otml file

0 views
Skip to first unread message

Geoffrey Kwan

unread,
Apr 11, 2008, 7:06:52 PM4/11/08
to otrun...@googlegroups.com
Hi OTrunk Guys,

    I am working on a converter from Wise 2.0 projects to Wise 3.0 projects (in otml file form) that we will load in to the authoring tool. This is so we can easily convert old Wise 2.0 projects to Wise 3.0 projects in an authorable/editable state.

I have gotten some of the basic step conversion implemented such as Evidence, Display Page, Outside Link, Note, Student Assessment, Self Check/Self Assessment. What I have done to implement the conversion is load up the Wise 2.0 project exported zip file, constructed the project from the xml within the zip file, and then called saveCurnit to save the project in otml file form. Now I need to get the following steps converted

OTrunk
OTrunkDIY
OTrunkModel
WiseDraw

How should I go about working on this? I see that there is already an OTrunkConverter written by Aaron, but this uses rims and pods. How can I create an OTrunk step without using rims and pods?

Are there files that I can look at that can help me figure out how to convert these OTrunk steps?

Thanks,
Geoff

Scott Cytacki

unread,
Apr 14, 2008, 2:22:37 PM4/14/08
to otrun...@googlegroups.com
For those that are following the OTrunk list. There is an ongoing
effort to port a system that was using XMLEncoder for its serialization
format to using OTrunk for serialization. The system being ported is
the called Pas. This question is related to that effort.

----

Geoff, you should be able to use the same converters, for now you can
take out the code that makes the rims.

But you will probably have to add the rim code back in once we sort out
the OTrunkCurnit user data persistence.

It would be easier to maintain both converters if they shared the same
code. Are you able to do that?

Scott

Geoffrey Kwan

unread,
Apr 15, 2008, 7:27:59 PM4/15/08
to otrun...@googlegroups.com
In Wisedraw2Converter.java I have commented out the pod code but when the step is transferred to otml, it's empty and just looks like this below

<OTGenericOTrunkStep />

I noticed there was code utilizing a URL to insert the data into the step.
            URL podURL = addToArchive("drawing.otml", otmlInput);
            step.setAuthoredDataURL(podURL);
It creates a "drawing.otml" file and then sets the step to point to it but this utilizes pods and throws a nullpointer.

Trying this
            step.setTarget(drawingTool);
accomplishes nothing as well.


How can I insert the data into the step?


Here's the code in the Wisedraw2Converter.java after commenting out the pod stuff.


    public PasStep getTypedPasStep() {
        OTrunkStep step = new OTrunkStep();
       
        /*
         * The java code below creates this xml file
         *
<otrunk>
  <imports>
    <import class="org.concord.otrunk.OTSystem"/>
    <import class="org.concord.otrunk.view.OTViewEntry"/>
    <import class="org.concord.otrunk.view.OTViewService"/>
    <import class="org.concord.graph.util.state.OTDrawingTool"/>
    <import class="org.concord.otrunk.view.document.OTCompoundDoc"/>
  </imports>
  <objects>
    <OTSystem>
      <services>
        <OTViewService>
          <viewEntries>
            <OTViewEntry
              objectClass="org.concord.graph.util.state.OTDrawingTool"
              viewClass="org.concord.datagraph.state.OTDataDrawingToolView"/>
            <OTViewEntry
              objectClass="org.concord.otrunk.view.document.OTDocument"
              viewClass="org.concord.otrunk.view.document.OTDocumentView"/>
          </viewEntries>
        </OTViewService>
      </services>
      <root>
        <OTCompoundDoc>
          <bodyText>
            Hello World<br/>
            <object refid="${drawing1}"/>
          </bodyText>
          <documentRefs>
            <OTDrawingTool local_id="drawing1"/>
          </documentRefs>
        </OTCompoundDoc>     
      </root>
    </OTSystem>
  </objects>
</otrunk>
         */
       
        // Need to create the OTrunk state here
        OTDatabase otDb = new XMLDatabase();
        OTDrawingTool drawingTool = null;
        try {
            OTrunk otrunk = new OTrunkImpl(otDb);
            OTSystem system = (OTSystem)otrunk.createObject(OTSystem.class);
            otrunk.setRoot(system);

            OTObjectList bundles = system.getBundles();
            OTViewBundle viewBundle =
                (OTViewBundle) otrunk.createObject(OTViewBundle.class);
            bundles.add(viewBundle);

            OTViewEntry viewEntry;
            // Create drawing tool view mapping
            viewEntry = (OTViewEntry)otrunk.createObject(OTViewEntry.class);
            viewEntry.setObjectClass(OTDrawingTool.class.getName());
            viewEntry.setViewClass(OTDataDrawingToolView.class.getName());
            viewBundle.getViewEntries().add(viewEntry);

            // Create document view mapping
            viewEntry = (OTViewEntry)otrunk.createObject(OTViewEntry.class);
            viewEntry.setObjectClass(OTCompoundDoc.class.getName());
            viewEntry.setViewClass(OTDocumentView.class.getName());
            viewBundle.getViewEntries().add(viewEntry);

            OTCompoundDoc compoundDoc =
                (OTCompoundDoc)otrunk.createObject(OTCompoundDoc.class);
            system.setRoot(compoundDoc);
                       
            drawingTool =
                (OTDrawingTool)otrunk.createObject(OTDrawingTool2.class);
           
            Map<String, URI> backgrounds = getNamedUris("backgrounds");

            Set<Entry<String, URI>> entries = backgrounds.entrySet();

            if(entries.size() > 0) {
                Entry<String, URI> entry = entries.iterator().next();

                URL backgroundURL = entry.getValue().toURL();

                // This is a hack because there isn't a better way yet
                BlobResource blobResource = new BlobResource(backgroundURL);
                OTDataObject drawingToolDO =
                    otDb.getOTDataObject(null, drawingTool.getGlobalId());
                drawingToolDO.setResource("backgroundImage", blobResource);
            }

            List<URI> stamps = getUris("stamps");


            for (URI uri : stamps) {
                URL url = uri.toURL();

           
                OTDrawingStamp stamp =
                    (OTDrawingStamp)otrunk.createObject(OTDrawingStamp.class);
                drawingTool.getStamps().add(stamp);
               
                stamp.setAlwaysOn(true);
                               
                // This is a hack because there isn't a better way yet
                BlobResource blobResource = new BlobResource(url);
               
                OTDataObject stampDO =
                    otDb.getOTDataObject(null, stamp.getGlobalId());
                stampDO.setResource("src", blobResource);
            }
           
            String instructionText = getInstructionText();
                       
            // Strip off the header
            instructionText =
                instructionText.replaceFirst("(?s).*<body>(.*)</body>.*", "$1");

            instructionText += "<object refid=\"" +
                drawingTool.otExternalId() + "\"/>";
            compoundDoc.setBodyText(instructionText);
                       
            // now we need to write out this database to a file and then
            // refer to that file url
            File outputFile = File.createTempFile("drawing", "otml");
            ExporterJDOM.export(outputFile, otDb.getRoot(), otDb);

            InputStream otmlInput = new FileInputStream(outputFile);
//            URL podURL = addToArchive("drawing.otml", otmlInput);
//           
//            step.setAuthoredDataURL(podURL);
//           
//            // Setup the icons for this step           
//            URL iconUrl;
//            BeanIcons icons = new BeanIcons();
//           
//            iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_COLOR_16x16);
//            if(iconUrl != null){           
//                InputStream iconInput = iconUrl.openStream();
//                URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
//                icons.setColor16x16(podUrl);
//            }       
//            iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_COLOR_32x32);
//            if(iconUrl != null){           
//                InputStream iconInput = iconUrl.openStream();
//                URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
//                icons.setColor32x32(podUrl);
//            }
//            iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_MONO_16x16);
//            if(iconUrl != null){           
//                InputStream iconInput = iconUrl.openStream();
//                URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
//                icons.setMono16x16(podUrl);
//            }
//            iconUrl = PasStepIconProvider.getIconUrl("draw", BeanInfo.ICON_MONO_32x32);
//            if(iconUrl != null){           
//                InputStream iconInput = iconUrl.openStream();
//                URL podUrl = addToArchive(iconUrl.getFile(), iconInput);
//                icons.setMono32x32(podUrl);
//            }
        } catch (Exception e){
            e.printStackTrace();
        }
//       
//        // FIXME need to take care of the introduction html
//        // can try putting it in OTDocument later
//        // step.setIntroductionHtml(getInstructionText());
//
//
//        Rim<byte[]> rim = new Rim<byte[]>();
//
//        //rim.setShape(String.class);
//        rim.setShape(byte[].class);
//        rim.setName("otrunk_drawing");
//        step.setWorkRim(rim);
//        getPod().add(rim);
       
        //the stuff below here is Geoff trying to get the drawing data into the step and not part of the original converter
        try {
            //step.setAuthoredDataURL(new URL("hello"));
        } catch(Exception e) {
            e.printStackTrace();
        }
        //step.setTarget(drawingTool);
        return step;
    }

I've been extending the previous converter so that they can share the same code when needed.

Thanks,
Geoff
Reply all
Reply to author
Forward
0 new messages