use of org.olat.course.nodes.cl.model.DBCheckbox 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));
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method calculateResource.
@Test
public void calculateResource() {
// create checkbox to delete
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-13");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-14");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-15");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-11", 2356l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId1 = UUID.randomUUID().toString();
DBCheckbox checkbox1 = checkboxManager.createDBCheckbox(checkboxId1, ores, resSubPath);
String checkboxId2 = UUID.randomUUID().toString();
DBCheckbox checkbox2 = checkboxManager.createDBCheckbox(checkboxId2, ores, resSubPath);
String checkboxId3 = UUID.randomUUID().toString();
DBCheckbox checkbox3 = checkboxManager.createDBCheckbox(checkboxId3, ores, resSubPath);
// create a check
checkboxManager.createCheck(checkbox1, id1, 3.0f, Boolean.TRUE);
checkboxManager.createCheck(checkbox2, id1, 2.0f, Boolean.TRUE);
checkboxManager.createCheck(checkbox1, id2, 4.0f, Boolean.TRUE);
checkboxManager.createCheck(checkbox3, id2, 5.5f, Boolean.TRUE);
checkboxManager.createCheck(checkbox3, id3, 1.0f, Boolean.FALSE);
dbInstance.commitAndCloseSession();
// create a reference which must stay
OLATResourceable oresRef = OresHelper.createOLATResourceableInstance("checkbox-12", 2357l);
String resSubPathRef = UUID.randomUUID().toString();
String checkboxIdRef = UUID.randomUUID().toString();
DBCheckbox checkboxRef = checkboxManager.createDBCheckbox(checkboxIdRef, oresRef, resSubPathRef);
checkboxManager.createCheck(checkboxRef, id1, 3.0f, Boolean.TRUE);
checkboxManager.createCheck(checkboxRef, id3, 2.0f, Boolean.TRUE);
dbInstance.commitAndCloseSession();
// delete all checks and checklist of the resource
checkboxManager.deleteCheckbox(ores, resSubPath);
dbInstance.commitAndCloseSession();
// verify id1
List<DBCheck> checksId1 = checkboxManager.loadCheck(id1, ores, resSubPath);
Assert.assertNotNull(checksId1);
Assert.assertEquals(0, checksId1.size());
List<DBCheck> checksId1Ref = checkboxManager.loadCheck(id1, oresRef, resSubPathRef);
Assert.assertNotNull(checksId1Ref);
Assert.assertEquals(1, checksId1Ref.size());
// verify id2
List<DBCheck> checksId2 = checkboxManager.loadCheck(id2, ores, resSubPath);
Assert.assertNotNull(checksId2);
Assert.assertEquals(0, checksId2.size());
List<DBCheck> checksId2Ref = checkboxManager.loadCheck(id2, oresRef, resSubPathRef);
Assert.assertNotNull(checksId2Ref);
Assert.assertEquals(0, checksId2Ref.size());
// verify id3
List<DBCheck> checksId3 = checkboxManager.loadCheck(id3, ores, resSubPath);
Assert.assertNotNull(checksId3);
Assert.assertEquals(0, checksId3.size());
List<DBCheck> checksId3Ref = checkboxManager.loadCheck(id3, oresRef, resSubPathRef);
Assert.assertNotNull(checksId3Ref);
Assert.assertEquals(1, checksId3Ref.size());
}
use of org.olat.course.nodes.cl.model.DBCheckbox 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());
}
use of org.olat.course.nodes.cl.model.DBCheckbox 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());
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method loadAssessmentDatas.
@Test
public void loadAssessmentDatas() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-5");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-6");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-9", 2353l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId1 = UUID.randomUUID().toString();
DBCheckbox checkbox1 = checkboxManager.createDBCheckbox(checkboxId1, ores, resSubPath);
String checkboxId2 = UUID.randomUUID().toString();
DBCheckbox checkbox2 = checkboxManager.createDBCheckbox(checkboxId2, ores, resSubPath);
// create a check
DBCheck check1_1 = checkboxManager.createCheck(checkbox1, id1, null, Boolean.TRUE);
DBCheck check1_2 = checkboxManager.createCheck(checkbox2, id1, null, Boolean.TRUE);
DBCheck check2_1 = checkboxManager.createCheck(checkbox1, id2, null, Boolean.TRUE);
DBCheck check3_1 = checkboxManager.createCheck(checkbox1, id3, null, Boolean.TRUE);
DBCheck check3_2 = checkboxManager.createCheck(checkbox2, id3, null, Boolean.FALSE);
dbInstance.commitAndCloseSession();
// load the check
List<AssessmentData> loadedChecks = checkboxManager.getAssessmentDatas(ores, resSubPath, null, null);
Assert.assertNotNull(loadedChecks);
Assert.assertEquals(3, loadedChecks.size());
List<DBCheck> collectedChecks = new ArrayList<>();
for (AssessmentData loadedCheck : loadedChecks) {
for (DBCheck loaded : loadedCheck.getChecks()) {
collectedChecks.add(loaded);
}
}
Assert.assertEquals(5, collectedChecks.size());
Assert.assertTrue(collectedChecks.contains(check1_1));
Assert.assertTrue(collectedChecks.contains(check1_2));
Assert.assertTrue(collectedChecks.contains(check2_1));
Assert.assertTrue(collectedChecks.contains(check3_1));
Assert.assertTrue(collectedChecks.contains(check3_2));
}
Aggregations