Skip to content

Commit

Permalink
SAK-41653 Student response in Matching questions with images shows HT…
Browse files Browse the repository at this point in the history
…ML code instead of images (sakaiproject#6854)
  • Loading branch information
Miguel Pellicer authored and juanjmerono committed May 2, 2019
1 parent ad2a4a5 commit a7e91d1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.sakaiproject.tool.assessment.jsf.convert;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import org.apache.commons.text.StringEscapeUtils;

@FacesConverter("org.sakaiproject.tool.assessment.jsf.convert.AnswerHTMLConverter")
public class AnswerHTMLConverter implements Converter {

public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {

return getAsString(arg0, arg1, arg2);
}

public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
String text = (String)arg2;
if (text == null) return null;

return StringEscapeUtils.unescapeHtml4(text);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import org.sakaiproject.util.ResourceLoader;

@FacesConverter("org.sakaiproject.tool.assessment.jsf.convert.AnswerSurveyConverter")
public class AnswerSurveyConverter implements Converter {

private static ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.TimeZone;

import javax.faces.convert.DateTimeConverter;
import javax.faces.convert.FacesConverter;

import org.sakaiproject.time.cover.TimeService;
import org.sakaiproject.util.ResourceLoader;
Expand All @@ -12,6 +13,7 @@
* This class is a wrapper for {@link DateTimeConverter}.<br>
* The locale and time zone by Sakai preferences are used as a default.
*/
@FacesConverter("org.sakaiproject.tool.assessment.jsf.convert.DateTimeConverterWrap")
public class DateTimeConverterWrap extends DateTimeConverter {

@Override
Expand Down
14 changes: 0 additions & 14 deletions samigo/samigo-app/src/webapp/WEB-INF/faces-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1450,19 +1450,5 @@
<validator-id>finQuestionValidator</validator-id>
<validator-class>org.sakaiproject.tool.assessment.jsf.validator.FinQuestionValidator</validator-class>
</validator>

<converter>
<converter-id>javax.faces.DateTime</converter-id>
<converter-class>org.sakaiproject.tool.assessment.jsf.convert.DateTimeConverterWrap</converter-class>
</converter>

<converter>
<converter-id>
org.sakaiproject.tool.assessment.jsf.convert.AnswerSurveyConverter
</converter-id>
<converter-class>
org.sakaiproject.tool.assessment.jsf.convert.AnswerSurveyConverter
</converter-class>
</converter>

</faces-config>
35 changes: 20 additions & 15 deletions samigo/samigo-app/src/webapp/jsf/evaluation/questionScore.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -941,10 +941,15 @@ $Id$
</h:panelGroup>
</f:facet>
<!-- display of answer to file upload question is diffenent from other types - daisyf -->
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '6' && questionScores.typeId != '7' && questionScores.typeId != '5' && questionScores.typeId != '16'}" >
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '1' and questionScores.typeId != '2' and questionScores.typeId != '9' and questionScores.typeId != '12' and questionScores.typeId != '6' && questionScores.typeId != '7' && questionScores.typeId != '5' && questionScores.typeId != '16'}" >
<f:converter converterId="org.sakaiproject.tool.assessment.jsf.convert.AnswerSurveyConverter" />
</h:outputText>


<%-- Multiple choice, Multiple correct, Multiple single selection and matching questions --%>
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '9' || questionScores.typeId == '12'}">
<f:converter converterId="org.sakaiproject.tool.assessment.jsf.convert.AnswerHTMLConverter" />
</h:outputText>

<h:panelGroup rendered="#{questionScores.selectedSARationaleView == '1' && questionScores.typeId == '5'}">
<h:outputText value="#{description.answer}" escape="false"/>
<h:outputLink title="#{evaluationMessages.t_fullShortAnswer}" value="#" onclick="window.open('/portal/tool/#{requestScope['sakai.tool.placement.id']}/jsf/evaluation/fullShortAnswer.faces?idString=#{description.assessmentGradingId}','fullShortAnswer','width=600,height=600,scrollbars=yes, resizable=yes');" onkeypress="window.open('/portal/tool/#{requestScope['sakai.tool.placement.id']}/jsf/evaluation/fullShortAnswer.faces?idString=#{description.assessmentGradingId}','fullShortAnswer','width=600,height=600,scrollbars=yes, resizable=yes');">
Expand All @@ -965,16 +970,7 @@ $Id$
<h:panelGroup rendered="#{(questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '12' || questionScores.typeId == '4') && description.rationale ne '' && questionScores.selectedSARationaleView == '2'}">
<h:outputText escape="false" value="#{description.rationale}"/>
</h:panelGroup>



<%--
<h:outputLink title="#{evaluationMessages.t_rationale}"
rendered="#{(questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '12 || questionScores.typeId == '4') && description.rationale ne ''}"
value="#" onclick="javascript:window.alert('#{description.rationale}');" onkeypress="javascript:window.alert('#{description.rationale}');" >
<h:outputText value="(#{evaluationMessages.click_rationale})"/>
</h:outputLink>
--%>
<h:panelGroup rendered="#{questionScores.typeId == '6'}">
<f:subview id="displayFileUpload2">
<%@ include file="/jsf/evaluation/item/displayFileUploadAnswer.jsp" %>
Expand Down Expand Up @@ -1016,10 +1012,15 @@ $Id$
</h:commandLink>
</h:panelGroup>
</f:facet>
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '6' and questionScores.typeId != '7' && questionScores.typeId != '5' and questionScores.typeId != '16'}" >
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '1' and questionScores.typeId != '2' and questionScores.typeId != '9' and questionScores.typeId != '12' and questionScores.typeId != '6' and questionScores.typeId != '7' && questionScores.typeId != '5' and questionScores.typeId != '16'}" >
<f:converter converterId="org.sakaiproject.tool.assessment.jsf.convert.AnswerSurveyConverter" />
</h:outputText>

