use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class AssessmentTestComponent method isItemFeedbackAllowed.
// <xsl:if test="$itemFeedbackAllowed and $sessionStatus='final'">
// <xsl:variable name="itemFeedbackAllowed" as="xs:boolean"
// select="if ($reviewMode)
// then (/qti:assessentItem/@adaptive='true' or $showFeedback)
// else (not($solutionMode))"/>
public boolean isItemFeedbackAllowed(TestPlanNode itemNode, AssessmentItem assessmentItem, RenderingRequest options) {
ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
boolean itemFeedbackAllowed = false;
if (itemSessionState.getSessionStatus() == SessionStatus.FINAL) {
if (options.isReviewMode()) {
if (assessmentItem.getAdaptive() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
itemFeedbackAllowed = true;
}
} else if (!options.isSolutionMode()) {
itemFeedbackAllowed = true;
}
}
return itemFeedbackAllowed;
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState 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.ItemSessionState in project openolat by klemens.
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 klemens.
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 klemens.
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>");
}
Aggregations