Search in sources :

Example 21 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeBuilder method computePermissions.

private void computePermissions(TaxonomyTreeNode root) {
    List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(taxonomy, identity, new Date());
    Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences = new HashMap<>();
    for (TaxonomyCompetence competence : competences) {
        TaxonomyLevel level = competence.getTaxonomyLevel();
        if (levelToCompetences.containsKey(level)) {
            levelToCompetences.get(level).add(competence.getCompetenceType());
        } else {
            List<TaxonomyCompetenceTypes> types = new ArrayList<>(4);
            types.add(competence.getCompetenceType());
            levelToCompetences.put(level, types);
        }
    }
    computePermissionsRecursive(root, levelToCompetences);
    trimRecursive(root);
}
Also used : HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 22 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class QItemQueriesDAOTest method shouldGetItemsIsTeacher.

@Test
public void shouldGetItemsIsTeacher() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
    TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
    TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
    Identity ownerAndTeacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, ownerAndTeacher, null);
    Identity teacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, teacher, null);
    Identity noTeacher = createRandomIdentity();
    QuestionItemImpl item11 = createRandomItem(ownerAndTeacher);
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(ownerAndTeacher);
    item12.setTaxonomyLevel(taxonomySubLevel);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndTeacher, null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(ownerAndTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(noTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isFalse();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isFalse();
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) Test(org.junit.Test)

Example 23 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class QItemQueriesDAOTest method createRandomItem.

private QuestionItemImpl createRandomItem(Identity owner) {
    String title = UUID.randomUUID().toString();
    String format = QTI21Constants.QTI_21_FORMAT;
    String language = Locale.ENGLISH.getLanguage();
    TaxonomyLevel taxonLevel = null;
    String dir = null;
    String rootFilename = null;
    return questionItemDao.createAndPersist(owner, title, format, language, taxonLevel, dir, rootFilename, qItemType);
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 24 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class DocumentPoolMainController method doSelectTaxonomyLevel.

private DocumentPoolLevelController doSelectTaxonomyLevel(UserRequest ureq, TaxonomyTreeNode node) {
    if (isTaxonomyAdmin || node.isCanRead() || node.isCanWrite()) {
        TaxonomyLevel level = node.getTaxonomyLevel();
        SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
        TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(node, subscriptionCtx);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("TaxonomyLevel", node.getTaxonomyLevel().getKey());
        WindowControl bwControl = addToHistory(ureq, ores, null);
        DocumentPoolLevelController levelCtrl = new DocumentPoolLevelController(ureq, bwControl, level, node, secCallback);
        listenTo(levelCtrl);
        String displayName = level.getDisplayName();
        content.popUpToRootController(ureq);
        List<TreeNode> parentLines = TreeHelper.getTreePath(node);
        for (int i = 1; i < parentLines.size() - 1; i++) {
            TreeNode parent = parentLines.get(i);
            content.pushController(parent.getTitle(), null, parent);
        }
        content.pushController(displayName, levelCtrl);
        return levelCtrl;
    }
    return null;
}
Also used : TaxonomyVFSSecurityCallback(org.olat.modules.taxonomy.ui.component.TaxonomyVFSSecurityCallback) OLATResourceable(org.olat.core.id.OLATResourceable) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) WindowControl(org.olat.core.gui.control.WindowControl)

Example 25 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class QuestionItemDetailsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == copyConfirmationCtrl) {
        doPostCopy(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == conversionConfirmationCtrl) {
        doPostConvert(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == selectGroupCtrl) {
        if (event instanceof BusinessGroupSelectionEvent) {
            BusinessGroupSelectionEvent bge = (BusinessGroupSelectionEvent) event;
            List<BusinessGroup> groups = bge.getGroups();
            if (groups.size() > 0) {
                QuestionItem item = (QuestionItem) ((SelectBusinessGroupController) source).getUserObject();
                doShareItemsWithGroup(ureq, item, groups);
                metadatasCtrl.updateShares();
            }
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == selectPoolCtrl) {
        cmc.deactivate();
        if (event instanceof QPoolSelectionEvent) {
            QPoolSelectionEvent qpe = (QPoolSelectionEvent) event;
            List<Pool> pools = qpe.getPools();
            if (pools.size() > 0) {
                QuestionItemShort item = (QuestionItemShort) selectPoolCtrl.getUserObject();
                doShareItemsWithPool(ureq, item, pools);
                metadatasCtrl.updateShares();
            }
        }
        cleanUp();
    } else if (source == reviewActionCtrl) {
        if (QItemReviewEvent.START.equals(event.getCommand())) {
            doConfirmStartReview(ureq);
        } else if (QItemReviewEvent.DO.equals(event.getCommand())) {
            openReview(ureq);
        }
    } else if (source == reviewStartCtrl) {
        if (event == Event.DONE_EVENT) {
            TaxonomyLevel taxonomyLevel = reviewStartCtrl.getSelectedTaxonomyLevel();
            doStartReview(ureq, taxonomyLevel);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == reviewCtrl) {
        if (event == Event.DONE_EVENT) {
            float rating = reviewCtrl.getCurrentRatting();
            String comment = reviewCtrl.getComment();
            doRate(ureq, rating, comment);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == confirmEndOfLifeCtrl) {
        boolean endOfLife = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        if (endOfLife) {
            QuestionItem item = (QuestionItem) confirmEndOfLifeCtrl.getUserObject();
            doEndOfLife(ureq, item);
        }
        cleanUp();
    } else if (source == deleteConfirmationCtrl) {
        if (event == Event.DONE_EVENT) {
            List<QuestionItemShort> items = deleteConfirmationCtrl.getItemsToDelete();
            doDelete(ureq, items);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == cmc) {
        cleanUp();
    } else if (source == questionCtrl) {
        if (event instanceof QItemEdited) {
            questionEdited = true;
            fireEvent(ureq, event);
        }
    } else if (source == metadatasCtrl) {
        if (event instanceof QItemEdited) {
            reloadData(ureq);
            fireEvent(ureq, event);
        }
    }
    super.event(ureq, source, event);
}
Also used : QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) BusinessGroup(org.olat.group.BusinessGroup) QPoolSelectionEvent(org.olat.modules.qpool.ui.events.QPoolSelectionEvent) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) List(java.util.List) ArrayList(java.util.ArrayList) QuestionItem(org.olat.modules.qpool.QuestionItem)

Aggregations

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)238 Taxonomy (org.olat.modules.taxonomy.Taxonomy)122 Test (org.junit.Test)106 Identity (org.olat.core.id.Identity)58 ArrayList (java.util.ArrayList)40 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)40 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)24 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)24 URI (java.net.URI)22 HttpResponse (org.apache.http.HttpResponse)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)18 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 HashMap (java.util.HashMap)14 List (java.util.List)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)12 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)12 Path (javax.ws.rs.Path)10