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