Search in sources :

Example 1 with AssessmentTestSessionStatistics

use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.

the class IQIdentityListCourseNodeController method doConfirmExtraTime.

private void doConfirmExtraTime(UserRequest ureq) {
    List<IdentityRef> identities = getSelectedIdentities();
    if (identities == null || identities.isEmpty()) {
        showWarning("warning.users.extra.time");
        return;
    }
    List<AssessmentTestSession> testSessions = new ArrayList<>(identities.size());
    for (IdentityRef identity : identities) {
        List<AssessmentTestSessionStatistics> sessionsStatistics = qtiService.getAssessmentTestSessionsStatistics(getCourseRepositoryEntry(), courseNode.getIdent(), identity);
        if (!sessionsStatistics.isEmpty()) {
            if (sessionsStatistics.size() > 1) {
                Collections.sort(sessionsStatistics, new AssessmentTestSessionDetailsComparator());
            }
            AssessmentTestSession lastSession = sessionsStatistics.get(0).getTestSession();
            if (lastSession != null && lastSession.getFinishTime() == null) {
                testSessions.add(lastSession);
            }
        }
    }
    if (testSessions == null || testSessions.isEmpty()) {
        showWarning("warning.users.extra.time");
        return;
    }
    extraTimeCtrl = new ConfirmExtraTimeController(ureq, getWindowControl(), getCourseRepositoryEntry(), testSessions);
    listenTo(extraTimeCtrl);
    String title = translate("extra.time");
    cmc = new CloseableModalController(getWindowControl(), null, extraTimeCtrl.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionDetailsComparator(org.olat.course.nodes.iq.QTI21IdentityListCourseNodeToolsController.AssessmentTestSessionDetailsComparator) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Example 2 with AssessmentTestSessionStatistics

use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAO method getUserTestSessionsStatistics.

public List<AssessmentTestSessionStatistics> getUserTestSessionsStatistics(RepositoryEntryRef courseEntry, String courseSubIdent, IdentityRef identity) {
    StringBuilder sb = new StringBuilder();
    sb.append("select session,").append(" (select count(itemSession.key) from qtiassessmentitemsession itemSession").append("   where itemSession.assessmentTestSession.key=session.key and itemSession.manualScore is not null").append(" ) as correctItems").append(" from qtiassessmenttestsession session").append(" left join fetch session.testEntry testEntry").append(" left join fetch testEntry.olatResource testResource").append("  where session.repositoryEntry.key=:repositoryEntryKey and session.identity.key=:identityKey and ");
    if (StringHelper.containsNonWhitespace(courseSubIdent)) {
        sb.append("session.subIdent=:subIdent");
    } else {
        sb.append("session.subIdent is null");
    }
    sb.append(" order by session.creationDate desc");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("repositoryEntryKey", courseEntry.getKey()).setParameter("identityKey", identity.getKey());
    if (StringHelper.containsNonWhitespace(courseSubIdent)) {
        query.setParameter("subIdent", courseSubIdent);
    }
    List<Object[]> raws = query.getResultList();
    List<AssessmentTestSessionStatistics> stats = new ArrayList<>(raws.size());
    for (Object[] raw : raws) {
        AssessmentTestSession testSession = (AssessmentTestSession) raw[0];
        int numOfCorrectedItems = (raw[1] == null ? 0 : ((Number) raw[1]).intValue());
        stats.add(new AssessmentTestSessionStatistics(testSession, numOfCorrectedItems));
    }
    return stats;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) ArrayList(java.util.ArrayList)

Example 3 with AssessmentTestSessionStatistics

use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project openolat by klemens.

the class AssessmentTestSessionDAO method getUserTestSessionsStatistics.

public List<AssessmentTestSessionStatistics> getUserTestSessionsStatistics(RepositoryEntryRef courseEntry, String courseSubIdent, IdentityRef identity) {
    StringBuilder sb = new StringBuilder();
    sb.append("select session,").append(" (select count(itemSession.key) from qtiassessmentitemsession itemSession").append("   where itemSession.assessmentTestSession.key=session.key and itemSession.manualScore is not null").append(" ) as correctItems").append(" from qtiassessmenttestsession session").append(" left join fetch session.testEntry testEntry").append(" left join fetch testEntry.olatResource testResource").append("  where session.repositoryEntry.key=:repositoryEntryKey and session.identity.key=:identityKey and ");
    if (StringHelper.containsNonWhitespace(courseSubIdent)) {
        sb.append("session.subIdent=:subIdent");
    } else {
        sb.append("session.subIdent is null");
    }
    sb.append(" order by session.creationDate desc");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("repositoryEntryKey", courseEntry.getKey()).setParameter("identityKey", identity.getKey());
    if (StringHelper.containsNonWhitespace(courseSubIdent)) {
        query.setParameter("subIdent", courseSubIdent);
    }
    List<Object[]> raws = query.getResultList();
    List<AssessmentTestSessionStatistics> stats = new ArrayList<>(raws.size());
    for (Object[] raw : raws) {
        AssessmentTestSession testSession = (AssessmentTestSession) raw[0];
        int numOfCorrectedItems = (raw[1] == null ? 0 : ((Number) raw[1]).intValue());
        stats.add(new AssessmentTestSessionStatistics(testSession, numOfCorrectedItems));
    }
    return stats;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) ArrayList(java.util.ArrayList)

Example 4 with AssessmentTestSessionStatistics

use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project openolat by klemens.

the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.

@Test
public void getUserTestSessionsStatistics() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession);
    dbInstance.commit();
    for (int i = 0; i < 4; i++) {
        ParentPartItemRefs parentParts = new ParentPartItemRefs();
        String sectionIdentifier = UUID.randomUUID().toString();
        parentParts.setSectionIdentifier(sectionIdentifier);
        String testPartIdentifier = UUID.randomUUID().toString();
        parentParts.setTestPartIdentifier(testPartIdentifier);
        AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
        Assert.assertNotNull(itemSession);
        dbInstance.commit();
        if (i % 2 == 0) {
            itemSession.setManualScore(new BigDecimal(3));
            itemSessionDao.merge(itemSession);
        }
    }
    dbInstance.commitAndCloseSession();
    List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
    Assert.assertNotNull(sessionsStatistics);
    Assert.assertEquals(1, sessionsStatistics.size());
    AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
    Assert.assertNotNull(sessionStatistics.getTestSession());
    Assert.assertEquals(testSession, sessionStatistics.getTestSession());
    Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with AssessmentTestSessionStatistics

use of org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.

@Test
public void getUserTestSessionsStatistics() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession);
    dbInstance.commit();
    for (int i = 0; i < 4; i++) {
        ParentPartItemRefs parentParts = new ParentPartItemRefs();
        String sectionIdentifier = UUID.randomUUID().toString();
        parentParts.setSectionIdentifier(sectionIdentifier);
        String testPartIdentifier = UUID.randomUUID().toString();
        parentParts.setTestPartIdentifier(testPartIdentifier);
        AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
        Assert.assertNotNull(itemSession);
        dbInstance.commit();
        if (i % 2 == 0) {
            itemSession.setManualScore(new BigDecimal(3));
            itemSessionDao.merge(itemSession);
        }
    }
    dbInstance.commitAndCloseSession();
    List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
    Assert.assertNotNull(sessionsStatistics);
    Assert.assertEquals(1, sessionsStatistics.size());
    AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
    Assert.assertNotNull(sessionStatistics.getTestSession());
    Assert.assertEquals(testSession, sessionStatistics.getTestSession());
    Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)8 AssessmentTestSessionStatistics (org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics)8 ArrayList (java.util.ArrayList)6 BigDecimal (java.math.BigDecimal)2 Test (org.junit.Test)2 IdentityRef (org.olat.basesecurity.IdentityRef)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Identity (org.olat.core.id.Identity)2 AssessmentTestSessionDetailsComparator (org.olat.course.nodes.iq.QTI21IdentityListCourseNodeToolsController.AssessmentTestSessionDetailsComparator)2 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)2 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)2 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)2 TestPlan (uk.ac.ed.ph.jqtiplus.state.TestPlan)2 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)2 TestNodeType (uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType)2 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)2 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)2