<%-- Multiple choice, Multiple correct, Multiple single selection and matching questions --%>
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '9' || questionScores.typeId == '12'}">
<f:converter converterId="org.sakaiproject.tool.assessment.jsf.convert.AnswerHTMLConverter" />
</h:outputText>

<h:panelGroup rendered="#{questionScores.selectedSARationaleView == '1' && questionScores.typeId == '5'}">
<h:outputText value="#{description.answer}" escape="false"/>
<h:outputLink title="#{evaluationMessages.t_fullShortAnswer}" value="#" onclick="javascript:window.open('fullShortAnswer.faces?idString=#{description.assessmentGradingId}','fullShortAnswer','width=600,height=600,scrollbars=yes, resizable=yes');" onkeypress="javascript:window.open('fullShortAnswer.faces?idString=#{description.assessmentGradingId}','fullShortAnswer','width=600,height=600,scrollbars=yes, resizable=yes');">
Expand All @@ -1043,7 +1044,6 @@ $Id$
<h:outputText escape="false" value="#{description.rationale}"/>
</h:panelGroup>


<h:panelGroup rendered="#{questionScores.typeId == '6'}">
<f:subview id="displayFileUpload3">
<%@ include file="/jsf/evaluation/item/displayFileUploadAnswer.jsp" %>
Expand Down Expand Up @@ -1083,7 +1083,12 @@ $Id$
</h:commandLink>
</h:panelGroup>
</f:facet>
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '6' and questionScores.typeId != '7' && questionScores.typeId != '5' and questionScores.typeId != '16'}" />
<h:outputText value="#{description.answer}" escape="false" rendered="#{questionScores.typeId != '1' and questionScores.typeId != '2' and questionScores.typeId != '9' and questionScores.typeId != '12' and questionScores.typeId != '6' and questionScores.typeId != '7' && questionScores.typeId != '5' and questionScores.typeId != '16'}" />

<%-- Multiple choice, Multiple correct, Multiple single selection and matching questions --%>
<h:outputText value="#{description.answer}" escape="false" rendered="#{ questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '9' || questionScores.typeId == '12'}">
<f:converter converterId="org.sakaiproject.tool.assessment.jsf.convert.AnswerHTMLConverter" />
</h:outputText>

<h:panelGroup rendered="#{questionScores.selectedSARationaleView == '1' && questionScores.typeId == '5'}">
<h:outputText value="#{description.answer}" escape="false"/>
Expand All @@ -1106,7 +1111,7 @@ $Id$
<h:panelGroup rendered="#{(questionScores.typeId == '1' || questionScores.typeId == '2' || questionScores.typeId == '12' || questionScores.typeId == '4') && description.rationale ne '' && questionScores.selectedSARationaleView == '2'}">
<h:outputText escape="false" value="#{description.rationale}"/>
</h:panelGroup>

<h:panelGroup rendered="#{questionScores.typeId == '6'}">
<f:subview id="displayFileUpload4">
<%@ include file="/jsf/evaluation/item/displayFileUploadAnswer.jsp" %>
Expand Down

0 comments on commit a7e91d1

Please sign in to comment.