use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.
the class AssessmentParser method parse.
/**
* @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("assessment");
Assessment assessment = new Assessment();
// attributes
Attribute attr = element.attribute("ident");
if (attr != null)
assessment.setIdent(attr.getValue());
attr = element.attribute("title");
if (attr != null)
assessment.setTitle(attr.getValue());
// elements
// DURATION
QTIObject duration = (QTIObject) parserManager.parse(element.element("duration"));
assessment.setDuration(duration);
// ASSESSMENTCONTROL
List assessmentcontrolsXML = element.elements("assessmentcontrol");
List assessmentcontrols = new ArrayList();
for (Iterator i = assessmentcontrolsXML.iterator(); i.hasNext(); ) {
assessmentcontrols.add(parserManager.parse((Element) i.next()));
assessment.setInheritControls(true);
}
if (assessmentcontrols.size() == 0) {
assessmentcontrols.add(new Control());
assessment.setInheritControls(false);
}
assessment.setAssessmentcontrols(assessmentcontrols);
// OUTCOMES PROCESSING
OutcomesProcessing outcomesProcessing = (OutcomesProcessing) parserManager.parse(element.element("outcomes_processing"));
if (outcomesProcessing != null)
assessment.setOutcomes_processing(outcomesProcessing);
// SELECTION ORDERING
SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
if (selectionOrdering != null) {
assessment.setSelection_ordering(selectionOrdering);
} else {
assessment.setSelection_ordering(new SelectionOrdering());
}
// SECTIONS
List sectionsXML = element.elements("section");
List sections = new ArrayList();
for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
sections.add(parserManager.parse((Element) i.next()));
}
assessment.setSections(sections);
// ITEMS
List itemsXML = element.elements("item");
List items = new ArrayList();
for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
items.add(parserManager.parse((Element) i.next()));
}
assessment.setItems(items);
// OBJECTIVES
Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
if (mattext != null)
assessment.setObjectives(mattext.getTextTrim());
// METADATA
Metadata metadata = (Metadata) parserManager.parse(element.element("qtimetadata"));
if (metadata != null)
assessment.setMetadata(metadata);
return assessment;
}
use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.
the class QTIWordExport method renderAssessment.
public static void renderAssessment(Assessment assessment, OpenXMLDocument document, Translator translator) {
String title = assessment.getTitle();
document.appendTitle(title);
OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
if (outcomesProcessing != null) {
String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
String cutValueLabel = translator.translate("cut_value");
document.appendText(cutValueLabel + ": " + cutValue, true);
}
String objectives = assessment.getObjectives();
document.appendText(objectives, true);
}
use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convert.
public AssessmentTest convert(VFSContainer originalContainer, QTIDocument doc, QTI21DeliveryOptions qti21Options) throws URISyntaxException {
Assessment assessment = doc.getAssessment();
AssessmentTest assessmentTest = new AssessmentTest();
String assessmentTestIdentifier = IdentifierGenerator.newAssessmentTestFilename();
File testFile = new File(unzippedDirRoot, assessmentTestIdentifier + ".xml");
manifest.appendAssessmentTest(testFile.getName());
assessmentTest.setIdentifier(assessmentTestIdentifier);
assessmentTest.setTitle(assessment.getTitle());
assessmentTest.setToolName(QTI21Constants.TOOLNAME);
assessmentTest.setToolVersion(Settings.getVersion());
convertDuration((Duration) assessment.getDuration(), assessmentTest);
TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTest);
ItemSessionControl itemSessionControl = testPart.getItemSessionControl();
Control tmpControl = QTIEditHelper.getControl(assessment);
if (tmpControl.getSolution() == Control.CTRL_YES) {
itemSessionControl.setShowSolution(Boolean.TRUE);
}
if (qti21Options != null) {
qti21Options.setHideFeedbacks(false);
if (assessment.isInheritControls() && tmpControl.getFeedback() != Control.CTRL_YES) {
qti21Options.setHideFeedbacks(true);
}
}
AssessmentTestBuilder assessmentTestBuilder = new AssessmentTestBuilder(assessmentTest);
// root
List<Section> sections = assessment.getSections();
for (Section section : sections) {
convert(section, testPart);
}
// this are lost in QTI 2.1
// assessment.getSelection_ordering().getOrderType();
// assessment.getSelection_ordering().getSelectionNumber();
OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
if (outcomesProcessing != null) {
String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
if (StringHelper.containsNonWhitespace(cutValue)) {
try {
assessmentTestBuilder.setCutValue(Double.valueOf(cutValue));
} catch (NumberFormatException e) {
log.error("Cannot parse cut value: " + cutValue, e);
}
}
}
assessmentTestBuilder.setMaxScore(atomicMaxScore.doubleValue());
assessmentTest = assessmentTestBuilder.build();
persistAssessmentObject(testFile, assessmentTest);
manifest.write(new File(unzippedDirRoot, "imsmanifest.xml"));
copyMaterial(originalContainer);
return assessmentTest;
}
use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project openolat by klemens.
the class AssessmentParser method parse.
/**
* @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
*/
public Object parse(Element element) {
// assert element.getName().equalsIgnoreCase("assessment");
Assessment assessment = new Assessment();
// attributes
Attribute attr = element.attribute("ident");
if (attr != null)
assessment.setIdent(attr.getValue());
attr = element.attribute("title");
if (attr != null)
assessment.setTitle(attr.getValue());
// elements
// DURATION
QTIObject duration = (QTIObject) parserManager.parse(element.element("duration"));
assessment.setDuration(duration);
// ASSESSMENTCONTROL
List assessmentcontrolsXML = element.elements("assessmentcontrol");
List assessmentcontrols = new ArrayList();
for (Iterator i = assessmentcontrolsXML.iterator(); i.hasNext(); ) {
assessmentcontrols.add(parserManager.parse((Element) i.next()));
assessment.setInheritControls(true);
}
if (assessmentcontrols.size() == 0) {
assessmentcontrols.add(new Control());
assessment.setInheritControls(false);
}
assessment.setAssessmentcontrols(assessmentcontrols);
// OUTCOMES PROCESSING
OutcomesProcessing outcomesProcessing = (OutcomesProcessing) parserManager.parse(element.element("outcomes_processing"));
if (outcomesProcessing != null)
assessment.setOutcomes_processing(outcomesProcessing);
// SELECTION ORDERING
SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
if (selectionOrdering != null) {
assessment.setSelection_ordering(selectionOrdering);
} else {
assessment.setSelection_ordering(new SelectionOrdering());
}
// SECTIONS
List sectionsXML = element.elements("section");
List sections = new ArrayList();
for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
sections.add(parserManager.parse((Element) i.next()));
}
assessment.setSections(sections);
// ITEMS
List itemsXML = element.elements("item");
List items = new ArrayList();
for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
items.add(parserManager.parse((Element) i.next()));
}
assessment.setItems(items);
// OBJECTIVES
Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
if (mattext != null)
assessment.setObjectives(mattext.getTextTrim());
// METADATA
Metadata metadata = (Metadata) parserManager.parse(element.element("qtimetadata"));
if (metadata != null)
assessment.setMetadata(metadata);
return assessment;
}
use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project openolat by klemens.
the class QTI12To21Converter method convert.
public AssessmentTest convert(VFSContainer originalContainer, QTIDocument doc, QTI21DeliveryOptions qti21Options) throws URISyntaxException {
Assessment assessment = doc.getAssessment();
AssessmentTest assessmentTest = new AssessmentTest();
String assessmentTestIdentifier = IdentifierGenerator.newAssessmentTestFilename();
File testFile = new File(unzippedDirRoot, assessmentTestIdentifier + ".xml");
manifest.appendAssessmentTest(testFile.getName());
assessmentTest.setIdentifier(assessmentTestIdentifier);
assessmentTest.setTitle(assessment.getTitle());
assessmentTest.setToolName(QTI21Constants.TOOLNAME);
assessmentTest.setToolVersion(Settings.getVersion());
convertDuration((Duration) assessment.getDuration(), assessmentTest);
TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTest);
ItemSessionControl itemSessionControl = testPart.getItemSessionControl();
Control tmpControl = QTIEditHelper.getControl(assessment);
if (tmpControl.getSolution() == Control.CTRL_YES) {
itemSessionControl.setShowSolution(Boolean.TRUE);
}
if (qti21Options != null) {
qti21Options.setHideFeedbacks(false);
if (assessment.isInheritControls() && tmpControl.getFeedback() != Control.CTRL_YES) {
qti21Options.setHideFeedbacks(true);
}
}
AssessmentTestBuilder assessmentTestBuilder = new AssessmentTestBuilder(assessmentTest);
// root
List<Section> sections = assessment.getSections();
for (Section section : sections) {
convert(section, testPart);
}
// this are lost in QTI 2.1
// assessment.getSelection_ordering().getOrderType();
// assessment.getSelection_ordering().getSelectionNumber();
OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
if (outcomesProcessing != null) {
String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
if (StringHelper.containsNonWhitespace(cutValue)) {
try {
assessmentTestBuilder.setCutValue(Double.valueOf(cutValue));
} catch (NumberFormatException e) {
log.error("Cannot parse cut value: " + cutValue, e);
}
}
}
assessmentTestBuilder.setMaxScore(atomicMaxScore.doubleValue());
assessmentTest = assessmentTestBuilder.build();
persistAssessmentObject(testFile, assessmentTest);
manifest.write(new File(unzippedDirRoot, "imsmanifest.xml"));
copyMaterial(originalContainer);
return assessmentTest;
}
Aggregations