Search in sources :

Example 6 with AssessmentData

use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.

the class CheckboxManagerTest method loadAssessmentDatas_inGroup.

@Test
public void loadAssessmentDatas_inGroup() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-19");
    BusinessGroup group = businessGroupDao.createAndPersist(null, "gcheck", "gcheck-desc", 0, 10, true, true, false, false, false);
    businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    String checkboxId = UUID.randomUUID().toString();
    String resSubPath = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, entry.getOlatResource(), resSubPath);
    DBCheck check = checkboxManager.createCheck(checkbox, id, null, Boolean.TRUE);
    dbInstance.commitAndCloseSession();
    List<BusinessGroup> groups = Collections.singletonList(group);
    List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(entry.getOlatResource(), resSubPath, null, groups);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(1, loadedChecks.size());
    AssessmentData data = loadedChecks.get(0);
    Assert.assertNotNull(data);
    Assert.assertNotNull(data.getChecks());
    Assert.assertEquals(1, data.getChecks().size());
    Assert.assertEquals(check, data.getChecks().get(0));
    Assert.assertEquals(id, data.getIdentity());
}
Also used : AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) DBCheck(org.olat.course.nodes.cl.model.DBCheck) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 7 with AssessmentData

use of org.olat.course.nodes.cl.model.AssessmentData in project openolat by klemens.

the class CheckboxManagerTest method loadAssessmentDatas_inGroupAndCourse.

@Test
public void loadAssessmentDatas_inGroupAndCourse() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity groupParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("check-20");
    BusinessGroup group = businessGroupDao.createAndPersist(null, "gcheck", "gcheck-desc", 0, 10, true, true, false, false, false);
    businessGroupRelationDao.addRole(groupParticipant, group, GroupRoles.participant.name());
    Identity courseParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("check-21");
    repositoryEntryRelationDao.addRole(courseParticipant, entry, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // add some noise
    Identity courseOwner = JunitTestHelper.createAndPersistIdentityAsRndUser("check-22");
    repositoryEntryRelationDao.addRole(courseOwner, entry, GroupRoles.owner.name());
    Identity groupWaiting = JunitTestHelper.createAndPersistIdentityAsRndUser("check-23");
    businessGroupRelationDao.addRole(groupWaiting, group, GroupRoles.waiting.name());
    dbInstance.commitAndCloseSession();
    String checkboxId = UUID.randomUUID().toString();
    String resSubPath = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, entry.getOlatResource(), resSubPath);
    DBCheck checkGroup = checkboxManager.createCheck(checkbox, groupParticipant, null, Boolean.TRUE);
    DBCheck checkCourse = checkboxManager.createCheck(checkbox, courseParticipant, null, Boolean.TRUE);
    DBCheck checkNotVisible1 = checkboxManager.createCheck(checkbox, groupWaiting, null, Boolean.FALSE);
    DBCheck checkNotVisible2 = checkboxManager.createCheck(checkbox, courseOwner, null, Boolean.FALSE);
    dbInstance.commitAndCloseSession();
    List<BusinessGroup> groups = Collections.singletonList(group);
    List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(entry.getOlatResource(), resSubPath, entry, groups);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(2, loadedChecks.size());
    List<DBCheck> collectedChecks = new ArrayList<>();
    for (AssessmentData loadedCheck : loadedChecks) {
        for (DBCheck loaded : loadedCheck.getChecks()) {
            collectedChecks.add(loaded);
        }
    }
    Assert.assertEquals(2, collectedChecks.size());
    Assert.assertTrue(collectedChecks.contains(checkGroup));
    Assert.assertTrue(collectedChecks.contains(checkCourse));
    Assert.assertFalse(collectedChecks.contains(checkNotVisible1));
    Assert.assertFalse(collectedChecks.contains(checkNotVisible2));
}
Also used : AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) DBCheck(org.olat.course.nodes.cl.model.DBCheck) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 8 with AssessmentData

use of org.olat.course.nodes.cl.model.AssessmentData in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadAssessmentDatas_inGroupAndCourse.

