"Numeric Response" questions (FIN): validation error

Description

Samigo generates a stack trace when instructor types a FIN question answer key without the close bracket (}).

Steps to reproduce the issue:

1. Create a new assessment.
2. Add a FIN question to the assessment with that question text:

"Follow the sequence 1, 2, 3, 4, { "
3. Try to save the question. Samigo generates the next stack trace:

"org.sakaiproject.portal.api.PortalHandlerException: org.sakaiproject.tool.api.ToolException: javax.servlet.ServletException: String index out of range: -101
at org.sakaiproject.portal.charon.handlers.ToolHandler.doPost(ToolHandler.java:75)
caused by: org.sakaiproject.tool.api.ToolException: javax.servlet.ServletException: String index out of range: -101
at org.sakaiproject.portal.charon.SkinnableCharonPortal.forwardTool(SkinnableCharonPortal.java:1581)
caused by: javax.servlet.ServletException: String index out of range: -101
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -101
at java.lang.String.substring(String.java:1911)
at org.sakaiproject.tool.assessment.jsf.validator.FinQuestionValidator.validate(FinQuestionValidator.java:58)
at javax.faces.component.UIInput.validateValue(UIInput.java:801)
at javax.faces.component.UIInput.validate(UIInput.java:665)
at javax.faces.component.UIInput.executeValidate(UIInput.java:869)
at javax.faces.component.UIInput.processValidators(UIInput.java:432)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:932)
at javax.faces.component.UIForm.processValidators(UIForm.java:190)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:932)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:362)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:98)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)..."

Attachments

1
  • 23 Jun 2015, 02:40 PM

relates to

Activity

Show:

Hudson CI Server August 5, 2015 at 9:20 PM

SUCCESS: Integrated in sakai-10-java-1.7 #221 (See http://builds.sakaiproject.org:8080/job/sakai-10-java-1.7/221/)
https://sakaiproject.atlassian.net/browse/SAM-2565#icft=SAM-2565 merge PR 719 from git (enietzel@anisakai.com: rev 320402)

Angel Nueda Lozano July 6, 2015 at 3:17 AM

Tested in https://trunk-mysql.nightly.sakaiproject.org
It works as expected

Juanjo Meroño June 24, 2015 at 2:27 AM

Take a look at this PR that solves the issue:
https://github.com/sakaiproject/sakai/pull/719/files

Former user June 23, 2015 at 2:40 PM

I looked at this briefly in our 10.2 installation and it seemed to me that the problem here is that the validation code responsible for checking the text between curly braces (samigo-app/src/java/org/sakaiproject/tool/assessment/jsf/validator/FinQuestionValidator.java, method validate) is executed before the code responsible for checking the syntax (and presence) of the braces themselves (samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/author/ItemAddListener.java, method isErrorFIN). The former has no logic to check the brace syntax, and this exception is thrown when it finds no closing brace (thus a string index of -1) and attempts to fetch a substring between a non-zero index and that.

I wrote a 'quick-fix' to simply catch this exception in the FinQuestionValidator.java validation code so that it'll let the brace syntax checking do it's job and catch these cases. Hacky, but it works. I've attached this patch in case anyone wants it (SAM-2565_uva-10.2-exception-catch.patch).

I expect a better fix would be to reverse the order that these checks happen, but I don't know how to do that and we wanted a fix ASAP.

Alexandre Ballesté Crevillén June 22, 2015 at 1:13 AM

Tested in sakai-trunk.atica.um.es, works as described.

Fixed

Details

Priority

Affects versions

Fix versions

Assignee

Reporter

Labels

Created May 19, 2015 at 3:31 AM
Updated April 17, 2018 at 8:26 AM
Resolved June 25, 2015 at 5:24 AM