Search in sources :

Example 6 with AssessmentTestSession

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

the class AssessmentItemComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentItemComponent cmp = (AssessmentItemComponent) source;
    sb.append("<div class='qtiworks o_assessmentitem'>");
    ItemSessionController itemSessionController = cmp.getItemSessionController();
    CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
    /* Create appropriate options that link back to this controller */
    final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
    if (candidateSession != null && candidateSession.isExploded()) {
        renderExploded(sb, translator);
    } else if (candidateSessionContext.isTerminated()) {
        renderTerminated(sb, translator);
    } else {
        /* Look up most recent event */
        // assertSessionEntered(candidateSession);
        final CandidateEvent latestEvent = candidateSessionContext.getLastEvent();
        /* Load the ItemSessionState */
        // candidateDataService.loadItemSessionState(latestEvent);
        final ItemSessionState itemSessionState = cmp.getItemSessionController().getItemSessionState();
        /* Touch the session's duration state if appropriate */
        if (itemSessionState.isEntered() && !itemSessionState.isEnded() && !itemSessionState.isSuspended()) {
            final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
            itemSessionController.touchDuration(timestamp);
        }
        /* Render event */
        AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
        renderItemEvent(renderHints, sb, cmp, latestEvent, itemSessionState, ubu, translator);
    }
    sb.append("</div>");
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 7 with AssessmentTestSession

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

the class IQIdentityListCourseNodeController method getExtraTimes.

/**
 * @return A map identity key to extra time
 */
private Map<Long, ExtraTimeInfos> getExtraTimes() {
    Map<Long, ExtraTimeInfos> identityToExtraTime = new HashMap<>();
    List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(getCourseRepositoryEntry(), courseNode.getIdent(), getReferencedRepositoryEntry());
    // sort by identity, then by creation date
    Collections.sort(sessions, new AssessmentTestSessionComparator());
    Long currentIdentityKey = null;
    for (AssessmentTestSession session : sessions) {
        Long identityKey = session.getIdentity().getKey();
        if (currentIdentityKey == null || !currentIdentityKey.equals(identityKey)) {
            if (session.getFinishTime() == null && session.getExtraTime() != null) {
                Integer extraTimeInSeconds = session.getExtraTime();
                Date start = session.getCreationDate();
                ExtraTimeInfos infos = new ExtraTimeInfos(extraTimeInSeconds, start);
                identityToExtraTime.put(identityKey, infos);
            }
            currentIdentityKey = identityKey;
        }
    }
    return identityToExtraTime;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) HashMap(java.util.HashMap) Date(java.util.Date)

Example 8 with AssessmentTestSession

use of org.olat.ims.qti21.AssessmentTestSession 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 9 with AssessmentTestSession

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

the class QTI21IdentityListCourseNodeToolsController method doConfirmExtraTime.

private void doConfirmExtraTime(UserRequest ureq) {
    List<AssessmentTestSession> testSessions = Collections.singletonList(lastSession);
    extraTimeCtrl = new ConfirmExtraTimeController(ureq, getWindowControl(), courseEntry, 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) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 10 with AssessmentTestSession

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

the class QTI21AssessmentRunController method doDownloadSignature.

private void doDownloadSignature(UserRequest ureq) {
    MediaResource resource = null;
    if (courseNode instanceof IQTESTCourseNode) {
        IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
        AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
        AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
        File signature = qtiService.getAssessmentResultSignature(session);
        if (signature.exists()) {
            resource = new DownloadeableMediaResource(signature);
        }
    }
    if (resource == null) {
        resource = new NotFoundMediaResource();
    }
    ureq.getDispatchResult().setResultingMediaResource(resource);
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) DownloadeableMediaResource(org.olat.fileresource.DownloadeableMediaResource) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

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