View Issue Details

IDProjectCategoryView StatusLast Update
08490Feature requests[All Projects] Response browsingpublic2019-03-18 18:59
Reporterrjm972Assigned To 
PrioritynormalSeverityfeature 
Status newResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary08490: Do not display unchecked options in multiple choice (checkbox questions
Description

This is a suggestion about displaying the results of multiple choice (i.e., checkbox) questions.

Consider the following questions as an example:

Please indicate what foods you like:

  • Hamburgers
  • Hotdogs
  • Pizza
  • Steak
  • Chicken

Currently, when the survey responses are displayed, multiple choice responses are displayed by repeating the question + all of the available choices + yes (or blank) beside each one. The current response view is as follows:

Please indicate what foods you like:(Hamburgers) Yes
Please indicate what foods you like:(Hotdogs)
Please indicate what foods you like:(Pizza) Yes
Please indicate what foods you like:(Steak) Yes
Please indicate what foods you like:(Chicken)

It would be nice to have the option of displaying the results as follows:

Please indicate what foods you like: Hamburgers
Pizza
Steak

Thanks for considering this!

TagsNo tags attached.

Activities

Jugen

Jugen

2019-01-28 19:52

reporter   ~50331

This looks very similar to a problem I solved, where I wanted something like "Hamburgers, Pizza, Steak" in the detailed admin notification email template.
I created an ExpressionManager function called "listifop", that I would like to submit to be included in em_core_helper.php

The function definition is:
'listifop' => array('exprmgr_listifop', 'LEMlistifop', gT('Return a list of retAttr from sgqa1...sgqaN which pass the criteria (cmpAttr op value)'), 'string listifop(cmpAttr, op, value, retAttr, glue, sgqa1, sgqa2,...,sgqaN)', '', -6),

For example for the above food multiple choice selections you would have: listifop( 'value', '==', 'Y', 'question', ',', that.food.sgqa )

Jugen

Jugen

2019-01-29 08:55

reporter   ~50333

Just to clarify the idea behind the suggested new function "listifop" is that it will basically behave like the countifop function but it's return value will be like that of the implode function.
So it'll be like countifop + implode => listifop

Jugen

Jugen

2019-01-31 16:42

reporter   ~50374

So if there are no objections I'd like to submit a pull request for this with the following code which I have already been using in my survey:

function exprmgr_listifop( $args )
{
$result = "";
$cmpAttr = array_shift($args);
$op = array_shift($args);
$value = array_shift($args);
$retAttr = array_shift($args);
$glue = array_shift($args);

$validAttributes = "/" . ExpressionManager::$RDP_regex_var_attr . "/";
if ( ! preg_match( $validAttributes, $cmpAttr ) ) return $cmpAttr . " not recognized ?!";
if ( ! preg_match( $validAttributes, $retAttr ) ) return $retAttr . " not recognized ?!";

foreach ($args as $sgqa)
{
    $cmpVal = LimeExpressionManager::GetVarAttribute($sgqa,$cmpAttr,null,-1,-1);
    $match = false;

    switch ($op)
    {
        case '==': case 'eq': $match = ($cmpVal == $value); break;
        case '>=': case 'ge': $match = ($cmpVal >= $value); break;
        case '>' : case 'gt': $match = ($cmpVal > $value);  break;
        case '<=': case 'le': $match = ($cmpVal <= $value); break;
        case '<' : case 'lt': $match = ($cmpVal < $value);  break;
        case '!=': case 'ne': $match = ($cmpVal != $value); break;
        case 'RX': try { $match = preg_match( $value, $cmpVal ); }
        catch ( Exception $ex ) { return "Invalid RegEx"; } break;
    }

    if ( $match )
    {
        $retVal = LimeExpressionManager::GetVarAttribute($sgqa,$retAttr,null,-1,-1);
        if ( $result != "" ) $result .= $glue;
        $result .= $retVal;
    }
}

return $result;

}

DenisChenu

DenisChenu

2019-02-01 09:14

developer   ~50381

Where displaying result ?

In export : do your own export
In print answers : can be done in theme

Jugen

Jugen

2019-02-01 09:49

reporter   ~50382

Displaying result in email.

Jugen

Jugen

2019-02-07 15:21

reporter   ~50443

Submitted PR #1215, please review

Jugen

Jugen

2019-03-18 18:59

reporter   ~51042

PR#1215 was accepted, and released in 3.16.1
This issue can now be closed as resolved.

Issue History

Date Modified Username Field Change
2013-12-25 05:09 rjm972 New Issue
2019-01-28 19:52 Jugen Note Added: 50331
2019-01-29 08:55 Jugen Note Added: 50333
2019-01-31 16:42 Jugen Note Added: 50374
2019-02-01 09:14 DenisChenu Note Added: 50381
2019-02-01 09:49 Jugen Note Added: 50382
2019-02-07 15:21 Jugen Note Added: 50443
2019-03-18 18:59 Jugen Note Added: 51042