Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-7412

Exporting response data for question with multiple !other options doesn't work properly


    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor Minor
    • 3.5.4
    • 3.3.7
    • Module: Questionnaire
    • None

      Given a Radio Button question with the following possible answers:

      !other=Something that squeeks
      !other=Something that bites

      ... & a number of responses selecting each !other option, when exporting the data it's impossible to see which !other option was actually selected

      The following patch resolves this (against 92d950c):

      git diff

      diff --git a/questionnaire.class.php b/questionnaire.class.php
      index 7daab5b..215b4d2 100644
      --- a/questionnaire.class.php
      +++ b/questionnaire.class.php
      @@ -3218,7 +3218,7 @@ class questionnaire {
                           $content = $choicesbyqid[$qid][$responserow->choice_id]->content;
                           if (preg_match('/^!other/', $content)) {
                               // If this has an "other" text, use it.
      -                        $responsetxt = get_string('other', 'questionnaire');
      +                        $responsetxt = preg_replace(["/^!other=/", "/^!other/"], ['', get_string('other', 'questionnaire')], $content);
                               $responsetxt1 = $responserow->response;
                           } else if (($choicecodes == 1) && ($choicetext == 1)) {
                               $responsetxt = $c.' : '.$content;

      This leads to the correct data in the exported file, instead of the generic "Other:" language string as currently used:

      Q01_ANIMAL Q01_ANIMAL_Other
      Something that bites Crocodile
      Something that squeeks Big bird
      Other: Ewok

            mchurch Mike Churchward
            pholden Paul Holden
            0 Vote for this issue
            1 Start watching this issue


                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.