Search in sources :

Example 6 with QTIResultSet

use of org.olat.ims.qti.QTIResultSet 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 7 with QTIResultSet

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

the class OLATUpgrade_11_0_0 method processAssessmentPropertyForIQTEST.

/**
 * If a QTI ser is found, the test is in progress. If not, check if some result set is available
 * and if the test has essay to set the status as inReview or done.
 *
 * @param assessedIdentity
 * @param entry
 * @param cNode
 * @param course
 */
private void processAssessmentPropertyForIQTEST(Identity assessedIdentity, AssessmentEntryImpl entry, IQTESTCourseNode cNode, ICourse course) {
    entry.setAssessmentStatus(AssessmentEntryStatus.notStarted);
    if (iqTestPersisterExists(assessedIdentity, cNode, course)) {
        entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
    } else {
        RepositoryEntry ref = cNode.getReferencedRepositoryEntry();
        if (ref != null) {
            Long courseResourceableId = course.getResourceableId();
            List<QTIResultSet> resultSets = qtiResultManager.getResultSets(courseResourceableId, cNode.getIdent(), ref.getKey(), assessedIdentity);
            if (resultSets.size() > 0) {
                if (OnyxModule.isOnyxTest(ref.getOlatResource())) {
                    // make it later with the flag fully assessed
                    entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
                } else if (checkEssay(ref)) {
                    entry.setAssessmentStatus(AssessmentEntryStatus.inReview);
                } else {
                    entry.setAssessmentStatus(AssessmentEntryStatus.done);
                }
            }
        }
    }
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 8 with QTIResultSet

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

the class QTIStatisticsManagerLargeTest method setUp.

@Before
public void setUp() throws Exception {
    if (isInitialized)
        return;
    RepositoryEntry re = createRepository();
    olatResource = re.getOlatResource().getResourceableId();
    repositoryRef = re.getKey();
    olatResourceDetail = UUID.randomUUID().toString().replace("-", "");
    getItemObjectList();
    double scoreQuestion1 = 0.0d, scoreQuestion2 = 0.0d, scoreQuestion3 = 0.0d, scoreQuestion4 = 0.0d;
    float maxScoreQ1 = 0, maxScoreQ2 = 0, maxScoreQ3 = 0, maxScoreQ4 = 0;
    // insert value into resultset
    for (int i = 0; i < numberOfParticipants; i++) {
        QTIResultSet test = new QTIResultSet();
        float setScore = (float) Math.ceil(Math.random() * maxScore);
        if (setScore >= 4.0d) {
            numberOfTestPassed++;
            test.setIsPassed(true);
        } else {
            numberOfTestFailed++;
            test.setIsPassed(false);
        }
        long tempTestDuration = Math.round((Math.random() * 100000) + 1.0);
        averageDuration += tempTestDuration;
        averageScore += setScore;
        scorePerParticipant.add(setScore);
        assertNotNull(allDurations);
        allDurations.add(tempTestDuration);
        test.setOlatResource(olatResource);
        test.setOlatResourceDetail(olatResourceDetail);
        test.setRepositoryRef(repositoryRef);
        test.setScore(setScore);
        test.setDuration(tempTestDuration);
        test.setIdentity(JunitTestHelper.createAndPersistIdentityAsUser("test" + i));
        test.setAssessmentID(111L);
        Calendar cal = Calendar.getInstance();
        cal.set(2013, 8, 23, (int) (Math.random() * 1000 % 60), (int) (Math.random() * 1000 % 60), (int) (Math.random() * 1000 % 60));
        test.setLastModified(cal.getTime());
        dbInstance.saveObject(test);
        // insert values into result
        for (int j = 0; j < numberOfQuestions; j++) {
            QTIResult testres = new QTIResult();
            testres.setResultSet(test);
            long tempDuration = Math.round((Math.random() * 10000) + 1.0);
            testres.setDuration(tempDuration);
            testres.setIp("127.0.0.1");
            testres.setAnswer("asdf");
            if (j == 0) {
                testres.setItemIdent("QTIEDIT:SCQ:1000007885");
                if (i % 4 == 0) {
                    testres.setAnswer("1000007887[[1000007890]]");
                } else if (i % 4 == 1) {
                    testres.setAnswer("1000007887[[1000009418]]");
                } else if (i % 4 == 2) {
                    testres.setAnswer("1000007887[[1000009464]]");
                } else if (i % 4 == 3) {
                    testres.setAnswer("1000007887[[1000007890]]");
                }
                float score = (float) Math.ceil(Math.random());
                scoreQ1 += score;
                testres.setScore(score);
                scoreQuestion1 += score;
                if (score == 1.0f) {
                    maxScoreQ1++;
                }
            } else if (j == 1) {
                testres.setItemIdent("QTIEDIT:MCQ:1000009738");
                float score = (float) Math.ceil(Math.random() * 3);
                scoreQ2 += score;
                testres.setScore(score);
                scoreQuestion2 += score;
                if (score < 3.0f) {
                    wrongAnswersQ2++;
                } else {
                    rightAnswersQ2++;
                    maxScoreQ2++;
                }
            } else if (j == 2) {
                testres.setItemIdent("QTIEDIT:KPRIM:1000010376");
                durationQ3 += tempDuration;
                float score = (float) Math.ceil(Math.random() * 2);
                testres.setScore(score);
                scoreQuestion3 += score;
                if (score == 2.0f) {
                    maxScoreQ3++;
                }
            } else if (j == 3) {
                testres.setItemIdent("QTIEDIT:FIB:1000010792");
                if (i % 4 == 0) {
                    testres.setAnswer("Huagagaagaga");
                    fibAnswers.add("Huagagaagaga");
                } else if (i % 4 == 1) {
                    testres.setAnswer("Yikes");
                    fibAnswers.add("Yikes");
                } else if (i % 4 == 2 || i % 4 == 3) {
                    testres.setAnswer("Muragarara");
                    fibAnswers.add("Muragarara");
                }
                float score = (float) Math.ceil(Math.random());
                testres.setScore(score);
                scoreQuestion4 += score;
                if (score == 1.0f) {
                    maxScoreQ4++;
                }
            }
            testres.setLastModified(new Date());
            testres.setTstamp(new Date());
            dbInstance.saveObject(testres);
        }
        dbInstance.commitAndCloseSession();
    }
    dbInstance.commitAndCloseSession();
    durationQ3 = (durationQ3 / numberOfParticipants);
    scoreQ1 = scoreQ1 / numberOfParticipants;
    scoreQ2 = scoreQ2 / numberOfParticipants;
    averageScore = averageScore / numberOfParticipants;
    averageDuration = averageDuration / numberOfParticipants;
    averageScorePerQuestion.put("QTIEDIT:SCQ:1000007885", scoreQuestion1 / numberOfParticipants);
    averageScorePerQuestion.put("QTIEDIT:MCQ:1000009738", scoreQuestion2 / numberOfParticipants);
    averageScorePerQuestion.put("QTIEDIT:KPRIM:1000010376", scoreQuestion3 / numberOfParticipants);
    averageScorePerQuestion.put("QTIEDIT:FIB:1000010792", scoreQuestion4 / numberOfParticipants);
    averageRightAnswersInPercent.add(maxScoreQ1 / numberOfParticipants);
    averageRightAnswersInPercent.add(maxScoreQ2 / numberOfParticipants);
    averageRightAnswersInPercent.add(maxScoreQ3 / numberOfParticipants);
    averageRightAnswersInPercent.add(maxScoreQ4 / numberOfParticipants);
    identToANumOfRightAnswers.put("QTIEDIT:SCQ:1000007885", maxScoreQ1);
    identToANumOfRightAnswers.put("QTIEDIT:MCQ:1000009738", maxScoreQ2);
    identToANumOfRightAnswers.put("QTIEDIT:KPRIM:1000010376", maxScoreQ3);
    identToANumOfRightAnswers.put("QTIEDIT:FIB:1000010792", maxScoreQ4);
    // sort allDurations List asc
    Collections.sort(allDurations);
    Collections.sort(scorePerParticipant);
    isInitialized = true;
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) QTIResult(org.olat.ims.qti.QTIResult) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Before(org.junit.Before)

Example 9 with QTIResultSet

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

the class QTIStatisticsManagerTest method testResultStatistics.

/**
 * retrieve the results of the last modified result set
 */
@Test
public void testResultStatistics() {
    RepositoryEntry re = createRepository();
    long assessmentId = 838l;
    String resSubPath = "1238";
    String firstQuestion = "id:123";
    String secondQuestion = "id:124";
    String thirdQuestion = "id:125";
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-20");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-21");
    // 3 try for id1
    QTIResultSet set1_1 = createSet(2.0f, assessmentId, id1, re, resSubPath, modDate(3, 8, 8), modDate(3, 8, 12));
    QTIResult result1_1_1 = createResult(firstQuestion, "test 1", set1_1);
    QTIResult result1_1_2 = createResult(secondQuestion, "test 2", set1_1);
    QTIResult result1_1_3 = createResult(thirdQuestion, "test 3", set1_1);
    QTIResultSet set1_3 = createSet(6.0f, assessmentId, id1, re, resSubPath, modDate(3, 14, 7), modDate(3, 14, 38));
    QTIResult result1_3_1 = createResult(firstQuestion, "test 1", set1_3);
    QTIResult result1_3_2 = createResult(secondQuestion, "test 2", set1_3);
    QTIResult result1_3_3 = createResult(thirdQuestion, "test 3", set1_3);
    QTIResultSet set1_2 = createSet(4.0f, assessmentId, id1, re, resSubPath, modDate(3, 10, 34), modDate(3, 10, 45));
    QTIResult result1_2_1 = createResult(firstQuestion, "test 1", set1_2);
    QTIResult result1_2_2 = createResult(secondQuestion, "test 2", set1_2);
    QTIResult result1_2_3 = createResult(thirdQuestion, "test 3", set1_2);
    // 1 try for id2
    QTIResultSet set2_1 = createSet(6.0f, assessmentId, id2, re, resSubPath, modDate(3, 9, 21), modDate(3, 9, 45));
    QTIResult result2_1_1 = createResult(firstQuestion, "test 1", set2_1);
    QTIResult result2_1_2 = createResult(secondQuestion, "test 2", set2_1);
    QTIResult result2_1_3 = createResult(thirdQuestion, "test 3", set2_1);
    dbInstance.commit();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(re.getOlatResource().getResourceableId(), resSubPath);
    List<QTIStatisticResult> results = qtiStatisticsManager.getResults(searchParams);
    Assert.assertNotNull(results);
    Assert.assertEquals(6, results.size());
    List<Long> setKeys = PersistenceHelper.toKeys(results);
    Assert.assertTrue(setKeys.contains(result1_3_1.getKey()));
    Assert.assertTrue(setKeys.contains(result1_3_2.getKey()));
    Assert.assertTrue(setKeys.contains(result1_3_3.getKey()));
    Assert.assertTrue(setKeys.contains(result2_1_1.getKey()));
    Assert.assertTrue(setKeys.contains(result2_1_2.getKey()));
    Assert.assertTrue(setKeys.contains(result2_1_3.getKey()));
    Assert.assertFalse(setKeys.contains(result1_1_1.getKey()));
    Assert.assertFalse(setKeys.contains(result1_1_2.getKey()));
    Assert.assertFalse(setKeys.contains(result1_1_3.getKey()));
    Assert.assertFalse(setKeys.contains(result1_2_1.getKey()));
    Assert.assertFalse(setKeys.contains(result1_2_2.getKey()));
    Assert.assertFalse(setKeys.contains(result1_2_3.getKey()));
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) QTIResult(org.olat.ims.qti.QTIResult) QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) QTIStatisticResult(org.olat.ims.qti.statistics.model.QTIStatisticResult) Test(org.junit.Test)

Example 10 with QTIResultSet

use of org.olat.ims.qti.QTIResultSet in project OpenOLAT by OpenOLAT.

the class IQTestHelper method createSet.

public static QTIResultSet createSet(float score, long assessmentId, Identity id, RepositoryEntry re, String resSubPath, Date creationDate, Date modDate) {
    QTIResultSet test = new QTIResultSet();
    if (score >= 4.0d) {
        test.setIsPassed(true);
    } else {
        test.setIsPassed(false);
    }
    test.setOlatResource(re.getOlatResource().getResourceableId());
    test.setOlatResourceDetail(resSubPath);
    test.setRepositoryRef(re.getKey());
    test.setScore(score);
    long duration = Math.round((Math.random() * 1000 * 60 * 60) + 1l);
    test.setDuration(duration);
    test.setIdentity(id);
    test.setAssessmentID(assessmentId);
    test.setCreationDate(creationDate);
    test.setLastModified(modDate);
    DB dbInstance = DBFactory.getInstance();
    dbInstance.getCurrentEntityManager().persist(test);
    return test;
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) DB(org.olat.core.commons.persistence.DB)

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