use of org.olat.oo.xml.manifest.OpenOLATMetadataType in project OpenOLAT by OpenOLAT.
the class ManifestMetadataBuilder method getOpenOLATMetadata.
/**
* Return the openolat metadata if it exists or, if specified, create
* one and append it to the metadata of the resource.
*
* @param resource The resource with the metadata
* @param create True create the qtiMetadata
* @return
*/
public OpenOLATMetadataType getOpenOLATMetadata(boolean create) {
List<Object> anyMetadataList = getMetadataList();
OpenOLATMetadataType ooMetadata = null;
for (Object anyMetadata : anyMetadataList) {
if (anyMetadata instanceof JAXBElement<?> && ((JAXBElement<?>) anyMetadata).getValue() instanceof OpenOLATMetadataType) {
ooMetadata = (OpenOLATMetadataType) ((JAXBElement<?>) anyMetadata).getValue();
}
}
if (ooMetadata == null && create) {
ooMetadata = ooObjectFactory.createOpenOLATMetadataType();
getMetadataList().add(ooObjectFactory.createOoMetadata(ooMetadata));
}
return ooMetadata;
}
use of org.olat.oo.xml.manifest.OpenOLATMetadataType in project openolat by klemens.
the class ManifestMetadataBuilder method getOpenOLATMetadata.
/**
* Return the openolat metadata if it exists or, if specified, create
* one and append it to the metadata of the resource.
*
* @param resource The resource with the metadata
* @param create True create the qtiMetadata
* @return
*/
public OpenOLATMetadataType getOpenOLATMetadata(boolean create) {
List<Object> anyMetadataList = getMetadataList();
OpenOLATMetadataType ooMetadata = null;
for (Object anyMetadata : anyMetadataList) {
if (anyMetadata instanceof JAXBElement<?> && ((JAXBElement<?>) anyMetadata).getValue() instanceof OpenOLATMetadataType) {
ooMetadata = (OpenOLATMetadataType) ((JAXBElement<?>) anyMetadata).getValue();
}
}
if (ooMetadata == null && create) {
ooMetadata = ooObjectFactory.createOpenOLATMetadataType();
getMetadataList().add(ooObjectFactory.createOoMetadata(ooMetadata));
}
return ooMetadata;
}
use of org.olat.oo.xml.manifest.OpenOLATMetadataType in project openolat by klemens.
the class ManifestPackageTest method readManifest.
/**
* @throws URISyntaxException
*/
@Test
public void readManifest() throws URISyntaxException {
URL xmlUrl = ManifestPackageTest.class.getResource("resources/manifest/oo_assessmentitem_imsmanifest_12_2.xml");
File xmlFile = new File(xmlUrl.toURI());
ManifestBuilder manifest = ManifestBuilder.read(xmlFile);
ManifestMetadataBuilder questionMetadata = manifest.getResourceBuilderByHref("sca9b540c9684ba58f489f02e8b5c590.xml");
Assert.assertNotNull(questionMetadata);
// LOM
String title = questionMetadata.getTitle();
Assert.assertEquals("Metadata", title);
String identifier = questionMetadata.getIdentifier();
Assert.assertEquals("id9f1ae47b-dc7f-482e-a688-111287f99fa6", identifier);
String keywords = questionMetadata.getGeneralKeywords();
Assert.assertTrue(keywords.contains("Meta"));
Assert.assertTrue(keywords.contains("data"));
Assert.assertTrue(keywords.contains("keywords"));
String context = "de";
Assert.assertEquals("de", context);
// educational
String educationContext = questionMetadata.getEducationContext();
Assert.assertEquals("Primarschule", educationContext);
String typicalLearningTime = "P1DT2H3M4S";
Assert.assertEquals("P1DT2H3M4S", typicalLearningTime);
// lifecycle
String version = "1.0";
Assert.assertEquals("1.0", version);
// classification
String taxonomyPath = questionMetadata.getClassificationTaxonomy();
Assert.assertEquals("/Mathematik/Topologie", taxonomyPath);
// QTI 2.1
QTIMetadataType qtiMetadata = questionMetadata.getQtiMetadata(false);
Assert.assertTrue(qtiMetadata.getInteractionType().contains("choiceInteraction"));
Assert.assertEquals("OpenOLAT", qtiMetadata.getToolName());
Assert.assertEquals("12.3a", qtiMetadata.getToolVersion());
// OpenOLAT specific
OpenOLATMetadataType openolatMetadata = questionMetadata.getOpenOLATMetadata(false);
Assert.assertEquals(Double.valueOf(0.5d), openolatMetadata.getDiscriminationIndex());
Assert.assertEquals(Double.valueOf(0.3d), openolatMetadata.getDifficulty());
Assert.assertEquals(Double.valueOf(0.4d), openolatMetadata.getStandardDeviation());
Assert.assertEquals(Integer.valueOf(1), openolatMetadata.getDistractors());
Assert.assertEquals("sc", openolatMetadata.getQuestionType());
Assert.assertEquals(Integer.valueOf(12), openolatMetadata.getUsage());
Assert.assertEquals("formative", openolatMetadata.getAssessmentType());
}
use of org.olat.oo.xml.manifest.OpenOLATMetadataType in project OpenOLAT by OpenOLAT.
the class ManifestPackageTest method readManifest.
/**
* @throws URISyntaxException
*/
@Test
public void readManifest() throws URISyntaxException {
URL xmlUrl = ManifestPackageTest.class.getResource("resources/manifest/oo_assessmentitem_imsmanifest_12_2.xml");
File xmlFile = new File(xmlUrl.toURI());
ManifestBuilder manifest = ManifestBuilder.read(xmlFile);
ManifestMetadataBuilder questionMetadata = manifest.getResourceBuilderByHref("sca9b540c9684ba58f489f02e8b5c590.xml");
Assert.assertNotNull(questionMetadata);
// LOM
String title = questionMetadata.getTitle();
Assert.assertEquals("Metadata", title);
String identifier = questionMetadata.getIdentifier();
Assert.assertEquals("id9f1ae47b-dc7f-482e-a688-111287f99fa6", identifier);
String keywords = questionMetadata.getGeneralKeywords();
Assert.assertTrue(keywords.contains("Meta"));
Assert.assertTrue(keywords.contains("data"));
Assert.assertTrue(keywords.contains("keywords"));
String context = "de";
Assert.assertEquals("de", context);
// educational
String educationContext = questionMetadata.getEducationContext();
Assert.assertEquals("Primarschule", educationContext);
String typicalLearningTime = "P1DT2H3M4S";
Assert.assertEquals("P1DT2H3M4S", typicalLearningTime);
// lifecycle
String version = "1.0";
Assert.assertEquals("1.0", version);
// classification
String taxonomyPath = questionMetadata.getClassificationTaxonomy();
Assert.assertEquals("/Mathematik/Topologie", taxonomyPath);
// QTI 2.1
QTIMetadataType qtiMetadata = questionMetadata.getQtiMetadata(false);
Assert.assertTrue(qtiMetadata.getInteractionType().contains("choiceInteraction"));
Assert.assertEquals("OpenOLAT", qtiMetadata.getToolName());
Assert.assertEquals("12.3a", qtiMetadata.getToolVersion());
// OpenOLAT specific
OpenOLATMetadataType openolatMetadata = questionMetadata.getOpenOLATMetadata(false);
Assert.assertEquals(Double.valueOf(0.5d), openolatMetadata.getDiscriminationIndex());
Assert.assertEquals(Double.valueOf(0.3d), openolatMetadata.getDifficulty());
Assert.assertEquals(Double.valueOf(0.4d), openolatMetadata.getStandardDeviation());
Assert.assertEquals(Integer.valueOf(1), openolatMetadata.getDistractors());
Assert.assertEquals("sc", openolatMetadata.getQuestionType());
Assert.assertEquals(Integer.valueOf(12), openolatMetadata.getUsage());
Assert.assertEquals("formative", openolatMetadata.getAssessmentType());
}
use of org.olat.oo.xml.manifest.OpenOLATMetadataType in project OpenOLAT by OpenOLAT.
the class AssessmentItemMetadata method fromBuilder.
public void fromBuilder(ManifestMetadataBuilder metadata) {
// general
keywords = metadata.getGeneralKeywords();
coverage = metadata.getCoverage();
// educational
EducationalType educational = metadata.getEducational(false);
if (educational != null) {
level = metadata.getEducationContext();
}
typicalLearningTime = metadata.getEducationalLearningTime();
// taxonomy
taxonomyPath = metadata.getClassificationTaxonomy();
// rights
license = metadata.getLicense();
// qti metadata
QTIMetadataType qtiMetadata = metadata.getQtiMetadata(true);
if (qtiMetadata != null) {
if (qtiMetadata.getToolName() != null) {
editor = qtiMetadata.getToolName();
}
if (qtiMetadata.getToolVersion() != null) {
editorVersion = qtiMetadata.getToolVersion();
}
}
// openolat metadata
OpenOLATMetadataType openolatMetadata = metadata.getOpenOLATMetadata(false);
if (openolatMetadata != null) {
if (openolatMetadata.getDiscriminationIndex() != null) {
differentiation = new BigDecimal(openolatMetadata.getDiscriminationIndex());
}
if (openolatMetadata.getDifficulty() != null) {
difficulty = new BigDecimal(openolatMetadata.getDifficulty());
}
if (openolatMetadata.getStandardDeviation() != null) {
stdevDifficulty = new BigDecimal(openolatMetadata.getStandardDeviation());
}
if (openolatMetadata.getDistractors() != null) {
numOfAnswerAlternatives = openolatMetadata.getDistractors().intValue();
}
if (openolatMetadata.getTopic() != null) {
topic = openolatMetadata.getTopic();
}
if (openolatMetadata.getAssessmentType() != null) {
assessmentType = openolatMetadata.getAssessmentType();
}
if (openolatMetadata.getCreator() != null) {
creator = openolatMetadata.getCreator();
}
if (openolatMetadata.getAdditionalInformations() != null) {
additionalInformations = openolatMetadata.getAdditionalInformations();
}
}
}
Aggregations