How to make a sub-question in Survey mandatory?

salvadormarchan
Kilo Guru

Hi All,

 

I am given the task to make the sub-questions in Survey mandatory (depending on the response in the main question). I am needing of a lead or tip where to start.

 

So, basically, the main question may have 5 different options to response (e.g. Very Satisfied, Satisfied, Neutral, Dissatisfied, Very Dissatisfied) and if the user replies with Neutral, Dissatisfied, or Very Dissatisfied,   a extra field shows (e.g. field='Feedback'; datatype=string; max length=1000). In OOB, this can't be mandatory but I believe it can be reconfigure via UI Page, UI Macro; HOWEVER, I am not sure where to start. Perhaps, if can anybody point out to me which components are affected to customized and reconfigure this, i deeply appreciate it.

 

Thanks,

Dor

1 ACCEPTED SOLUTION

salvadormarchan
Kilo Guru

I think I got it...here's the details



at the UI Page: assessment_take2


Go to Client Script window pane:


*** Inside function showDescendantsByValue(instanceQuestionId, value), add this script (near the bottom of the function):



//============================================================================DOR TEST


              var myElem = $('ASMTQUESTION:' + childId);


              if (value != '-1') {


                    myElem.required = true;


              }


//===========================================================================DOR TEST


  showDescendantsByValue(childId, childValue);


  displayedQuestions[childId] = true;






*** Inside function hideDescendants(instanceQuestionId), add this script (near the bottom of the function):


hideDescendants(childIds[i]);

//============================================================================DOR TEST


                              var myElem = $('ASMTQUESTION:' + childIds[i]);


                              myElem.required = false;


//===========================================================================DOR TEST


delete displayedQuestions[childIds[i]];

View solution in original post

2 REPLIES 2

salvadormarchan
Kilo Guru

I think I got it...here's the details



at the UI Page: assessment_take2


Go to Client Script window pane:


*** Inside function showDescendantsByValue(instanceQuestionId, value), add this script (near the bottom of the function):



//============================================================================DOR TEST


              var myElem = $('ASMTQUESTION:' + childId);


              if (value != '-1') {


                    myElem.required = true;


              }


//===========================================================================DOR TEST


  showDescendantsByValue(childId, childValue);


  displayedQuestions[childId] = true;






*** Inside function hideDescendants(instanceQuestionId), add this script (near the bottom of the function):


hideDescendants(childIds[i]);

//============================================================================DOR TEST


                              var myElem = $('ASMTQUESTION:' + childIds[i]);


                              myElem.required = false;


//===========================================================================DOR TEST


delete displayedQuestions[childIds[i]];

Community Alums
Not applicable

Hi Salvador,



Thanks for sharing this. I'm having the same requirement. I add the codes to the Client Script at the location you mentioned but when I hit Try It button, an error came out; 'There was an unexpected failure with this assessment, invalid type provided'.



I'm currently using Survey with 4 questions (numeric scale) and 1 multi line text. If any of the 4 questions has 3 selected, the multi line text should be mandatory.



I'm wondering if you're using the Survey module or the Survey Wizard module for your survey. Can you please share and let me know?



Advanced thanks!


ana.