Mask - Hide sensitive answer

More
4 months 3 weeks ago #167887 by kpopovich
kpopovich created the topic: Mask - Hide sensitive answer
Is it possible to have a question with short text and have the answer masked as they type it? Say if we were having a user type in their ID number or last 4 digits of a sensitive number?

Please Log in or Create an account to join the conversation.

More
4 months 3 weeks ago #167904 by tpartner
tpartner replied the topic: Mask - Hide sensitive answer
Not out of the box but in version 3.x you could make a custom question based on short-text but using input type="password" instead of type="text".

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
4 months 3 weeks ago #167919 by kpopovich
kpopovich replied the topic: Mask - Hide sensitive answer
Hi! Thanks for the reply. I'm trying to figure out as well as search how to create a custom question and find where I can change the input type but I'm not getting anywhere. Can you offer some help? I'm running version 3.7

Thanks!

Please Log in or Create an account to join the conversation.

More
4 months 3 weeks ago #167931 by tpartner
tpartner replied the topic: Mask - Hide sensitive answer
Sorry, not this week - on vacation checking in from my phone.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
4 months 3 weeks ago #168049 by kpopovich
kpopovich replied the topic: Mask - Hide sensitive answer
No worries, I tried doing some research and reading, but was unable to figure out a way to do this. Whenever you have a free moment if you could give me some advice on how to accomplish this. I would be greatful.

Thank you!

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago - 4 months 2 weeks ago #168092 by tpartner
tpartner replied the topic: Mask - Hide sensitive answer
To create a custom "password" question...

1) Copy the directory /themes/question/browserdetect to /upload/themes/question/.

2) Rename the new directory "password".

3) Delete the directory /upload/themes/question/password/survey/questions/answer/shortfreetext/assets.

4) Edit the file /upload/themes/question/password/survey/questions/answer/shortfreetext/config.xml so it looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
 
<config>
    <!-- These metadata will be displayed in the template configuration page. They are not used for now. -->
    <metadata>
        <name>password</name>
        <creationDate>01/05/2018</creationDate>
        <author>Tony Partner</author>
        <license>GNU General Public License version 2 or later</license>
        <version>1.0</version>
        <apiVersion>1</apiVersion>
        <description>Password input (masked characters)</description>
    </metadata>
 
    <!--
        CSS/JS files to load.
        Any files here will be loaded via the asset manager (when in config.php debug = 0)
    -->
    <files>
        <css>
        </css>
        <js>
        </js>
    </files>
 
    <custom_attributes>
    </custom_attributes>
 
    <!-- Datas about how LimeSurvey should load the core js/css of the question -->
    <engine>
        <load_core_css>true</load_core_css>
        <load_core_js>true</load_core_js>
        <show_as_template>true</show_as_template>
        <show_as_question_type>true</show_as_question_type>
    </engine>
</config>

5) Edit the file /upload/themes/question/password/survey/questions/answer/shortfreetext/text/item.twig so it looks something like this:

{#
/**
 * Shortfreetext, input text style, item Html
 *
 * $extraclass
 * $name        $ia[1]
 * $prefix
 * $suffix
 * $kpclass
 * $tiwidth
 * $dispVal
 * $maxlength
 * $checkconditionFunction
 **** Additional attributes:
 * @var question_template_attribute.add_platform_info
 */
#}

{% if withColumn %}
<div class='{{coreClass}} row'>
    <div class="{{extraclass}}">
{% else %}
<div class='{{coreClass}} {{extraclass}}'>
{% endif %}
 
        <!-- Input -->
        <input
            class="form-control {{kpclass}} password-input"
            type="password"
            name="{{name}}"
            id="answer{{name}}"
            value="{{dispVal}}"
            {% if inputsize is not empty %} size="{{inputsize}}" {% endif %}
            {% if maxlength is not empty %} maxlength='{{maxlength}}' {% endif %}
            aria-labelledby="ls-question-text-{{basename}}"
        />
{% if withColumn %}
    </div>
</div>
{% else %}
</div>
{% endif %}

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 4 months 2 weeks ago by tpartner.
The following user(s) said Thank You: LouisGac

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #168162 by kpopovich
kpopovich replied the topic: Mask - Hide sensitive answer
This is awesome, thank you very much. Two questions

1. Why does one have to delete the assets folder? If I delete the assets folder, it breaks the form and it doesn't load the page properly. If I copy the assets folder from the browserdetect question theme, it works fine. -- not a big issue, it appears this is working fine for me.

2. Within a question group, how can I require that the answer provided for Q1 be an exact match for Q2? Meaning, take what the user inputted into Q1 and require that they type the exact same thing in Q2 as well as keep the answer masked or as type "password"

Thanks very much for your assistance.

Please Log in or Create an account to join the conversation.

More
4 months 2 weeks ago #168203 by tpartner
tpartner replied the topic: Mask - Hide sensitive answer
1) I suspect that you are deleting the wrong folder. Look at the path I gave. Nothing in that folder is used in this custom question.

2) Please refer to the manual - look for "question validation".

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!