@Test
public void loadAssessmentDatas_inGroupAndCourse() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity groupParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("check-20");
    BusinessGroup group = businessGroupDao.createAndPersist(null, "gcheck", "gcheck-desc", 0, 10, true, true, false, false, false);
    businessGroupRelationDao.addRole(groupParticipant, group, GroupRoles.participant.name());
    Identity courseParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("check-21");
    repositoryEntryRelationDao.addRole(courseParticipant, entry, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // add some noise
    Identity courseOwner = JunitTestHelper.createAndPersistIdentityAsRndUser("check-22");
    repositoryEntryRelationDao.addRole(courseOwner, entry, GroupRoles.owner.name());
    Identity groupWaiting = JunitTestHelper.createAndPersistIdentityAsRndUser("check-23");
    businessGroupRelationDao.addRole(groupWaiting, group, GroupRoles.waiting.name());
    dbInstance.commitAndCloseSession();
    String checkboxId = UUID.randomUUID().toString();
    String resSubPath = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, entry.getOlatResource(), resSubPath);
    DBCheck checkGroup = checkboxManager.createCheck(checkbox, groupParticipant, null, Boolean.TRUE);
    DBCheck checkCourse = checkboxManager.createCheck(checkbox, courseParticipant, null, Boolean.TRUE);
    DBCheck checkNotVisible1 = checkboxManager.createCheck(checkbox, groupWaiting, null, Boolean.FALSE);
    DBCheck checkNotVisible2 = checkboxManager.createCheck(checkbox, courseOwner, null, Boolean.FALSE);
    dbInstance.commitAndCloseSession();
    List<BusinessGroup> groups = Collections.singletonList(group);
    List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(entry.getOlatResource(), resSubPath, entry, groups);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(2, loadedChecks.size());
    List<DBCheck> collectedChecks = new ArrayList<>();
    for (AssessmentData loadedCheck : loadedChecks) {
        for (DBCheck loaded : loadedCheck.getChecks()) {
            collectedChecks.add(loaded);
        }
    }
    Assert.assertEquals(2, collectedChecks.size());
    Assert.assertTrue(collectedChecks.contains(checkGroup));
    Assert.assertTrue(collectedChecks.contains(checkCourse));
    Assert.assertFalse(collectedChecks.contains(checkNotVisible1));
    Assert.assertFalse(collectedChecks.contains(checkNotVisible2));
}
Also used : AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) DBCheck(org.olat.course.nodes.cl.model.DBCheck) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 9 with AssessmentData

use of org.olat.course.nodes.cl.model.AssessmentData in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadAssessmentDatas_inGroup.

@Test
public void loadAssessmentDatas_inGroup() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-19");
    BusinessGroup group = businessGroupDao.createAndPersist(null, "gcheck", "gcheck-desc", 0, 10, true, true, false, false, false);
    businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    String checkboxId = UUID.randomUUID().toString();
    String resSubPath = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, entry.getOlatResource(), resSubPath);
    DBCheck check = checkboxManager.createCheck(checkbox, id, null, Boolean.TRUE);
    dbInstance.commitAndCloseSession();
    List<BusinessGroup> groups = Collections.singletonList(group);
    List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(entry.getOlatResource(), resSubPath, null, groups);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(1, loadedChecks.size());
    AssessmentData data = loadedChecks.get(0);
    Assert.assertNotNull(data);
    Assert.assertNotNull(data.getChecks());
    Assert.assertEquals(1, data.getChecks().size());
    Assert.assertEquals(check, data.getChecks().get(0));
    Assert.assertEquals(id, data.getIdentity());
}
Also used : AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) DBCheck(org.olat.course.nodes.cl.model.DBCheck) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 10 with AssessmentData

use of org.olat.course.nodes.cl.model.AssessmentData in project OpenOLAT by OpenOLAT.

the class CheckboxManagerTest method loadAssessmentDatas_inCourse.

@Test
public void loadAssessmentDatas_inCourse() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-18");
    repositoryEntryRelationDao.addRole(id, entry, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    String checkboxId = UUID.randomUUID().toString();
    String resSubPath = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, entry.getOlatResource(), resSubPath);
    DBCheck check = checkboxManager.createCheck(checkbox, id, null, Boolean.TRUE);
    dbInstance.commitAndCloseSession();
    // load and check the check
    List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(entry.getOlatResource(), resSubPath, entry, null);
    Assert.assertNotNull(loadedChecks);
    Assert.assertEquals(1, loadedChecks.size());
    AssessmentData data = loadedChecks.get(0);
    Assert.assertNotNull(data);
    Assert.assertNotNull(data.getChecks());
    Assert.assertEquals(1, data.getChecks().size());
    Assert.assertEquals(check, data.getChecks().get(0));
    Assert.assertEquals(id, data.getIdentity());
}
Also used : AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) DBCheck(org.olat.course.nodes.cl.model.DBCheck) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Aggregations

AssessmentData (org.olat.course.nodes.cl.model.AssessmentData)20 Identity (org.olat.core.id.Identity)14 DBCheck (org.olat.course.nodes.cl.model.DBCheck)14 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Test (org.junit.Test)8 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)8 BusinessGroup (org.olat.group.BusinessGroup)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 IOException (java.io.IOException)4 OutputStream (java.io.OutputStream)4 ZipEntry (java.util.zip.ZipEntry)4 ZipOutputStream (java.util.zip.ZipOutputStream)4 ShieldOutputStream (org.olat.core.util.io.ShieldOutputStream)4 Checkbox (org.olat.course.nodes.cl.model.Checkbox)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)4 Collections (java.util.Collections)2 List (java.util.List)2 Locale (java.util.Locale)2 Map (java.util.Map)2