Single/Multiple Choice always mandatory?

You need to be logged in to post messages in the forums. New users may register here.

Jordan Hirsch

Member since:
09 January 2008

Posts: 10

Tuesday 14 July 2009 10:38:55 am

I don't see an option to set the "mandatory" status of a single/multiple choice survey question - it seems to be always set to mandatory = 1. Is there a way to set this in the admin?

Also, the logic in the view template for a single/multiple choice question is using the "num" attribute of the $question object to determine whether or not to display an asterisk next to the question - shouldn't it be using the mandatory attribute?

Thank you.

Technical Project Manager & Content Management Expert
http://jordan.teamhirsch.com

eZ publish Certified Developer
http://ez.no/certification/verify/146562

Author, 2007 Publication of the Year
http://ez.no/company/news/ez_awards_2007_prize_winners

Music/Technology Blogger
http://wiredformusic.blogspot.com

Up

Bjørn Reiten

Member since:
22 February 2008

Posts: 35

Wednesday 15 July 2009 6:43:29 am

Hi,

I think this is because of historic reasons for how single/multiple choice was working in the first version as well.

The question is required if you add a choice with radio buttons. Then you need to select one of the choices.

For the checkboxes you can either choose none, all of them or some, so in this case it will not be mandatory.

For a select-list, you'll allways have a choice.

The type of question is stored in the num attribute, which is why the asterix is controlled by this value.

Cheers,
Bjørn
Up

Jordan Hirsch

Member since:
09 January 2008

Posts: 10

Thursday 16 July 2009 9:03:04 am

Thanks, Bjorn.

If people are curious, I updated the code on my installation to allow the user to make single/multiple choice questions mandatory.

In extension/ezsurvey/design/standard/templates/survey/view/multiplechoice.tpl:
I replaced
{switch match=$question.num}{case match=1}<strong class="required">*</strong>{/case}{case match=2}*{/case}{/switch}

with
{section show=$question.mandatory}<strong class="required">*</strong>{/section}


In extension/ezsurvey/design/standard/templates/survey/edit/multiplechoice.tpl:
I added
<div class="block">


















 if ( !$http->hasPostVariable( $postSurveyAnswer ) and










 if ( !$http->hasPostVariable( $postSurveyAnswer ) and












{section show=$preview|not}

with
{if is_set($preview)|not}


I hope this is useful for someone else!

Technical Project Manager & Content Management Expert
http://jordan.teamhirsch.com

eZ publish Certified Developer
http://ez.no/certification/verify/146562

Author, 2007 Publication of the Year
http://ez.no/company/news/ez_awards_2007_prize_winners

Music/Technology Blogger
http://wiredformusic.blogspot.com

Up

You need to be logged in to post messages in the forums. New users may register here.