Search in sources :

Example 41 with AssessmentItemSession

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

the class CorrectionIdentityAssessmentItemListController method loadModel.

private void loadModel(boolean reset) {
    ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
    Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
    for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
        identifierToRefs.put(itemRef.getIdentifier(), itemRef);
    }
    List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(candidateSession);
    Map<String, AssessmentItemSession> identifierToItemSessions = new HashMap<>();
    for (AssessmentItemSession itemSession : allItemSessions) {
        identifierToItemSessions.put(itemSession.getAssessmentItemIdentifier(), itemSession);
    }
    // reorder to match the list of assessment items
    List<CorrectionIdentityAssessmentItemRow> rows = new ArrayList<>();
    TestSessionState testSessionState = model.getTestSessionStates().get(assessedIdentity);
    List<TestPlanNode> nodes = testSessionState.getTestPlan().getTestPlanNodeList();
    for (TestPlanNode node : nodes) {
        if (node.getTestNodeType() == TestNodeType.ASSESSMENT_ITEM_REF) {
            TestPlanNodeKey key = node.getKey();
            AssessmentItemRef itemRef = identifierToRefs.get(key.getIdentifier());
            AssessmentItemSession itemSession = identifierToItemSessions.get(key.getIdentifier().toString());
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
            AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(key);
            boolean manualCorrection = model.isManualCorrection(itemRef);
            CorrectionIdentityAssessmentItemRow row = new CorrectionIdentityAssessmentItemRow(assessedIdentity, item, itemRef, metadata, candidateSession, itemSession, itemSessionState, manualCorrection);
            row.setTitle(title);
            row.setTitleCssClass("o_icon_user");
            rows.add(row);
        }
    }
    tableModel.setObjects(rows);
    tableEl.reset(reset, reset, true);
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) CorrectionIdentityAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionIdentityAssessmentItemRow) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 42 with AssessmentItemSession

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

the class CorrectionIdentityInteractionsController method getStatus.

protected String getStatus() {
    AssessmentItemSession itemSession = correction.getItemSession();
    StringBuilder sb = new StringBuilder();
    if (itemSession != null) {
        if (itemSession.getManualScore() != null) {
            sb.append("<i class='o_icon o_icon_ok'> </i>");
        } else if (!correction.isItemSessionStatusFinal()) {
            sb.append("<i class='o_icon o_icon_warn'> </i> ").append(translate("warning.not.submitted"));
        } else if (manualScore) {
            sb.append("<i class='o_icon o_icon_warn'> </i>");
        } else {
            sb.append("<i class='o_icon o_icon_ok'> </i> <span class='badge'>").append(translate("correction.auto")).append("</span>");
        }
    } else {
        sb.append("<i class='o_icon o_icon_warn'> </i> ").append(translate("warning.not.submitted"));
    }
    return sb.toString();
}
Also used : AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession)

Example 43 with AssessmentItemSession

use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.

the class QTI21ServiceImpl method recalculateAssessmentTestSessionScores.

@Override
public AssessmentTestSession recalculateAssessmentTestSessionScores(Long sessionKey) {
    dbInstance.commit();
    // fresh and lock by the identity assessmentItem controller
    AssessmentTestSession candidateSession = getAssessmentTestSession(sessionKey);
    BigDecimal totalScore = BigDecimal.valueOf(0l);
    BigDecimal totalManualScore = BigDecimal.valueOf(0l);
    List<AssessmentItemSession> itemResults = itemSessionDao.getAssessmentItemSessions(candidateSession);
    for (AssessmentItemSession itemResult : itemResults) {
        if (itemResult.getManualScore() != null) {
            totalManualScore = totalManualScore.add(itemResult.getManualScore());
        } else if (itemResult.getScore() != null) {
            totalScore = totalScore.add(itemResult.getScore());
        }
    }
    candidateSession.setScore(totalScore);
    candidateSession.setManualScore(totalManualScore);
    return testSessionDao.update(candidateSession);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) BigDecimal(java.math.BigDecimal)

Example 44 with AssessmentItemSession

use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.

the class QTI21ArchiveFormat method calculateSectionScore.

private BigDecimal calculateSectionScore(SessionResponses responses, SectionInfos section) {
    BigDecimal sectionScore = BigDecimal.valueOf(0l);
    for (ItemInfos item : section.getItemInfos()) {
        AssessmentItemRef itemRef = item.getAssessmentItemRef();
        String itemRefIdentifier = itemRef.getIdentifier().toString();
        AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
        if (itemSession != null) {
            if (itemSession.getManualScore() != null) {
                sectionScore = sectionScore.add(itemSession.getManualScore());
            } else if (itemSession.getScore() != null) {
                sectionScore = sectionScore.add(itemSession.getScore());
            }
        }
    }
    return sectionScore;
}
Also used : AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) BigDecimal(java.math.BigDecimal)

