| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : handlers/multiplechoice/display.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : September 21, 2004 |
|---|
| 6 | Last Updated : October 12, 2005 |
|---|
| 7 | History : minor format change (rkc 10/7/05) |
|---|
| 8 | 255 limit (rkc 10/12/05) |
|---|
| 9 | Purpose : Supports True/False, Yes/No |
|---|
| 10 | ---> |
|---|
| 11 | |
|---|
| 12 | <cfparam name="attributes.single" default="true"> |
|---|
| 13 | <cfparam name="attributes.other" default="false"> |
|---|
| 14 | <cfparam name="attributes.question"> |
|---|
| 15 | <cfparam name="attributes.r_result" default="result"> |
|---|
| 16 | <cfparam name="attributes.answer"> |
|---|
| 17 | <cfparam name="attributes.step"> |
|---|
| 18 | |
|---|
| 19 | <cfset showForm = true> |
|---|
| 20 | <cfset forceOther = false> |
|---|
| 21 | |
|---|
| 22 | <cfif isDefined("form.submit")> |
|---|
| 23 | <cfif not isDefined("form.question#attributes.step#") and attributes.question.required> |
|---|
| 24 | <cfset errors = "You must answer the question."> |
|---|
| 25 | <cfelseif attributes.other and isDefined("form.question#attributes.step#") and form["question#attributes.step#"] is "" and not len(trim(form["question#attributes.step#_other"]))> |
|---|
| 26 | <cfset forceOther = true> |
|---|
| 27 | <cfset errors = "If you select Other for an answer, you must fill something out."> |
|---|
| 28 | <cfelse> |
|---|
| 29 | <cfparam name="form.question#attributes.step#" default=""> |
|---|
| 30 | <cfset form["question#attributes.step#"] = left(form["question#attributes.step#"], 255)> |
|---|
| 31 | <!--- |
|---|
| 32 | The list append function below handles adding question_other to main answer. |
|---|
| 33 | This is used for multichoicemultiother |
|---|
| 34 | ---> |
|---|
| 35 | <cfif isDefined("form.question#attributes.step#_other") and len(form["question#attributes.step#_other"])> |
|---|
| 36 | <cfset caller[attributes.r_result] = listAppend(form["question#attributes.step#"],form["question#attributes.step#_other"])> |
|---|
| 37 | <cfelse> |
|---|
| 38 | <cfset caller[attributes.r_result] = form["question#attributes.step#"]> |
|---|
| 39 | </cfif> |
|---|
| 40 | </cfif> |
|---|
| 41 | </cfif> |
|---|
| 42 | |
|---|
| 43 | <cfset answers = application.question.getAnswers(attributes.question.id)> |
|---|
| 44 | |
|---|
| 45 | <!--- |
|---|
| 46 | If a value exists in the answer that is NOT in the list, then its the Other |
|---|
| 47 | ---> |
|---|
| 48 | <cfset ids = valueList(answers.id)> |
|---|
| 49 | <cfloop index="a" list="#attributes.answer#"> |
|---|
| 50 | <cfif not listFindNoCase(ids, a)> |
|---|
| 51 | <cfparam name="form.question#attributes.step#_other" default="#a#"> |
|---|
| 52 | </cfif> |
|---|
| 53 | </cfloop> |
|---|
| 54 | <cfparam name="form.question#attributes.step#_other" default=""> |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | <cfif isDefined("errors")> |
|---|
| 58 | <cfoutput> |
|---|
| 59 | <p class="error">#errors#</p> |
|---|
| 60 | </cfoutput> |
|---|
| 61 | </cfif> |
|---|
| 62 | |
|---|
| 63 | <cfoutput> |
|---|
| 64 | <p> |
|---|
| 65 | <div class="question">#attributes.step#) #attributes.question.question#</div> |
|---|
| 66 | <div class="answers"> |
|---|
| 67 | <cfif attributes.single> |
|---|
| 68 | <cfset type="radio"> |
|---|
| 69 | <cfelse> |
|---|
| 70 | <cfset type="checkbox"> |
|---|
| 71 | </cfif> |
|---|
| 72 | <cfloop query="answers"> |
|---|
| 73 | <input type="#type#" name="question#attributes.step#" value="#id#" <cfif listFindNoCase(attributes.answer,id)>checked</cfif>>#answer#<br> |
|---|
| 74 | </cfloop> |
|---|
| 75 | <cfif attributes.other> |
|---|
| 76 | <input type="#type#" name="question#attributes.step#" value="" <cfif len(form["question#attributes.step#_other"]) or forceOther>checked</cfif>>Other |
|---|
| 77 | <input type="text" name="question#attributes.step#_other" value="#form["question#attributes.step#_other"]#" maxlength="255"> |
|---|
| 78 | </cfif> |
|---|
| 79 | </div> |
|---|
| 80 | </p> |
|---|
| 81 | </cfoutput> |
|---|
| 82 | |
|---|
| 83 | <cfsetting enablecfoutputonly=false> |
|---|
| 84 | |
|---|
| 85 | <cfexit method="exittag"> |
|---|