Search in sources :

Example 96 with RepositoryEntry

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 97 with RepositoryEntry

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 98 with RepositoryEntry

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);
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 99 with RepositoryEntry

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));
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 100 with RepositoryEntry

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));
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

RepositoryEntry (org.olat.repository.RepositoryEntry)2108 Test (org.junit.Test)922 Identity (org.olat.core.id.Identity)888 BusinessGroup (org.olat.group.BusinessGroup)344 ArrayList (java.util.ArrayList)258 File (java.io.File)246 ICourse (org.olat.course.ICourse)246 Date (java.util.Date)234 OLATResource (org.olat.resource.OLATResource)200 URI (java.net.URI)176 HttpResponse (org.apache.http.HttpResponse)172 OLATResourceable (org.olat.core.id.OLATResourceable)132 RepositoryManager (org.olat.repository.RepositoryManager)122 Roles (org.olat.core.id.Roles)104 RepositoryService (org.olat.repository.RepositoryService)104 LectureBlock (org.olat.modules.lecture.LectureBlock)94 Path (javax.ws.rs.Path)90 URL (java.net.URL)84 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 WindowControl (org.olat.core.gui.control.WindowControl)74