Search in sources :

Example 31 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject in project openolat by klemens.

the class QTIStatisticsManagerLargeTest method testItemStatistics_singleChoice_0.

@Test
public void testItemStatistics_singleChoice_0() {
    QTIItemObject itemObject = itemObjects.get(0);
    double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
    Assert.assertEquals(scoreQ1, stats.getAverageScore(), 0.1);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Test(org.junit.Test)

Example 32 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject in project openolat by klemens.

the class QTIStatisticsManagerLargeTest method testItemStatistics_multipleChoice_1.

@Test
public void testItemStatistics_multipleChoice_1() {
    QTIItemObject itemObject = itemObjects.get(1);
    double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
    double difficulty = rightAnswersQ2 / (double) numberOfParticipants;
    Assert.assertEquals(difficulty, stats.getDifficulty(), 0.1);
    Assert.assertEquals(scoreQ2, stats.getAverageScore(), 0.1);
    Assert.assertEquals(wrongAnswersQ2, stats.getNumOfIncorrectAnswers());
    Assert.assertEquals(numberOfParticipants - wrongAnswersQ2, stats.getNumOfCorrectAnswers());
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Test(org.junit.Test)

Example 33 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject in project openolat by klemens.

the class QTIStatisticsManagerLargeTest method testItemStatistics_kprim_2.

@Test
public void testItemStatistics_kprim_2() {
    QTIItemObject itemObject = itemObjects.get(2);
    double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
    float durationQ3InSec = durationQ3;
    Assert.assertEquals(durationQ3InSec, stats.getAverageDuration(), 1.0f);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Test(org.junit.Test)

Example 34 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject in project openolat by klemens.

the class IQEditReplaceWizard method doStep2.

private void doStep2(UserRequest ureq) {
    String nodeTitle = courseNode.getShortTitle();
    if (results != null && !results.isEmpty()) {
        exportDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
        UserManager um = UserManager.getInstance();
        String charset = um.getUserCharset(ureq.getIdentity());
        QTIExportManager qem = QTIExportManager.getInstance();
        Long repositoryRef = results.get(0).getResultSet().getRepositoryRef();
        List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(repositoryRef);
        QTIExportFormatter formatter;
        if (courseNode instanceof IQTESTCourseNode) {
            formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
        } else if (courseNode instanceof IQSELFCourseNode) {
            formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
            ((QTIExportFormatterCSVType1) formatter).setAnonymous(true);
        } else {
            formatter = new QTIExportFormatterCSVType3(ureq.getLocale(), null, "\t", "\"", "\r\n", false);
        }
        Map<Class<?>, QTIExportItemFormatConfig> qtiItemConfigs = getQTIItemConfigs(qtiItemObjectList);
        formatter.setMapWithExportItemConfigs(qtiItemConfigs);
        resultExportFile = qem.exportResults(formatter, results, qtiItemObjectList, courseNode.getShortTitle(), exportDir, charset, ".xls");
        vcStep2 = createVelocityContainer("replacewizard_step2");
        String[] args1 = new String[] { Integer.toString(learners.size()) };
        vcStep2.contextPut("information", translate("replace.wizard.information.paragraph1", args1));
        String[] args2 = new String[] { exportDir.getName(), resultExportFile };
        vcStep2.contextPut("information_par2", translate("replace.wizard.information.paragraph2", args2));
        vcStep2.contextPut("nodetitle", nodeTitle);
        showFileButton = LinkFactory.createButton("replace.wizard.showfile", vcStep2, this);
    } else {
        // it exists no result
        String[] args = new String[] { Integer.toString(numberOfQtiSerEntries) };
        vcStep2 = createVelocityContainer("replacewizard_step2");
        vcStep2.contextPut("information", translate("replace.wizard.information.empty.results", args));
        vcStep2.contextPut("nodetitle", nodeTitle);
    }
    nextBtn = LinkFactory.createButton("replace.wizard.next", vcStep2, this);
    setNextWizardStep(translate("replace.wizard.title.step2"), vcStep2);
}
Also used : QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) QTIExportFormatterCSVType3(org.olat.ims.qti.export.QTIExportFormatterCSVType3) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) UserManager(org.olat.user.UserManager) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) QTIObjectTreeBuilder(org.olat.ims.qti.export.helper.QTIObjectTreeBuilder) IQSELFCourseNode(org.olat.course.nodes.IQSELFCourseNode) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig)

Example 35 with QTIItemObject

use of org.olat.ims.qti.export.helper.QTIItemObject 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)

Aggregations

QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)36 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)20 HashMap (java.util.HashMap)10 QTIResult (org.olat.ims.qti.QTIResult)8 QTIObjectTreeBuilder (org.olat.ims.qti.export.helper.QTIObjectTreeBuilder)8 Test (org.junit.Test)6 QTIResultManager (org.olat.ims.qti.QTIResultManager)6 QTIExportItemFormatConfig (org.olat.ims.qti.export.QTIExportItemFormatConfig)6 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)6 StatisticsItem (org.olat.ims.qti.statistics.model.StatisticsItem)6 QTIExportEssayItemFormatConfig (org.olat.ims.qti.export.QTIExportEssayItemFormatConfig)4 QTIExportFIBItemFormatConfig (org.olat.ims.qti.export.QTIExportFIBItemFormatConfig)4 QTIExportFormatter (org.olat.ims.qti.export.QTIExportFormatter)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportFormatterCSVType3 (org.olat.ims.qti.export.QTIExportFormatterCSVType3)4 QTIExportKPRIMItemFormatConfig (org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig)4 QTIExportMCQItemFormatConfig (org.olat.ims.qti.export.QTIExportMCQItemFormatConfig)4 QTIExportSCQItemFormatConfig (org.olat.ims.qti.export.QTIExportSCQItemFormatConfig)4 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2