Welcome, Guest
Username: Password: Remember me

TOPIC: Creating new answer template

Creating new answer template 2 years 6 months ago #72427

  • javierab
  • javierab's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Hi,
I'm new to Lime Survey, and I was wondering if there's a way to create a new Answer type for a question: I need a composition of number and character, with a verification function, and as I'll use it quite a lot it would be nice to save it as a template, so it would appear always.
I've taken a look at the source code, but I really don't get a thing. Is there some further documentation about it?

Thanks in advance!
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72436

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
Adding a new question type would involve major modifications to the source code.

Can you please be more specific about your requirements?

Do you need two text inputs in the same question or just validate a single input?
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72443

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
If you are just trying to validate a field to have a specified mix of characters and numbers, you can use the validation field, which uses regular expression tests to validate each entry. There are good examples of this in 1.92.
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72449

  • javierab
  • javierab's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
I would like to do two things: First, see that the structure is ok (which can indeed be done with a regexp, thanks for the idea :P), and then I need to check if that input makes 'sense' (like, getting a part of the field [numbers], apply a function and compare to the other one [character]).

I don't mind going deep into the code (actually, I'd love to), but I just can't seem to find the place where the answer types are defined.
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72450

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Please provide more detail about how you would want to check that the input makes "sense".

You seem to be describing enhanced validation criteria, not a new question type. For example, you might have a numeric input and a CRC check digit. To do that, you'd want two validation types:
(1) Regular Expression - (the current type of validation)
(2) Validation Equation - let you execute any function(s) to further validate the input.

See, for example, this thread.

/Tom
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72451

  • javierab
  • javierab's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
That's exactly what I need! Does the 2nd type of validation exist?
The administrator has disabled public write access.

Re: Creating new answer template 2 years 6 months ago #72453

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Since that seems to be popular feature (and I need it too), it is now available, as of SVN revision 12142 in limesurvey_dev. So, this will be available as part of LS 1.92 RC3.

/Tom
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.175 seconds
Donation Image