Displaying MCMS result

Apr 11, 2008 at 11:13 AM
Steve,

I have successfully created a working web survey that displays results for all the MCSS (Multi Choice Single Select) questions. However, not being adept as XSL, I am having difficulty trying to display results for MCMS. Do you (or anyone else) have any template examples that I could use to point me in the right direction.

Many thanks,

Jules
Jul 1, 2008 at 2:21 PM
Has anyone got any ideas on this?
Coordinator
Jul 6, 2008 at 5:46 AM
Jules,

I thought I had a XSLT file that handled this, but I dug back through my files and was unable to find it.  I might be able to re-create it, but I'm not sure when I'll get to it, as (IIRC) it is somewhat involved.
Mar 10, 2009 at 12:55 AM
I had the same problem and solved it like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method = "html" indent = "yes"/>
  <xsl:template match = "/">  
    <xsl:for-each select = "//SurveyResult/Question">
      <xsl:variable name = "type" select = "@type"/>    
<xsl:if test = "$type = 'mcms'">
        <xsl:variable name = "qid" select = "@id"/>
        <p>
          <b>
            <xsl:value-of select = "//SurveyResult/Question[@id = $qid]/Statement"/>
          </b>
        </p>
        <xsl:variable name = "null" />
        <xsl:variable name = "total" select = "count(//SurveyResult/Answer[text() != $null and @questionId = $qid])"/>
        <div style = "margin-left: 15px;">
          <xsl:for-each select = "//SurveyResult/Question[@id = $qid]/Responses/Response">
            <xsl:variable name = "res" select = "."/>
            <xsl:variable name = "sum" select = "count(//SurveyResult/Answer[contains(text(),$res)and @questionId = $qid])"/>
            <xsl:variable name = "per" select = "$sum div $total * 100"/>
            <xsl:variable name = "len" select = "round($per * 4)"/>
            <xsl:value-of select = "$res"/>: <xsl:value-of select = "(round($per * 100)) div 100"/>%
            <div>
              <xsl:attribute name = "style">
                vertical-align: middle; margin-bottom: 15px; border: solid 1px; border-color: #99ccff #99ccff #336699 #336699; background-color: #6699cc; width: <xsl:value-of select = "$len"/>px;
              </xsl:attribute>
            </div>
          </xsl:for-each>
        </div>
        <b>Total Votes: </b>
        <xsl:value-of select = "$total"/>
        <hr/>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>  
</xsl:stylesheet>

    </xsl:for-each>
    
  </xsl:template>  
</xsl:stylesheet>
Mar 10, 2009 at 12:19 PM
Bikerbene you are 'The Man' (or Woman). Many thanks that seems to work a treat.

Steve, please take note. Might I suggest you include Bikerbene's code in your sample file.

Regards,

Jules
Coordinator
Mar 25, 2009 at 4:17 PM
Thanks Bikerbene!  I'm going to put on my TODO to include this XSLT in my TestHarness, if that is okay with you?
Mar 25, 2009 at 7:06 PM
For sure. Thats cool that you like it. It just took me half an hour to change your code into this even though I'm not a coder ;)