From b48c59f782b4a53a5892f84d2f8e78569cb2d600 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Tue, 6 Aug 2019 10:57:54 +0200
Subject: [PATCH] OO-4174: add exclusion filter while importing questions in
 video quizz

---
 .../qti/editor/QTIEditorMainController.java   |  3 +-
 .../qpool/model/SearchQuestionItemParams.java |  3 ++
 .../qpool/ui/AbstractItemListController.java  | 16 +++++----
 .../modules/qpool/ui/ItemListController.java  |  8 +++++
 .../ui/ItemListMyCompetencesController.java   |  7 ++--
 .../qpool/ui/ItemListMyListsController.java   |  8 +++--
 .../qpool/ui/ItemListMySharesController.java  | 14 +++++---
 .../qpool/ui/SelectItemController.java        | 35 ++++++++++++++-----
 .../datasource/CollectionOfItemsSource.java   |  8 +++++
 .../ui/datasource/SharedItemsSource.java      |  8 +++++
 .../ui/metadata/ExtendedSearchController.java |  8 +++--
 .../qpool/ui/metadata/MetaUIFactory.java      | 21 ++++++-----
 .../question/VideoQuestionEditController.java | 18 +++++++++-
 13 files changed, 120 insertions(+), 37 deletions(-)

diff --git a/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java b/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java
index f3fd80b3758..a40d0bf2ad9 100644
--- a/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java
+++ b/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java
@@ -1048,8 +1048,7 @@ public class QTIEditorMainController extends MainLayoutBasicController implement
 	private GenericQtiNode doConvertItemToQtiNode(QuestionItemView qitemv) {
 		VFSContainer editorContainer = qtiPackage.getBaseDir();
 		Item theItem = qtiQpoolServiceProvider.exportToQTIEditor(qitemv, editorContainer);
-		GenericQtiNode node = new ItemNode(theItem, qtiPackage);
-		return node;
+		return new ItemNode(theItem, qtiPackage);
 	}
 	
 	private void doSelectQItem(UserRequest ureq) {
diff --git a/src/main/java/org/olat/modules/qpool/model/SearchQuestionItemParams.java b/src/main/java/org/olat/modules/qpool/model/SearchQuestionItemParams.java
index a193884bf6d..367c6eadea4 100644
--- a/src/main/java/org/olat/modules/qpool/model/SearchQuestionItemParams.java
+++ b/src/main/java/org/olat/modules/qpool/model/SearchQuestionItemParams.java
@@ -354,6 +354,9 @@ public class SearchQuestionItemParams implements Cloneable {
 		if(itemType != null) {
 			clone.itemType = itemType;
 		}
+		if(excludedItemTypes != null) {
+			clone.excludedItemTypes = excludedItemTypes;
+		}
 		if(taxonomyLevel != null) {
 			clone.taxonomyLevel = taxonomyLevel;
 		}
diff --git a/src/main/java/org/olat/modules/qpool/ui/AbstractItemListController.java b/src/main/java/org/olat/modules/qpool/ui/AbstractItemListController.java
index 54774c286b6..3d4361395a4 100644
--- a/src/main/java/org/olat/modules/qpool/ui/AbstractItemListController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/AbstractItemListController.java
@@ -75,6 +75,7 @@ import org.olat.modules.qpool.QuestionItemView;
 import org.olat.modules.qpool.QuestionItemView.OrderBy;
 import org.olat.modules.qpool.manager.QuestionPoolLicenseHandler;
 import org.olat.modules.qpool.model.ItemWrapper;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.security.QPoolSecurityCallbackFactory;
 import org.olat.modules.qpool.ui.QuestionItemDataModel.Cols;
 import org.olat.modules.qpool.ui.events.QItemMarkedEvent;
@@ -100,6 +101,7 @@ public abstract class AbstractItemListController extends FormBasicController
 	
 	private final String prefsKey;
 	protected final String restrictToFormat;
+	protected final List<QItemType> excludeTypes;
 	private ExtendedSearchController extendedSearchCtrl;
 	private QuestionItemPreviewController previewCtrl;
 	private QuickViewMetadataController quickViewMetadataCtrl;
@@ -123,21 +125,22 @@ public abstract class AbstractItemListController extends FormBasicController
 	
 	public AbstractItemListController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback securityCallback,
 			QuestionItemsSource source, String key, boolean searchAllTaxonomyLevels) {
-		this(ureq, wControl, securityCallback, source, null, key, searchAllTaxonomyLevels);
+		this(ureq, wControl, securityCallback, source, null, null, key, searchAllTaxonomyLevels);
 	}
 	
 	public AbstractItemListController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback securityCallback,
 			QuestionItemsSource source, String key) {
-		this(ureq, wControl, securityCallback, source, null, key, false);
+		this(ureq, wControl, securityCallback, source, null, null, key, false);
 	}
 	
 	public AbstractItemListController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback securityCallback,
