use of org.olat.course.nodes.cl.model.DBCheck in project OpenOLAT by OpenOLAT.
the class CheckboxManagerImpl method createCheck.
protected DBCheck createCheck(DBCheckbox checkbox, Identity owner, Float score, Boolean checked) {
DBCheck check = new DBCheck();
check.setCreationDate(new Date());
check.setLastModified(new Date());
check.setIdentity(owner);
check.setCheckbox(checkbox);
check.setChecked(checked);
check.setScore(score);
dbInstance.getCurrentEntityManager().persist(check);
return check;
}
use of org.olat.course.nodes.cl.model.DBCheck in project openolat by klemens.
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.DBCheck in project openolat by klemens.
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);
}
use of org.olat.course.nodes.cl.model.DBCheck in project openolat by klemens.
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.DBCheck in project openolat by klemens.
the class CheckboxManagerTest method loadChecks_byOres.
@Test
public void loadChecks_byOres() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-8", 2352l);
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, null, Boolean.TRUE);
dbInstance.commitAndCloseSession();
// load the check
List<DBCheck> loadedChecks = checkboxManager.loadCheck(id, ores, resSubPath);
Assert.assertNotNull(loadedChecks);
Assert.assertEquals(1, loadedChecks.size());
Assert.assertEquals(check, loadedChecks.get(0));
}
Aggregations