use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderTestItem.
private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
final TestSessionController testSessionController = component.getTestSessionController();
final TestSessionState testSessionState = testSessionController.getTestSessionState();
String key = itemRefKey.toString();
/* We finally do the transform on the _item_ (NB!) */
sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
// test part feedback 'during'
// test feedback 'during'
TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
renderer.setCandidateCommentAllowed(allowComments);
// write section rubric
renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
// test part -> section -> item
renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
// controls
sb.append("<div class='o_button_group o_assessmentitem_controls'>");
// submit button
final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
Component submit = component.getQtiItem().getSubmitButton().getComponent();
submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
}
// advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
if (options.isAdvanceTestItemAllowed()) {
// TODO need to find if there is a next question
String title = translator.translate("assessment.test.nextQuestion");
renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
}
// nextItem
if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
String title = translator.translate("assessment.test.nextQuestion");
renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
}
// testPartNavigationAllowed"
if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
String title = translator.translate("assessment.test.questionMenu");
renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
}
// endTestPartAllowed
if (options.isEndTestPartAllowed()) {
String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
}
// reviewMode
if (options.isReviewMode()) {
String title = translator.translate("assessment.test.backToTestFeedback");
renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
}
// <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
String title = translator.translate("assessment.solution.show");
renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
}
if (options.isReviewMode() && options.isSolutionMode()) {
String title = translator.translate("assessment.solution.hide");
renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
}
// end controls
sb.append("</div>");
// end assessmentItem
sb.append("</div>");
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderTestItemBody.
private void renderTestItemBody(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, URLBuilder ubu, Translator translator, RenderingRequest options) {
final ItemSessionState itemSessionState = component.getItemSessionState(itemNode.getKey());
URI itemSystemId = itemNode.getItemSystemId();
ResolvedAssessmentItem resolvedAssessmentItem = component.getResolvedAssessmentTest().getResolvedAssessmentItemBySystemIdMap().get(itemSystemId);
if (resolvedAssessmentItem == null) {
log.error("Missing assessment item: " + itemSystemId);
renderMissingItem(sb, translator);
return;
}
final AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
sb.append("<div class='o_assessmentitem_wrapper'>");
// title + status
sb.append("<h4 class='itemTitle'>");
renderItemStatus(sb, itemSessionState, options, translator);
renderMaxScoreItem(sb, component, itemSessionState, translator);
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(title).append("</h4>").append("<div id='itemBody' class='o_qti_item_body clearfix'>");
// render itemBody
assessmentItem.getItemBody().getBlocks().forEach(block -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, block, ubu, translator));
// comment
renderComment(renderer, sb, component, itemSessionState, translator);
// end body
sb.append("</div>");
// Display active modal feedback (only after responseProcessing)
if (component.isItemFeedbackAllowed(itemNode, assessmentItem, options)) {
renderTestItemModalFeedback(renderer, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
}
// end wrapper
sb.append("</div>");
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityInteractionsController method initFormExtendedTextInteraction.
private ItemBodyResultFormItem initFormExtendedTextInteraction(TestPlanNodeKey testPlanNodeKey, TestSessionState testSessionState, AssessmentTestSession assessmentTestSession, FormItemContainer layoutCont) {
ItemSessionState sessionState = testSessionState.getItemSessionStates().get(testPlanNodeKey);
String responseId = "responseItem_" + id + "_" + count++;
ItemBodyResultFormItem responseFormItem = new ItemBodyResultFormItem(responseId, resolvedAssessmentItem);
responseFormItem.setItemSessionState(sessionState);
responseFormItem.setCandidateSessionContext(new TerminatedStaticCandidateSessionContext(assessmentTestSession));
responseFormItem.setResolvedAssessmentTest(resolvedAssessmentTest);
responseFormItem.setResourceLocator(inputResourceLocator);
responseFormItem.setAssessmentObjectUri(assessmentObjectUri);
responseFormItem.setMapperUri(mapperUri);
layoutCont.add(responseFormItem);
return responseFormItem;
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CorrectionIdentityAssessmentItemListController method doSelect.
private void doSelect(UserRequest ureq, CorrectionIdentityAssessmentItemRow row) {
removeAsListenerAndDispose(identityItemCtrl);
doUnlock();
AssessmentItemRef itemRef = row.getItemRef();
TestSessionState testSessionState = qtiService.loadTestSessionState(candidateSession);
List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
AssessmentItemSession reloadItemSession = null;
if (nodes.size() == 1) {
TestPlanNode itemNode = nodes.get(0);
String stringuifiedIdentifier = itemNode.getKey().getIdentifier().toString();
ParentPartItemRefs parentParts = AssessmentTestHelper.getParentSection(itemNode.getKey(), testSessionState, model.getResolvedAssessmentTest());
reloadItemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
}
// lock on item, need to check the lock on identity / test
String lockSubKey = "item-" + reloadItemSession.getKey();
OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
if (lockResult.isSuccess()) {
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);
ResolvedAssessmentItem resolvedAssessmentItem = model.getResolvedAssessmentTest().getResolvedAssessmentItem(itemRef);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, row, tableModel.getObjects(), model);
listenTo(identityItemCtrl);
stackPanel.pushController(assessmentItem.getTitle(), identityItemCtrl);
updatePreviousNext();
}
} else {
String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
}
}
Aggregations