-			QuestionItemsSource source, String restrictToFormat, String key) {
-		this(ureq, wControl, securityCallback, source, restrictToFormat, key, false);
+			QuestionItemsSource source, String restrictToFormat, List<QItemType> excludeTypes, String key) {
+		this(ureq, wControl, securityCallback, source, restrictToFormat, excludeTypes, key, false);
 	}
 	
 	public AbstractItemListController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback securityCallback,
-			QuestionItemsSource source, String restrictToFormat, String key, boolean searchAllTaxonomyLevels) {
+			QuestionItemsSource source, String restrictToFormat, List<QItemType> excludeTypes,
+			String key, boolean searchAllTaxonomyLevels) {
 		super(ureq, wControl, "item_list");
 
 		this.securityCallback = securityCallback;
@@ -145,12 +148,13 @@ public abstract class AbstractItemListController extends FormBasicController
 		this.itemsSource = source;
 		this.roles = ureq.getUserSession().getRoles();
 		this.restrictToFormat = restrictToFormat;
+		this.excludeTypes = excludeTypes;
 
 		eventBus = ureq.getUserSession().getSingleUserEventCenter();
 		eventBus.registerFor(this, getIdentity(), QuestionPoolMainEditorController.QITEM_MARKED);
 		
 		extendedSearchCtrl = new ExtendedSearchController(ureq, getWindowControl(), getSecurityCallback(), key,
-				mainForm, searchAllTaxonomyLevels);
+				mainForm, excludeTypes, searchAllTaxonomyLevels);
 		extendedSearchCtrl.setEnabled(false);
 		
 		initForm(ureq);
