use of uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl 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.EffectiveItemSessionControl 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>");
}
use of uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl in project openolat by klemens.
the class AssessmentTestComponentRenderer method renderReviewAssessmentItem.
private void renderReviewAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
EffectiveItemSessionControl itemSessionControl = itemNode.getEffectiveItemSessionControl();
// <xsl:variable name="reviewable" select="@allowReview='true' or @showFeedback='true'" as="xs:boolean"/>
boolean reviewable = itemSessionControl.isAllowReview() || itemSessionControl.isShowFeedback();
// <xsl:variable name="itemSessionState" select="$testSessionState/qw:item[@key=current()/@key]/qw:itemSessionState" as="element(qw:itemSessionState)"/>
ItemSessionState itemSessionState = component.getTestSessionController().getTestSessionState().getItemSessionStates().get(itemNode.getKey());
// <xsl:if test="$currentTestPart/@navigationMode='nonlinear' or exists($itemSessionState/@entryTime)">
TestPart currentTestPart = component.getTestPart(component.getCurrentTestPartNode().getIdentifier());
if (currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR || itemSessionState.getEntryTime() != null) {
sb.append("<li class='o_assessmentitem'>");
sb.append("<button type='button' onclick=\"");
String key = itemNode.getKey().toString();
sb.append(FormJSHelper.getXHRFnCallFor(component.getQtiItem(), true, true, new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key)));
sb.append(";\" class='btn btn-default' ").append(" disabled", !reviewable).append("><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
if (!reviewable) {
renderItemStatusMessage("reviewNotAllowed", "assessment.item.status.reviewNot", sb, translator);
} else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
renderItemStatusMessage("reviewInvalid", "assessment.item.status.reviewInvalidAnswer", sb, translator);
} else if (itemSessionState.isResponded()) {
renderItemStatusMessage("review", "assessment.item.status.review", sb, translator);
} else if (itemSessionState.getEntryTime() != null) {
renderItemStatusMessage("reviewNotAnswered", "assessment.item.status.reviewNotAnswered", sb, translator);
} else {
renderItemStatusMessage("reviewNotSeen", "assessment.item.status.reviewNotSeen", sb, translator);
}
sb.append("</button></li>");
}
}
use of uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderReviewAssessmentItem.
private void renderReviewAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
EffectiveItemSessionControl itemSessionControl = itemNode.getEffectiveItemSessionControl();
// <xsl:variable name="reviewable" select="@allowReview='true' or @showFeedback='true'" as="xs:boolean"/>
boolean reviewable = itemSessionControl.isAllowReview() || itemSessionControl.isShowFeedback();
// <xsl:variable name="itemSessionState" select="$testSessionState/qw:item[@key=current()/@key]/qw:itemSessionState" as="element(qw:itemSessionState)"/>
ItemSessionState itemSessionState = component.getTestSessionController().getTestSessionState().getItemSessionStates().get(itemNode.getKey());
// <xsl:if test="$currentTestPart/@navigationMode='nonlinear' or exists($itemSessionState/@entryTime)">
TestPart currentTestPart = component.getTestPart(component.getCurrentTestPartNode().getIdentifier());
if (currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR || itemSessionState.getEntryTime() != null) {
sb.append("<li class='o_assessmentitem'>");
sb.append("<button type='button' onclick=\"");
String key = itemNode.getKey().toString();
sb.append(FormJSHelper.getXHRFnCallFor(component.getQtiItem(), true, true, new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key)));
sb.append(";\" class='btn btn-default' ").append(" disabled", !reviewable).append("><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
if (!reviewable) {
renderItemStatusMessage("reviewNotAllowed", "assessment.item.status.reviewNot", sb, translator);
} else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
renderItemStatusMessage("reviewInvalid", "assessment.item.status.reviewInvalidAnswer", sb, translator);
} else if (itemSessionState.isResponded()) {
renderItemStatusMessage("review", "assessment.item.status.review", sb, translator);
} else if (itemSessionState.getEntryTime() != null) {
renderItemStatusMessage("reviewNotAnswered", "assessment.item.status.reviewNotAnswered", sb, translator);
} else {
renderItemStatusMessage("reviewNotSeen", "assessment.item.status.reviewNotSeen", sb, translator);
}
sb.append("</button></li>");
}
}
Aggregations