use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.
the class QTI21ServiceImpl method resumeItem.
private void resumeItem(TestPlanNodeKey lastEntryItemKey, TestSessionState testSessionState) {
TestPlan plan = testSessionState.getTestPlan();
Date now = new Date();
for (TestPlanNode currentNode = plan.getNode(lastEntryItemKey); currentNode != null; currentNode = currentNode.getParent()) {
TestNodeType type = currentNode.getTestNodeType();
TestPlanNodeKey currentNodeKey = currentNode.getKey();
switch(type) {
case TEST_PART:
{
TestPartSessionState state = testSessionState.getTestPartSessionStates().get(currentNodeKey);
if (state != null) {
state.setDurationIntervalStartTime(now);
}
break;
}
case ASSESSMENT_SECTION:
{
AssessmentSectionSessionState sessionState = testSessionState.getAssessmentSectionSessionStates().get(currentNodeKey);
if (sessionState != null) {
sessionState.setDurationIntervalStartTime(now);
}
break;
}
case ASSESSMENT_ITEM_REF:
{
ItemSessionState itemState = testSessionState.getItemSessionStates().get(currentNodeKey);
if (itemState != null) {
itemState.setDurationIntervalStartTime(now);
}
break;
}
default:
{
// root doesn't match any session state
break;
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.
the class AssessmentTestComponent method getCurrentTestPartNode.
public TestPlanNode getCurrentTestPartNode() {
TestSessionState sessionState = getTestSessionController().getTestSessionState();
TestPlanNodeKey testPlanNodeKey = sessionState.getCurrentTestPartKey();
return sessionState.getTestPlan().getNode(testPlanNodeKey);
}
use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.
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;
}
use of uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey in project openolat by klemens.
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 klemens.
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);
}
Aggregations