diff --git a/src/main/java/org/olat/modules/qpool/ui/ItemListController.java b/src/main/java/org/olat/modules/qpool/ui/ItemListController.java
index 73d3c586f28..9e624f4fdf8 100644
--- a/src/main/java/org/olat/modules/qpool/ui/ItemListController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/ItemListController.java
@@ -33,6 +33,7 @@ import org.olat.core.gui.components.link.Link;
 import org.olat.core.gui.control.WindowControl;
 import org.olat.modules.qpool.QPoolSecurityCallback;
 import org.olat.modules.qpool.QuestionItemView;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.ui.events.QItemViewEvent;
 
 /**
@@ -51,6 +52,13 @@ public class ItemListController extends AbstractItemListController {
 		initForm(ureq);
 	}
 	
+	public ItemListController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback, QuestionItemsSource source,
+			String restrictToFormat, List<QItemType> excludeTypes) {
+		super(ureq, wControl, secCallback, source, restrictToFormat, excludeTypes, "qti-select");
+		
+		initForm(ureq);
+	}
+	
 	@Override
 	protected void initButtons(UserRequest ureq, FormItemContainer formLayout) {
 		getItemsTable().setMultiSelect(true);
diff --git a/src/main/java/org/olat/modules/qpool/ui/ItemListMyCompetencesController.java b/src/main/java/org/olat/modules/qpool/ui/ItemListMyCompetencesController.java
index df88358e369..4aa1db1ab09 100644
--- a/src/main/java/org/olat/modules/qpool/ui/ItemListMyCompetencesController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/ItemListMyCompetencesController.java
@@ -35,6 +35,7 @@ import org.olat.core.gui.control.WindowControl;
 import org.olat.core.util.StringHelper;
 import org.olat.modules.qpool.QPoolSecurityCallback;
 import org.olat.modules.qpool.QuestionItemView;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.ui.datasource.EmptyItemsSource;
 import org.olat.modules.qpool.ui.datasource.FinalItemsSource;
 import org.olat.modules.qpool.ui.events.QItemViewEvent;
@@ -57,8 +58,9 @@ public class ItemListMyCompetencesController extends AbstractItemListController
     private QPoolTaxonomyTreeBuilder qpoolTaxonomyTreeBuilder;
 
 
-	public ItemListMyCompetencesController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback, String restrictToFormat) {
-		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, "qti-select");
+	public ItemListMyCompetencesController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback,
+			String restrictToFormat, List<QItemType> excludeTypes) {
+		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, excludeTypes, "qti-select");
 	}
 	
 	public boolean hasCompetences() {
@@ -115,6 +117,7 @@ public class ItemListMyCompetencesController extends AbstractItemListController
 		} else {
 			FinalItemsSource source = new FinalItemsSource(getIdentity(), ureq.getUserSession().getRoles(), getLocale(), level);
 			source.getDefaultParams().setFormat(restrictToFormat);
+			source.getDefaultParams().setExcludedItemTypes(excludeTypes);
 			updateSource(source);
 		}
 	}
diff --git a/src/main/java/org/olat/modules/qpool/ui/ItemListMyListsController.java b/src/main/java/org/olat/modules/qpool/ui/ItemListMyListsController.java
index d4b0f71acac..8ea1dcb1e25 100644
--- a/src/main/java/org/olat/modules/qpool/ui/ItemListMyListsController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/ItemListMyListsController.java
@@ -36,6 +36,7 @@ import org.olat.core.util.StringHelper;
 import org.olat.modules.qpool.QPoolSecurityCallback;
 import org.olat.modules.qpool.QuestionItemCollection;
 import org.olat.modules.qpool.QuestionItemView;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.ui.datasource.CollectionOfItemsSource;
 import org.olat.modules.qpool.ui.datasource.EmptyItemsSource;
 import org.olat.modules.qpool.ui.events.QItemViewEvent;
@@ -53,8 +54,9 @@ public class ItemListMyListsController extends AbstractItemListController {
     
 	private List<QuestionItemCollection> myCollections;
 
-	public ItemListMyListsController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback, String restrictToFormat) {
-		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, "qti-select");
+	public ItemListMyListsController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback,
+			String restrictToFormat, List<QItemType> excludeTypes) {
+		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, excludeTypes, "qti-select");
 	}
 	
 	@Override
@@ -92,6 +94,7 @@ public class ItemListMyListsController extends AbstractItemListController {
             QuestionItemCollection firstCollection = myCollections.get(0);
             CollectionOfItemsSource source = new CollectionOfItemsSource(firstCollection, getIdentity(), ureq.getUserSession().getRoles(), getLocale());
             source.setRestrictToFormat(restrictToFormat);
+			source.setExcludedItemTypes(excludeTypes);
             updateSource(source);
         } else {
 			myListEl.setEnabled(false);
@@ -134,6 +137,7 @@ public class ItemListMyListsController extends AbstractItemListController {
 		} else {
 			CollectionOfItemsSource source = new CollectionOfItemsSource(myCollection, getIdentity(), ureq.getUserSession().getRoles(), getLocale());
 			source.setRestrictToFormat(restrictToFormat);
+			source.setExcludedItemTypes(excludeTypes);
 			updateSource(source);
 		}
 	}
diff --git a/src/main/java/org/olat/modules/qpool/ui/ItemListMySharesController.java b/src/main/java/org/olat/modules/qpool/ui/ItemListMySharesController.java
index 6c55a75b49b..2080c8474a5 100644
--- a/src/main/java/org/olat/modules/qpool/ui/ItemListMySharesController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/ItemListMySharesController.java
@@ -40,6 +40,7 @@ import org.olat.modules.qpool.Pool;
 import org.olat.modules.qpool.QPoolSecurityCallback;
 import org.olat.modules.qpool.QuestionItemView;
 import org.olat.modules.qpool.QuestionPoolModule;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.ui.datasource.EmptyItemsSource;
 import org.olat.modules.qpool.ui.datasource.PoolItemsSource;
 import org.olat.modules.qpool.ui.datasource.SharedItemsSource;
@@ -63,8 +64,9 @@ public class ItemListMySharesController extends AbstractItemListController {
 	@Autowired
 	private QuestionPoolModule qpoolModule;
 
-	public ItemListMySharesController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback, String restrictToFormat) {
-		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, "qti-select");
+	public ItemListMySharesController(UserRequest ureq, WindowControl wControl, QPoolSecurityCallback secCallback,
+			String restrictToFormat, List<QItemType> excludeTypes) {
+		super(ureq, wControl, secCallback, new EmptyItemsSource(), restrictToFormat, excludeTypes, "qti-select");
 	}
 	
 	@Override
@@ -116,15 +118,17 @@ public class ItemListMySharesController extends AbstractItemListController {
 			myShareEl.setEnabled(false);
 		} else {
 			myShareEl.select(myShareKeys[0], true);
-			if(myPools.size() > 0) {
+			if(!myPools.isEmpty()) {
 				Pool firstPool = myPools.get(0);
 				PoolItemsSource source = new PoolItemsSource(getIdentity(), roles, getLocale(), firstPool);
 				source.getDefaultParams().setFormat(restrictToFormat);
+				source.getDefaultParams().setExcludedItemTypes(excludeTypes);
 				updateSource(source);
-			} else if(myGroups.size() > 0) {
+			} else if(!myGroups.isEmpty()) {
 				BusinessGroup firstGroup = myGroups.get(0);
 				SharedItemsSource source = new SharedItemsSource(firstGroup, getIdentity(), roles, getLocale(), false);
 				source.setRestrictToFormat(restrictToFormat);
+				source.setExcludedItemTypes(excludeTypes);
 				updateSource(source);
 			}
 		}
@@ -173,6 +177,7 @@ public class ItemListMySharesController extends AbstractItemListController {
 		} else {
 			PoolItemsSource source = new PoolItemsSource(getIdentity(), ureq.getUserSession().getRoles(), getLocale(), myPool);
 			source.getDefaultParams().setFormat(restrictToFormat);
+			source.getDefaultParams().setExcludedItemTypes(excludeTypes);
 			updateSource(source);
 		}
 	}
@@ -190,6 +195,7 @@ public class ItemListMySharesController extends AbstractItemListController {
 		} else {
 			SharedItemsSource source = new SharedItemsSource(myGroup, getIdentity(), ureq.getUserSession().getRoles(), getLocale(), false);
 			source.setRestrictToFormat(restrictToFormat);
+			source.setExcludedItemTypes(excludeTypes);
 			updateSource(source);
 		}
 	}
diff --git a/src/main/java/org/olat/modules/qpool/ui/SelectItemController.java b/src/main/java/org/olat/modules/qpool/ui/SelectItemController.java
index b4dfdc327ff..ed666154b9c 100644
--- a/src/main/java/org/olat/modules/qpool/ui/SelectItemController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/SelectItemController.java
@@ -19,6 +19,9 @@
  */
 package org.olat.modules.qpool.ui;
 
