Skip to content
Snippets Groups Projects
Commit d7868b18 authored by srosse's avatar srosse
Browse files

OO-3956: correction help for text entry interaction

parent daa86444
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 15 deletions
......@@ -177,16 +177,14 @@ public class CorrectionIdentityInteractionsController extends FormBasicControlle
AssessmentTestSession testSession = correction.getTestSession();
TestSessionState testSessionState = correction.getTestSessionState();
answerItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
answerItem = initFormInteraction(testPlanNodeKey, testSessionState, testSession, formLayout, true);
formLayout.add("answer", answerItem);
viewSolutionButton = uifactory.addFormLink("view.solution", formLayout);
viewSolutionButton.setIconLeftCSS("o_icon o_icon_open_togglebox");
viewSolutionButton.setVisible(hasSolution());
solutionItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
solutionItem = initFormInteraction(testPlanNodeKey, testSessionState, testSession, formLayout, false);
solutionItem.setVisible(false);
solutionItem.setShowSolution(true);
formLayout.add("solution", solutionItem);
......@@ -347,8 +345,9 @@ public class CorrectionIdentityInteractionsController extends FormBasicControlle
return sb.toString();
}
private ItemBodyResultFormItem initFormExtendedTextInteraction(TestPlanNodeKey testPlanNodeKey,
TestSessionState testSessionState, AssessmentTestSession assessmentTestSession, FormItemContainer layoutCont) {
private ItemBodyResultFormItem initFormInteraction(TestPlanNodeKey testPlanNodeKey,
TestSessionState testSessionState, AssessmentTestSession assessmentTestSession,
FormItemContainer layoutCont, boolean correctionHelp) {
ItemSessionState sessionState = testSessionState.getItemSessionStates().get(testPlanNodeKey);
......@@ -360,6 +359,7 @@ public class CorrectionIdentityInteractionsController extends FormBasicControlle
responseFormItem.setResourceLocator(inputResourceLocator);
responseFormItem.setAssessmentObjectUri(assessmentObjectUri);
responseFormItem.setMapperUri(mapperUri);
responseFormItem.setCorrectionHelp(correctionHelp);
layoutCont.add(responseFormItem);
return responseFormItem;
}
......
......@@ -56,9 +56,10 @@ public abstract class AssessmentObjectComponent extends AbstractComponent implem
private Context context;
private final boolean mathAssess;
private boolean hideFeedbacks = false;
private boolean correctionHelp = false;
private boolean maxScoreAssessmentItem = false;
private final boolean mathAssess;
private String mapperUri;
private String submissionMapperUri;
......@@ -118,6 +119,14 @@ public abstract class AssessmentObjectComponent extends AbstractComponent implem
this.maxScoreAssessmentItem = maxScoreAssessmentItem;
}
public boolean isCorrectionHelp() {
return correctionHelp;
}
public void setCorrectionHelp(boolean correctionHelp) {
this.correctionHelp = correctionHelp;
}
public abstract String getResponseUniqueIdentifier(ItemSessionState itemSessionState, Interaction interaction);
public abstract Interaction getInteractionOfResponseUniqueIdentifier(String responseUniqueId);
......
......@@ -1015,6 +1015,7 @@ public abstract class AssessmentObjectComponentRenderer extends DefaultComponent
ctx.put("itemSessionState", itemSessionState);
ctx.put("isItemSessionOpen", component.isItemSessionOpen(itemSessionState, renderer.isSolutionMode()));
ctx.put("isItemSessionEnded", component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode()));
ctx.put("isCorrectionHelp", component.isCorrectionHelp());
Renderer fr = Renderer.getInstance(component, translator, ubu, new RenderResult(), renderer.getGlobalSettings());
AssessmentRenderer fHints = renderer.newHints(fr);
......
......@@ -115,6 +115,14 @@ public abstract class AssessmentObjectFormItem extends FormItemImpl implements F
getComponent().setCandidateSessionContext(candidateSessionContext);
}
public boolean isCorrectionHelp() {
return getComponent().isCorrectionHelp();
}
public void setCorrectionHelp(boolean enable) {
getComponent().setCorrectionHelp(enable);
}
protected Map<Identifier, StringResponseData> extractStringResponseData() {
final Map<Identifier, StringResponseData> responseMap = new HashMap<>();
......
......@@ -39,6 +39,8 @@ import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.ims.qti21.AssessmentTestSession;
import org.olat.ims.qti21.manager.CorrectResponsesUtil;
import org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry;
import org.olat.ims.qti21.ui.CandidateSessionContext;
import uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute;
......@@ -67,6 +69,7 @@ import uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice;
import uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg;
......@@ -587,16 +590,30 @@ public class AssessmentObjectVelocityRenderDecorator extends VelocityRenderDecor
public String getResponseValueAsBase64(Identifier identifier) {
AssessmentTestSession assessmentTestSession = avc.getCandidateSessionContext().getCandidateSession();
return AssessmentRenderFunctions.getResponseValueAsBase64(assessmentItem, assessmentTestSession, itemSessionState, identifier, isSolutionMode());
}
public ResponseDeclaration getResponseDeclaration(Identifier identifier) {
return AssessmentRenderFunctions.getResponseDeclaration(assessmentItem, identifier);
}
public Boolean isCorrectTextEntry(TextEntryInteraction textEntry) {
if(textEntry == null) return null;
Value val = getResponseValue(textEntry.getResponseIdentifier());
if(val == null) {
val = NullValue.INSTANCE;
}
String stringuifiedResponses = toString(val);
AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(assessmentItem, textEntry);
stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
boolean correct = correctAnswers.match(stringuifiedResponses);
return Boolean.valueOf(correct);
}
public String renderClassAttr(BodyElement block) {
List<String> classAttr = block.getClassAttr();
if(classAttr != null && classAttr.size() > 0) {
if(classAttr != null && !classAttr.isEmpty()) {
for(String attr:classAttr) {
if(target.getLastChar() != ' ') target.append(" ");
target.append(attr);
......
......@@ -103,6 +103,14 @@ public class AssessmentTestFormItem extends AssessmentObjectFormItem {
public void setMaxScoreAssessmentItem(boolean maxScoreAssessmentItem) {
component.setMaxScoreAssessmentItem(maxScoreAssessmentItem);
}
public boolean isCorrectionHelp() {
return component.isCorrectionHelp();
}
public void setCorrectionHelp(boolean correctionHelp) {
component.setCorrectionHelp(correctionHelp);
}
public ResolvedAssessmentTest getResolvedAssessmentTest() {
return component.getResolvedAssessmentTest();
......
......@@ -8,6 +8,7 @@
#set($checkJavaScript = $r.checkJavaScript($responseDeclaration,$interaction.patternmask))
<input name="qtiworks_presented_${responseIdentifier}" type="hidden" value="1"/>
<span class="$localName">
#if($r.isTrue($isCorrectionHelp))<i class="o_icon #if($r.isCorrectTextEntry($interaction)) o_icon_correct_response #else o_icon_incorrect_response #end"> </i> #end
<input id="od_${responseIdentifier}" type="text" name="qtiworks_response_${responseIdentifier}" #if($responseInputString && !$responseInputString.isEmpty()) value="$r.escapeHtml($responseInputString)" #else value="" #end #if(!$r.isItemSessionEnded()) $r.placeholder($interaction) #end #if($r.isItemSessionEnded()) disabled #end #if($isBadResponse) class='badResponse' #end #if($interaction.expectedLength) size='$interaction.expectedLength' #end #if($checks && $checks.size() > 0) onchange='$checkJavaScript' #end autocomplete="off" required="required"/>
#if($isBadResponse)
<span class="badResponse">
......
......@@ -90,6 +90,7 @@ $fa-css-prefix: "o_icon" !default;
.o_icon_compulsory:before { content: $fa-var-asterisk; }
.o_icon_content_popup:before { content: $fa-var-external-link; }
.o_icon_correct_answer:before { content: $fa-var-check; color: $brand-success; }
.o_icon_correct_response:before { content: $fa-var-check-circle-o; color: $brand-success; }
.o_icon_correction:before { content: $fa-var-pencil;}
.o_icon_customize:before { content: $fa-var-gear;}
.o_icon_delete_item:before { content: $fa-var-trash;}
......@@ -129,6 +130,7 @@ $fa-css-prefix: "o_icon" !default;
.o_icon_impress:before { content: $fa-var-info-circle; }
.o_icon_important:before { content: $fa-var-exclamation-triangle; color: $brand-warning;}
.o_icon_import:before { content: $fa-var-upload; }
.o_icon_incorrect_response:before { content: $fa-var-times-circle-o; color: $brand-danger; }
.o_icon_info:before { content: $fa-var-info-circle; color: $brand-info}
.o_icon_info_msg:before { content: $fa-var-exclamation-circle; color: $brand-danger}
.o_icon_info_resource:before { content: $fa-var-info-circle;}
......
This diff is collapsed.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment