Search in sources :

Example 1 with QItemType

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

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 2 with QItemType

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

the class QTIImportProcessor method processItemQuestionType.

private boolean processItemQuestionType(QuestionItemImpl poolItem, String ident, Element itemEl) {
    boolean openolatFormat = false;
    // question type: mc, sc...
    QuestionType type = null;
    // test with openolat ident
    if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_SCQ)) {
        type = QuestionType.SC;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_MCQ)) {
        type = QuestionType.MC;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_FIB)) {
        type = QuestionType.FIB;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_ESSAY)) {
        type = QuestionType.ESSAY;
        openolatFormat = true;
    } else if (ident != null && ident.startsWith(ItemParser.ITEM_PREFIX_KPRIM)) {
        type = QuestionType.KPRIM;
        openolatFormat = true;
    } else if (itemEl.selectNodes("//render_choice").size() == 1) {
        Element lidEl = (Element) itemEl.selectSingleNode("//response_lid");
        String rcardinality = getAttributeValue(lidEl, "rcardinality");
        if ("Single".equals(rcardinality)) {
            type = QuestionType.SC;
        } else if ("Multiple".equals(rcardinality)) {
            type = QuestionType.MC;
        }
    } else if (itemEl.selectNodes("//render_fib").size() == 1) {
        type = QuestionType.FIB;
    }
    if (type != null) {
        QItemType itemType = qItemTypeDao.loadByType(type.name());
        poolItem.setType(itemType);
    }
    return openolatFormat;
}
Also used : Element(org.dom4j.Element) QuestionType(org.olat.modules.qpool.QuestionType) QItemType(org.olat.modules.qpool.model.QItemType)

Example 3 with QItemType

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

the class PoolDAOTest method getPools_ofItem.

@Test
public void getPools_ofItem() {
    // create a pool
    String poolName = "NGC-" + UUID.randomUUID().toString();
    Pool pool1 = poolDao.createPool(null, poolName, true);
    Pool pool2 = poolDao.createPool(null, poolName + "-b", true);
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    poolDao.addItemToPool(item, Collections.singletonList(pool1), false);
    poolDao.addItemToPool(item, Collections.singletonList(pool2), true);
    dbInstance.commitAndCloseSession();
    // retrieve the pools
    List<Pool> pools = poolDao.getPools(item);
    Assert.assertNotNull(pools);
    Assert.assertEquals(2, pools.size());
    Assert.assertTrue(pools.contains(pool1));
    Assert.assertTrue(pools.contains(pool2));
}
Also used : QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 4 with QItemType

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

the class PoolDAOTest method addItemToPool.

@Test
public void addItemToPool() {
    // create a pool
    String poolName = "NGC-" + UUID.randomUUID().toString();
    Pool pool = poolDao.createPool(null, poolName, true);
    Assert.assertNotNull(pool);
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    Assert.assertNotNull(item);
    dbInstance.commitAndCloseSession();
    // get pools
    poolDao.addItemToPool(item, Collections.singletonList(pool), false);
    dbInstance.commit();
}
Also used : QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 5 with QItemType

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

the class PoolDAOTest method isMemberOfPrivatePools_groupOnly.

@Test
public void isMemberOfPrivatePools_groupOnly() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsUser("Group-owner-" + UUID.randomUUID().toString());
    Identity participant = JunitTestHelper.createAndPersistIdentityAsUser("Group-participant-" + UUID.randomUUID().toString());
    // create a group to share 2 items
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    BusinessGroup group = businessGroupDao.createAndPersist(owner, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    QuestionItem item = questionDao.createAndPersist(owner, "Shared-Item-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    questionDao.share(item, group.getResource());
    businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(item);
    Assert.assertNotNull(group);
    // retrieve them
    boolean isOwnerMember = poolDao.isMemberOfPrivatePools(owner);
    Assert.assertTrue(isOwnerMember);
    boolean isParticipantMember = poolDao.isMemberOfPrivatePools(participant);
    Assert.assertTrue(isParticipantMember);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Aggregations

QItemType (org.olat.modules.qpool.model.QItemType)118 Test (org.junit.Test)94 QuestionItem (org.olat.modules.qpool.QuestionItem)82 Identity (org.olat.core.id.Identity)58 BusinessGroup (org.olat.group.BusinessGroup)22 QuestionItemView (org.olat.modules.qpool.QuestionItemView)18 Pool (org.olat.modules.qpool.Pool)12 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)12 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)12 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 URI (java.net.URI)8 ArrayList (java.util.ArrayList)8 HttpResponse (org.apache.http.HttpResponse)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)8 QEducationalContext (org.olat.modules.qpool.model.QEducationalContext)8 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)8 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionType (org.olat.modules.qpool.QuestionType)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 InputStream (java.io.InputStream)4