+import java.util.Collections;
+import java.util.List;
+
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.Component;
 import org.olat.core.gui.components.link.Link;
@@ -35,6 +38,7 @@ import org.olat.core.util.StringHelper;
 import org.olat.core.util.UserSession;
 import org.olat.modules.qpool.QPoolSecurityCallback;
 import org.olat.modules.qpool.QuestionPoolModule;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.security.QPoolSecurityCallbackFactory;
 import org.olat.modules.qpool.ui.datasource.DefaultItemsSource;
 import org.olat.modules.qpool.ui.datasource.MarkedItemsSource;
@@ -50,8 +54,11 @@ import org.springframework.beans.factory.annotation.Autowired;
  */
 public class SelectItemController extends BasicController {
 	
-	private Link myCompetencesLink, mySharesLink, myListsLink;
-	private final Link markedItemsLink, ownedItemsLink;
+	private Link myListsLink;
+	private Link mySharesLink;
+	private Link ownedItemsLink;
+	private Link myCompetencesLink;
+	private final Link markedItemsLink;
 	private final SegmentViewComponent segmentView;
 	private final VelocityContainer mainVC;
 	private ItemListController ownedItemsCtrl;
@@ -59,7 +66,9 @@ public class SelectItemController extends BasicController {
     private ItemListMyListsController myListsCtrl;
 	private ItemListMySharesController mySharesCtrl;
 	private ItemListMyCompetencesController myCompetencesCtrl;
-	private String restrictToFormat;
+	
+	private final String restrictToFormat;
+	private final List<QItemType> excludeTypes;
 	
 	private final QPoolSecurityCallback secCallback;
 	
@@ -68,8 +77,14 @@ public class SelectItemController extends BasicController {
 	@Autowired
 	private QPoolSecurityCallbackFactory qPoolSecurityCallbackFactory;
 	
+
 	public SelectItemController(UserRequest ureq, WindowControl wControl, String restrictToFormat) {
+		this(ureq, wControl, restrictToFormat, Collections.emptyList());
+	}
+	
+	public SelectItemController(UserRequest ureq, WindowControl wControl, String restrictToFormat, List<QItemType> excludeTypes) {
 		super(ureq, wControl);
+		this.excludeTypes = excludeTypes;
 		this.restrictToFormat = restrictToFormat;
 		mainVC = createVelocityContainer("item_list_overview");
 		
@@ -96,7 +111,7 @@ public class SelectItemController extends BasicController {
 			segmentView.addSegment(mySharesLink, false);
         }
 		if(StringHelper.isLong(qpoolModule.getTaxonomyQPoolKey()) && qpoolModule.isReviewProcessEnabled()) {
-			myCompetencesCtrl = new ItemListMyCompetencesController(ureq, getWindowControl(), secCallback, restrictToFormat);
+			myCompetencesCtrl = new ItemListMyCompetencesController(ureq, getWindowControl(), secCallback, restrictToFormat, excludeTypes);
 			listenTo(myCompetencesCtrl);
 			if(myCompetencesCtrl.hasCompetences()) {
 				myCompetencesLink = LinkFactory.createLink("my.competences", mainVC, this);
@@ -148,7 +163,8 @@ public class SelectItemController extends BasicController {
 			DefaultItemsSource source = new MarkedItemsSource(getIdentity(), ureq.getUserSession().getRoles(), getLocale(), "Fav");
 			source.getDefaultParams().setFavoritOnly(true);
 			source.getDefaultParams().setFormat(restrictToFormat);
-			markedItemsCtrl = new ItemListController(ureq, getWindowControl(), secCallback, source);
+			source.getDefaultParams().setExcludedItemTypes(excludeTypes);
+			markedItemsCtrl = new ItemListController(ureq, getWindowControl(), secCallback, source, restrictToFormat, excludeTypes);
 			listenTo(markedItemsCtrl);
 		}
 		int numOfMarkedItems = markedItemsCtrl.updateList();
@@ -161,7 +177,8 @@ public class SelectItemController extends BasicController {
 			DefaultItemsSource source = new MyItemsSource(getIdentity(), ureq.getUserSession().getRoles(), getLocale(), "My"); 
 			source.getDefaultParams().setAuthor(getIdentity());
 			source.getDefaultParams().setFormat(restrictToFormat);
-			ownedItemsCtrl = new ItemListController(ureq, getWindowControl(), secCallback, source);
+			source.getDefaultParams().setExcludedItemTypes(excludeTypes);
+			ownedItemsCtrl = new ItemListController(ureq, getWindowControl(), secCallback, source, restrictToFormat, excludeTypes);
 			listenTo(ownedItemsCtrl);
 		}
 		ownedItemsCtrl.updateList();
@@ -170,7 +187,7 @@ public class SelectItemController extends BasicController {
 
     private void updateMyLists(UserRequest ureq) {
         if(myListsCtrl == null) {
-            myListsCtrl = new ItemListMyListsController(ureq, getWindowControl(), secCallback, restrictToFormat);
+            myListsCtrl = new ItemListMyListsController(ureq, getWindowControl(), secCallback, restrictToFormat, excludeTypes);
             listenTo(myListsCtrl);
         }
         mainVC.put("itemList", myListsCtrl.getInitialComponent());
@@ -178,7 +195,7 @@ public class SelectItemController extends BasicController {
 
 	private void updateMyShares(UserRequest ureq) {
 		if(mySharesCtrl == null) {
-			mySharesCtrl = new ItemListMySharesController(ureq, getWindowControl(), secCallback, restrictToFormat);
+			mySharesCtrl = new ItemListMySharesController(ureq, getWindowControl(), secCallback, restrictToFormat, excludeTypes);
 			listenTo(mySharesCtrl);
 		}
 		mainVC.put("itemList", mySharesCtrl.getInitialComponent());
@@ -186,7 +203,7 @@ public class SelectItemController extends BasicController {
 	
 	private void updateMyCompetences(UserRequest ureq) {
 		if(myCompetencesCtrl == null) {
-			myCompetencesCtrl = new ItemListMyCompetencesController(ureq, getWindowControl(), secCallback, restrictToFormat);
+			myCompetencesCtrl = new ItemListMyCompetencesController(ureq, getWindowControl(), secCallback, restrictToFormat, excludeTypes);
 			listenTo(myCompetencesCtrl);
 		}
 		mainVC.put("itemList", myCompetencesCtrl.getInitialComponent());
diff --git a/src/main/java/org/olat/modules/qpool/ui/datasource/CollectionOfItemsSource.java b/src/main/java/org/olat/modules/qpool/ui/datasource/CollectionOfItemsSource.java
index 244aff20355..90568872a0a 100644
--- a/src/main/java/org/olat/modules/qpool/ui/datasource/CollectionOfItemsSource.java
+++ b/src/main/java/org/olat/modules/qpool/ui/datasource/CollectionOfItemsSource.java
@@ -40,6 +40,7 @@ import org.olat.modules.qpool.QuestionItemCollection;
 import org.olat.modules.qpool.QuestionItemShort;
 import org.olat.modules.qpool.QuestionItemView;
 import org.olat.modules.qpool.QuestionStatus;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.model.SearchQuestionItemParams;
 import org.olat.modules.qpool.ui.QuestionItemsSource;
 import org.olat.modules.qpool.ui.metadata.QPoolSearchEvent;
@@ -62,6 +63,7 @@ public class CollectionOfItemsSource implements QuestionItemsSource {
 	private QPoolSearchEvent extendedSearchParameters;
 	
 	private String restrictToFormat;
+	private List<QItemType> excludedItemTypes;
 	
 	public CollectionOfItemsSource(QuestionItemCollection collection, Identity identity, Roles roles, Locale locale) {
 		this.roles = roles;
@@ -79,6 +81,10 @@ public class CollectionOfItemsSource implements QuestionItemsSource {
 		this.restrictToFormat = restrictToFormat;
 	}
 	
+	public void setExcludedItemTypes(List<QItemType> excludedItemTypes) {
+		this.excludedItemTypes = excludedItemTypes;
+	}
+	
 	@Override
 	public void setExtendedSearchParams(QPoolSearchEvent parameters) {
 		this.extendedSearchParameters = parameters;
@@ -204,6 +210,7 @@ public class CollectionOfItemsSource implements QuestionItemsSource {
 			params.setFormat(restrictToFormat);
 		}
 		params.setCollection(collection);
+		params.setExcludedItemTypes(excludedItemTypes);
 		ResultInfos<QuestionItemView> items = qpoolService.getItems(params, 0, -1);
 		return items.getObjects();
 	}
@@ -232,6 +239,7 @@ public class CollectionOfItemsSource implements QuestionItemsSource {
 		if(StringHelper.containsNonWhitespace(restrictToFormat)) {
 			params.setFormat(restrictToFormat);
 		}
+		params.setExcludedItemTypes(excludedItemTypes);
 		params.setCollection(collection);
 		return params;
 	}
diff --git a/src/main/java/org/olat/modules/qpool/ui/datasource/SharedItemsSource.java b/src/main/java/org/olat/modules/qpool/ui/datasource/SharedItemsSource.java
index f2389e34b7a..5d1e71c1a5c 100644
--- a/src/main/java/org/olat/modules/qpool/ui/datasource/SharedItemsSource.java
+++ b/src/main/java/org/olat/modules/qpool/ui/datasource/SharedItemsSource.java
@@ -40,6 +40,7 @@ import org.olat.modules.qpool.QuestionItem;
 import org.olat.modules.qpool.QuestionItemShort;
 import org.olat.modules.qpool.QuestionItemView;
 import org.olat.modules.qpool.QuestionStatus;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.model.SearchQuestionItemParams;
 import org.olat.modules.qpool.ui.QuestionItemsSource;
 import org.olat.modules.qpool.ui.metadata.QPoolSearchEvent;
@@ -61,6 +62,7 @@ public class SharedItemsSource implements QuestionItemsSource {
 	
 	private String searchString;
 	private String restrictToFormat;
+	private List<QItemType> excludedItemTypes;
 	private QPoolSearchEvent extendedSearchParameters;
 
 	public SharedItemsSource(BusinessGroup group, Identity identity, Roles roles, Locale locale, boolean admin) {
@@ -80,6 +82,10 @@ public class SharedItemsSource implements QuestionItemsSource {
 		this.restrictToFormat = restrictToFormat;
 	}
 	
+	public void setExcludedItemTypes(List<QItemType> excludedItemTypes) {
+		this.excludedItemTypes = excludedItemTypes;
+	}
+	
 	@Override
 	public void setExtendedSearchParams(QPoolSearchEvent parameters) {
 		extendedSearchParameters = parameters;
@@ -200,6 +206,7 @@ public class SharedItemsSource implements QuestionItemsSource {
 		if(StringHelper.containsNonWhitespace(restrictToFormat)) {
 			params.setFormat(restrictToFormat);
 		}
+		params.setExcludedItemTypes(excludedItemTypes);
 		ResultInfos<QuestionItemView> items = qpoolService.getItems(params, 0, -1);
 		return items.getObjects();
 	}
@@ -229,6 +236,7 @@ public class SharedItemsSource implements QuestionItemsSource {
 		if(StringHelper.containsNonWhitespace(restrictToFormat)) {
 			params.setFormat(restrictToFormat);
 		}
+		params.setExcludedItemTypes(excludedItemTypes);
 		params.setResource(group.getResource());
 		return params;
 	}
diff --git a/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java b/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java
index 8f73d52d969..2ec0a4a4f6e 100644
--- a/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java
+++ b/src/main/java/org/olat/modules/qpool/ui/metadata/ExtendedSearchController.java
@@ -48,6 +48,7 @@ import org.olat.modules.qpool.QPoolService;
 import org.olat.modules.qpool.QuestionStatus;
 import org.olat.modules.qpool.manager.QuestionPoolLicenseHandler;
 import org.olat.modules.qpool.model.QItemDocument;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.model.SearchQuestionItemParams;
 import org.olat.modules.qpool.ui.QuestionsController;
 import org.olat.modules.qpool.ui.metadata.MetaUIFactory.KeyValues;
@@ -72,6 +73,7 @@ public class ExtendedSearchController extends FormBasicController implements Ext
 	private final String prefsKey;
 	private ExtendedSearchPrefs prefs;
 	private final boolean allTaxonomyLevels;
+	private final List<QItemType> excludedItemTypes;
 	private boolean enabled = true;
 	private final QPoolSecurityCallback qPoolSecurityCallback;
 	
@@ -85,11 +87,13 @@ public class ExtendedSearchController extends FormBasicController implements Ext
 	private QuestionPoolLicenseHandler licenseHandler;
 
 	public ExtendedSearchController(UserRequest ureq, WindowControl wControl,
-			QPoolSecurityCallback qPoolSecurityCallback, String prefsKey, Form mainForm, boolean allTaxonomyLevels) {
+			QPoolSecurityCallback qPoolSecurityCallback, String prefsKey, Form mainForm,
+			List<QItemType> excludedItemTypes, boolean allTaxonomyLevels) {
 		super(ureq, wControl, LAYOUT_CUSTOM, "extended_search", mainForm);
 		setTranslator(Util.createPackageTranslator(QuestionsController.class, getLocale(), getTranslator()));
 		this.qPoolSecurityCallback = qPoolSecurityCallback;
 		this.allTaxonomyLevels = allTaxonomyLevels;
+		this.excludedItemTypes = excludedItemTypes;
 		searchAttributes = new SearchAttributes();
 		
 		this.prefsKey = prefsKey;
@@ -484,7 +488,7 @@ public class ExtendedSearchController extends FormBasicController implements Ext
 		
 		@Override
 		public FormItem createItem(String startValue) {
-			KeyValues types = MetaUIFactory.getQItemTypeKeyValues(getTranslator(), qpoolService);
+			KeyValues types = MetaUIFactory.getQItemTypeKeyValues(getTranslator(), excludedItemTypes, qpoolService);
 			return createItem(types.getKeys(), types.getValues(), startValue);
 		}
 
diff --git a/src/main/java/org/olat/modules/qpool/ui/metadata/MetaUIFactory.java b/src/main/java/org/olat/modules/qpool/ui/metadata/MetaUIFactory.java
index ac069f4f8c6..05ad034cada 100644
--- a/src/main/java/org/olat/modules/qpool/ui/metadata/MetaUIFactory.java
+++ b/src/main/java/org/olat/modules/qpool/ui/metadata/MetaUIFactory.java
@@ -20,6 +20,7 @@
 package org.olat.modules.qpool.ui.metadata;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
@@ -92,22 +93,24 @@ public class MetaUIFactory {
 				.findFirst().orElse(null);
 	}
 	
-	public static KeyValues getQItemTypeKeyValues(Translator translator, QPoolService qpoolService) {
+	public static KeyValues getQItemTypeKeyValues(Translator translator, List<QItemType> excludedItemTypes, QPoolService qpoolService) {
 		List<QItemType> types = qpoolService.getAllItemTypes();
-		String[] typeKeys = new String[types.size()];
-		String[] typeValues = new String[types.size()];
-		int count = 0;
+		List<String> typeKeys = new ArrayList<>(types.size());
+		List<String> typeValues = new ArrayList<>(types.size());
 		for(QItemType type:types) {
-			typeKeys[count] = type.getType();
+			if(excludedItemTypes != null && excludedItemTypes.contains(type)) {
+				continue;
+			}
+			
+			typeKeys.add(type.getType());
 			String translation = translator.translate("item.type." + type.getType().toLowerCase());
 			if(translation.length() > 128) {
-				typeValues[count] = typeKeys[count];
+				typeValues.add(type.getType());
 			} else {
-				typeValues[count] = translation;
+				typeValues.add(translation);
 			}
-			count++;
 		}
-		return new KeyValues(typeKeys, typeValues);
+		return new KeyValues(typeKeys.toArray(new String[typeKeys.size()]), typeValues.toArray(new String[typeValues.size()]));
 	}
 	
 	public static QItemType getQItemTypeByKey(String key, QPoolService qpoolService) {
diff --git a/src/main/java/org/olat/modules/video/ui/question/VideoQuestionEditController.java b/src/main/java/org/olat/modules/video/ui/question/VideoQuestionEditController.java
index 707c6c24f5a..824e5aea7a2 100644
--- a/src/main/java/org/olat/modules/video/ui/question/VideoQuestionEditController.java
+++ b/src/main/java/org/olat/modules/video/ui/question/VideoQuestionEditController.java
@@ -21,6 +21,7 @@ package org.olat.modules.video.ui.question;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
@@ -60,8 +61,11 @@ import org.olat.ims.qti21.ui.assessment.components.QuestionTypeFlexiCellRenderer
 import org.olat.ims.qti21.ui.editor.AssessmentItemEditorController;
 import org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent;
 import org.olat.modules.assessment.ui.ScoreCellRenderer;
+import org.olat.modules.qpool.QPoolService;
 import org.olat.modules.qpool.QuestionItemFull;
 import org.olat.modules.qpool.QuestionItemView;
+import org.olat.modules.qpool.QuestionType;
+import org.olat.modules.qpool.model.QItemType;
 import org.olat.modules.qpool.ui.SelectItemController;
 import org.olat.modules.qpool.ui.events.QItemViewEvent;
 import org.olat.modules.video.VideoManager;
@@ -202,6 +206,8 @@ public class VideoQuestionEditController extends BasicController {
 		@Autowired
 		private VideoManager videoManager;
 		@Autowired
+		private QPoolService questionPoolService;
+		@Autowired
 		private QTI21QPoolServiceProvider qti21QPoolServiceProvider;
 		
 		public VideoQuestionsController(UserRequest ureq, WindowControl wControl) {
@@ -338,7 +344,17 @@ public class VideoQuestionEditController extends BasicController {
 			removeAsListenerAndDispose(cmc);
 			removeAsListenerAndDispose(selectQItemCtrl);
 			
-			selectQItemCtrl = new SelectItemController(ureq, getWindowControl(), QTI21Constants.QTI_21_FORMAT);
+			List<QItemType> itemTypes = questionPoolService.getAllItemTypes();
+			List<QItemType> excludedItemTypes = new ArrayList<>();
+			for(QItemType t:itemTypes) {
+				if(t.getType().equalsIgnoreCase(QuestionType.DRAWING.name())
+						|| t.getType().equalsIgnoreCase(QuestionType.ESSAY.name())
+						|| t.getType().equalsIgnoreCase(QuestionType.UPLOAD.name())) {
+					excludedItemTypes.add(t);
+				}
+			}
+
+			selectQItemCtrl = new SelectItemController(ureq, getWindowControl(), QTI21Constants.QTI_21_FORMAT, excludedItemTypes);
 			listenTo(selectQItemCtrl);
 
 			cmc = new CloseableModalController(getWindowControl(), translate("close"), selectQItemCtrl.getInitialComponent(), true, translate("title.add") );
-- 
GitLab