Example 45 with AssessmentItemSession

use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.

the class QTI21ArchiveFormat method writeDataRow.

private void writeDataRow(int num, SessionResponses responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    int col = 0;
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    AssessmentTestSession testSession = responses.getTestSession();
    AssessmentEntry entry = testSession.getAssessmentEntry();
    Identity assessedIdentity = entry.getIdentity();
    // user properties
    if (assessedIdentity == null) {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                if (userPropertyHandlers.get(0) == userPropertyHandler) {
                    dataRow.addCell(col++, translator.translate("anonym.user"), null);
                } else {
                    col++;
                }
            }
        }
    } else if (anonymizerCallback != null) {
        String anonymizedName = anonymizerCallback.getAnonymizedUserName(assessedIdentity);
        dataRow.addCell(col++, anonymizedName, null);
    } else {
        User assessedUser = assessedIdentity.getUser();
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
                dataRow.addCell(col++, property, null);
            }
        }
    }
    // homepage
    if (anonymizerCallback == null) {
        String homepage;
        if (entry.getIdentity() == null) {
            homepage = "";
        } else {
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry.getIdentity());
            homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
        }
        dataRow.addCell(col++, homepage, null);
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            if (entry.getScore() != null) {
                dataRow.addCell(col++, entry.getScore(), null);
            } else {
                col++;
            }
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            if (entry.getPassed() != null) {
                dataRow.addCell(col++, entry.getPassed().toString(), null);
            } else {
                col++;
            }
        }
    }
    // assesspoints, passed, ipaddress, date, duration
    if (testSession.getScore() != null) {
        dataRow.addCell(col++, testSession.getScore(), null);
    } else {
        col++;
    }
    if (testSession.getManualScore() != null) {
        dataRow.addCell(col++, testSession.getManualScore(), null);
    } else {
        col++;
    }
    if (testSession.getFinalScore() != null) {
        dataRow.addCell(col++, testSession.getFinalScore(), null);
    } else {
        col++;
    }
    if (testSession.getPassed() != null) {
        dataRow.addCell(col++, testSession.getPassed().toString(), null);
    } else {
        col++;
    }
    if (anonymizerCallback == null) {
        dataRow.addCell(col++, testSession.getCreationDate(), workbook.getStyles().getDateStyle());
    }
    dataRow.addCell(col++, toDurationInMilliseconds(testSession.getDuration()), null);
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            AssessmentItemRef itemRef = item.getAssessmentItemRef();
            String itemRefIdentifier = itemRef.getIdentifier().toString();
            AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    AssessmentResponse response = responses.getResponse(itemRefIdentifier, interaction.getResponseIdentifier());
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeInteractionData(item.getAssessmentItem(), response, interaction, j, dataRow, col, workbook);
                }
            }
            // score, start, duration
            if (itemSession == null) {
                if (exportConfig.isPointCol()) {
                    col++;
                }
                if (exportConfig.isCommentCol()) {
                    col++;
                }
                if (exportConfig.isTimeCols()) {
                    col += anonymizerCallback != null ? 1 : 2;
                }
            } else {
                if (exportConfig.isPointCol()) {
                    if (itemSession.getManualScore() != null) {
                        dataRow.addCell(col++, itemSession.getManualScore(), null);
                    } else {
                        dataRow.addCell(col++, itemSession.getScore(), null);
                    }
                }
                if (exportConfig.isCommentCol()) {
                    dataRow.addCell(col++, itemSession.getCoachComment(), null);
                }
                if (exportConfig.isTimeCols()) {
                    if (anonymizerCallback == null) {
                        dataRow.addCell(col++, itemSession.getCreationDate(), workbook.getStyles().getTimeStyle());
                    }
                    dataRow.addCell(col++, toDurationInMilliseconds(itemSession.getDuration()), null);
                }
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                BigDecimal score = calculateSectionScore(responses, section);
                if (score != null) {
                    dataRow.addCell(col++, score, workbook.getStyles().getLightGrayStyle());
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) User(org.olat.core.id.User) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) ContextEntry(org.olat.core.id.context.ContextEntry) BigDecimal(java.math.BigDecimal) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)40 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)24 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)18 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)18 HashMap (java.util.HashMap)16 Identity (org.olat.core.id.Identity)16 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)16 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)16 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)12 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)12 BigDecimal (java.math.BigDecimal)10 ArrayList (java.util.ArrayList)10 Date (java.util.Date)8 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)8 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 Test (org.junit.Test)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6