Search in sources :

Example 36 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox 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 37 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.

the class CheckboxManagerTest method syncCheckBox.

@Test
public void syncCheckBox() {
    // build a list of checkbox to sync
    CheckboxList list = new CheckboxList();
    Checkbox checkbox1 = new Checkbox();
    checkbox1.setCheckboxId(UUID.randomUUID().toString());
    checkbox1.setTitle("Sync me");
    list.add(checkbox1);
    Checkbox checkbox2 = new Checkbox();
    checkbox2.setCheckboxId(UUID.randomUUID().toString());
    checkbox2.setTitle("Sync me too");
    list.add(checkbox2);
    // sync them to the database
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-4", 2348l);
    String resSubPath = UUID.randomUUID().toString();
    checkboxManager.syncCheckbox(list, ores, resSubPath);
    dbInstance.commitAndCloseSession();
    // load them
    List<DBCheckbox> dbCheckboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(dbCheckboxList);
    Assert.assertEquals(2, dbCheckboxList.size());
    for (DBCheckbox dbCheckbox : dbCheckboxList) {
        Assert.assertNotNull(dbCheckbox);
        Assert.assertNotNull(dbCheckbox.getKey());
        Assert.assertNotNull(dbCheckbox.getCheckboxId());
        Assert.assertTrue(dbCheckbox.getCheckboxId().equals(checkbox1.getCheckboxId()) || dbCheckbox.getCheckboxId().equals(checkbox2.getCheckboxId()));
    }
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) OLATResourceable(org.olat.core.id.OLATResourceable) Checkbox(org.olat.course.nodes.cl.model.Checkbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 38 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.

the class CheckboxManagerTest method createCheckBox.

@Test
public void createCheckBox() {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-1", 2345l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    dbInstance.commit();
    Assert.assertNotNull(checkbox);
    Assert.assertNotNull(checkbox.getKey());
    Assert.assertNotNull(checkbox.getCreationDate());
    Assert.assertEquals(checkboxId, checkbox.getCheckboxId());
    Assert.assertEquals("checkbox-1", checkbox.getResName());
    Assert.assertEquals(new Long(2345l), checkbox.getResId());
    Assert.assertEquals(resSubPath, checkbox.getResSubPath());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 39 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox in project openolat by klemens.

the class CheckboxManagerTest method removeCheckBox.

@Test
public void removeCheckBox() {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("checkbox-3", 2347l);
    String resSubPath = UUID.randomUUID().toString();
    String checkboxId = UUID.randomUUID().toString();
    DBCheckbox checkbox = checkboxManager.createDBCheckbox(checkboxId, ores, resSubPath);
    dbInstance.commit();
    Assert.assertNotNull(checkbox);
    // load it
    List<DBCheckbox> checkboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(checkboxList);
    Assert.assertEquals(1, checkboxList.size());
    dbInstance.commitAndCloseSession();
    // remove
    checkboxManager.removeCheckbox(checkboxList.get(0));
    dbInstance.commitAndCloseSession();
    // reload
    List<DBCheckbox> deletedCheckboxList = checkboxManager.loadCheckbox(ores, resSubPath);
    Assert.assertNotNull(checkboxList);
    Assert.assertEquals(0, deletedCheckboxList.size());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) DBCheckbox(org.olat.course.nodes.cl.model.DBCheckbox) Test(org.junit.Test)

Example 40 with DBCheckbox

use of org.olat.course.nodes.cl.model.DBCheckbox 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

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