Search in sources :

Example 21 with QTIResultSet

use of org.olat.ims.qti.QTIResultSet in project openolat by klemens.

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 22 with QTIResultSet

use of org.olat.ims.qti.QTIResultSet in project openolat by klemens.

the class QTI12ResultsExportMediaResource method createResultDetail.

private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
    Long resourceId = courseEnv.getCourseResourceableId();
    String resourceDetail = courseNode.getIdent();
    Long resid = courseNode.getReferencedRepositoryEntry().getKey();
    List<QTIResultSet> resultSets = qtiResultManager.getResultSets(resourceId, resourceDetail, resid, identity);
    List<ResultDetail> assessments = new ArrayList<ResultDetail>();
    for (QTIResultSet qtiResultSet : resultSets) {
        Long assessmentID = qtiResultSet.getAssessmentID();
        String idPath = idDir + translator.translate("table.user.attempt") + (resultSets.indexOf(qtiResultSet) + 1) + SEP;
        createZipDirectory(zout, idPath);
        String linkToHTML = createHTMLfromQTIResultSet(idPath, idDir, zout, identity, qtiResultSet);
        // content of result table
        ResultDetail resultDetail = new ResultDetail(createLink(String.valueOf(assessmentID), linkToHTML, true), assessmentDateFormat.format(qtiResultSet.getCreationDate()), displayDateFormat.format(new Date(qtiResultSet.getDuration())), qtiResultSet.getScore(), createPassedIcons(qtiResultSet.getIsPassed()), linkToHTML);
        assessments.add(resultDetail);
    }
    return assessments;
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) ArrayList(java.util.ArrayList) Date(java.util.Date)

Aggregations

QTIResultSet (org.olat.ims.qti.QTIResultSet)22 RepositoryEntry (org.olat.repository.RepositoryEntry)14 Identity (org.olat.core.id.Identity)8 Date (java.util.Date)6 Test (org.junit.Test)6 QTIResult (org.olat.ims.qti.QTIResult)6 ArrayList (java.util.ArrayList)4 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)4 AssessmentContext (org.olat.ims.qti.container.AssessmentContext)4 HttpItemInput (org.olat.ims.qti.container.HttpItemInput)4 ItemContext (org.olat.ims.qti.container.ItemContext)4 ItemInput (org.olat.ims.qti.container.ItemInput)4 SectionContext (org.olat.ims.qti.container.SectionContext)4 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)4 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)4 Calendar (java.util.Calendar)2 List (java.util.List)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 Before (org.junit.Before)2 DB (org.olat.core.commons.persistence.DB)2