use of org.olat.course.nodes.cl.model.DBCheckbox 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());
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.
the class CheckboxManagerTest method loadCheckBox.
@Test
public void loadCheckBox() {
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-2", 2346l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId = UUID.randomUUID().toString();
DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
dbInstance.commit();
// load it
List<DBCheckbox> checkboxList = checkboxManager.loadCheckbox(ores, resSubPath);
Assert.assertNotNull(checkboxList);
Assert.assertEquals(1, checkboxList.size());
DBCheckbox dbCheckbox = checkboxList.get(0);
Assert.assertEquals(checkbox, dbCheckbox);
// paranoia check
Assert.assertNotNull(dbCheckbox.getCreationDate());
Assert.assertEquals(checkboxId, dbCheckbox.getCheckboxId());
Assert.assertEquals(resSubPath, dbCheckbox.getResSubPath());
Assert.assertEquals("checkbox-2", dbCheckbox.getResName());
Assert.assertEquals(new Long(2346l), dbCheckbox.getResId());
Assert.assertEquals(resSubPath, dbCheckbox.getResSubPath());
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.
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 klemens.
the class CheckboxManagerTest method loadCheck.
@Test
public void loadCheck() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-2");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-6", 2350l);
String resSubPath = UUID.randomUUID().toString();
String checkboxId = UUID.randomUUID().toString();
DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
// create a check
DBCheck check = checkboxManager.createCheck(checkbox, id, new Float(1.0), Boolean.TRUE);
dbInstance.commitAndCloseSession();
// load the check
DBCheck loadedCheck = checkboxManager.loadCheck(checkbox, id);
// paranoia check
Assert.assertNotNull(loadedCheck);
Assert.assertEquals(check, loadedCheck);
Assert.assertEquals(id, loadedCheck.getIdentity());
Assert.assertEquals(checkbox, loadedCheck.getCheckbox());
Assert.assertEquals(Boolean.TRUE, loadedCheck.getChecked());
Assert.assertEquals(1.0f, loadedCheck.getScore().floatValue(), 0.00001);
}
use of org.olat.course.nodes.cl.model.DBCheckbox 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));
}
Aggregations