Search in sources :

Example 16 with DBCheckbox

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);
}
Also used : 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 17 with DBCheckbox

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);
}
Also used : 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 18 with DBCheckbox

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);
}
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 19 with DBCheckbox

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);
}
Also used : 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 20 with DBCheckbox

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

DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)46 Test (org.junit.Test)34 OLATResourceable (org.olat.core.id.OLATResourceable)28 Identity (org.olat.core.id.Identity)26 DBCheck (org.olat.course.nodes.cl.model.DBCheck)22 AssessmentData (org.olat.course.nodes.cl.model.AssessmentData)8 Checkbox (org.olat.course.nodes.cl.model.Checkbox)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 BusinessGroup (org.olat.group.BusinessGroup)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 EntityManager (javax.persistence.EntityManager)2 IdentityImpl (org.olat.basesecurity.IdentityImpl)2 AssessmentBatch (org.olat.course.nodes.cl.model.AssessmentBatch)2 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)2