Search in sources :

Example 6 with QtiContentPackageExtractor

use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor 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

QtiContentPackageExtractor (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor)6 QtiContentPackageSummary (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageSummary)6 File (java.io.File)4 Test (org.junit.Test)4 ContentPackageResource (uk.ac.ed.ph.jqtiplus.utils.contentpackaging.ContentPackageResource)4 FileOutputStream (java.io.FileOutputStream)2 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)2