Welcome to the LimeSurvey Community Forum

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

Class Representative Election

  • Candyman
  • Candyman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #211080 by Candyman
Class Representative Election was created by Candyman
Hi to all of you!

I wanted to create a simple survey for a class representative and it's deputy.

A person which has been given an vote for  class representative should not be visible for class representative deputy.

I used a "matrix by column" and prayed every pupil would be so kind to vote for two different persons. This has not worked well.

A dropdown with names A .... Z and a second dropdown with A .. Z without name e.g. M, which has been voted for class representative was a second thought.

I'm very new to limesurvey and I need a litte bit of input. Reading the manual has not enlighted me. I use Version 3.22.27+200720.

Any kind of help is appreciated. Thanks in advance!

Candyman
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211096 by tpartner
Replied by tpartner on topic Class Representative Election
Use an array-by-column with this sub-question validation:
 
 
Code:
(!is_empty(self.sq_SQ001) AND !is_empty(self.sq_SQ002)) AND (self.sq_SQ001 != self.sq_SQ002)

 

 

Sample survey attached: 

File Attachment:

File Name: limesurvey...5771.lss
File Size:24 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago - 3 years 3 months ago #211105 by Joffm
Replied by Joffm on topic Class Representative Election
Well, 
here are some ideas beyond tpartner's solution which is the easiest.
Of course, both are his creations as well.
 
First you may consider a maxdiff approach
 

Or you could think of something like a cardsort
 

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 3 months ago by Joffm.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211110 by DenisChenu
Replied by DenisChenu on topic Class Representative Election
Max-diff are a QuestionTheme ?
github.com/tpartner?tab=repositories

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211117 by Joffm
Replied by Joffm on topic Class Representative Election
No, it's a javascript and css solution.
Code:
<script type="text/javascript" charset="utf-8">       
function maxDiff(qID, randomize) {
 
    // Identify some elements
    var thisQuestion = $('#question'+qID);
    var thisTable = $('table.subquestion-list:eq(0)', thisQuestion);
 
    // Assign a new question class
    $(thisQuestion).addClass('max-diff-array');
 
    // Move the columns
     $('thead tr:eq(0)', thisTable).prepend($('thead tr:eq(0) th:eq(1)', thisTable));
    $('tr.answers-list', thisTable).each(function(i){
    $('td.answer-item:eq(0)', this).prependTo(this);
    });
 
    // Random rows
    if(randomize) {
        var rowsArr = [];
        $('tr.answers-list', thisTable).each(function(i){
            $(this).attr('data-index', i);
            rowsArr.push(i);
        });
        shuffleArray(rowsArr);
        $(rowsArr).each(function(i){
            $('tbody', thisTable).append($('tr[data-index="'+this+'"]', thisTable));
        });
    }
 
    // Prevent clicking twice in the same row
    $('input[type="radio"]', thisQuestion).on('click', function () {
 
        $('input[type="radio"]', thisQuestion).prop('disabled', false);
        $('input[type="radio"]:checked', thisQuestion).each(function(i) {
            var thisRow = $(this).closest('tr.answers-list');
            $('input[type="radio"]', thisRow).not(this).prop('disabled', true);
        });
    });
 
    // Fix up the row classes
    var rowClass = 1;
    $('tr.answers-list', thisTable).each(function(i) {
        $(this).addClass('array'+(2-(i%2)));
    });
}
function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}
  
  $(document).ready(function(){
        // Call the maxDiff() function
        // Set the second parameter to true for randomized rows
        maxDiff({QID}, true);
    });
</script>
Code:
<style type="text/css">.ls-answers tbody .answertext {
    text-align: center;
}
</style>

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211120 by tpartner
Replied by tpartner on topic Class Representative Election

Max-diff are a QuestionTheme ?

I suppose it could be. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • Candyman
  • Candyman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #211130 by Candyman
Replied by Candyman on topic Class Representative Election
Thanks for your quick response!

I've imported the lss and modified it to my requests.

With a little help ... everything is gettin' better.
The topic has been locked.
  • Candyman
  • Candyman's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 3 months ago #211132 by Candyman
Replied by Candyman on topic Class Representative Election
Wow!

I'll take the first suggestion but I show respect for your solution.

I'm lucky understanding the first one, changing the language with another post in this forum made by you.

Thanks a million!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211149 by DenisChenu
Replied by DenisChenu on topic Class Representative Election

tpartner wrote:

Max-diff are a QuestionTheme ?

I suppose it could be. :)

Yes, surely and directly with HTML

For the complete system : great to all Expression by QuestionTheme :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211157 by tpartner
Replied by tpartner on topic Class Representative Election

es, surely and directly with HTML

I'm pretty sure it would need some JS, for example, to disable the options when a corresponding option in the other column is selected.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #211178 by DenisChenu
Replied by DenisChenu on topic Class Representative Election

tpartner wrote: I'm pretty sure it would need some JS, for example, to disable the options when a corresponding option in the other column is selected.

Yes but the right/left part are better in HTML :)

About js : i always think it must be ther to help, but never think it can be disabled (more and more user use nojs extension for example).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose