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);
}
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();
}
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);
}
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;
}
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);
}
Aggregations