Search in sources :

Example 86 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method extraTimeAssessmentTestSession.

@Override
public void extraTimeAssessmentTestSession(AssessmentTestSession session, int extraTime, Identity actor) {
    testSessionDao.extraTime(session, extraTime);
    // commit before event
    dbInstance.commit();
    AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
    candidateAuditLogger.logTestExtend(session, extraTime, actor);
    RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
    OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent)

Example 87 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method deleteAuthorAssessmentTestSession.

@Override
public boolean deleteAuthorAssessmentTestSession(RepositoryEntryRef testEntry) {
    log.audit("Delete author assessment sessions for test: " + testEntry);
    List<AssessmentTestSession> sessions = testSessionDao.getAuthorAssessmentTestSession(testEntry);
    for (AssessmentTestSession session : sessions) {
        File fileStorage = testSessionDao.getSessionStorage(session);
        testSessionDao.deleteTestSession(session);
        FileUtils.deleteDirsAndFiles(fileStorage, true, true);
    }
    // make sure it's flushed on the database
    dbInstance.commit();
    return true;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) File(java.io.File)

Example 88 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method recalculateAssessmentTestSessionScores.

@Override
public AssessmentTestSession recalculateAssessmentTestSessionScores(Long sessionKey) {
    dbInstance.commit();
    // fresh and lock by the identity assessmentItem controller
    AssessmentTestSession candidateSession = getAssessmentTestSession(sessionKey);
    BigDecimal totalScore = BigDecimal.valueOf(0l);
    BigDecimal totalManualScore = BigDecimal.valueOf(0l);
    List<AssessmentItemSession> itemResults = itemSessionDao.getAssessmentItemSessions(candidateSession);
    for (AssessmentItemSession itemResult : itemResults) {
        if (itemResult.getManualScore() != null) {
            totalManualScore = totalManualScore.add(itemResult.getManualScore());
        } else if (itemResult.getScore() != null) {
            totalScore = totalScore.add(itemResult.getScore());
        }
    }
    candidateSession.setScore(totalScore);
    candidateSession.setManualScore(totalManualScore);
    return testSessionDao.update(candidateSession);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) BigDecimal(java.math.BigDecimal)

Example 89 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method pullSession.

@Override
public AssessmentTestSession pullSession(AssessmentTestSession session, DigitalSignatureOptions signatureOptions, Identity actor) {
    session = getAssessmentTestSession(session.getKey());
    if (session.getFinishTime() == null) {
        if (qtiModule.isDigitalSignatureEnabled()) {
            signAssessmentResult(session, signatureOptions, session.getIdentity());
        }
        session.setFinishTime(new Date());
    }
    session.setTerminationTime(new Date());
    session = updateAssessmentTestSession(session);
    // make sure that the changes committed before sending the event
    dbInstance.commit();
    AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
    candidateAuditLogger.logTestRetrieved(session, actor);
    OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new RetrieveAssessmentTestSessionEvent(session.getKey()), sessionOres);
    return session;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent) Date(java.util.Date)

Example 90 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method deleteAssessmentTestSession.

@Override
public boolean deleteAssessmentTestSession(List<Identity> identities, RepositoryEntryRef testEntry, RepositoryEntryRef entry, String subIdent) {
    Set<AssessmentEntry> entries = new HashSet<>();
    for (Identity identity : identities) {
        List<AssessmentTestSession> sessions = testSessionDao.getTestSessions(testEntry, entry, subIdent, identity);
        for (AssessmentTestSession session : sessions) {
            if (session.getAssessmentEntry() != null) {
                entries.add(session.getAssessmentEntry());
            }
            File fileStorage = testSessionDao.getSessionStorage(session);
            testSessionDao.deleteTestSession(session);
            FileUtils.deleteDirsAndFiles(fileStorage, true, true);
        }
    }
    for (AssessmentEntry assessmentEntry : entries) {
        assessmentEntryDao.resetAssessmentEntry(assessmentEntry);
    }
    return true;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)107 Identity (org.olat.core.id.Identity)45 RepositoryEntry (org.olat.repository.RepositoryEntry)36 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)32 File (java.io.File)30 ArrayList (java.util.ArrayList)24 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)24 Date (java.util.Date)22 Test (org.junit.Test)20 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)20 HashMap (java.util.HashMap)17 InMemoryAssessmentTestSession (org.olat.ims.qti21.model.InMemoryAssessmentTestSession)14 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)14 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)12 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)12 IOException (java.io.IOException)10 BigDecimal (java.math.BigDecimal)10 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)10