Search in sources :

Example 11 with AssessmentTestSession

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

the class IQSELFCourseNode method getUserScoreEvaluation.

/**
 * @see org.olat.course.nodes.SelfAssessableCourseNode#getUserScoreEvaluation(org.olat.course.run.userview.UserCourseEnvironment)
 */
@Override
public ScoreEvaluation getUserScoreEvaluation(final UserCourseEnvironment userCourseEnv) {
    // read score from properties save score, passed and attempts information
    ScoreEvaluation scoreEvaluation = null;
    RepositoryEntry referencedRepositoryEntry = getReferencedRepositoryEntry();
    if (referencedRepositoryEntry != null && OnyxModule.isOnyxTest(getReferencedRepositoryEntry().getOlatResource())) {
        AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
        Identity mySelf = userCourseEnv.getIdentityEnvironment().getIdentity();
        Boolean passed = am.getNodePassed(this, mySelf);
        Float score = am.getNodeScore(this, mySelf);
        Long assessmentID = am.getAssessmentID(this, mySelf);
        // <OLATCE-374>
        Boolean fullyAssessed = am.getNodeFullyAssessed(this, mySelf);
        scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
    // </OLATCE-374>
    } else if (referencedRepositoryEntry != null && ImsQTI21Resource.TYPE_NAME.equals(referencedRepositoryEntry.getOlatResource().getResourceableTypeName())) {
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        Identity assessedIdentity = userCourseEnv.getIdentityEnvironment().getIdentity();
        AssessmentTestSession testSession = CoreSpringFactory.getImpl(QTI21Service.class).getLastAssessmentTestSessions(courseEntry, getIdent(), referencedRepositoryEntry, assessedIdentity);
        if (testSession != null) {
            boolean fullyAssessed = (testSession.getFinishTime() != null || testSession.getTerminationTime() != null);
            Float score = testSession.getScore().floatValue();
            return new ScoreEvaluation(score, testSession.getPassed(), fullyAssessed, testSession.getKey());
        }
    } else {
        Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
        long olatResourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
        QTIResultSet qTIResultSet = CoreSpringFactory.getImpl(IQManager.class).getLastResultSet(identity, olatResourceId, this.getIdent());
        if (qTIResultSet != null) {
            Boolean passed = qTIResultSet.getIsPassed();
            Boolean fullyAssessed = qTIResultSet.getFullyAssessed();
            scoreEvaluation = new ScoreEvaluation(Float.valueOf(qTIResultSet.getScore()), passed, fullyAssessed, new Long(qTIResultSet.getAssessmentID()));
        }
    }
    return scoreEvaluation;
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentManager(org.olat.course.assessment.AssessmentManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 12 with AssessmentTestSession

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

the class AssessmentItemSessionDAO method createAndPersistAssessmentItemSession.

public AssessmentItemSession createAndPersistAssessmentItemSession(AssessmentTestSession assessmentTestSession, ParentPartItemRefs parentParts, String assessmentItemIdentifier) {
    AssessmentItemSessionImpl itemSession = new AssessmentItemSessionImpl();
    Date now = new Date();
    itemSession.setCreationDate(now);
    itemSession.setLastModified(now);
    itemSession.setAssessmentItemIdentifier(assessmentItemIdentifier);
    itemSession.setAssessmentTestSession(assessmentTestSession);
    if (parentParts != null) {
        itemSession.setSectionIdentifier(parentParts.getSectionIdentifier());
        itemSession.setTestPartIdentifier(parentParts.getTestPartIdentifier());
    }
    dbInstance.getCurrentEntityManager().persist(itemSession);
    return itemSession;
}
Also used : AssessmentItemSessionImpl(org.olat.ims.qti21.model.jpa.AssessmentItemSessionImpl) Date(java.util.Date)

Example 13 with AssessmentTestSession

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

the class AssessmentTestSessionDAO method createAndPersistTestSession.

public AssessmentTestSession createAndPersistTestSession(RepositoryEntry testEntry, RepositoryEntry repositoryEntry, String subIdent, AssessmentEntry assessmentEntry, Identity identity, String anonymousIdentifier, boolean authorMode) {
    AssessmentTestSessionImpl testSession = new AssessmentTestSessionImpl();
    Date now = new Date();
    testSession.setCreationDate(now);
    testSession.setLastModified(now);
    testSession.setTestEntry(testEntry);
    testSession.setRepositoryEntry(repositoryEntry);
    testSession.setSubIdent(subIdent);
    testSession.setAssessmentEntry(assessmentEntry);
    testSession.setAuthorMode(authorMode);
    testSession.setExploded(false);
    testSession.setIdentity(identity);
    testSession.setAnonymousIdentifier(anonymousIdentifier);
    testSession.setStorage(createSessionStorage(testSession));
    dbInstance.getCurrentEntityManager().persist(testSession);
    return testSession;
}
Also used : AssessmentTestSessionImpl(org.olat.ims.qti21.model.jpa.AssessmentTestSessionImpl) Date(java.util.Date)

Example 14 with AssessmentTestSession

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

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

the class QTI21ServiceImpl method getItemSessionStateFile.

private File getItemSessionStateFile(CandidateEvent candidateEvent) {
    AssessmentTestSession candidateSession = candidateEvent.getCandidateSession();
    File myStore = testSessionDao.getSessionStorage(candidateSession);
    return new File(myStore, "itemSessionState.xml");
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) 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