| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : handlers/matrix/stats.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : October 7, 2005 |
|---|
| 6 | Last Updated : March 30, 2006 |
|---|
| 7 | History : Fix to ordering (rkc 2/11/06) |
|---|
| 8 | : tableprefix fix (rkc 3/30/06) |
|---|
| 9 | Purpose : Maxtrix |
|---|
| 10 | ---> |
|---|
| 11 | |
|---|
| 12 | <cfparam name="attributes.questionidfk"> |
|---|
| 13 | <cfparam name="attributes.r_data" type="variablename"> |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | <cfset data = structNew()> |
|---|
| 17 | |
|---|
| 18 | <!--- get my answer data ---> |
|---|
| 19 | <cfset answers = application.question.getAnswers(attributes.questionidfk)> |
|---|
| 20 | |
|---|
| 21 | <cfquery name="getAnswers" dbtype="query"> |
|---|
| 22 | select * |
|---|
| 23 | from answers |
|---|
| 24 | where rank >= 0 |
|---|
| 25 | order by rank asc |
|---|
| 26 | </cfquery> |
|---|
| 27 | |
|---|
| 28 | <cfquery name="getItems" dbtype="query"> |
|---|
| 29 | select * |
|---|
| 30 | from answers |
|---|
| 31 | where rank < 0 |
|---|
| 32 | order by rank desc |
|---|
| 33 | </cfquery> |
|---|
| 34 | |
|---|
| 35 | <!--- Pass to data a sorted list of answers to use in graphiing. ---> |
|---|
| 36 | <cfset data.sortedAnswers = valueList(getAnswers.id)> |
|---|
| 37 | <!--- Pass to data a sorted list of items to use in graphiing. ---> |
|---|
| 38 | <cfset data.sortedItems = valueList(getItems.id)> |
|---|
| 39 | |
|---|
| 40 | <cfloop query="getItems"> |
|---|
| 41 | |
|---|
| 42 | <cfset itemid = id> |
|---|
| 43 | <cfset item = answer> |
|---|
| 44 | <cfset data[itemid] = structNew()> |
|---|
| 45 | |
|---|
| 46 | <cfloop query="getAnswers"> |
|---|
| 47 | |
|---|
| 48 | <cfquery name="getcount" datasource="#application.settings.dsn#"> |
|---|
| 49 | select count(answeridfk) as total |
|---|
| 50 | from #application.settings.tableprefix#results |
|---|
| 51 | where answeridfk = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#id#"> |
|---|
| 52 | and itemidfk = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#itemid#"> |
|---|
| 53 | </cfquery> |
|---|
| 54 | |
|---|
| 55 | <cfset data[itemid][id] = structNew()> |
|---|
| 56 | <cfset data[itemid][id].label = answer> |
|---|
| 57 | <cfset data[itemid][id].count = getcount.total> |
|---|
| 58 | <cfset data[itemid][id].rank = rank> |
|---|
| 59 | <cfset data[itemid].label = item> |
|---|
| 60 | </cfloop> |
|---|
| 61 | |
|---|
| 62 | </cfloop> |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | <cfset caller[attributes.r_data] = data> |
|---|
| 67 | <cfsetting enablecfoutputonly=false> |
|---|
| 68 | |
|---|
| 69 | <cfexit method="exittag"> |
|---|