Search in sources :

Example 26 with DBCheck

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;
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) Date(java.util.Date)

Example 27 with DBCheck

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);
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 28 with DBCheck

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);
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 29 with DBCheck

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());
}
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)

Example 30 with DBCheck

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));
}
Also used : DBCheck(org.olat.course.nodes.cl.model.DBCheck) OLATResourceable(org.olat.core.id.OLATResourceable) Identity(org.olat.core.id.Identity) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Aggregations

DBCheck (org.olat.course.nodes.cl.model.DBCheck)34 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)26 Identity (org.olat.core.id.Identity)22 Test (org.junit.Test)18 AssessmentData (org.olat.course.nodes.cl.model.AssessmentData)14 HashMap (java.util.HashMap)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 ArrayList (java.util.ArrayList)10 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 BusinessGroup (org.olat.group.BusinessGroup)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)3 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Locale (java.util.Locale)2 Map (java.util.Map)2