Search in sources :

Example 1 with ContentPackageResource

use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource in project openolat by klemens.

the class QTI21AssessmentTestHandlerTest method readManifest.

private boolean readManifest(File tmpDir) throws ImsManifestException, XmlResourceNotFoundException {
    QtiContentPackageExtractor extractor = new QtiContentPackageExtractor(tmpDir);
    QtiContentPackageSummary summary = extractor.parse();
    List<ContentPackageResource> items = summary.getItemResources();
    List<ContentPackageResource> tests = summary.getTestResources();
    return items.size() == 1 && tests.size() == 1;
}
Also used : QtiContentPackageSummary(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary) ContentPackageResource(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource) QtiContentPackageExtractor(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor)

Example 2 with ContentPackageResource

use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentTestHandlerTest method readManifest.

private boolean readManifest(File tmpDir) throws ImsManifestException, XmlResourceNotFoundException {
    QtiContentPackageExtractor extractor = new QtiContentPackageExtractor(tmpDir);
    QtiContentPackageSummary summary = extractor.parse();
    List<ContentPackageResource> items = summary.getItemResources();
    List<ContentPackageResource> tests = summary.getTestResources();
    return items.size() == 1 && tests.size() == 1;
}
Also used : QtiContentPackageSummary(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary) ContentPackageResource(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource) QtiContentPackageExtractor(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor)

Example 3 with ContentPackageResource

use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource in project OpenOLAT by OpenOLAT.

the class ManifestPackageTest method makeManifest.

@Test
public void makeManifest() throws XmlResourceNotFoundException, ImsManifestException, IOException {
    ManifestBuilder manifest = ManifestBuilder.createAssessmentTestBuilder();
    String testFilename = manifest.appendAssessmentTest();
    String itemFilename = manifest.appendAssessmentItem();
    Assert.assertNotNull(testFilename);
    Assert.assertNotNull(itemFilename);
    File tmpDir = new File(WebappHelper.getTmpDir(), "itembuilder" + UUID.randomUUID());
    tmpDir.mkdirs();
    File manifestFile = new File(tmpDir, "imsmanifest.xml");
    FileOutputStream out = new FileOutputStream(manifestFile);
    manifest.write(out);
    out.flush();
    out.close();
    QtiContentPackageExtractor extractor = new QtiContentPackageExtractor(tmpDir);
    QtiContentPackageSummary summary = extractor.parse();
    List<ContentPackageResource> items = summary.getItemResources();
    List<ContentPackageResource> tests = summary.getTestResources();
    Assert.assertEquals(1, items.size());
    Assert.assertEquals(1, tests.size());
    ManifestBuilder reloadManifest = ManifestBuilder.read(manifestFile);
    Assert.assertNotNull(reloadManifest);
    FileUtils.deleteDirsAndFiles(tmpDir.toPath());
}
Also used : FileOutputStream(java.io.FileOutputStream) QtiContentPackageSummary(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary) File(java.io.File) ContentPackageResource(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource) QtiContentPackageExtractor(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor) Test(org.junit.Test)

Example 4 with ContentPackageResource

use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource in project openolat by klemens.

the class ManifestPackageTest method makeManifest.

@Test
public void makeManifest() throws XmlResourceNotFoundException, ImsManifestException, IOException {
    ManifestBuilder manifest = ManifestBuilder.createAssessmentTestBuilder();
    String testFilename = manifest.appendAssessmentTest();
    String itemFilename = manifest.appendAssessmentItem();
    Assert.assertNotNull(testFilename);
    Assert.assertNotNull(itemFilename);
    File tmpDir = new File(WebappHelper.getTmpDir(), "itembuilder" + UUID.randomUUID());
    tmpDir.mkdirs();
    File manifestFile = new File(tmpDir, "imsmanifest.xml");
    FileOutputStream out = new FileOutputStream(manifestFile);
    manifest.write(out);
    out.flush();
    out.close();
    QtiContentPackageExtractor extractor = new QtiContentPackageExtractor(tmpDir);
    QtiContentPackageSummary summary = extractor.parse();
    List<ContentPackageResource> items = summary.getItemResources();
    List<ContentPackageResource> tests = summary.getTestResources();
    Assert.assertEquals(1, items.size());
    Assert.assertEquals(1, tests.size());
    ManifestBuilder reloadManifest = ManifestBuilder.read(manifestFile);
    Assert.assertNotNull(reloadManifest);
    FileUtils.deleteDirsAndFiles(tmpDir.toPath());
}
Also used : FileOutputStream(java.io.FileOutputStream) QtiContentPackageSummary(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary) File(java.io.File) ContentPackageResource(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource) QtiContentPackageExtractor(uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor) Test(org.junit.Test)

Aggregations

ContentPackageResource (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource)4 QtiContentPackageExtractor (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor)4 QtiContentPackageSummary (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary)4 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 Test (org.junit.Test)2