Search in sources :

Example 81 with QuestionItemImpl

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

the class GeneralMetadataEditController 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.setTopic(topicEl.getValue());
        if (taxonomyLevelEl.isOneSelected()) {
            String selectedKey = taxonomyLevelEl.getSelectedKey();
            TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
            itemImpl.setTaxonomyLevel(taxonomyLevel);
        } else {
            itemImpl.setTaxonomyLevel(null);
        }
        QEducationalContext context = contextEl.isOneSelected() ? qpoolService.getEducationlContextByLevel(contextEl.getSelectedKey()) : null;
        itemImpl.setEducationalContext(context);
        if (StringHelper.containsNonWhitespace(keywordsEl.getValue())) {
            itemImpl.setKeywords(keywordsEl.getValue());
        } else {
            itemImpl.setKeywords("");
        }
        if (StringHelper.containsNonWhitespace(coverageEl.getValue())) {
            itemImpl.setCoverage(coverageEl.getValue());
        } else {
            itemImpl.setCoverage("");
        }
        if (StringHelper.containsNonWhitespace(addInfosEl.getValue())) {
            itemImpl.setAdditionalInformations(addInfosEl.getValue());
        } else {
            itemImpl.setAdditionalInformations(null);
        }
        itemImpl.setLanguage(languageEl.getValue());
        String assessmentType = assessmentTypeEl.isOneSelected() ? assessmentTypeEl.getSelectedKey() : null;
        itemImpl.setAssessmentType(assessmentType);
        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) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Example 82 with QuestionItemImpl

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

the class MetadataBulkChangeController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    updatedItems = new ArrayList<>();
    for (QuestionItemShort item : items) {
        QuestionItem fullItem = qpoolService.loadItemById(item.getKey());
        if (fullItem instanceof QuestionItemImpl) {
            QuestionItemImpl itemImpl = (QuestionItemImpl) fullItem;
            QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
            builder.withBefore(itemImpl);
            formOKGeneral(itemImpl);
            formOKQuestion(itemImpl);
            formOKTechnical(itemImpl);
            formOKRights(itemImpl);
            QuestionItem merged = qpoolService.updateItem(itemImpl);
            builder.withAfter(itemImpl);
            qpoolService.persist(builder.create());
            updatedItems.add(merged);
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 83 with QuestionItemImpl

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

the class QuestionListController method doCreateNewItem.

private void doCreateNewItem(UserRequest ureq, String title, TaxonomyLevel taxonomyLevel, QItemFactory factory) {
    QuestionItem item = factory.createItem(getIdentity(), title, getLocale());
    List<QuestionItem> newItems = Collections.singletonList(item);
    getSource().postImport(newItems, false);
    if (taxonomyLevel != null && item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        itemImpl.setTaxonomyLevel(taxonomyLevel);
        qpoolService.updateItem(itemImpl);
    }
    if (licenseModule.isEnabled(licenseHandler)) {
        // The QItemFactory may create a no license as part of the import process.
        // But for new question items the default license should be created.
        // So delete the no license first, so that the default license can be created.
        licenseService.delete(item);
        licenseService.createDefaultLicense(item, licenseHandler, getIdentity());
    }
    getItemsTable().reset();
    dbInstance.commit();
    qpoolService.index(newItems);
    QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_NEW);
    builder.withAfter(item);
    qpoolService.persist(builder.create());
    QPoolEvent qce = new QPoolEvent(QPoolEvent.ITEM_CREATED);
    fireEvent(ureq, qce);
    doOpenDetails(ureq, item);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 84 with QuestionItemImpl

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

the class QuestionItemDetailsController method doStartReview.

private void doStartReview(UserRequest ureq, TaxonomyLevel taxonomyLevel) {
    QuestionItem item = metadatasCtrl.getItem();
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        if (itemImpl.getTaxonomyLevel() == null || !itemImpl.getTaxonomyLevel().equals(taxonomyLevel)) {
            itemImpl.setTaxonomyLevel(taxonomyLevel);
        }
    }
    doChangeQuestionStatus(ureq, item, QuestionStatus.review);
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 85 with QuestionItemImpl

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

the class QuestionItemDetailsController method doChangeQuestionStatus.

private void doChangeQuestionStatus(UserRequest ureq, QuestionItem item, QuestionStatus newStatus) {
    if (!newStatus.equals(item.getQuestionStatus()) && item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.STATUS_CHANGED);
        builder.withBefore(itemImpl);
        builder.withMessage("New status: " + newStatus);
        itemImpl.setQuestionStatus(newStatus);
        qpoolService.updateItem(itemImpl);
        builder.withAfter(item);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_STATUS_CHANGED, item.getKey()));
    }
    reloadData(ureq);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent)

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