use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class CorrectionAssessmentItemListController method doSelect.
private void doSelect(UserRequest ureq, AssessmentItemListEntry listEntry, List<? extends AssessmentItemListEntry> selectedItemSessions) {
removeAsListenerAndDispose(identityItemCtrl);
doUnlock();
AssessmentItemRef itemRef = listEntry.getItemRef();
AssessmentItemSession reloadItemSession = null;
if (listEntry.getItemSession() != null) {
reloadItemSession = qtiService.getAssessmentItemSession(listEntry.getItemSession());
}
// lock on item, need to check the lock on identity / test
String lockSubKey = "item-" + listEntry.getAssessedIdentity().getKey() + "-" + listEntry.getItemRef().getIdentifier().toString();
OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
if (lockResult.isSuccess()) {
Identity assessedIdentity = listEntry.getAssessedIdentity();
AssessmentTestSession candidateSession = listEntry.getTestSession();
TestSessionState testSessionState = qtiService.loadTestSessionState(listEntry.getTestSession());
List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
if (nodes.size() == 1) {
TestPlanNode itemNode = nodes.get(0);
ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
itemCorrection.setItemSession(reloadItemSession);
identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, listEntry, selectedItemSessions, model);
listenTo(identityItemCtrl);
updatePreviousNext();
stackPanel.pushController(listEntry.getLabel(), identityItemCtrl);
}
} else {
String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
}
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class AssessmentTreeComponentRenderer method renderItemStatus.
private void renderItemStatus(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator, RenderingRequest options) {
ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
renderItemStatus(sb, itemSessionState, options, translator);
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class AssessmentTreeComponentRenderer method renderAssessmentItemAttempts.
private void renderAssessmentItemAttempts(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
// attempts
int numOfAttempts = itemSessionState.getNumAttempts();
int maxAttempts = 0;
if (itemProcessingContext instanceof ItemSessionController) {
ItemSessionController itemSessionController = (ItemSessionController) itemProcessingContext;
maxAttempts = itemSessionController.getItemSessionControllerSettings().getMaxAttempts();
}
sb.append("<span class='o_assessmentitem_attempts ");
if (maxAttempts > 0) {
if (maxAttempts - numOfAttempts > 0) {
sb.append("o_assessmentitem_attempts_limited");
} else {
sb.append("o_assessmentitem_attempts_nomore");
}
String title = translator.translate("attemptsleft", new String[] { Integer.toString((maxAttempts - numOfAttempts)) });
sb.append("' title=\"").append(StringHelper.escapeHtml(title)).append("\">");
sb.append(numOfAttempts).append(" / ").append(Integer.toString(maxAttempts));
} else {
sb.append("'>").append(numOfAttempts);
}
sb.append("</span>");
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class FeedbackResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FeedbackResultComponent cmp = (FeedbackResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
sb.append("<div class='modalFeedback'>");
renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
sb.append("</div>");
}
}
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class QTI21ItemBodyController method createNewItemSessionStateAndController.
private ItemSessionController createNewItemSessionStateAndController() {
/* Resolve the underlying JQTI+ object */
final ItemProcessingMap itemProcessingMap = new ItemProcessingInitializer(resolvedAssessmentItem, true).initialize();
/* Create fresh state for session */
final ItemSessionState itemSessionState = new ItemSessionState();
final ItemSessionControllerSettings itemSessionControllerSettings = new ItemSessionControllerSettings();
itemSessionControllerSettings.setTemplateProcessingLimit(25);
itemSessionControllerSettings.setMaxAttempts(10);
/* Create controller and wire up notification recorder */
final ItemSessionController sessionController = new ItemSessionController(qtiService.jqtiExtensionManager(), itemSessionControllerSettings, itemProcessingMap, itemSessionState);
sessionController.addNotificationListener(new NotificationRecorder(NotificationLevel.ERROR));
sessionController.initialize(new Date());
return sessionController;
}
Aggregations