Custom labels array-5-pt

More
11 months 2 weeks ago #146425 by Tomtefar
Tomtefar created the topic: Custom labels array-5-pt
Hi,

I just upgraded to Version 2.57.1+161205 and it is fantastic. However, I cannot figure out how to solve a problem that is very important to me.

I need custom labels on the array-5-pt question. I had this on 2.06, used this theme:
www.toolsforresearch.com/limesurvey-responsive-template
and added a row above the labels (editing question.pstpl). I get this to work now as well (using the default theme) but the problem arises due to the new responsiveness. See images below what I try to achieve and what the problem is.

I know of the array where I can create my own labels but this is not an option for me. I will run a standardized test for thousands of times with 150+ questions so the database will be cluttered with answer alternatives.

Do anyone have any input to how I can solve this? I have two thoughts of my own but I do not know how to make them work (I am not a good developer):
- Get my old solution to work with the new responsiveness
- Turn off the new responsiveness somehow so it will be the same format but more compacted like before
- Simply changing the labels for arrat-5-pt questions to be “1 – Disagree”, 2, 3, 4, “5 – Agree”. Preferably in the theme itself.

I am very pressed for time and all help is extremely appreciated!
Thank you!
Regards
Attachments:

Please Log in to join the conversation.

More
11 months 2 weeks ago #146426 by Tomtefar
Tomtefar replied the topic: Custom labels array-5-pt
I found a way of doing this ay adding a new class and manipulating it in CSS to these files:

limesurvey\application\views\survey\questions\arrays\5point\rows\cells

thead.php:
<th class="<?php echo $class; ?> text-center <?php if ($th_content=='1') { echo "NEW-CLASS-1"; } ?>" style="<?php echo $style; ?>" >
<?php echo $th_content;?>
</th>

answer_td_input.php:
<div class="visible-xs-block label-text label-clickable <?php if ($i=='1') { echo "NEW-CLASS-1"; } ?>" id="label-answer<?php echo $myfname;?>-<?php echo $i; ?>">
<?php echo $i;?>
</div>

The css:
.NEW-CLASS-1:after {
content: " - Disagree";
}

However, I do not like the solution because it modifies the application. Would prefer to have everyting in the theme. Is there any way to achive this in the js file in the theme or simular?

Thank you!

Please Log in to join the conversation.

More
11 months 2 weeks ago - 11 months 2 weeks ago #146432 by Tomtefar
Tomtefar replied the topic: Custom labels array-5-pt
After a lot of hours trying different things I found a solution on my own. Here is the solution if anyone comes across this in the future.

Open “question.pstpl” and add this code to the end:
<script type="text/javascript" charset="utf-8">
 
    /* -------------- This is a modification to change labels for array-5-pt questions -------------- */
    /* Will find the number 1 and 5 in array-5-pt questions and replace them with other header when it is a table (computer size). Needs lang code in CSS to work */
    $('.array-5-pt .array1').each(function () {
        $(this).html($(this).html().replace('1</th>','<div class="sv" lang="sv">1 - Instämmer inte</div><div class="en" lang="en">1 - Disagree</div></th>'));
        $(this).html($(this).html().replace('5</th>','<div class="sv" lang="sv">5 - Instämmer</div><div class="en" lang="en">5 - Agree</div></th>'));
    });
    /* Will find the number 1 and 5 in array-5-pt questions and replace them with other header when it is in mobile mode. Needs lang code in CSS to work */
    $('.array-5-pt .answer-cell-2').each(function () {
        $(this).html($(this).html().replace('1    </div>','<div class="sv" lang="sv">1 - Instämmer inte</div><div class="en" lang="en">1 - Disagree</div></div>'));
        $(this).html($(this).html().replace('5    </div>','<div class="sv" lang="sv">5 - Instämmer</div><div class="en" lang="en">5 - Agree</div></div>'));
    });
 
</script>

Then add this code to “template.css”:
/* Language, removes text that is in the wrong language */
.lang-sv .en {display:none}
.lang-en .sv {display:none}

Now you will have working labels on all devices with language support.
Last Edit: 11 months 2 weeks ago by Tomtefar.

Please Log in to join the conversation.

More
11 months 1 week ago #146493 by DenisChenu
DenisChenu replied the topic: Custom labels array-5-pt
Hi,

Why not use an Array question type with custom answers ? Really more easy.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
11 months 1 week ago #146503 by Tomtefar
Tomtefar replied the topic: Custom labels array-5-pt
I will run a standardized test for thousands of times with 150+ questions so the database will be cluttered with answer alternatives if I do so. So this alternative is the best one for me:)

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!