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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.3.7
    • Fix Version/s: 3.5.4
    • Component/s: Module: Questionnaire
    • Labels:
      None

      Description

      Given a Radio Button question with the following possible answers:

      Cat
      !other
      !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

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Jan/19