Search

Hey hoh to you all,

A thought has crossed my mind and was wondering if peeps had any insight into using Symphony to create an online scoring application for a series of questions?

I have 4 modules each with varying degrees of questions and a pass rate of %80 to achieve on each module. Was trying to figure out the best way to approach the counting part in XSLT in order to determine a pass rate or not.

Am planning on using Members extension and possibly member claims to track successful progress at each stage and subsequent return to the tool at later stages.. i.e some users may take 1 stage and not do stage 2,3,4 until later in the week/month.

Any thoughts?

It can definitely be done, no questions there.

When it comes to storing the calculations, you would need (IMO) to store the totals possible for each section, then total up each users score in another section. Just do the percentages on a visual basis when you display it in your XSLT.

I built a custom event for Jesse recently that calculates averages this way and stores data over two sections, and it wasn't that hard to do... Running totals wouldn't be too hard to do either, and can be built to store for a user to go away mid session and resume later if that was needed.

Cool man, I shall be having a play over weekend.

Got a flash Quiz to integrate with it as well.. i.e Flash Quiz with pure HTML fallback.. (Don't ask.) clients requirement.

Woud it be cool pick pick your brains on the count front at some point? no rush really just haven't dealt with calculating in XSLT.

I'm gonna store the pass rate as a preference in backend.. so there is a constant to match against for total score exceeding required score etc.. it's the running total stuff that hasn't quite stuck yet.

Counting and calculations are relatively easy in XSLT. They just form part of any xpath expression.

I built a small internal site to allow people to vote on dishes cooked by other co-workers. AKA a 'bake-off'. Each staff member can vote on an entry, giving a score for 4 categories (taste, texture, originality, appearance).

This is the template used to sort all the entries by their averaged score:

<xsl:template match="entries">
    <div id="entries">
        <xsl:apply-templates select="entry">            
            <xsl:sort order="descending" data-type="number" select="
                sum(
                    /data/votes/entry[@link-id = current()/@id]/entry/taste |
                    /data/votes/entry[@link-id = current()/@id]/entry/texture | 
                    /data/votes/entry[@link-id = current()/@id]/entry/appearance |
                    /data/votes/entry[@link-id = current()/@id]/entry/originality
                    ) 
                div 
                    count(
                    /data/votes/entry[@link-id = current()/@id]/entry 
                    ) 
            "/>
        </xsl:apply-templates>
    </div>
</xsl:template>

This is a re-usable template for calculating each entry's averaged individual score for each category:

<xsl:template name="display-score"> 
    <xsl:param name="item-name" />
    <xsl:variable name="score-sum" select="sum(/data/votes/entry[@link-id = current()/@id]/entry/*[local-name()=$item-name])"/>
    <xsl:variable name="score-count" select="count(/data/votes/entry[@link-id = current()/@id]/entry/*[local-name()=$item-name])"/>
    <xsl:value-of select="format-number($score-sum div $score-count,'#.0')"/>
</xsl:template>

Then to actually display an averaged score for a category:

<dt>Texture</dt>
<dd>
    <xsl:call-template name="display-score">
        <xsl:with-param name="item-name" select="'texture'"/>
    </xsl:call-template>
</dd>

I make no claims that any of this was done in the most efficient or succinct manner, but hopefully it gives you an idea of the sort of thing you can do.

Awesome Henry, thanks for sharing!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details