use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method isIdentityInBusinessGroupNameOwner.
@Test
public void isIdentityInBusinessGroupNameOwner() {
// create relations
Identity id = JunitTestHelper.createAndPersistIdentityAsUser(UUID.randomUUID().toString());
RepositoryEntry resource1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "rel-bgis-1", "rel-bgis-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, resource1);
businessGroupRelationDao.addRelationToResource(group1, resource2);
businessGroupRelationDao.addRole(id, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check
boolean test1 = businessGroupRelationDao.isIdentityInBusinessGroup(id, null, true, true, resource1);
Assert.assertTrue(test1);
// name doesn't exist
boolean test2 = businessGroupRelationDao.isIdentityInBusinessGroup(id, 1l, true, true, resource1);
Assert.assertFalse(test2);
// wrong resource
boolean test4 = businessGroupRelationDao.isIdentityInBusinessGroup(id, null, true, true, resource3);
Assert.assertFalse(test4);
// check null
boolean test5 = businessGroupRelationDao.isIdentityInBusinessGroup(id, null, true, true, resource1);
Assert.assertTrue(test5);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAOTest method isIdentityInBusinessGroupKeyOwner.
@Test
public void isIdentityInBusinessGroupKeyOwner() {
// create relations
Identity id = JunitTestHelper.createAndPersistIdentityAsUser(UUID.randomUUID().toString());
RepositoryEntry resource1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry resource3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "rel-bgiskey-1", "rel-bgiskey-1-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, resource1);
businessGroupRelationDao.addRelationToResource(group1, resource2);
businessGroupRelationDao.addRole(id, group1, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check
boolean test1 = businessGroupRelationDao.isIdentityInBusinessGroup(id, group1.getKey(), true, true, resource1);
Assert.assertTrue(test1);
// key doesn't exist
boolean test2 = businessGroupRelationDao.isIdentityInBusinessGroup(id, 1l, true, true, resource1);
Assert.assertFalse(test2);
boolean test3 = businessGroupRelationDao.isIdentityInBusinessGroup(id, group1.getKey(), true, true, resource3);
Assert.assertFalse(test3);
// check null
boolean test5 = businessGroupRelationDao.isIdentityInBusinessGroup(id, null, true, true, resource1);
Assert.assertTrue(test5);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class QTIResultManagerTest method hasResultSets_negativeTest.
@Test
public void hasResultSets_negativeTest() {
RepositoryEntry re = createRepository();
String resSubPath = "qtiResult35";
boolean hasSet = qtiResultManager.hasResultSets(re.getOlatResource().getResourceableId(), resSubPath, re.getKey());
Assert.assertFalse(hasSet);
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class QTIResultManagerTest method selectResults.
@Test
public void selectResults() {
RepositoryEntry re = createRepository();
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-result-mgr-6");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-result-mgr-7");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-result-mgr-8");
dbInstance.commit();
long assessmentId = 841l;
String resSubPath = "qtiResult37";
String itemIdent = "NES:PS4:849235789";
QTIResultSet set1_1 = createSet(1.0f, assessmentId, id1, re, resSubPath, modDate(3, 8, 5), modDate(3, 8, 20));
QTIResult result1_1 = createResult(itemIdent, "Hello world", set1_1);
QTIResultSet set2_1 = createSet(3.0f, assessmentId, id2, re, resSubPath, modDate(3, 14, 8), modDate(3, 14, 32));
QTIResult result2_1 = createResult(itemIdent, "Bonjour madame", set2_1);
QTIResultSet set3_1 = createSet(5.0f, assessmentId, id3, re, resSubPath, modDate(3, 10, 35), modDate(3, 10, 55));
QTIResult result3_1 = createResult(itemIdent, "Tschuss", set3_1);
dbInstance.commit();
// order by last name
List<QTIResult> resultsType1 = qtiResultManager.selectResults(re.getOlatResource().getResourceableId(), resSubPath, re.getKey(), null, 1);
Assert.assertNotNull(resultsType1);
Assert.assertEquals(3, resultsType1.size());
Assert.assertTrue(resultsType1.contains(result1_1));
Assert.assertTrue(resultsType1.contains(result2_1));
Assert.assertTrue(resultsType1.contains(result3_1));
// order by last name
List<QTIResult> resultsType2 = qtiResultManager.selectResults(re.getOlatResource().getResourceableId(), resSubPath, re.getKey(), null, 2);
Assert.assertNotNull(resultsType2);
Assert.assertEquals(3, resultsType2.size());
Assert.assertTrue(resultsType2.contains(result1_1));
Assert.assertTrue(resultsType2.contains(result2_1));
Assert.assertTrue(resultsType2.contains(result3_1));
// order by creation date
List<QTIResult> resultsType3 = qtiResultManager.selectResults(re.getOlatResource().getResourceableId(), resSubPath, re.getKey(), null, 3);
Assert.assertNotNull(resultsType3);
Assert.assertEquals(3, resultsType3.size());
Assert.assertTrue(resultsType3.contains(result1_1));
Assert.assertTrue(resultsType3.contains(result2_1));
Assert.assertTrue(resultsType3.contains(result3_1));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class QTIResultManagerTest method getResultSets_withIdentity.
@Test
public void getResultSets_withIdentity() {
RepositoryEntry re = createRepository();
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-result-mgr-3");
dbInstance.commit();
long assessmentId = 839l;
String resSubPath = "qtiResult36";
// 3 try for id1
QTIResultSet set1_1 = createSet(1.0f, assessmentId, id, re, resSubPath, modDate(3, 8, 5), modDate(3, 8, 20));
QTIResultSet set1_3 = createSet(3.0f, assessmentId, id, re, resSubPath, modDate(3, 14, 8), modDate(3, 14, 32));
QTIResultSet set1_2 = createSet(5.0f, assessmentId, id, re, resSubPath, modDate(3, 10, 35), modDate(3, 10, 55));
dbInstance.commit();
List<QTIResultSet> set = qtiResultManager.getResultSets(re.getOlatResource().getResourceableId(), resSubPath, re.getKey(), id);
Assert.assertNotNull(set);
Assert.assertEquals(3, set.size());
Assert.assertTrue(set.contains(set1_1));
Assert.assertTrue(set.contains(set1_2));
Assert.assertTrue(set.contains(set1_3));
}
Aggregations