Search in sources :

Example 1 with XmlResourceNotFoundException

use of uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method getAssessmentResult.

@Override
public AssessmentResult getAssessmentResult(AssessmentTestSession candidateSession) {
    File assessmentResultFile = getAssessmentResultFile(candidateSession);
    ResourceLocator fileResourceLocator = new PathResourceLocator(assessmentResultFile.getParentFile().toPath());
    ResourceLocator inputResourceLocator = ImsQTI21Resource.createResolvingResourceLocator(fileResourceLocator);
    URI assessmentResultUri = assessmentResultFile.toURI();
    QtiObjectReader qtiObjectReader = qtiXmlReader().createQtiObjectReader(inputResourceLocator, false, false);
    try {
        QtiObjectReadResult<AssessmentResult> result = qtiObjectReader.lookupRootNode(assessmentResultUri, AssessmentResult.class);
        return result.getRootNode();
    } catch (XmlResourceNotFoundException | QtiXmlInterpretationException | ClassCastException e) {
        log.error("", e);
        return null;
    }
}
Also used : ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiObjectReader(uk.ac.ed.ph.jqtiplus.reading.QtiObjectReader) File(java.io.File) URI(java.net.URI) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) ResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)

Example 2 with XmlResourceNotFoundException

use of uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException in project openolat by klemens.

the class QTI21ServiceImpl method getAssessmentResult.

@Override
public AssessmentResult getAssessmentResult(AssessmentTestSession candidateSession) {
    File assessmentResultFile = getAssessmentResultFile(candidateSession);
    ResourceLocator fileResourceLocator = new PathResourceLocator(assessmentResultFile.getParentFile().toPath());
    ResourceLocator inputResourceLocator = ImsQTI21Resource.createResolvingResourceLocator(fileResourceLocator);
    URI assessmentResultUri = assessmentResultFile.toURI();
    QtiObjectReader qtiObjectReader = qtiXmlReader().createQtiObjectReader(inputResourceLocator, false, false);
    try {
        QtiObjectReadResult<AssessmentResult> result = qtiObjectReader.lookupRootNode(assessmentResultUri, AssessmentResult.class);
        return result.getRootNode();
    } catch (XmlResourceNotFoundException | QtiXmlInterpretationException | ClassCastException e) {
        log.error("", e);
        return null;
    }
}
Also used : ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiObjectReader(uk.ac.ed.ph.jqtiplus.reading.QtiObjectReader) File(java.io.File) URI(java.net.URI) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) ResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)

Aggregations

File (java.io.File)2 URI (java.net.URI)2 PathResourceLocator (org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)2 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)2 QtiObjectReader (uk.ac.ed.ph.jqtiplus.reading.QtiObjectReader)2 QtiXmlInterpretationException (uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException)2 XmlResourceNotFoundException (uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException)2 ClassPathResourceLocator (uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator)2 ResourceLocator (uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator)2