Search in sources :

Example 1 with MultipartFileInfos

use of org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos in project OpenOLAT by OpenOLAT.

the class AbstractQtiWorksController method extractFileResponseData.

protected Map<Identifier, ResponseInput> extractFileResponseData() {
    Map<Identifier, ResponseInput> fileResponseMap = new HashMap<>();
    Set<String> parameterNames = new HashSet<>(mainForm.getRequestMultipartFilesSet());
    parameterNames.addAll(mainForm.getRequestParameterSet());
    for (String name : parameterNames) {
        if (name.startsWith("qtiworks_uploadpresented_")) {
            String responseIdentifierString = name.substring("qtiworks_uploadpresented_".length());
            Identifier responseIdentifier;
            try {
                responseIdentifier = getResponseIdentifierFromUniqueId(responseIdentifierString);
            // responseIdentifier = Identifier.parseString(responseIdentifierString);
            } catch (final QtiParseException e) {
                throw new RuntimeException("Bad response identifier encoded in parameter " + name, e);
            }
            String multipartName = "qtiworks_uploadresponse_" + responseIdentifierString;
            MultipartFileInfos multipartFile = mainForm.getRequestMultipartFileInfos(multipartName);
            if (multipartFile == null) {
                throw new RuntimeException("Expected to find multipart file with name " + multipartName);
            }
            fileResponseMap.put(responseIdentifier, new FileInput(multipartFile));
        }
    }
    return fileResponseMap;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) FileInput(org.olat.ims.qti21.ui.ResponseInput.FileInput) MultipartFileInfos(org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos) QtiParseException(uk.ac.ed.ph.jqtiplus.exception.QtiParseException) HashSet(java.util.HashSet)

Example 2 with MultipartFileInfos

use of org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos in project openolat by klemens.

the class AbstractQtiWorksController method extractFileResponseData.

protected Map<Identifier, ResponseInput> extractFileResponseData() {
    Map<Identifier, ResponseInput> fileResponseMap = new HashMap<>();
    Set<String> parameterNames = new HashSet<>(mainForm.getRequestMultipartFilesSet());
    parameterNames.addAll(mainForm.getRequestParameterSet());
    for (String name : parameterNames) {
        if (name.startsWith("qtiworks_uploadpresented_")) {
            String responseIdentifierString = name.substring("qtiworks_uploadpresented_".length());
            Identifier responseIdentifier;
            try {
                responseIdentifier = getResponseIdentifierFromUniqueId(responseIdentifierString);
            // responseIdentifier = Identifier.parseString(responseIdentifierString);
            } catch (final QtiParseException e) {
                throw new RuntimeException("Bad response identifier encoded in parameter " + name, e);
            }
            String multipartName = "qtiworks_uploadresponse_" + responseIdentifierString;
            MultipartFileInfos multipartFile = mainForm.getRequestMultipartFileInfos(multipartName);
            if (multipartFile == null) {
                throw new RuntimeException("Expected to find multipart file with name " + multipartName);
            }
            fileResponseMap.put(responseIdentifier, new FileInput(multipartFile));
        }
    }
    return fileResponseMap;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) FileInput(org.olat.ims.qti21.ui.ResponseInput.FileInput) MultipartFileInfos(org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos) QtiParseException(uk.ac.ed.ph.jqtiplus.exception.QtiParseException) HashSet(java.util.HashSet)

Example 3 with MultipartFileInfos

use of org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos in project OpenOLAT by OpenOLAT.

the class AssessmentObjectFormItem method extractFileResponseData.

protected Map<Identifier, MultipartFileInfos> extractFileResponseData() {
    Map<Identifier, MultipartFileInfos> fileResponseMap = new HashMap<Identifier, MultipartFileInfos>();
    Set<String> parameterNames = new HashSet<>(getRootForm().getRequestMultipartFilesSet());
    parameterNames.addAll(getRootForm().getRequestParameterSet());
    for (String name : parameterNames) {
        if (name.startsWith("qtiworks_uploadpresented_")) {
            String responseIdentifierString = name.substring("qtiworks_uploadpresented_".length());
            Identifier responseIdentifier;
            try {
                responseIdentifier = Identifier.parseString(responseIdentifierString);
            } catch (final QtiParseException e) {
                throw new RuntimeException("Bad response identifier encoded in parameter " + name, e);
            }
            String multipartName = "qtiworks_uploadresponse_" + responseIdentifierString;
            MultipartFileInfos multipartFile = getRootForm().getRequestMultipartFileInfos(multipartName);
            if (multipartFile == null) {
                throw new RuntimeException("Expected to find multipart file with name " + multipartName);
            }
            fileResponseMap.put(responseIdentifier, multipartFile);
        }
    }
    return fileResponseMap;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) MultipartFileInfos(org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos) QtiParseException(uk.ac.ed.ph.jqtiplus.exception.QtiParseException) HashSet(java.util.HashSet)

Example 4 with MultipartFileInfos

use of org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos in project openolat by klemens.

the class AssessmentObjectFormItem method extractFileResponseData.

protected Map<Identifier, MultipartFileInfos> extractFileResponseData() {
    Map<Identifier, MultipartFileInfos> fileResponseMap = new HashMap<Identifier, MultipartFileInfos>();
    Set<String> parameterNames = new HashSet<>(getRootForm().getRequestMultipartFilesSet());
    parameterNames.addAll(getRootForm().getRequestParameterSet());
    for (String name : parameterNames) {
        if (name.startsWith("qtiworks_uploadpresented_")) {
            String responseIdentifierString = name.substring("qtiworks_uploadpresented_".length());
            Identifier responseIdentifier;
            try {
                responseIdentifier = Identifier.parseString(responseIdentifierString);
            } catch (final QtiParseException e) {
                throw new RuntimeException("Bad response identifier encoded in parameter " + name, e);
            }
            String multipartName = "qtiworks_uploadresponse_" + responseIdentifierString;
            MultipartFileInfos multipartFile = getRootForm().getRequestMultipartFileInfos(multipartName);
            if (multipartFile == null) {
                throw new RuntimeException("Expected to find multipart file with name " + multipartName);
            }
            fileResponseMap.put(responseIdentifier, multipartFile);
        }
    }
    return fileResponseMap;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) MultipartFileInfos(org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos) QtiParseException(uk.ac.ed.ph.jqtiplus.exception.QtiParseException) HashSet(java.util.HashSet)

Aggregations

HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 MultipartFileInfos (org.olat.core.gui.components.form.flexible.impl.MultipartFileInfos)4 QtiParseException (uk.ac.ed.ph.jqtiplus.exception.QtiParseException)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 FileInput (org.olat.ims.qti21.ui.ResponseInput.FileInput)2