use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.
the class CheckboxManagerTest method countChecks_resource.
@Test
public void countChecks_resource() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-17");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-12", 2354l);
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);
String checkboxId4 = UUID.randomUUID().toString();
checkboxManager.createDBCheckbox(checkboxId4, ores, resSubPath);
// create a check
checkboxManager.createCheck(checkbox1, id1, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox2, id1, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox1, id2, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox3, id2, null, Boolean.TRUE);
dbInstance.commitAndCloseSession();
// count the checks
int checked = checkboxManager.countChecks(ores, resSubPath);
Assert.assertEquals(4, checked);
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method countChecks_resource.
@Test
public void countChecks_resource() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-17");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-12", 2354l);
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);
String checkboxId4 = UUID.randomUUID().toString();
checkboxManager.createDBCheckbox(checkboxId4, ores, resSubPath);
// create a check
checkboxManager.createCheck(checkbox1, id1, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox2, id1, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox1, id2, null, Boolean.TRUE);
checkboxManager.createCheck(checkbox3, id2, null, Boolean.TRUE);
dbInstance.commitAndCloseSession();
// count the checks
int checked = checkboxManager.countChecks(ores, resSubPath);
Assert.assertEquals(4, checked);
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method createCheck.
@Test
public void createCheck() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-1");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-5", 2349l);
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();
// paranoia check
Assert.assertNotNull(check);
Assert.assertNotNull(check.getKey());
Assert.assertNotNull(check.getCreationDate());
Assert.assertNotNull(check.getLastModified());
Assert.assertEquals(id, check.getIdentity());
Assert.assertEquals(checkbox, check.getCheckbox());
Assert.assertEquals(Boolean.TRUE, check.getChecked());
Assert.assertEquals(1.0f, check.getScore().floatValue(), 0.00001);
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method calculateScore.
@Test
public void calculateScore() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-9");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-10");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-11");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-10", 2355l);
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);
String checkboxId4 = UUID.randomUUID().toString();
DBCheckbox checkbox4 = checkboxManager.createDBCheckbox(checkboxId4, 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(checkbox4, id2, 1.0f, Boolean.FALSE);
dbInstance.commitAndCloseSession();
// count the checks
float score1 = checkboxManager.calculateScore(id1, ores, resSubPath);
Assert.assertEquals(5.0f, score1, 0.0001);
float score2 = checkboxManager.calculateScore(id2, ores, resSubPath);
Assert.assertEquals(9.5f, score2, 0.0001);
float score3 = checkboxManager.calculateScore(id3, ores, resSubPath);
Assert.assertEquals(0.0f, score3, 0.0001);
}
use of org.olat.course.nodes.cl.model.DBCheckbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerTest method testCheck.
@Test
public void testCheck() {
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);
dbInstance.commitAndCloseSession();
// check
checkboxManager.check(checkbox, id, new Float(1.515), Boolean.FALSE);
dbInstance.commitAndCloseSession();
// load the check
DBCheck loadedCheck = checkboxManager.loadCheck(checkbox, id);
// paranoia check
Assert.assertNotNull(loadedCheck);
Assert.assertEquals(id, loadedCheck.getIdentity());
Assert.assertEquals(checkbox, loadedCheck.getCheckbox());
Assert.assertEquals(Boolean.FALSE, loadedCheck.getChecked());
Assert.assertEquals(1.515f, loadedCheck.getScore().floatValue(), 0.00001);
}
Aggregations