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

Structural problem with calculated questions in some cases

    XMLWordPrintable

    Details

    • 11 status:
      Resolved
    • Previous Issue Keys:
      SAM-2708
    • Test Plan:
      Hide

      1. Create a calculated question with this question text "

      {VAR1}

      FORM1" and save the question.

      2. Change the question text with "

      {VAR1_CAMBIADA}

      FORM1

      {VAR2} FORM2" and save the question.

      3. Change the question text with "VAR1 {FORM1} {VAR2}

      FORM2

      {VAR3}

      FORM3" and click the "Extract variables and formulas" button.

      4. Introduce the text "

      {FORM1}

      *2" in the "var1" field and save the question.

      5. Try to edit again the question, an error is displayed. The question is no longer available.

      Show
      1. Create a calculated question with this question text " {VAR1} FORM1 " and save the question. 2. Change the question text with " {VAR1_CAMBIADA} FORM1 {VAR2} FORM2 " and save the question. 3. Change the question text with " VAR1 {FORM1} {VAR2} FORM2 {VAR3} FORM3 " and click the "Extract variables and formulas" button. 4. Introduce the text " {FORM1} *2" in the "var1" field and save the question. 5. Try to edit again the question, an error is displayed. The question is no longer available.

      Description

      The calculated questions have 2 kinds of items: variables and formulas. Every item has to have an unique sequence number.

      The problem: There are differents use cases that allow two different items to have the same sequence. The question becomes corrupted when it happens.

      The cause: The sequence number is generated taking into account the number of items instead of the max value of the sequence.

      Example:

      Step 1:

      Calculated question:

       {b} + 1 = {{a}} 

      Internally is stored like

      "a" Sequence 1
      "b" Sequence 2

      Step 2:

      Modify the question:

       {c} + 1 = {{a}} 

      There is a new item "c". The sequence number is calculated taking into account the number of items before adding the new item: 2. Therefore the next sequence number is 3. Internally is stored like

      "a" Sequence 1
      "c" Sequence 3

      Modify the question again:

       {c} + {d} + 1 = {{a}} 

      There is a new item "d". The sequence number is calculated taking into account the number of items before adding the new item: 2. Therefore the next sequence number is 3. Internally is stored like

      "a" Sequence 1
      "c" Sequence 3
      "d" Sequence 3

      This is an error because every item should have an unique sequence number.

      The code lines implicated are: CalculatedQuestionExtractListener.java:174/203

      That kind of problem throws the error below when user tries to open the question:

      2016-01-28 11:44:41,192 ERROR ajp-bio-8017-exec-748 org.sakaiproject.tool.assessment.ui.listener.author.ItemModifyListener - Could not populate ItemBean
      java.lang.NumberFormatException: For input string: "6*{is}/{is}"
      	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1250)
      	at java.lang.Double.valueOf(Double.java:504)
      	at org.sakaiproject.tool.assessment.services.GradingService.determineRandomValuesForRanges(GradingService.java:2909)
      	at org.sakaiproject.tool.assessment.ui.listener.author.CalculatedQuestionExtractListener.validateCalculations(CalculatedQuestionExtractListener.java:430)
      	at org.sakaiproject.tool.assessment.ui.listener.author.ItemModifyListener.populateItemTextForCalculatedQuestion(ItemModifyListener.java:743)
      	at org.sakaiproject.tool.assessment.ui.listener.author.ItemModifyListener.populateItemBean(ItemModifyListener.java:207)
      	at org.sakaiproject.tool.assessment.ui.listener.author.ItemModifyListener.processAction(ItemModifyListener.java:111)
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                raulsv Raúl Sánchez Vegas
                Reporter:
                raulsv Raúl Sánchez Vegas
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code