Search in sources :

Example 21 with QTIResult

use of org.olat.ims.qti.QTIResult in project openolat by klemens.

the class QTIExportManager method selectAndExportResults.

/**
 * @param locale
 * @param olatResource
 * @param shortTitle
 * @param olatResourceDetail
 * @param repositoryRef
 * @param type
 * @param exportDirectory
 * @param anonymizerCallback callback that should be used to anonymize the user names or NULL if row counter
 * should be used (only for type 2 and 3)
 * @return
 */
public boolean selectAndExportResults(QTIExportFormatter qef, Long courseResId, String shortTitle, String olatResourceDetail, Long testReKey, File exportDirectory, String charset, String fileNameSuffix) {
    boolean resultsFoundAndExported = false;
    QTIResultManager qrm = QTIResultManager.getInstance();
    List<QTIResult> results = qrm.selectResults(courseResId, olatResourceDetail, testReKey, null, qef.getType());
    if (results.size() > 0) {
        QTIResult res0 = results.get(0);
        List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(new Long(res0.getResultSet().getRepositoryRef()));
        qef.setQTIItemObjectList(qtiItemObjectList);
        if (results.size() > 0) {
            createContentOfExportFile(results, qtiItemObjectList, qef);
            writeContentToFile(shortTitle, exportDirectory, charset, qef, fileNameSuffix);
            resultsFoundAndExported = true;
        }
    }
    return resultsFoundAndExported;
}
Also used : QTIResult(org.olat.ims.qti.QTIResult) QTIResultManager(org.olat.ims.qti.QTIResultManager) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) QTIObjectTreeBuilder(org.olat.ims.qti.export.helper.QTIObjectTreeBuilder)

Example 22 with QTIResult

use of org.olat.ims.qti.QTIResult in project openolat by klemens.

the class QTIExportManager method createContentOfExportFile.

/**
 * @param locale Locale used for export file headers / default values
 * @param results
 * @param type
 * @param anonymizerCallback
 * @return String
 */
private void createContentOfExportFile(List<QTIResult> qtiResults, List<QTIItemObject> qtiItemObjectList, QTIExportFormatter qef) {
    qef.openReport();
    // formatter has information about how to format the different qti objects
    Map<Class<?>, QTIExportItemFormatConfig> mapWithConfigs = qef.getMapWithExportItemConfigs();
    QTIExportItemFactory qeif = new QTIExportItemFactory(mapWithConfigs);
    while (qtiResults.size() > 0) {
        List<QTIResult> assessIDresults = stripNextAssessID(qtiResults);
        qef.openResultSet(new QTIExportSet(assessIDresults.get(0)));
        for (QTIItemObject element : qtiItemObjectList) {
            QTIResult qtir = element.extractQTIResult(assessIDresults);
            qef.visit(qeif.getExportItem(qtir, element));
        }
        qef.closeResultSet();
    }
    qef.closeReport();
}
Also used : QTIResult(org.olat.ims.qti.QTIResult) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject)

Aggregations

QTIResult (org.olat.ims.qti.QTIResult)22 Date (java.util.Date)10 QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)8 QTIResultManager (org.olat.ims.qti.QTIResultManager)6 QTIResultSet (org.olat.ims.qti.QTIResultSet)6 QTIObjectTreeBuilder (org.olat.ims.qti.export.helper.QTIObjectTreeBuilder)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ArrayList (java.util.ArrayList)4 Identity (org.olat.core.id.Identity)4 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)4 File (java.io.File)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Calendar (java.util.Calendar)2 List (java.util.List)2 ZipEntry (java.util.zip.ZipEntry)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Group (org.olat.basesecurity.Group)2