Search in sources :

Example 71 with QuestionItemImpl

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

the class QuestionPoolServiceImpl method getRootLeaf.

@Override
public VFSLeaf getRootLeaf(QuestionItemShort item) {
    QuestionItemImpl reloadedItem = questionItemDao.loadById(item.getKey());
    if (reloadedItem == null) {
        return null;
    }
    VFSContainer root = qpoolModule.getRootContainer();
    VFSItem dir = root.resolve(reloadedItem.getDirectory());
    if (dir instanceof VFSContainer) {
        VFSContainer itemContainer = (VFSContainer) dir;
        VFSItem rootLeaf = itemContainer.resolve(reloadedItem.getRootFilename());
        if (rootLeaf instanceof VFSLeaf) {
            return (VFSLeaf) rootLeaf;
        }
    }
    return null;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 72 with QuestionItemImpl

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

the class QuestionPoolServiceImpl method deleteItems.

@Override
public void deleteItems(List<? extends QuestionItemShort> items) {
    if (items == null || items.isEmpty()) {
        // nothing to do
        return;
    }
    List<SecurityGroup> secGroups = new ArrayList<>();
    for (QuestionItemShort item : items) {
        markManager.deleteMarks(item);
        commentAndRatingService.deleteAllIgnoringSubPath(item);
        licenseService.delete(item);
        QuestionItem loadedItem = loadItemById(item.getKey());
        if (loadedItem instanceof QuestionItemImpl) {
            QuestionItemImpl itemImpl = (QuestionItemImpl) loadedItem;
            qpoolFileStorage.deleteDir(itemImpl.getDirectory());
            secGroups.add(itemImpl.getOwnerGroup());
        }
        dbInstance.intermediateCommit();
    }
    poolDao.removeFromPools(items);
    questionItemDao.removeFromShares(items);
    collectionDao.deleteItemFromCollections(items);
    questionItemDao.delete(items);
    // Delete SecurityGroup after the item to avoid foreign key constraint violation.
    for (SecurityGroup secGroup : secGroups) {
        securityManager.deleteSecurityGroup(secGroup);
    }
    for (QuestionItemShort item : items) {
        lifeIndexer.deleteDocument(QItemDocument.TYPE, item.getKey());
    }
    // allow reload of data
    dbInstance.getCurrentEntityManager().flush();
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList) SecurityGroup(org.olat.basesecurity.SecurityGroup) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 73 with QuestionItemImpl

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

the class QuestionPoolServiceImpl method updateItem.

@Override
public QuestionItem updateItem(QuestionItem item) {
    QuestionItem previousItem = loadItemById(item.getKey());
    QuestionStatus previousStatus = previousItem != null ? previousItem.getQuestionStatus() : null;
    QuestionStatus newStatus = item.getQuestionStatus();
    if (statusChanged(previousStatus, newStatus)) {
        if (item instanceof QuestionItemImpl) {
            QuestionItemImpl itemImpl = (QuestionItemImpl) item;
            itemImpl.setQuestionStatusLastModified(new Date());
        }
        if (reviewService.isReviewStarting(previousStatus, newStatus)) {
            reviewService.startReview(item);
        }
    }
    QuestionItem mergedItem = questionItemDao.merge(item);
    dbInstance.commit();
    lifeIndexer.indexDocument(QItemDocument.TYPE, mergedItem.getKey());
    return mergedItem;
}
Also used : QuestionStatus(org.olat.modules.qpool.QuestionStatus) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) Date(java.util.Date)

Example 74 with QuestionItemImpl

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

the class QuestionItemDAO method createAndPersist.

public QuestionItemImpl createAndPersist(Identity owner, String title, String format, String language, TaxonomyLevel taxonLevel, String dir, String rootFilename, QItemType type) {
    QuestionItemImpl item = create(title, format, dir, rootFilename);
    if (type != null) {
        item.setType(type);
    }
    item.setLanguage(language);
    item.setTaxonomyLevel(taxonLevel);
    persist(owner, item);
    return item;
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl)

Example 75 with QuestionItemImpl

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

the class QuestionItemDAO method copy.

/**
 * The method make a copy of the original question. The copy is not persisted.
 *
 * @param original
 * @return A copy of the question.
 */
public QuestionItemImpl copy(QuestionItemImpl original) {
    String title = "(Copy) " + original.getTitle();
    QuestionItemImpl copy = create(title, original.getFormat(), null, original.getRootFilename());
    // general
    copy.setMasterIdentifier(original.getIdentifier());
    copy.setDescription(original.getDescription());
    copy.setKeywords(original.getKeywords());
    copy.setCoverage(original.getCoverage());
    copy.setAdditionalInformations(original.getAdditionalInformations());
    copy.setLanguage(original.getLanguage());
    // classification
    copy.setTaxonomyLevel(original.getTaxonomyLevel());
    copy.setTopic(original.getTopic());
    // educational
    copy.setEducationalContext(original.getEducationalContext());
    copy.setEducationalLearningTime(original.getEducationalLearningTime());
    // item
    copy.setType(original.getType());
    copy.setDifficulty(original.getDifficulty());
    copy.setStdevDifficulty(original.getStdevDifficulty());
    copy.setDifferentiation(original.getDifferentiation());
    copy.setNumOfAnswerAlternatives(original.getNumOfAnswerAlternatives());
    copy.setUsage(0);
    copy.setAssessmentType(original.getAssessmentType());
    // lifecycle
    copy.setItemVersion(original.getItemVersion());
    copy.setStatus(QuestionStatus.draft.name());
    // technical
    copy.setEditor(original.getEditor());
    copy.setEditorVersion(original.getEditorVersion());
    return copy;
}
Also used : 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