Displaying MCMS result

Apr 11, 2008 at 11:13 AM

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,

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

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"/>
            <xsl:value-of select = "//SurveyResult/Question[@id = $qid]/Statement"/>
        <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"/>%
              <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;
        <b>Total Votes: </b>
        <xsl:value-of select = "$total"/>

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.


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 ;)