use of org.olat.ims.qti21.model.xml.Onyx38ToQtiWorksHandler in project OpenOLAT by OpenOLAT.
the class CopyAndConvertVisitor method convertXmlFile.
/**
* Convert the XML files, assessmentItem or assessmentTest
*
* @param inputFile
* @param outputFile
*/
public boolean convertXmlFile(Path inputFile, Path outputFile) {
try {
boolean validated = true;
QTI21Infos fileInfos = scanFile(inputFile);
// inherit from test if needed
if (fileInfos.getEditor() == null && infos.getEditor() != null) {
fileInfos.setEditor(infos.getEditor());
fileInfos.setVersion(infos.getVersion());
}
if (onyx38Family(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new Onyx38ToQtiWorksHandler(xtw);
}
});
} else if (onyxWebFamily(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new OnyxToQtiWorksHandler(xtw, infos);
}
});
if (validated && fileInfos.getType() == InputType.assessmentItem) {
// check templateVariables
checkAssessmentItem(outputFile);
}
} else {
Files.copy(inputFile, outputFile, StandardCopyOption.REPLACE_EXISTING);
}
return validated;
} catch (IOException | FactoryConfigurationError e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti21.model.xml.Onyx38ToQtiWorksHandler in project openolat by klemens.
the class CopyAndConvertVisitor method convertXmlFile.
/**
* Convert the XML files, assessmentItem or assessmentTest
*
* @param inputFile
* @param outputFile
*/
public boolean convertXmlFile(Path inputFile, Path outputFile) {
try {
boolean validated = true;
QTI21Infos fileInfos = scanFile(inputFile);
// inherit from test if needed
if (fileInfos.getEditor() == null && infos.getEditor() != null) {
fileInfos.setEditor(infos.getEditor());
fileInfos.setVersion(infos.getVersion());
}
if (onyx38Family(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new Onyx38ToQtiWorksHandler(xtw);
}
});
} else if (onyxWebFamily(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new OnyxToQtiWorksHandler(xtw, infos);
}
});
if (validated && fileInfos.getType() == InputType.assessmentItem) {
// check templateVariables
checkAssessmentItem(outputFile);
}
} else {
Files.copy(inputFile, outputFile, StandardCopyOption.REPLACE_EXISTING);
}
return validated;
} catch (IOException | FactoryConfigurationError e) {
log.error("", e);
return false;
}
}
Aggregations