Search in sources :

Example 6 with QTIItemObject

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

the class QTIExportFormatterCSVType3 method closeReport.

public void closeReport() {
    if (qtiItemObjectList == null) {
        throw new OLATRuntimeException(null, "Can not format report when qtiItemObjectList is null", null);
    }
    String legend = translator.translate("legend");
    sb.append(car + car);
    sb.append(legend);
    sb.append(car + car);
    int y = 1;
    for (Iterator<QTIItemObject> iter = qtiItemObjectList.iterator(); iter.hasNext(); ) {
        QTIItemObject element = iter.next();
        sb.append(element.getItemIdent());
        sb.append(sep);
        sb.append(emb);
        sb.append(escape(element.getItemTitle()));
        sb.append(emb);
        sb.append(car);
        // CELFI#107
        sb.append(sep + sep + sep + sep);
        String question = element.getQuestionText();
        if (tagless) {
            question = FilterFactory.getXSSFilter(-1).filter(question);
            question = FilterFactory.getHtmlTagsFilter().filter(question);
        }
        question = StringEscapeUtils.unescapeHtml(question);
        sb.append(question);
        sb.append(car);
        // CELFI#107 END
        List<String> responseLabelMaterials = element.getResponseLabelMaterials();
        for (int i = 0; i < element.getResponseIdentifier().size(); i++) {
            sb.append(sep + sep);
            sb.append(y);
            sb.append("_");
            sb.append(element.getItemType());
            sb.append(i + 1);
            sb.append(sep);
            sb.append(element.getResponseIdentifier().get(i));
            sb.append(sep);
            if (responseLabelMaterials != null) {
                String s = responseLabelMaterials.get(i);
                s = StringEscapeUtils.unescapeHtml(s);
                if (tagless) {
                    s = s.replaceAll("\\<.*?\\>", "");
                }
                sb.append(Formatter.stripTabsAndReturns(s));
            }
            sb.append(car);
        }
        y++;
    }
    sb.append(car + car);
    sb.append("SCQ");
    sb.append(sep);
    sb.append("Single Choice Question");
    sb.append(car);
    sb.append("MCQ");
    sb.append(sep);
    sb.append("Multiple Choice Question");
    sb.append(car);
    sb.append("FIB");
    sb.append(sep);
    sb.append("Fill in the blank");
    sb.append(car);
    sb.append("ESS");
    sb.append(sep);
    sb.append("Essay");
    sb.append(car);
    sb.append("KPR");
    sb.append(sep);
    sb.append("Kprim (K-Type)");
    sb.append(car + car);
    sb.append("R:");
    sb.append(sep);
    sb.append("Radio button (SCQ)");
    sb.append(car);
    sb.append("C:");
    sb.append(sep);
    sb.append("Check box (MCQ or KPR)");
    sb.append(car);
    sb.append("B:");
    sb.append(sep);
    sb.append("Blank (FIB)");
    sb.append(car);
    sb.append("A:");
    sb.append(sep);
    sb.append("Area (ESS)");
    sb.append(car + car);
    sb.append("x_Ry");
    sb.append(sep);
    sb.append("Radio Button y of SCQ x, e.g. 1_R1");
    sb.append(car);
    sb.append("x_Cy");
    sb.append(sep);
    sb.append("Check Box y of MCQ x or two Radio Buttons y of KPR x, e.g. 3_C2");
    sb.append(car);
    sb.append("x_By");
    sb.append(sep);
    sb.append("Blank y of FIB x, e.g. 17_B2");
    sb.append(car);
    sb.append("x_Ay");
    sb.append(sep);
    sb.append("Area y of ESS x, e.g. 4_A1");
    sb.append(car + car);
    sb.append("Kprim:");
    sb.append(sep);
    sb.append("'+' = yes");
    sb.append(sep);
    sb.append("'-' = no");
    sb.append(sep);
    sb.append("'.' = no answer");
    sb.append(sep);
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject)

