Search in sources :

Example 41 with QuestionItemImpl

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

the class QuestionItemAuditLogDAOTest method shouldConvertToXMLAndBack.

@Test
public void shouldConvertToXMLAndBack() {
    QItemType qItemType = qItemTypeDao.loadByType(QuestionType.MC.name());
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qitem-audit-log");
    String title = "NGC 55";
    String format = QTI21Constants.QTI_21_FORMAT;
    String language = Locale.ENGLISH.getLanguage();
    QuestionItemImpl item = questionDao.createAndPersist(id, title, format, language, null, null, null, qItemType);
    String xml = sut.toXml(item);
    QuestionItem itemFromXml = sut.questionItemFromXml(xml);
    assertThat(itemFromXml.getTitle()).isEqualTo(title);
    assertThat(itemFromXml.getFormat()).isEqualTo(format);
    assertThat(itemFromXml.getLanguage()).isEqualTo(language);
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 42 with QuestionItemImpl

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

the class QuestionMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        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);
        BigDecimal difficulty = toBigDecimal(difficultyEl.getValue());
        itemImpl.setDifficulty(difficulty);
        BigDecimal stdevDifficulty = toBigDecimal(stdevDifficultyEl.getValue());
        itemImpl.setStdevDifficulty(stdevDifficulty);
        BigDecimal differentiation = toBigDecimal(differentiationEl.getValue());
        itemImpl.setDifferentiation(differentiation);
        int numOfAnswerAlternatives = toInt(numAnswerAltEl.getValue());
        itemImpl.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
        int numUsage = toInt(usageEl.getValue());
        itemImpl.setUsage(numUsage);
        item = qpoolService.updateItem(itemImpl);
        builder.withAfter(item);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) MetaUIFactory.bigDToString(org.olat.modules.qpool.ui.metadata.MetaUIFactory.bigDToString) BigDecimal(java.math.BigDecimal) MetaUIFactory.validateBigDecimal(org.olat.modules.qpool.ui.metadata.MetaUIFactory.validateBigDecimal) MetaUIFactory.toBigDecimal(org.olat.modules.qpool.ui.metadata.MetaUIFactory.toBigDecimal)

Example 43 with QuestionItemImpl

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

the class RightsMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        if (licenseModule.isEnabled(licenseHandler)) {
            if (licenseEl != null && licenseEl.isOneSelected()) {
                String licenseTypeKey = licenseEl.getSelectedKey();
                LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
                license.setLicenseType(licneseType);
            }
            String licensor = null;
            String freetext = null;
            if (licensorEl != null && licensorEl.isVisible()) {
                licensor = StringHelper.containsNonWhitespace(licensorEl.getValue()) ? licensorEl.getValue() : null;
            }
            if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
                freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
            }
            license.setLicensor(licensor);
            license.setFreetext(freetext);
            license = licenseService.update(license);
            licensorEl.setValue(license.getLicensor());
            licenseFreetextEl.setValue(license.getFreetext());
        }
        item = qpoolService.updateItem(item);
        builder.withAfter(itemImpl);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 44 with QuestionItemImpl

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

the class RightsMetadataEditController method doOpenAuthorManager.

private void doOpenAuthorManager(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        groupController = new GroupController(ureq, getWindowControl(), true, true, false, true, false, false, itemImpl.getOwnerGroup());
        listenTo(groupController);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), groupController.getInitialComponent(), true, translate("manage.owners"));
        cmc.activate();
        listenTo(cmc);
    }
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) GroupController(org.olat.admin.securitygroup.gui.GroupController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 45 with QuestionItemImpl

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

the class TechnicalMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        itemImpl.setItemVersion(versionEl.getValue());
        item = qpoolService.updateItem(item);
        builder.withAfter(itemImpl);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl)

Aggregations

QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)108 QuestionItem (org.olat.modules.qpool.QuestionItem)32 Test (org.junit.Test)20 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)16 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)16 Identity (org.olat.core.id.Identity)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)14 QuestionItemView (org.olat.modules.qpool.QuestionItemView)14 File (java.io.File)12 VFSItem (org.olat.core.util.vfs.VFSItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)12 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)12 ArrayList (java.util.ArrayList)10 QItemType (org.olat.modules.qpool.model.QItemType)10 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)10 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)7 Taxonomy (org.olat.modules.taxonomy.Taxonomy)7