Search in sources :

Example 81 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method getUserTestSessionsStatistics.

@Test
public void getUserTestSessionsStatistics() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession);
    dbInstance.commit();
    for (int i = 0; i < 4; i++) {
        ParentPartItemRefs parentParts = new ParentPartItemRefs();
        String sectionIdentifier = UUID.randomUUID().toString();
        parentParts.setSectionIdentifier(sectionIdentifier);
        String testPartIdentifier = UUID.randomUUID().toString();
        parentParts.setTestPartIdentifier(testPartIdentifier);
        AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, UUID.randomUUID().toString());
        Assert.assertNotNull(itemSession);
        dbInstance.commit();
        if (i % 2 == 0) {
            itemSession.setManualScore(new BigDecimal(3));
            itemSessionDao.merge(itemSession);
        }
    }
    dbInstance.commitAndCloseSession();
    List<AssessmentTestSessionStatistics> sessionsStatistics = testSessionDao.getUserTestSessionsStatistics(courseEntry, subIdent, assessedIdentity);
    Assert.assertNotNull(sessionsStatistics);
    Assert.assertEquals(1, sessionsStatistics.size());
    AssessmentTestSessionStatistics sessionStatistics = sessionsStatistics.get(0);
    Assert.assertNotNull(sessionStatistics.getTestSession());
    Assert.assertEquals(testSession, sessionStatistics.getTestSession());
    Assert.assertEquals(2, sessionStatistics.getNumOfCorrectedItems());
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentTestSessionStatistics(org.olat.ims.qti21.model.jpa.AssessmentTestSessionStatistics) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 82 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method hasActiveTestSession_negative.

@Test
public void hasActiveTestSession_negative() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-5");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, null, testEntry);
    dbInstance.commit();
    // create an assessment test session
    AssessmentTestSession testSession1 = testSessionDao.createAndPersistTestSession(testEntry, null, null, assessmentEntry, assessedIdentity, null, true);
    Assert.assertNotNull(testSession1);
    dbInstance.commitAndCloseSession();
    // check that there isn't any active test session (only author mode)
    boolean hasTestSession = testSessionDao.hasActiveTestSession(testEntry);
    Assert.assertFalse(hasTestSession);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 83 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentTestSessionDAOTest method createTestSession_course.

@Test
public void createTestSession_course() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    String subIdent = UUID.randomUUID().toString();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-2");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
    dbInstance.commit();
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, false);
    Assert.assertNotNull(testSession);
    dbInstance.commit();
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 84 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class AssessmentItemSessionDAOTest method createAndGetItemSession.

@Test
public void createAndGetItemSession() {
    // prepare a test and a user
    RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
    Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("response-session-1");
    AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
    dbInstance.commit();
    String itemIdentifier = UUID.randomUUID().toString();
    ParentPartItemRefs parentParts = new ParentPartItemRefs();
    String sectionIdentifier = UUID.randomUUID().toString();
    parentParts.setSectionIdentifier(sectionIdentifier);
    String testPartIdentifier = UUID.randomUUID().toString();
    parentParts.setTestPartIdentifier(testPartIdentifier);
    // make test, item and response
    AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "_", assessmentEntry, assessedIdentity, null, true);
    Assert.assertNotNull(testSession);
    AssessmentItemSession itemSession = itemSessionDao.createAndPersistAssessmentItemSession(testSession, parentParts, itemIdentifier);
    Assert.assertNotNull(itemSession);
    dbInstance.commitAndCloseSession();
    AssessmentItemSession reloadedItemSession = itemSessionDao.getAssessmentItemSession(testSession, itemIdentifier);
    Assert.assertNotNull(reloadedItemSession);
    Assert.assertNotNull(reloadedItemSession.getCreationDate());
    Assert.assertNotNull(reloadedItemSession.getLastModified());
    Assert.assertEquals(itemIdentifier, reloadedItemSession.getAssessmentItemIdentifier());
    Assert.assertEquals(sectionIdentifier, reloadedItemSession.getSectionIdentifier());
    Assert.assertEquals(testPartIdentifier, reloadedItemSession.getTestPartIdentifier());
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 85 with AssessmentEntry

use of org.olat.modules.assessment.AssessmentEntry in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_0_0 method convertUserEfficiencyStatemen.

private void convertUserEfficiencyStatemen(RepositoryEntry courseEntry) {
    try {
        final ICourse course = CourseFactory.loadCourse(courseEntry);
        CourseNode rootNode = course.getRunStructure().getRootNode();
        Set<Long> identityKeys = new HashSet<>(loadIdentityKeyOfAssessmentEntries(courseEntry, rootNode.getIdent()));
        int count = 0;
        List<UserEfficiencyStatementLight> statements = getUserEfficiencyStatements(courseEntry);
        for (UserEfficiencyStatementLight statement : statements) {
            Identity identity = statement.getIdentity();
            if (!identityKeys.contains(identity.getKey())) {
                AssessmentEntry entry = createAssessmentEntry(identity, null, course, courseEntry, rootNode.getIdent());
                if (statement.getScore() != null) {
                    entry.setScore(new BigDecimal(statement.getScore()));
                }
                if (statement.getPassed() != null) {
                    entry.setPassed(statement.getPassed());
                }
                dbInstance.getCurrentEntityManager().persist(entry);
                if (count++ % 25 == 0) {
                    dbInstance.commitAndCloseSession();
                }
            }
        }
    } catch (Exception e) {
        log.error("Error with " + courseEntry.getKey() + " " + courseEntry, e);
    }
    dbInstance.commitAndCloseSession();
}
Also used : UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) ICourse(org.olat.course.ICourse) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) CorruptedCourseException(org.olat.course.CorruptedCourseException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) HashSet(java.util.HashSet)

Aggregations

AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)150 Identity (org.olat.core.id.Identity)88 RepositoryEntry (org.olat.repository.RepositoryEntry)70 Test (org.junit.Test)50 ICourse (org.olat.course.ICourse)38 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)32 File (java.io.File)26 Date (java.util.Date)26 HashMap (java.util.HashMap)22 BigDecimal (java.math.BigDecimal)20 ArrayList (java.util.ArrayList)20 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)20 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)16 CourseNode (org.olat.course.nodes.CourseNode)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)12 AssessmentManager (org.olat.course.assessment.AssessmentManager)12 BusinessGroup (org.olat.group.BusinessGroup)12 List (java.util.List)10