Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Matrix mit Mehrfachnennungen

  • Userino
  • Userino's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #200591 by Userino
Matrix mit Mehrfachnennungen was created by Userino
Liebes Forum,

ich möchte eine Matrix mit der Option zur Mehrfachnennung erstellen. Soweit alles klar. Allerdings soll in der Zeile der Mehrfachnennungen auch ein Feld "keine Angabe" exisitieren, wobei die restlichen Felder deaktiviert werden sollen. Schließlich ist es theoretisch nicht sinnvoll neben der Option "keine Angabe" doch eine weitere Angabe zu nennen. Was bisher aber praktisch möglich ist. Gibt es entsprechende Möglichkeiten bei LimeSurvey?

Ich freue mich sehr über Ideen!

Liebe Grüße!

Version 3.22.4+200212
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200600 by Joffm
Replied by Joffm on topic Matrix mit Mehrfachnennungen
Hallo,
die erste und simpelste Lösung ist natürlich die Fragenvalidierung.
Hier kannst Du ja festlegen, dass
WENN das Feld "keine Angabe" ausgewählt wurde, die Gesamtzahl der gewählten Optionen gleich "1" ist.
(((count(self.sq_Y001)==1) and (C2_Y001_X004==1)) OR (C2_Y001_X004!=1)) and
(((count(self.sq_Y002)==1) and (C2_Y002_X004==1)) OR (C2_Y002_X004!=1)) and
(((count(self.sq_Y003)==1) and (C2_Y003_X004==1)) OR (C2_Y003_X004!=1))
...

Wie Du siehst, ist die Y-Achse mit "Y001", "Y002",... kodiert, die X-Achse entsprechend mit "X001", "X002",...






Es gibt auch ein javascript workaround:
Füge dies in den Quellcode der Frage ein:
Code:
<script>
// A jQuery plugin to render column(s) in checkbox arrays exclusive
(function( $ ){
 
  $.fn.cbExclusiveColumns = function(options) {  
 
    var opts = $.extend( {
      //columns: [3,4] // Column(s) to be exclusive (comma-separated) 
    }, options);
 
    return this.each(function() { 
 
      var thisQuestion = $(this)
 
      // Add some classes to the checkbox cells
      $('td.answer-item', thisQuestion).addClass('normal-item');
      $('tr.subquestion-list', thisQuestion).each(function(i) {
        var thisRow = $(this);
        $.each(opts.columns, function(i, val) {
          $('td.answer-item:eq('+(val-1)+')', thisRow).removeClass('normal-item').addClass('exclusive-item');
        });
      });
 
      // A listener on the checkboxes
      $('input[type="checkbox"]', thisQuestion).on('change', function (event) {
        handleExclusive($(this).closest('td'));
      });
 
      function handleExclusive(thisCell) {
 
        var thisRow = $(thisCell).closest('tr');
 
        // Uncheck the appropriate boxes in a row
        if ($(thisCell).hasClass('normal-item')) {
          $('.exclusive-item input[type="checkbox"]', thisRow).prop('checked', false);
          $('.exclusive-item input[type="text"]', thisRow).val('');
        }
        else {
          $('.answer-item', thisRow).not(thisCell).find('input[type="checkbox"]').prop('checked', false);
          $('.answer-item', thisRow).not(thisCell).find('input[type="text"]').val('');
        }
 
        // Check conditions (relevance)
        $('td.answer-item', thisRow).each(function(i) {
          var thisValue = '';
          if($('input[type="checkbox"]', this).is(':checked')) {
            thisValue = 1;
          }
          var thisSGQA = $('input[type="checkbox"]', this).attr('id').replace(/cbox_/, '');
 
          $('input[type="hidden"]', this).attr('value', thisValue);
          fixnum_checkconditions(thisValue, thisSGQA, 'hidden');
        });
      }
    });
 
  };
})( jQuery );
</script> <script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    $('#question{QID}').cbExclusiveColumns({
      columns: [4] // Column(s) to be exclusive (comma-separated)
    });
  });
</script>

Du siehst auch hier, dass Du ganz unten anpassen musst, welche Spalte(n) exklusiv sein sollen.

Viele Erfolg
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
Moderators: Joffm

Lime-years ahead

Online-surveys for every purse and purpose