Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-36826

When the question/answer body contains the control character, such as ctrl-A, ctrl-K, ctrl-M, etc. The assessment can not be exported successfully

    Details

    • Type: Bug
    • Status: RESOLVED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.x
    • Fix Version/s: 2.8.0
    • Labels:
      None
    • Environment:
      Mac OSX, mysql DB
    • Previous Issue Keys:
      SAK-17420, SAM-628

      Description

      In tests/quizzes tool, when you export the assessment whose question or answer text body contains the control characters, such as ctrl-K, ctrl-M, ctrl-A etc(the ascii code of those characters <32 or =127), or "]]>" you will see the XML not well formatted - parse error. And the action of exporting assessment will fail.

      The way to recreate the problem is tricky, you somehow has to insert those control characters in your question or answer or description of the assessment. Then you will see the problem.

      The problem is that you cannot enclose those special chars in <![CDATA[...]]> . The solution is that you need to manually translate them to XML codes, and break one <![CDATA[....ctrl-k..]]> into
      <![CDATA[..]]>&#(int)char("K")<![CDATA[...]]>

      Here is the function:

      private String convertStrforCDATA(String myString)
      {

      StringBuffer sbuff = new StringBuffer("<![CDATA[");
      String sTemp = null;

      String escapeStr = myString.replaceAll("]]>", "]]>");

      for (int i = 0; i < escapeStr.length(); i++){
      if (escapeStr.charAt < 32 || escapeStr.charAt == 127)

      { sTemp = "]]>&#"+ (int)escapeStr.charAt(i)+ ";<![CDATA["; }

      else

      { sTemp = Character.toString(escapeStr.charAt(i)); }

      sbuff.append(sTemp);
      sTemp =null;
      }
      sbuff.append("]]>");
      return sbuff.toString();

      }

      Call this function before each <![CDATA[ in ItemHelper12Impl.java and AssessmentHelperBase.java
      Will provide the patch files later on.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                kimhuang Kim Huang (Inactive)
                Reporter:
                kimhuang Kim Huang (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code