use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityListController method loadModel.
private void loadModel(boolean reset, boolean lastSessions) {
if (lastSessions) {
model.loadLastSessions();
}
List<AssessmentItemRef> itemRefs = model.getResolvedAssessmentTest().getAssessmentItemRefs();
Map<String, AssessmentItemRef> identifierToItemRefMap = new HashMap<>();
for (AssessmentItemRef itemRef : itemRefs) {
identifierToItemRefMap.put(itemRef.getIdentifier().toString(), itemRef);
}
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);
}
}
int count = 0;
List<CorrectionIdentityRow> rows = new ArrayList<>(model.getNumberOfAssessedIdentities());
Map<Identity, CorrectionIdentityRow> identityToRows = new HashMap<>();
for (Map.Entry<Identity, AssessmentTestSession> entry : model.getLastSessions().entrySet()) {
String user = translate("number.assessed.identity", new String[] { Integer.toString(++count) });
CorrectionIdentityRow row = new CorrectionIdentityRow(user, entry.getKey(), entry.getValue(), userPropertyHandlers, getLocale());
rows.add(row);
identityToRows.put(entry.getKey(), row);
TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
AssessmentItemRef itemRef = identifierToItemRefMap.get(itemRefIdentifier);
AssessmentItemSession itemSession = itemSessionMap.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
appendStatistics(row, itemSession, itemEntry.getValue(), itemRef);
}
}
tableModel.setObjects(rows);
tableEl.reset(reset, reset, true);
}
use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey 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.TestPlanNodeKey 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.TestPlanNodeKey in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderTestEvent.
private void renderTestEvent(TestSessionController testSessionController, AssessmentRenderer renderer, StringOutput target, AssessmentTestComponent component, URLBuilder ubu, Translator translator) {
CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
CandidateTestEventType testEventType = candidateEvent.getTestEventType();
/* If session has terminated, render appropriate state and exit */
final TestSessionState testSessionState = testSessionController.getTestSessionState();
if (candidateSessionContext.isTerminated() || testSessionState.isExited()) {
renderTerminated(target, translator);
} else if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
renderer.setReviewMode(true);
TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
RenderingRequest options = RenderingRequest.getItemReview();
renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
} else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
renderer.setSolutionMode(true);
TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
RenderingRequest options = RenderingRequest.getItemSolution();
renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
} else {
/* Render current state */
final TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
if (testSessionState.isEnded()) {
/* At end of test, so show overall test feedback */
renderTestPartFeedback(renderer, target, component, ubu, translator);
} else if (currentTestPartKey != null) {
final TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
final TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
if (currentItemKey != null) {
/* An item is selected, so render it in appropriate state */
RenderingRequest options = RenderingRequest.getItem(testSessionController);
renderTestItem(renderer, target, component, currentItemKey, ubu, translator, options);
} else {
/* No item selected */
if (currentTestPartSessionState.isEnded()) {
/* testPart has ended, so must be showing testPart feedback */
renderTestPartFeedback(renderer, target, component, ubu, translator);
} else {
/* testPart not ended, so we must be showing the navigation menu in nonlinear mode */
renderNavigation(renderer, target, component, ubu, translator);
}
}
} else {
/* No current testPart == start of multipart test */
renderTestEntry(target, component, translator);
}
}
}
use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project OpenOLAT by OpenOLAT.
the class AssessmentTreeComponentRenderer method renderAssessmentItemLink.
/**
* @param sb
* @param component
* @param itemNode
* @return The event used or null
*/
private Event renderAssessmentItemLink(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
String key = itemNode.getKey().toString();
Form form = component.getQtiItem().getRootForm();
String dispatchId = component.getQtiItem().getFormDispatchId();
TestSessionController testSessionController = component.getTestSessionController();
TestSessionState testSessionState = testSessionController.getTestSessionState();
TestPart testPart = testSessionController.getCurrentTestPart();
TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
Event event;
if (testPart == null || testPart.getNavigationMode() == NavigationMode.NONLINEAR) {
if (testSessionState.isEnded() || currentTestPartSessionState.isEnded()) {
if (itemNode.getEffectiveItemSessionControl().isAllowReview() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
event = Event.reviewItem;
} else {
event = null;
}
} else {
event = Event.selectItem;
}
} else {
event = null;
}
if (event == null) {
sb.append("<span class='o_assessmentitem_nav_disabled'>");
} else {
sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", event.name()), new NameValuePair("item", key))).append(";\" class='o_sel_assessmentitem'>");
}
String title;
if (component.isShowTitles()) {
title = StringHelper.escapeHtml(itemNode.getSectionPartTitle());
} else {
int num = component.getCandidateSessionContext().getNumber(itemNode);
title = translator.translate("question.title", new String[] { Integer.toString(num) });
}
sb.append("<span class='questionTitle'>").append(title).append("</span>");
if (event == null) {
sb.append("</span>");
} else {
sb.append("</a>");
}
return event;
}
Aggregations