Search in sources :

Example 16 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class MetadataBulkChangeController method formOKQuestion.

private void formOKQuestion(QuestionItemImpl itemImpl) {
    if (isEnabled(contextEl)) {
        if (contextEl.isOneSelected()) {
            QEducationalContext context = qpoolService.getEducationlContextByLevel(contextEl.getSelectedKey());
            itemImpl.setEducationalContext(context);
        } else {
            itemImpl.setEducationalContext(null);
        }
    }
    if (isEnabled(learningTimeContainer)) {
        int day = learningTimeDayElement.getIntValue();
        int hour = learningTimeHourElement.getIntValue();
        int minute = learningTimeMinuteElement.getIntValue();
        int seconds = learningTimeSecondElement.getIntValue();
        String timeStr = MetadataConverterHelper.convertDuration(day, hour, minute, seconds);
        itemImpl.setEducationalLearningTime(timeStr);
    }
    if (isEnabled(difficultyEl))
        itemImpl.setDifficulty(toBigDecimal(difficultyEl.getValue()));
    if (isEnabled(stdevDifficultyEl))
        itemImpl.setStdevDifficulty(toBigDecimal(stdevDifficultyEl.getValue()));
    if (isEnabled(differentiationEl))
        itemImpl.setDifferentiation(toBigDecimal(differentiationEl.getValue()));
    if (isEnabled(numAnswerAltEl))
        itemImpl.setNumOfAnswerAlternatives(toInt(numAnswerAltEl.getValue()));
    if (isEnabled(assessmentTypeEl)) {
        String assessmentType = assessmentTypeEl.isOneSelected() ? assessmentTypeEl.getSelectedKey() : null;
        itemImpl.setAssessmentType(assessmentType);
    }
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Example 17 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class QEducationalContextsAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == createType) {
        doEdit(ureq, null);
    } else if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("delete-level".equals(se.getCommand())) {
                QEducationalContext row = model.getObject(se.getIndex());
                doConfirmDelete(ureq, row);
            } else if ("translate".equals(se.getCommand())) {
                QEducationalContext row = model.getObject(se.getIndex());
                doOpenTranslationTool(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Example 18 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class QTIImportProcessorTest method testImport_QTI12_metadata.

@Test
public void testImport_QTI12_metadata() throws IOException, URISyntaxException {
    URL itemUrl = QTIImportProcessorTest.class.getResource("mchc_i_001.xml");
    Assert.assertNotNull(itemUrl);
    File itemFile = new File(itemUrl.toURI());
    // get the document informations
    QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, itemFile.getName(), itemFile);
    List<QuestionItem> items = proc.process();
    Assert.assertNotNull(items);
    Assert.assertEquals(1, items.size());
    dbInstance.commitAndCloseSession();
    // check metadata
    QuestionItem item = items.get(0);
    Assert.assertEquals("Standard Multiple Choice Item", item.getTitle());
    // qmd_levelofdifficulty
    QEducationalContext level = item.getEducationalContext();
    Assert.assertNotNull(level);
    Assert.assertEquals("basic", level.getLevel());
    // qmd_toolvendor
    Assert.assertEquals("QTITools", item.getEditor());
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem) URL(java.net.URL) Test(org.junit.Test)

Example 19 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class QTIImportProcessor method processMetadataField.

/**
 * <ul>
 *  <li>qmd_computerscored</li>
 *  <li>qmd_feedbackpermitted</li>
 *  <li>qmd_hintspermitted</li>
 *  <li>qmd_itemtype -> (check is made on the content of the item)</li>
 *  <li>qmd_levelofdifficulty -> educational context</li>
 *  <li>qmd_maximumscore</li>
 *  <li>qmd_renderingtype</li>
 *  <li>qmd_responsetype</li>
 *  <li>qmd_scoringpermitted</li>
 *  <li>qmd_solutionspermitted</li>
 *  <li>qmd_status</li>
 *  <li>qmd_timedependence</li>
 *  <li>qmd_timelimit</li>
 *  <li>qmd_toolvendor -> editor</li>
 *  <li>qmd_topic</li>
 *  <li>qmd_material</li>
 *  <li>qmd_typeofsolution</li>
 *  <li>qmd_weighting</li>
 * </ul>
 * @param poolItem
 * @param labelEl
 * @param entryEl
 */
private void processMetadataField(QuestionItemImpl poolItem, Element labelEl, Element entryEl) {
    String label = labelEl.getText();
    String entry = entryEl.getText();
    if (QTIConstants.META_LEVEL_OF_DIFFICULTY.equals(label)) {
        if (StringHelper.containsNonWhitespace(entry)) {
            QEducationalContext context = qEduContextDao.loadByLevel(entry);
            if (context == null) {
                context = qEduContextDao.create(entry, true);
            }
            poolItem.setEducationalContext(context);
        }
    } else if (QTIConstants.META_ITEM_TYPE.equals(label)) {
        if (poolItem.getType() == null && StringHelper.containsNonWhitespace(entry)) {
            // some heuristic
            String typeStr = entry;
            if (typeStr.equalsIgnoreCase("MCQ") || typeStr.equalsIgnoreCase("Multiple choice")) {
                typeStr = QuestionType.MC.name();
            } else if (typeStr.equalsIgnoreCase("SCQ") || typeStr.equalsIgnoreCase("Single choice")) {
                typeStr = QuestionType.SC.name();
            } else if (typeStr.equalsIgnoreCase("fill-in") || typeStr.equals("Fill-in-the-Blank") || typeStr.equalsIgnoreCase("Fill-in-Blank") || typeStr.equalsIgnoreCase("Fill In the Blank")) {
                typeStr = QuestionType.FIB.name();
            } else if (typeStr.equalsIgnoreCase("Essay")) {
                typeStr = QuestionType.ESSAY.name();
            }
            QItemType type = qItemTypeDao.loadByType(entry);
            if (type == null) {
                type = qItemTypeDao.create(entry, true);
            }
            poolItem.setType(type);
        }
    } else if (QTIConstants.META_TOOLVENDOR.equals(label)) {
        poolItem.setEditor(entry);
    }
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) QItemType(org.olat.modules.qpool.model.QItemType)

Example 20 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.

the class MetaUIFactory method getContextKeyValues.

public static KeyValues getContextKeyValues(Translator translator, QPoolService qpoolService) {
    List<QEducationalContext> levels = qpoolService.getAllEducationlContexts();
    String[] contextKeys = new String[levels.size()];
    String[] contextValues = new String[levels.size()];
    int count = 0;
    for (QEducationalContext level : levels) {
        contextKeys[count] = level.getLevel();
        String i18nKey = "item.level." + level.getLevel().toLowerCase();
        String translation = translator.translate(i18nKey);
        if (i18nKey.equals(translation) || translation.length() > 256) {
            translation = level.getLevel();
        }
        contextValues[count++] = translation;
    }
    return new KeyValues(contextKeys, contextValues);
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Aggregations

QEducationalContext (org.olat.modules.qpool.model.QEducationalContext)34 Test (org.junit.Test)18 QItemType (org.olat.modules.qpool.model.QItemType)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 File (java.io.File)4 BigDecimal (java.math.BigDecimal)4 URL (java.net.URL)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)4 Date (java.util.Date)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Identity (org.olat.core.id.Identity)2 QTIMetadataConverter (org.olat.ims.qti.qpool.QTIMetadataConverter)2 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)2 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)2 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)2 Taxonomy (org.olat.modules.taxonomy.Taxonomy)2