Search in sources :

Example 16 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class HighScoreManagerTest method highscoreTest.

@Test
public void highscoreTest() {
    List<AssessmentEntry> assessEntries = new ArrayList<>();
    int[] scores = { 1, 23, 10 };
    Identity assessedIdentity = null;
    // Create entries, add to List
    for (int i = 0; i < scores.length; i++) {
        assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-2");
        RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
        String subIdent = UUID.randomUUID().toString();
        AssessmentEntry nodeAssessment = courseNodeAssessmentDao.createAssessmentEntry(assessedIdentity, subIdent, entry, subIdent, entry);
        nodeAssessment.setScore(new BigDecimal(scores[i]));
        dbInstance.commitAndCloseSession();
        AssessmentEntry reloadedAssessment = courseNodeAssessmentDao.loadAssessmentEntryById(nodeAssessment.getKey());
        assessEntries.add(reloadedAssessment);
    }
    List<Integer> ownIdIndices = new ArrayList<>();
    List<HighScoreTableEntry> allMembers = new ArrayList<>();
    List<HighScoreTableEntry> ownIdMembers = new ArrayList<>();
    List<List<HighScoreTableEntry>> allPodium = new ArrayList<>();
    allPodium.add(new ArrayList<>());
    allPodium.add(new ArrayList<>());
    allPodium.add(new ArrayList<>());
    double[] allScores = highScoreManager.sortRankByScore(assessEntries, allMembers, ownIdMembers, allPodium, ownIdIndices, 5, JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-2")).getScores();
    assertNotNull(allScores);
    assertEquals(allMembers.size(), scores.length);
    assertTrue(allScores[0] > 20);
    assertTrue(allScores[2] < 10);
    double[] histogramData = highScoreManager.processHistogramData(allScores, 0F, 30F).getModifiedScores();
    assertNotNull(histogramData);
    long classwidth = highScoreManager.processHistogramData(allScores, 0F, 30F).getClasswidth();
    assertEquals(2L, classwidth);
}
Also used : ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) HighScoreTableEntry(org.olat.course.highscore.ui.HighScoreTableEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 17 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentEntryDAOTest method createAssessmentEntry.

@Test
public void createAssessmentEntry() {
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-1");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = "39485349759";
    AssessmentEntry nodeAssessment = assessmentEntryDao.createAssessmentEntry(assessedIdentity, null, entry, subIdent, entry);
    Assert.assertNotNull(nodeAssessment);
    dbInstance.commitAndCloseSession();
    // check values
    Assert.assertNotNull(nodeAssessment.getKey());
    Assert.assertNotNull(nodeAssessment.getCreationDate());
    Assert.assertNotNull(nodeAssessment.getLastModified());
    Assert.assertEquals(assessedIdentity, nodeAssessment.getIdentity());
    Assert.assertEquals(entry, nodeAssessment.getRepositoryEntry());
    Assert.assertEquals(subIdent, nodeAssessment.getSubIdent());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 18 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentEntryDAOTest method loadAssessmentEntriesByAssessedIdentity.

@Test
public void loadAssessmentEntriesByAssessedIdentity() {
    Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-13");
    Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-14");
    Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-15");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    AssessmentEntry nodeAssessmentId1 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry);
    AssessmentEntry nodeAssessmentId2 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId3 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, null, entry, 3.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId4 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, refEntry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    dbInstance.commitAndCloseSession();
    // load for identity 1
    List<AssessmentEntry> assessmentEntriesId1 = assessmentEntryDao.loadAssessmentEntriesByAssessedIdentity(assessedIdentity1, entry);
    Assert.assertNotNull(assessmentEntriesId1);
    Assert.assertEquals(1, assessmentEntriesId1.size());
    Assert.assertTrue(assessmentEntriesId1.contains(nodeAssessmentId1));
    Assert.assertFalse(assessmentEntriesId1.contains(nodeAssessmentId2));
    Assert.assertFalse(assessmentEntriesId1.contains(nodeAssessmentId3));
    Assert.assertFalse(assessmentEntriesId1.contains(nodeAssessmentId4));
    // load for identity 2
    List<AssessmentEntry> assessmentEntriesId2 = assessmentEntryDao.loadAssessmentEntriesByAssessedIdentity(assessedIdentity2, entry);
    Assert.assertNotNull(assessmentEntriesId2);
    Assert.assertEquals(2, assessmentEntriesId2.size());
    Assert.assertFalse(assessmentEntriesId2.contains(nodeAssessmentId1));
    Assert.assertTrue(assessmentEntriesId2.contains(nodeAssessmentId2));
    Assert.assertTrue(assessmentEntriesId2.contains(nodeAssessmentId3));
    Assert.assertFalse(assessmentEntriesId2.contains(nodeAssessmentId4));
    // load for identity 3
    List<AssessmentEntry> assessmentEntriesId3 = assessmentEntryDao.loadAssessmentEntriesByAssessedIdentity(assessedIdentity3, entry);
    Assert.assertNotNull(assessmentEntriesId3);
    Assert.assertEquals(0, assessmentEntriesId3.size());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 19 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentEntryDAOTest method createAssessmentEntry_anonymous.

@Test
public void createAssessmentEntry_anonymous() {
    String anonymousIdentifier = UUID.randomUUID().toString();
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = "39485349759";
    AssessmentEntry nodeAssessment = assessmentEntryDao.createAssessmentEntry(null, anonymousIdentifier, entry, subIdent, entry);
    Assert.assertNotNull(nodeAssessment);
    dbInstance.commitAndCloseSession();
    // check values
    Assert.assertNotNull(nodeAssessment.getKey());
    Assert.assertNotNull(nodeAssessment.getCreationDate());
    Assert.assertNotNull(nodeAssessment.getLastModified());
    Assert.assertEquals(anonymousIdentifier, nodeAssessment.getAnonymousIdentifier());
    Assert.assertEquals(entry, nodeAssessment.getRepositoryEntry());
    Assert.assertEquals(subIdent, nodeAssessment.getSubIdent());
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 20 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentEntryDAOTest method loadAssessmentEntryBySubIdentWithStatus.

@Test
public void loadAssessmentEntryBySubIdentWithStatus() {
    Identity assessedIdentity1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-22");
    Identity assessedIdentity2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-23");
    Identity assessedIdentity3 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-24");
    Identity assessedIdentity4 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-25");
    Identity assessedIdentity5 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-node-25");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry refEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    BusinessGroup group = businessGroupDao.createAndPersist(null, "rel-bg-part-1", "rel-bgis-1-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(group, entry);
    businessGroupRelationDao.addRelationToResource(group, refEntry);
    businessGroupRelationDao.addRole(assessedIdentity1, group, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity2, group, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity3, group, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity4, group, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(assessedIdentity5, group, GroupRoles.coach.name());
    AssessmentEntry nodeAssessmentId1 = assessmentEntryDao.createAssessmentEntry(assessedIdentity1, null, entry, subIdent, refEntry);
    AssessmentEntry nodeAssessmentId2 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, subIdent, refEntry, 0.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId3 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, entry, null, entry, 12.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId4 = assessmentEntryDao.createAssessmentEntry(assessedIdentity2, null, refEntry, subIdent, refEntry, 3.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId5 = assessmentEntryDao.createAssessmentEntry(assessedIdentity3, null, entry, subIdent, refEntry, 6.0f, Boolean.TRUE, null, null);
    AssessmentEntry nodeAssessmentId6 = assessmentEntryDao.createAssessmentEntry(assessedIdentity4, null, entry, subIdent, refEntry, 1.0f, Boolean.FALSE, null, null);
    AssessmentEntry nodeAssessmentId7 = assessmentEntryDao.createAssessmentEntry(assessedIdentity5, null, entry, subIdent, refEntry, 10.0f, Boolean.TRUE, null, null);
    dbInstance.commitAndCloseSession();
    // load with our subIdent above
    List<AssessmentEntry> assessmentEntries = assessmentEntryDao.loadAssessmentEntryBySubIdentWithStatus(entry, subIdent, null, true);
    Assert.assertNotNull(assessmentEntries);
    Assert.assertEquals(2, assessmentEntries.size());
    Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId1));
    Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId2));
    Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId3));
    Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId4));
    Assert.assertTrue(assessmentEntries.contains(nodeAssessmentId5));
    Assert.assertTrue(assessmentEntries.contains(nodeAssessmentId6));
    Assert.assertFalse(assessmentEntries.contains(nodeAssessmentId7));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Aggregations

AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)150 Identity (org.olat.core.id.Identity)88 RepositoryEntry (org.olat.repository.RepositoryEntry)70 Test (org.junit.Test)50 ICourse (org.olat.course.ICourse)38 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)32 File (java.io.File)26 Date (java.util.Date)26 HashMap (java.util.HashMap)22 BigDecimal (java.math.BigDecimal)20 ArrayList (java.util.ArrayList)20 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)20 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)16 CourseNode (org.olat.course.nodes.CourseNode)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)12 AssessmentManager (org.olat.course.assessment.AssessmentManager)12 BusinessGroup (org.olat.group.BusinessGroup)12 List (java.util.List)10