Search in sources :

Example 1 with QtiModelBuildingError

use of uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method getTestProcessingMap.

private TestProcessingMap getTestProcessingMap() {
    boolean assessmentPackageIsValid = true;
    BadResourceException ex = resolvedAssessmentTest.getTestLookup().getBadResourceException();
    if (ex instanceof QtiXmlInterpretationException) {
        try {
            // try to log some informations
            QtiXmlInterpretationException exml = (QtiXmlInterpretationException) ex;
            logError(exml.getInterpretationFailureReason().toString(), null);
            for (QtiModelBuildingError err : exml.getQtiModelBuildingErrors()) {
                logError(err.toString(), null);
            }
        } catch (Exception e) {
            logError("", e);
        }
    }
    TestProcessingInitializer initializer = new TestProcessingInitializer(resolvedAssessmentTest, assessmentPackageIsValid);
    TestProcessingMap result = initializer.initialize();
    return result;
}
Also used : TestProcessingMap(uk.ac.ed.ph.jqtiplus.state.TestProcessingMap) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) TestProcessingInitializer(uk.ac.ed.ph.jqtiplus.running.TestProcessingInitializer) QtiModelBuildingError(uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError) ResponseBindingException(uk.ac.ed.ph.jqtiplus.exception.ResponseBindingException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 2 with QtiModelBuildingError

use of uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError in project openolat by klemens.

the class BadRessourceHelper method extractMessage.

public static void extractMessage(BadResourceException e, StringBuilder out) {
    if (e instanceof QtiXmlInterpretationException) {
        QtiXmlInterpretationException qe = (QtiXmlInterpretationException) e;
        if (qe.getQtiModelBuildingErrors() != null) {
            for (QtiModelBuildingError error : qe.getQtiModelBuildingErrors()) {
                String localName = error.getElementLocalName();
                String msg = error.getException().getMessage();
                if (error.getElementLocation() != null) {
                    int lineNumber = error.getElementLocation().getLineNumber();
                    out.append(lineNumber + " :: " + localName + " :: " + msg + "\n");
                } else {
                    out.append(localName + " :: " + msg + "\n");
                }
            }
        }
        if (qe.getInterpretationFailureReason() != null) {
            InterpretationFailureReason reason = qe.getInterpretationFailureReason();
            out.append("Failure: " + reason + "\n");
        }
        if (qe.getXmlParseResult() != null) {
            XmlParseResult result = qe.getXmlParseResult();
            if (result.getWarnings() != null) {
                for (SAXParseException saxex : result.getWarnings()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Warnings: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
            if (result.getErrors() != null) {
                for (SAXParseException saxex : result.getErrors()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Error: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
            if (result.getFatalErrors() != null) {
                for (SAXParseException saxex : result.getFatalErrors()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Fatal: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
        }
    }
}
Also used : XmlParseResult(uk.ac.ed.ph.jqtiplus.xmlutils.XmlParseResult) SAXParseException(org.xml.sax.SAXParseException) InterpretationFailureReason(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException.InterpretationFailureReason) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiModelBuildingError(uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError)

Example 3 with QtiModelBuildingError

use of uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError in project OpenOLAT by OpenOLAT.

the class BadRessourceHelper method extractMessage.

public static void extractMessage(BadResourceException e, StringBuilder out) {
    if (e instanceof QtiXmlInterpretationException) {
        QtiXmlInterpretationException qe = (QtiXmlInterpretationException) e;
        if (qe.getQtiModelBuildingErrors() != null) {
            for (QtiModelBuildingError error : qe.getQtiModelBuildingErrors()) {
                String localName = error.getElementLocalName();
                String msg = error.getException().getMessage();
                if (error.getElementLocation() != null) {
                    int lineNumber = error.getElementLocation().getLineNumber();
                    out.append(lineNumber + " :: " + localName + " :: " + msg + "\n");
                } else {
                    out.append(localName + " :: " + msg + "\n");
                }
            }
        }
        if (qe.getInterpretationFailureReason() != null) {
            InterpretationFailureReason reason = qe.getInterpretationFailureReason();
            out.append("Failure: " + reason + "\n");
        }
        if (qe.getXmlParseResult() != null) {
            XmlParseResult result = qe.getXmlParseResult();
            if (result.getWarnings() != null) {
                for (SAXParseException saxex : result.getWarnings()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Warnings: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
            if (result.getErrors() != null) {
                for (SAXParseException saxex : result.getErrors()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Error: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
            if (result.getFatalErrors() != null) {
                for (SAXParseException saxex : result.getFatalErrors()) {
                    int lineNumber = saxex.getLineNumber();
                    int columnNumber = saxex.getColumnNumber();
                    String msg = saxex.getMessage();
                    out.append("Fatal: " + lineNumber + ":" + columnNumber + " :: " + msg + "\n");
                }
            }
        }
    }
}
Also used : XmlParseResult(uk.ac.ed.ph.jqtiplus.xmlutils.XmlParseResult) SAXParseException(org.xml.sax.SAXParseException) InterpretationFailureReason(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException.InterpretationFailureReason) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiModelBuildingError(uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError)

Example 4 with QtiModelBuildingError

use of uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError in project openolat by klemens.

the class AssessmentTestDisplayController method getTestProcessingMap.

private TestProcessingMap getTestProcessingMap() {
    boolean assessmentPackageIsValid = true;
    BadResourceException ex = resolvedAssessmentTest.getTestLookup().getBadResourceException();
    if (ex instanceof QtiXmlInterpretationException) {
        try {
            // try to log some informations
            QtiXmlInterpretationException exml = (QtiXmlInterpretationException) ex;
            logError(exml.getInterpretationFailureReason().toString(), null);
            for (QtiModelBuildingError err : exml.getQtiModelBuildingErrors()) {
                logError(err.toString(), null);
            }
        } catch (Exception e) {
            logError("", e);
        }
    }
    TestProcessingInitializer initializer = new TestProcessingInitializer(resolvedAssessmentTest, assessmentPackageIsValid);
    TestProcessingMap result = initializer.initialize();
    return result;
}
Also used : TestProcessingMap(uk.ac.ed.ph.jqtiplus.state.TestProcessingMap) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) TestProcessingInitializer(uk.ac.ed.ph.jqtiplus.running.TestProcessingInitializer) QtiModelBuildingError(uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError) ResponseBindingException(uk.ac.ed.ph.jqtiplus.exception.ResponseBindingException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Aggregations

QtiModelBuildingError (uk.ac.ed.ph.jqtiplus.reading.QtiModelBuildingError)4 QtiXmlInterpretationException (uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException)4 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 SAXParseException (org.xml.sax.SAXParseException)2 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)2 ResponseBindingException (uk.ac.ed.ph.jqtiplus.exception.ResponseBindingException)2 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)2 InterpretationFailureReason (uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException.InterpretationFailureReason)2 TestProcessingInitializer (uk.ac.ed.ph.jqtiplus.running.TestProcessingInitializer)2 TestProcessingMap (uk.ac.ed.ph.jqtiplus.state.TestProcessingMap)2 XmlParseResult (uk.ac.ed.ph.jqtiplus.xmlutils.XmlParseResult)2