Search in sources :

Example 26 with QEducationalContext

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

the class QEducationalContextDAOTest method testGetItemLevels.

@Test
public void testGetItemLevels() {
    String levelStr = "primary-school-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, true);
    dbInstance.commit();
    // load it
    List<QEducationalContext> allLevels = qEduContextDao.getEducationalContexts();
    // check the values
    Assert.assertNotNull(allLevels);
    Assert.assertTrue(allLevels.contains(level));
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 27 with QEducationalContext

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

the class QEducationalContextDAOTest method testCreateAndGet_byLevel.

@Test
public void testCreateAndGet_byLevel() {
    String levelStr = "onlyLevel-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, true);
    dbInstance.commit();
    // load it
    QEducationalContext reloadedLevel = qEduContextDao.loadByLevel(levelStr);
    // check the values
    Assert.assertNotNull(reloadedLevel);
    Assert.assertEquals(level.getKey(), reloadedLevel.getKey());
    Assert.assertNotNull(reloadedLevel.getCreationDate());
    Assert.assertEquals(levelStr, reloadedLevel.getLevel());
    Assert.assertTrue(reloadedLevel.isDeletable());
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 28 with QEducationalContext

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

the class QEducationalContextDAOTest method testDelete_deletable.

@Test
public void testDelete_deletable() {
    String levelStr = "secondary-school-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, true);
    dbInstance.commitAndCloseSession();
    // delete it
    boolean deleted = qEduContextDao.delete(level);
    dbInstance.commitAndCloseSession();
    Assert.assertTrue(deleted);
    // check that the type is really, really deleted
    QEducationalContext reloadedLevel = qEduContextDao.loadById(level.getKey());
    Assert.assertNull(reloadedLevel);
    List<QEducationalContext> allLevels = qEduContextDao.getEducationalContexts();
    Assert.assertFalse(allLevels.contains(level));
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 29 with QEducationalContext

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

the class QEducationalContextDAO method create.

public QEducationalContext create(String level, boolean deletable) {
    QEducationalContext itemLevel = new QEducationalContext();
    itemLevel.setCreationDate(new Date());
    itemLevel.setLevel(level);
    itemLevel.setDeletable(deletable);
    dbInstance.getCurrentEntityManager().persist(itemLevel);
    return itemLevel;
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Date(java.util.Date)

Example 30 with QEducationalContext

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

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