Search in sources :

Example 1 with Img

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img in project OpenOLAT by OpenOLAT.

the class ImportExportHelper method getMaterials.

protected static List<String> getMaterials(AssessmentItem item) {
    List<String> materials = new ArrayList<>();
    QueryUtils.search(Img.class, item).forEach((img) -> {
        if (img.getSrc() != null) {
            materials.add(img.getSrc().toString());
        }
    });
    QueryUtils.search(A.class, item).forEach((a) -> {
        URI href = a.getHref();
        if (href != null && href.getHost() == null && href.getPath() != null) {
            materials.add(href.getPath());
        }
    });
    QueryUtils.search(Object.class, item).forEach((object) -> {
        if (StringHelper.containsNonWhitespace(object.getData())) {
            materials.add(object.getData());
        }
    });
    return materials;
}
Also used : A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) URI(java.net.URI)

Example 2 with Img

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img in project OpenOLAT by OpenOLAT.

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 3 with Img

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

the class ImportExportHelper method getMaterials.

protected static List<String> getMaterials(AssessmentItem item) {
    List<String> materials = new ArrayList<>();
    QueryUtils.search(Img.class, item).forEach((img) -> {
        if (img.getSrc() != null) {
            materials.add(img.getSrc().toString());
        }
    });
    QueryUtils.search(A.class, item).forEach((a) -> {
        URI href = a.getHref();
        if (href != null && href.getHost() == null && href.getPath() != null) {
            materials.add(href.getPath());
        }
    });
    QueryUtils.search(Object.class, item).forEach((object) -> {
        if (StringHelper.containsNonWhitespace(object.getData())) {
            materials.add(object.getData());
        }
    });
    return materials;
}
Also used : A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) URI(java.net.URI)

Example 4 with Img

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img 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)

Aggregations

URI (java.net.URI)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 Object (uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2