Search in sources :

Example 6 with Object

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object in project openolat by klemens.

the class AssessmentItemFactory method appendHotspotInteraction.

public static HotspotInteraction appendHotspotInteraction(ItemBody itemBody, Identifier responseDeclarationId, Identifier correctResponseId) {
    HotspotInteraction hotspotInteraction = new HotspotInteraction(itemBody);
    hotspotInteraction.setResponseIdentifier(responseDeclarationId);
    hotspotInteraction.setMaxChoices(1);
    itemBody.getBlocks().add(hotspotInteraction);
    Object graphicObject = new Object(hotspotInteraction);
    graphicObject.setType("image/png");
    graphicObject.setWidth("400");
    graphicObject.setHeight("320");
    hotspotInteraction.setObject(graphicObject);
    HotspotChoice choice = new HotspotChoice(hotspotInteraction);
    choice.setIdentifier(correctResponseId);
    choice.setFixed(Boolean.FALSE);
    choice.setShape(Shape.CIRCLE);
    List<Integer> coords = new ArrayList<>();
    coords.add(new Integer(55));
    coords.add(new Integer(77));
    coords.add(new Integer(8));
    choice.setCoords(coords);
    hotspotInteraction.getHotspotChoices().add(choice);
    return hotspotInteraction;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Example 7 with Object

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object in project OpenOLAT by OpenOLAT.

the class HotspotAssessmentItemBuilder method setBackground.

public void setBackground(String data, String mimeType, int height, int width) {
    Object graphichObject = hotspotInteraction.getObject();
    if (graphichObject == null) {
        graphichObject = new Object(hotspotInteraction);
        hotspotInteraction.setObject(graphichObject);
    }
    graphichObject.setData(data);
    graphichObject.setType(mimeType);
    if (height > 0) {
        graphichObject.setHeight(Integer.toString(height));
    } else {
        graphichObject.setHeight(null);
    }
    if (width > 0) {
        graphichObject.setWidth(Integer.toString(width));
    } else {
        graphichObject.setWidth(null);
    }
}
Also used : Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Example 8 with Object

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendHotspotInteraction.

public static HotspotInteraction appendHotspotInteraction(ItemBody itemBody, Identifier responseDeclarationId, Identifier correctResponseId) {
    HotspotInteraction hotspotInteraction = new HotspotInteraction(itemBody);
    hotspotInteraction.setResponseIdentifier(responseDeclarationId);
    hotspotInteraction.setMaxChoices(1);
    itemBody.getBlocks().add(hotspotInteraction);
    Object graphicObject = new Object(hotspotInteraction);
    graphicObject.setType("image/png");
    graphicObject.setWidth("400");
    graphicObject.setHeight("320");
    hotspotInteraction.setObject(graphicObject);
    HotspotChoice choice = new HotspotChoice(hotspotInteraction);
    choice.setIdentifier(correctResponseId);
    choice.setFixed(Boolean.FALSE);
    choice.setShape(Shape.CIRCLE);
    List<Integer> coords = new ArrayList<>();
    coords.add(new Integer(55));
    coords.add(new Integer(77));
    coords.add(new Integer(8));
    choice.setCoords(coords);
    hotspotInteraction.getHotspotChoices().add(choice);
    return hotspotInteraction;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Example 9 with Object

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object in project openolat by klemens.

the class ImportExportHelper method getMaterials.

protected static void getMaterials(AssessmentItem item, File itemFile, AssessmentItemsAndResources materials) {
    File directory = itemFile.getParentFile();
    QueryUtils.search(Img.class, item).forEach((img) -> {
        if (img.getSrc() != null) {
            String imgPath = img.getSrc().toString();
            File imgFile = new File(directory, imgPath);
            if (imgFile.exists()) {
                materials.addMaterial(new ItemMaterial(imgFile, imgPath));
            }
        }
    });
    QueryUtils.search(A.class, item).forEach((a) -> {
        URI href = a.getHref();
        if (href != null && href.getHost() == null && href.getPath() != null) {
            String hrefPath = href.getPath();
            File aFile = new File(directory, hrefPath);
            if (aFile.exists()) {
                materials.addMaterial(new ItemMaterial(aFile, hrefPath));
            }
        }
    });
    QueryUtils.search(Object.class, item).forEach((object) -> {
        if (StringHelper.containsNonWhitespace(object.getData())) {
            String path = object.getData();
            File objectFile = new File(directory, path);
            if (objectFile.exists()) {
                materials.addMaterial(new ItemMaterial(objectFile, path));
            }
        }
    });
}
Also used : A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) File(java.io.File) URI(java.net.URI)

Example 10 with Object

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object in project openolat by klemens.

the class DrawingAssessmentItemBuilder method setBackground.

public void setBackground(String data, String mimeType, int height, int width) {
    Object graphichObject = drawingInteraction.getObject();
    if (graphichObject == null) {
        graphichObject = new Object(drawingInteraction);
        drawingInteraction.setObject(graphichObject);
    }
    graphichObject.setData(data);
    graphichObject.setType(mimeType);
    if (height > 0) {
        graphichObject.setHeight(Integer.toString(height));
    } else {
        graphichObject.setHeight(null);
    }
    if (width > 0) {
        graphichObject.setWidth(Integer.toString(width));
    } else {
        graphichObject.setWidth(null);
    }
}
Also used : Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Aggregations

Object (uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)10 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 A (uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A)4 Img (uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img)4 File (java.io.File)2 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)2 HotspotChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)2