Example 7 with QTIItemObject

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

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 8 with QTIItemObject

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

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 9 with QTIItemObject

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

the class QTIStatisticsManagerLargeTest method getItemObjectList.

@SuppressWarnings("rawtypes")
private void getItemObjectList() {
    InputStream in = QTIStatisticsManagerLargeTest.class.getResourceAsStream("qti.xml");
    XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
    Document doc = xmlParser.parse(in, false);
    Element root = doc.getRootElement();
    List items = root.selectNodes("//item");
    itemObjects = new ArrayList<QTIItemObject>();
    for (Iterator iter = items.iterator(); iter.hasNext(); ) {
        Element el_item = (Element) iter.next();
        if (el_item.selectNodes(".//response_lid").size() > 0) {
            itemObjects.add(new ItemWithResponseLid(el_item));
        } else if (el_item.selectNodes(".//response_str").size() > 0) {
            itemObjects.add(new ItemWithResponseStr(el_item));
        }
    }
}
Also used : ItemWithResponseLid(org.olat.ims.qti.export.helper.ItemWithResponseLid) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) InputStream(java.io.InputStream) Element(org.dom4j.Element) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) ItemWithResponseStr(org.olat.ims.qti.export.helper.ItemWithResponseStr) XMLParser(org.olat.core.util.xml.XMLParser) Document(org.dom4j.Document) IMSEntityResolver(org.olat.ims.resources.IMSEntityResolver)

Example 10 with QTIItemObject

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

the class QTIStatisticsResource method prepare.

@Override
public void prepare(HttpServletResponse hres) {
    try {
        hres.setCharacterEncoding(encoding);
    } catch (Exception e) {
        log.error("", e);
    }
    CourseNode courseNode = resourceResult.getTestCourseNode();
    String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".csv";
    String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
    hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
    hres.setHeader("Content-Description", urlEncodedLabel);
    try {
        // fields separated by
        String sep = "\\t";
        // fields embedded by
        String emb = "\"";
        // carriage return
        String car = "\\r\\n";
        sep = QTIArchiver.convert2CtrlChars(sep);
        car = QTIArchiver.convert2CtrlChars(car);
        int exportType = 1;
        QTIExportFormatter formatter;
        if (QTIType.test.equals(resourceResult.getType())) {
            exportType = 1;
            formatter = new QTIExportFormatterCSVType1(locale, sep, emb, car, true);
        } else if (QTIType.survey.equals(resourceResult.getType())) {
            exportType = 2;
            formatter = new QTIExportFormatterCSVType3(locale, null, sep, emb, car, true);
        } else {
            return;
        }
        Long qtiRepoEntryKey = resourceResult.getQTIRepositoryEntry().getKey();
        List<QTIItemObject> itemList = new QTIObjectTreeBuilder().getQTIItemObjectList(resourceResult.getResolver());
        formatter.setMapWithExportItemConfigs(getQTIItemConfigs(itemList));
        QTIResultManager qrm = QTIResultManager.getInstance();
        QTIStatisticSearchParams params = resourceResult.getSearchParams();
        List<Group> limitToGroups = params.isMayViewAllUsersAssessments() ? null : params.getLimitToGroups();
        List<QTIResult> results = qrm.selectResults(resourceResult.getCourseOres().getResourceableId(), courseNode.getIdent(), qtiRepoEntryKey, limitToGroups, exportType);
        QTIExportManager.getInstance().exportResults(formatter, results, itemList, hres.getOutputStream());
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : QTIResult(org.olat.ims.qti.QTIResult) Group(org.olat.basesecurity.Group) QTIResultManager(org.olat.ims.qti.QTIResultManager) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) QTIExportFormatterCSVType3(org.olat.ims.qti.export.QTIExportFormatterCSVType3) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Date(java.util.Date) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) QTIObjectTreeBuilder(org.olat.ims.qti.export.helper.QTIObjectTreeBuilder) CourseNode(org.olat.course.nodes.CourseNode)

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