# SAMIGO: Solving problems of calculation pattern

XMLWordPrintable

#### Details

• Bug
• Status: Verified
• Major
• Resolution: Fixed
• 21.1, 20.4, 22.0 [Tentative]
• Hide
1. Import the assessment
2. You should edit the assessment
3. You should edit and save the calculted question

No error appears on log.

2. Fill Instructions
```[[3 * [phi]] ]

Kevin tiene {x} manzanas. Él compra {y} más. Ahora Kevin tiene [[{x}+{y}]]. Jane come {z} manzanas. Kevin tiene ahora {{w}} manzanas.
La fórmula w en el ejemplo anterior se definiría como: {x} + {y} - {z}```
1. Without this patch you can save but a UI warning should appear: 3 * [phi cannot be calculated and you cannot save.
Show
Import the assessment You should edit the assessment You should edit and save the calculted question No error appears on log. — Add a calculated question Fill Instructions [[3 * [phi]] ] Kevin tiene {x} manzanas. Él compra {y} más. Ahora Kevin tiene [[{x}+{y}]]. Jane come {z} manzanas. Kevin tiene ahora {{w}} manzanas. La fórmula w en el ejemplo anterior se definiría como: {x} + {y} - {z} Without this patch you can save but a UI warning should appear: 3 * [phi cannot be calculated and you cannot save.

#### Description

The main problem is that you cannot parse html-level languages ​​with infinite nests with regular expressions.

We need to change the CALCQ_CALCULATION_PATTERN.

The new CALCQ_CALCULATION_PATTERN musn't include all the expression with [[ ]]

Could be something like this:

`\└([^\└\┐]+)\┐? `

Key lines:

We need to replace that [[ for another character (maybe └└ ) and ]] for another different character (maybe ┐┐). Avoid using mathematical characters as opening or closing like * +, etc.

```15-abr-2021 10:23:46.303 WARN [ajp-nio-127.0.0.1-8016-exec-1] org.sakaiproject.portal.charon.handlers.SiteHandler.bufferContent Failed to buffer content.
org.sakaiproject.tool.api.ToolException: javax.servlet.ServletException
at org.sakaiproject.tool.impl.ActiveToolComponent\$MyActiveTool.forward(ActiveToolComponent.java:520)
at org.sakaiproject.portal.charon.SkinnableCharonPortal.forwardTool(SkinnableCharonPortal.java:1500)
at org.sakaiproject.portal.charon.handlers.SiteHandler.doToolBuffer(SiteHandler.java:1262)
at org.sakaiproject.portal.charon.handlers.SiteHandler.bufferContent(SiteHandler.java:1096)
at org.sakaiproject.portal.charon.handlers.SiteHandler.doSite(SiteHandler.java:508)
at org.sakaiproject.portal.charon.handlers.SiteHandler.doGet(SiteHandler.java:280)
at org.sakaiproject.portal.charon.handlers.SiteHandler.doGet(SiteHandler.java:164)
at org.sakaiproject.portal.charon.handlers.WorksiteHandler.doPost(WorksiteHandler.java:69)
at org.sakaiproject.portal.charon.SkinnableCharonPortal.doPost(SkinnableCharonPortal.java:1173)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:475)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:431)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol\$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint\$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
Caused by: javax.servlet.ServletException
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:683)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:426)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.sakaiproject.jsf.util.SamigoJsfTool.dispatch(SamigoJsfTool.java:360)
at org.sakaiproject.jsf2.util.JsfTool.doPost(JsfTool.java:250)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:352)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.sakaiproject.tool.impl.ActiveToolComponent\$MyActiveTool.forward(ActiveToolComponent.java:508)
... 36 more
Caused by: java.lang.StackOverflowError
at java.util.regex.Pattern\$GroupCurly.match(Pattern.java:4421)
at java.util.regex.Pattern\$LazyLoop.match(Pattern.java:4861)
at java.util.regex.Pattern\$GroupTail.match(Pattern.java:4731)
at java.util.regex.Pattern\$LazyLoop.matchInit(Pattern.java:4878)
at java.util.regex.Pattern\$Prolog.match(Pattern.java:4755)
at java.util.regex.Pattern\$GroupCurly.match1(Pattern.java:4504)
at java.util.regex.Pattern\$GroupCurly.match(Pattern.java:4421)
at java.util.regex.Pattern\$LazyLoop.match(Pattern.java:4861)
at java.util.regex.Pattern\$GroupTail.match(Pattern.java:4731)
at java.util.regex.Pattern\$LazyLoop.matchInit(Pattern.java:4878)
at java.util.regex.Pattern\$Prolog.match(Pattern.java:4755)
at java.util.regex.Pattern\$GroupCurly.match1(Pattern.java:4504)
at java.util.regex.Pattern\$GroupCurly.match(Pattern.java:4421)
at java.util.regex.Pattern\$LazyLoop.match(Pattern.java:4861)
at java.util.regex.Pattern\$GroupTail.match(Pattern.java:4731)
at java.util.regex.Pattern\$LazyLoop.matchInit(Pattern.java:4878)
at java.util.regex.Pattern\$Prolog.match(Pattern.java:4755) ```

#### Attachments

1. editing_the_question.png
7.06 MB
2. exported-assessment.xml
90 kB

#### People

Jesus Maria Mendez
Jesus Maria Mendez