Skip to content
Snippets Groups Projects
Commit b2156c24 authored by srosse's avatar srosse
Browse files

OO-535: fix some translation inheritance after moving MetadataController, fix some unit tests...

parent 14a96b02
No related branches found
No related tags found
No related merge requests found
Showing
with 59 additions and 43 deletions
......@@ -33,7 +33,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.qpool.Pool;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -51,7 +51,7 @@ public class PoolEditController extends FormBasicController {
public PoolEditController(UserRequest ureq, WindowControl wControl, Pool pool) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
this.pool = pool;
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
......
......@@ -56,8 +56,8 @@ import org.olat.core.util.Util;
import org.olat.modules.qpool.Pool;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.PoolImpl;
import org.olat.modules.qpool.ui.QuestionsController;
import org.olat.modules.qpool.ui.events.QPoolEvent;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
/**
*
......@@ -83,7 +83,7 @@ public class PoolsAdminController extends FormBasicController {
public PoolsAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "pools_admin");
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
initForm(ureq);
......
......@@ -32,7 +32,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QEducationalContext;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -49,7 +49,7 @@ public class QEducationalContextEditController extends FormBasicController {
public QEducationalContextEditController(UserRequest ureq, WindowControl wControl, QEducationalContext itemLevel) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
this.itemLevel = itemLevel;
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
......
......@@ -58,7 +58,7 @@ import org.olat.core.util.i18n.ui.TranslationToolI18nItemEditCrumbController;
import org.olat.core.util.prefs.Preferences;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QEducationalContext;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -85,7 +85,7 @@ public class QEducationalContextsAdminController extends FormBasicController {
public QEducationalContextsAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "levels_admin");
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
initForm(ureq);
......
......@@ -32,7 +32,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QItemType;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -49,7 +49,7 @@ public class QItemTypeEditController extends FormBasicController {
public QItemTypeEditController(UserRequest ureq, WindowControl wControl, QItemType itemType) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
this.itemType = itemType;
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
......
......@@ -58,7 +58,7 @@ import org.olat.core.util.i18n.ui.TranslationToolI18nItemEditCrumbController;
import org.olat.core.util.prefs.Preferences;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QItemType;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -85,7 +85,7 @@ public class QItemTypesAdminController extends FormBasicController {
public QItemTypesAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "types_admin");
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
initForm(ureq);
......
......@@ -32,7 +32,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QLicense;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -49,7 +49,7 @@ public class QLicenseEditController extends FormBasicController {
public QLicenseEditController(UserRequest ureq, WindowControl wControl, QLicense license) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
this.license = license;
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
......
......@@ -51,7 +51,7 @@ import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.util.Util;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.model.QLicense;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -77,7 +77,7 @@ public class QLicensesAdminController extends FormBasicController {
public QLicensesAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "licenses_admin");
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
initForm(ureq);
......
......@@ -35,7 +35,7 @@ import org.olat.core.gui.control.generic.closablewrapper.CloseableModalControlle
import org.olat.core.util.Util;
import org.olat.core.util.tree.TreeHelper;
import org.olat.modules.qpool.TaxonomyLevel;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -57,7 +57,7 @@ public class TaxonomyAdminController extends BasicController {
public TaxonomyAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
mainVC = createVelocityContainer("admin_study_fields");
......
......@@ -34,7 +34,7 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.core.util.Util;
import org.olat.modules.qpool.TaxonomyLevel;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -53,7 +53,7 @@ public class TaxonomyLevelController extends FormBasicController {
public TaxonomyLevelController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
initForm(ureq);
//make it invisible, no level to show
flc.setVisible(false);
......
......@@ -32,7 +32,7 @@ import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.TaxonomyLevel;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -50,7 +50,7 @@ public class TaxonomyLevelEditController extends FormBasicController {
public TaxonomyLevelEditController(UserRequest ureq, WindowControl wControl, TaxonomyLevel parentLevel, TaxonomyLevel taxonomyLevel) {
super(ureq, wControl);
setTranslator(Util.createPackageTranslator(MetadatasController.class, ureq.getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, ureq.getLocale(), getTranslator()));
this.parentLevel = parentLevel;
this.taxonomyLevel = taxonomyLevel;
......
......@@ -40,7 +40,7 @@ import org.olat.modules.qpool.ExportFormatOptions;
import org.olat.modules.qpool.QPoolSPI;
import org.olat.modules.qpool.QuestionItemShort;
import org.olat.modules.qpool.QuestionPoolModule;
import org.olat.modules.qpool.ui.metadata.MetadatasController;
import org.olat.modules.qpool.ui.QuestionsController;
/**
*
......@@ -55,7 +55,7 @@ public class ExportOverviewController extends StepFormBasicController {
public ExportOverviewController(UserRequest ureq, WindowControl wControl, Form rootForm, StepsRunContext runContext) {
super(ureq, wControl, rootForm, runContext, LAYOUT_VERTICAL, null);
setTranslator(Util.createPackageTranslator(MetadatasController.class, getLocale(), getTranslator()));
setTranslator(Util.createPackageTranslator(QuestionsController.class, getLocale(), getTranslator()));
format = (ExportFormatOptions)runContext.get("format");
......
......@@ -35,6 +35,7 @@ public class RolesVO {
private boolean author = false;
private boolean guestOnly = false;
private boolean institutionalResourceManager = false;
private boolean poolAdmin = false;
private boolean invitee = false;
public RolesVO() {
......@@ -48,11 +49,12 @@ public class RolesVO {
this.author = roles.isAuthor();
this.guestOnly = roles.isGuestOnly();
this.institutionalResourceManager = roles.isInstitutionalResourceManager();
this.poolAdmin = roles.isPoolAdmin();
this.invitee = roles.isInvitee();
}
public Roles toRoles() {
return new Roles(olatAdmin, userManager, groupManager, author, guestOnly, institutionalResourceManager, invitee);
return new Roles(olatAdmin, userManager, groupManager, author, guestOnly, institutionalResourceManager, poolAdmin, invitee);
}
public boolean isOlatAdmin() {
......@@ -103,6 +105,14 @@ public class RolesVO {
this.institutionalResourceManager = institutionalResourceManager;
}
public boolean isPoolAdmin() {
return poolAdmin;
}
public void setPoolAdmin(boolean poolAdmin) {
this.poolAdmin = poolAdmin;
}
public boolean isInvitee() {
return invitee;
}
......
......@@ -104,6 +104,8 @@ create table if not exists o_qtiresultset (
assessmentid bigint not null,
repositoryref_fk bigint not null,
ispassed bit,
issuspended bit default 0,
fullyassessed bit default 0,
score FLOAT(65,30),
duration bigint,
primary key (resultset_id)
......
......@@ -130,7 +130,7 @@ public class QTIImportProcessorTest extends OlatTestCase {
Assert.assertEquals("This is a multiple-choice example with image content. The rendering is a standard radio button style. No response processing is incorporated.", reloadItem.getDescription());
//question type
Assert.assertNotNull(reloadItem.getType());
Assert.assertEquals(QuestionType.SC.name(), reloadItem.getType().getType());
Assert.assertEquals(QuestionType.SC.name().toLowerCase(), reloadItem.getType().getType());
//check that the file is storead
VFSContainer itemDir = qpoolFileStorage.getContainer(reloadItem.getDirectory());
......@@ -167,7 +167,7 @@ public class QTIImportProcessorTest extends OlatTestCase {
//description -> qticomment
Assert.assertEquals("This is a standard numerical fill-in-blank (integer) example. No response processing is incorporated.", reloadItem.getDescription());
//question type
Assert.assertEquals(QuestionType.FIB.name(), reloadItem.getType().getType());
Assert.assertEquals(QuestionType.FIB.name().toLowerCase(), reloadItem.getType().getType());
}
/**
......@@ -218,7 +218,7 @@ public class QTIImportProcessorTest extends OlatTestCase {
Assert.assertEquals(QTIConstants.QTI_12_FORMAT, item.getFormat());
QItemType itemType = item.getType();
Assert.assertNotNull(itemType);
QuestionType type = QuestionType.valueOf(itemType.getType());
QuestionType type = QuestionType.valueOf(itemType.getType().toUpperCase());
if(type != null) {
switch(type) {
case SC: sc++; break;
......@@ -289,11 +289,11 @@ public class QTIImportProcessorTest extends OlatTestCase {
Assert.assertNotNull(itemNode);
//check the attachments
if(itemFull.getType().getType().equals(QuestionType.SC.name())) {
if(itemFull.getType().getType().equalsIgnoreCase(QuestionType.SC.name())) {
Assert.assertTrue(exists(itemFull, "media/image1.gif"));
Assert.assertTrue(exists(itemFull, "media/image2.gif"));
Assert.assertFalse(exists(itemFull, "media/image3.gif"));
} else if(itemFull.getType().getType().equals(QuestionType.MC.name())) {
} else if(itemFull.getType().getType().equalsIgnoreCase(QuestionType.MC.name())) {
Assert.assertFalse(exists(itemFull, "media/image1.gif"));
Assert.assertTrue(exists(itemFull, "media/image2.gif"));
Assert.assertTrue(exists(itemFull, "media/image3.gif"));
......
......@@ -93,11 +93,8 @@ public class MetadataConverterHelperTest extends OlatTestCase {
@Test
public void serializeQuestionItem() {
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
QuestionItem item = questionDao.createAndPersist(null, "Stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
Assert.assertNotNull(item);
}
}
\ No newline at end of file
......@@ -178,14 +178,15 @@ public class PoolDAOTest extends OlatTestCase {
@Test
public void removeItemFromPool_paranoid() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
//create a pool
String name1 = "NGC-" + UUID.randomUUID().toString();
Pool pool1 = poolDao.createPool(null, name1, true);
String name2 = "NGC-" + UUID.randomUUID().toString();
Pool pool2 = poolDao.createPool(null, name2, true);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item1 = questionItemDao.createAndPersist(null, "Cluster of stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item2 = questionItemDao.createAndPersist(null, "Nebula", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item1 = questionItemDao.createAndPersist(id, "Cluster of stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item2 = questionItemDao.createAndPersist(id, "Nebula", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
poolDao.addItemToPool(item1, Collections.singletonList(pool1), false);
poolDao.addItemToPool(item1, Collections.singletonList(pool2), false);
......@@ -193,9 +194,9 @@ public class PoolDAOTest extends OlatTestCase {
poolDao.addItemToPool(item2, Collections.singletonList(pool2), false);
dbInstance.commit();
SearchQuestionItemParams params1 = new SearchQuestionItemParams(null, null);
SearchQuestionItemParams params1 = new SearchQuestionItemParams(id, null);
params1.setPoolKey(pool1.getKey());
SearchQuestionItemParams params2 = new SearchQuestionItemParams(null, null);
SearchQuestionItemParams params2 = new SearchQuestionItemParams(id, null);
params2.setPoolKey(pool2.getKey());
//check
......@@ -228,15 +229,16 @@ public class PoolDAOTest extends OlatTestCase {
@Test
public void getItemsOfPool() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
//create a pool
String name = "NGC-" + UUID.randomUUID().toString();
Pool pool = poolDao.createPool(null, name, true);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item = questionItemDao.createAndPersist(id, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
poolDao.addItemToPool(item, Collections.singletonList(pool), false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(null, null);
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
params.setPoolKey(pool.getKey());
//retrieve
......@@ -291,16 +293,17 @@ public class PoolDAOTest extends OlatTestCase {
@Test
public void removeItemFromPools() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
//create a pool with an item
String name = "NGC-" + UUID.randomUUID().toString();
Pool pool = poolDao.createPool(null, name, true);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item = questionItemDao.createAndPersist(id, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
poolDao.addItemToPool(item, Collections.singletonList(pool), false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(null, null);
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
params.setPoolKey(pool.getKey());
//check the pool and remove the items
......
......@@ -46,6 +46,7 @@ import org.olat.modules.qpool.QuestionItemShort;
import org.olat.modules.qpool.QuestionItemView;
import org.olat.modules.qpool.QuestionType;
import org.olat.modules.qpool.model.QItemType;
import org.olat.modules.qpool.model.SearchQuestionItemParams;
import org.olat.test.JunitTestHelper;
import org.olat.test.OlatTestCase;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -114,10 +115,12 @@ public class QuestionPoolServiceTest extends OlatTestCase {
Assert.assertEquals("My private collection", newColl.getName());
dbInstance.commit();//check if it's alright
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
//retrieve the list of items in the collection
int numOfItemsInCollection = qpoolService.countItemsOfCollection(newColl);
Assert.assertEquals(2, numOfItemsInCollection);
ResultInfos<QuestionItemView> itemsOfCollection = qpoolService.getItemsOfCollection(newColl, null, 0, -1);
ResultInfos<QuestionItemView> itemsOfCollection = qpoolService.getItemsOfCollection(newColl, params, 0, -1);
Assert.assertNotNull(itemsOfCollection);
Assert.assertEquals(2, itemsOfCollection.getObjects().size());
List<Long> itemKeys = new ArrayList<Long>();
......
......@@ -640,6 +640,7 @@ public class UserMgmtTest extends OlatJerseyTestCase {
Assert.assertFalse(reloadRoles.isInstitutionalResourceManager());
Assert.assertFalse(reloadRoles.isInvitee());
Assert.assertFalse(reloadRoles.isOLATAdmin());
Assert.assertFalse(reloadRoles.isPoolAdmin());
Assert.assertTrue(reloadRoles.isUserManager());
conn.shutdown();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment