Search in sources :

Example 1 with QTIStatisticResultSet

use of org.olat.ims.qti.statistics.model.QTIStatisticResultSet in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerTest method testLastQTIResultsSetQuery.

/**
 * Test retrieve the last modified result set for every assessed users
 */
@Test
public void testLastQTIResultsSetQuery() {
    RepositoryEntry re = createRepository();
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-3");
    dbInstance.commit();
    long assessmentId = 835l;
    String resSubPath = "1234";
    // 3 try for id1
    QTIResultSet set1_1 = createSet(2.0f, assessmentId, id1, re, resSubPath, modDate(3, 8, 8), modDate(3, 8, 12));
    QTIResultSet set1_3 = createSet(6.0f, assessmentId, id1, re, resSubPath, modDate(3, 14, 7), modDate(3, 14, 38));
    QTIResultSet set1_2 = createSet(4.0f, assessmentId, id1, re, resSubPath, modDate(3, 10, 34), modDate(3, 10, 45));
    // 2 try for id2
    QTIResultSet set2_1 = createSet(6.0f, assessmentId, id2, re, resSubPath, modDate(3, 9, 21), modDate(3, 9, 45));
    QTIResultSet set2_2 = createSet(5.0f, assessmentId, id2, re, resSubPath, modDate(3, 12, 45), modDate(3, 12, 55));
    // 1 try for id1
    QTIResultSet set3_1 = createSet(1.0f, assessmentId, id3, re, resSubPath, modDate(3, 12, 1), modDate(3, 12, 12));
    dbInstance.commit();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(re.getOlatResource().getResourceableId(), resSubPath);
    List<QTIStatisticResultSet> sets = qtiStatisticsManager.getAllResultSets(searchParams);
    Assert.assertNotNull(sets);
    Assert.assertEquals(3, sets.size());
    List<Long> setKeys = PersistenceHelper.toKeys(sets);
    Assert.assertTrue(setKeys.contains(set1_3.getKey()));
    Assert.assertTrue(setKeys.contains(set2_2.getKey()));
    Assert.assertTrue(setKeys.contains(set3_1.getKey()));
    Assert.assertFalse(setKeys.contains(set1_1.getKey()));
    Assert.assertFalse(setKeys.contains(set1_2.getKey()));
    Assert.assertFalse(setKeys.contains(set2_1.getKey()));
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIStatisticResultSet(org.olat.ims.qti.statistics.model.QTIStatisticResultSet) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 2 with QTIStatisticResultSet

use of org.olat.ims.qti.statistics.model.QTIStatisticResultSet in project openolat by klemens.

the class QTIStatisticsManagerTest method testLastQTIResultsSetQuery.

/**
 * Test retrieve the last modified result set for every assessed users
 */
@Test
public void testLastQTIResultsSetQuery() {
    RepositoryEntry re = createRepository();
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-3");
    dbInstance.commit();
    long assessmentId = 835l;
    String resSubPath = "1234";
    // 3 try for id1
    QTIResultSet set1_1 = createSet(2.0f, assessmentId, id1, re, resSubPath, modDate(3, 8, 8), modDate(3, 8, 12));
    QTIResultSet set1_3 = createSet(6.0f, assessmentId, id1, re, resSubPath, modDate(3, 14, 7), modDate(3, 14, 38));
    QTIResultSet set1_2 = createSet(4.0f, assessmentId, id1, re, resSubPath, modDate(3, 10, 34), modDate(3, 10, 45));
    // 2 try for id2
    QTIResultSet set2_1 = createSet(6.0f, assessmentId, id2, re, resSubPath, modDate(3, 9, 21), modDate(3, 9, 45));
    QTIResultSet set2_2 = createSet(5.0f, assessmentId, id2, re, resSubPath, modDate(3, 12, 45), modDate(3, 12, 55));
    // 1 try for id1
    QTIResultSet set3_1 = createSet(1.0f, assessmentId, id3, re, resSubPath, modDate(3, 12, 1), modDate(3, 12, 12));
    dbInstance.commit();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(re.getOlatResource().getResourceableId(), resSubPath);
    List<QTIStatisticResultSet> sets = qtiStatisticsManager.getAllResultSets(searchParams);
    Assert.assertNotNull(sets);
    Assert.assertEquals(3, sets.size());
    List<Long> setKeys = PersistenceHelper.toKeys(sets);
    Assert.assertTrue(setKeys.contains(set1_3.getKey()));
    Assert.assertTrue(setKeys.contains(set2_2.getKey()));
    Assert.assertTrue(setKeys.contains(set3_1.getKey()));
    Assert.assertFalse(setKeys.contains(set1_1.getKey()));
    Assert.assertFalse(setKeys.contains(set1_2.getKey()));
    Assert.assertFalse(setKeys.contains(set2_1.getKey()));
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIStatisticResultSet(org.olat.ims.qti.statistics.model.QTIStatisticResultSet) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Identity (org.olat.core.id.Identity)2 QTIResultSet (org.olat.ims.qti.QTIResultSet)2 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)2 QTIStatisticResultSet (org.olat.ims.qti.statistics.model.QTIStatisticResultSet)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2