use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class CorrectionAssessmentItemListController method loadModel.
private void loadModel(boolean reset, boolean lastSessions) {
if (lastSessions) {
model.loadLastSessions();
}
ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
List<CorrectionAssessmentItemRow> itemRows = new ArrayList<>(itemRefs.size());
Map<String, CorrectionAssessmentItemRow> itemRefIdToRows = new HashMap<>();
for (AssessmentItemRef itemRef : itemRefs) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
FormLink toolsLink = uifactory.addFormLink("tools_" + (++counter), "tools", "", null, null, Link.NONTRANSLATED);
toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
CorrectionAssessmentItemRow itemRow = new CorrectionAssessmentItemRow(itemRef, assessmentItem, metadata, toolsLink);
toolsLink.setUserObject(itemRow);
itemRows.add(itemRow);
itemRefIdToRows.put(itemRef.getIdentifier().toString(), itemRow);
}
List<AssessmentItemSession> itemSessions = qtiService.getAssessmentItemSessions(model.getCourseEntry(), model.getSubIdent(), model.getTestEntry(), null);
Map<ItemSessionKey, AssessmentItemSession> itemSessionMap = new HashMap<>();
for (AssessmentItemSession itemSession : itemSessions) {
AssessmentTestSession candidateSession = itemSession.getAssessmentTestSession();
if (model.getReversedLastSessions().containsKey(candidateSession)) {
// the map contains all test sessions the user is allowed to correct
String itemRefIdentifier = itemSession.getAssessmentItemIdentifier();
itemSessionMap.put(new ItemSessionKey(candidateSession.getKey(), itemRefIdentifier), itemSession);
}
}
for (Map.Entry<Identity, AssessmentTestSession> entry : model.getLastSessions().entrySet()) {
if (model.getLastSessions().containsKey(entry.getKey())) {
TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
CorrectionAssessmentItemRow row = itemRefIdToRows.get(itemRefIdentifier);
if (row != null) {
AssessmentItemSession itemSession = itemSessionMap.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
appendStatistics(row, itemSession, itemEntry.getValue());
}
}
}
}
tableModel.setObjects(itemRows);
tableEl.reset(reset, reset, true);
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState 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);
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderNavigationAssessmentItem.
private void renderNavigationAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
String key = itemNode.getKey().toString();
sb.append("<li class='o_assessmentitem'>");
sb.append("<button type='button' onclick=\"");
Form form = component.getQtiItem().getRootForm();
String dispatchId = component.getQtiItem().getFormDispatchId();
sb.append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", Event.selectItem.name()), new NameValuePair("item", key)));
sb.append(";\" class='btn btn-default'><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
ItemSessionState itemSessionState = component.getItemSessionState(itemNode.getKey());
if (itemSessionState.getEndTime() != null) {
renderItemStatusMessage("ended", "assessment.item.status.finished", sb, translator);
} else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
renderItemStatusMessage("invalid", "assessment.item.status.needsAttention", sb, translator);
} else if (itemSessionState.isResponded() || itemSessionState.hasUncommittedResponseValues()) {
renderItemStatusMessage("answered", "assessment.item.status.answered", sb, translator);
} else if (itemSessionState.getEntryTime() != null) {
renderItemStatusMessage("notAnswered", "assessment.item.status.notAnswered", sb, translator);
} else {
renderItemStatusMessage("notPresented", "assessment.item.status.notSeen", sb, translator);
}
sb.append("</button>");
sb.append("</li>");
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderReviewAssessmentItem.
private void renderReviewAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
EffectiveItemSessionControl itemSessionControl = itemNode.getEffectiveItemSessionControl();
// <xsl:variable name="reviewable" select="@allowReview='true' or @showFeedback='true'" as="xs:boolean"/>
boolean reviewable = itemSessionControl.isAllowReview() || itemSessionControl.isShowFeedback();
// <xsl:variable name="itemSessionState" select="$testSessionState/qw:item[@key=current()/@key]/qw:itemSessionState" as="element(qw:itemSessionState)"/>
ItemSessionState itemSessionState = component.getTestSessionController().getTestSessionState().getItemSessionStates().get(itemNode.getKey());
// <xsl:if test="$currentTestPart/@navigationMode='nonlinear' or exists($itemSessionState/@entryTime)">
TestPart currentTestPart = component.getTestPart(component.getCurrentTestPartNode().getIdentifier());
if (currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR || itemSessionState.getEntryTime() != null) {
sb.append("<li class='o_assessmentitem'>");
sb.append("<button type='button' onclick=\"");
String key = itemNode.getKey().toString();
sb.append(FormJSHelper.getXHRFnCallFor(component.getQtiItem(), true, true, new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key)));
sb.append(";\" class='btn btn-default' ").append(" disabled", !reviewable).append("><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
if (!reviewable) {
renderItemStatusMessage("reviewNotAllowed", "assessment.item.status.reviewNot", sb, translator);
} else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
renderItemStatusMessage("reviewInvalid", "assessment.item.status.reviewInvalidAnswer", sb, translator);
} else if (itemSessionState.isResponded()) {
renderItemStatusMessage("review", "assessment.item.status.review", sb, translator);
} else if (itemSessionState.getEntryTime() != null) {
renderItemStatusMessage("reviewNotAnswered", "assessment.item.status.reviewNotAnswered", sb, translator);
} else {
renderItemStatusMessage("reviewNotSeen", "assessment.item.status.reviewNotSeen", sb, translator);
}
sb.append("</button></li>");
}
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponent method getResponseUniqueIdentifier.
@Override
public String getResponseUniqueIdentifier(ItemSessionState itemSessionState, Interaction interaction) {
TestPlanNodeKey tpnk = null;
for (Map.Entry<TestPlanNodeKey, ItemSessionState> entry : testSessionController.getTestSessionState().getItemSessionStates().entrySet()) {
if (entry.getValue() == itemSessionState) {
tpnk = entry.getKey();
break;
}
}
String id = "oo" + (tpnk.toString().replace(":", "_")) + "_" + interaction.getResponseIdentifier().toString();
responseIdentifiersMap.put(id, interaction);
return id;
}
Aggregations