|
| 1 | +{% raw %} |
| 2 | +<xsl:template match="choices" mode="one"> |
| 3 | + <xsl:variable name="displaytype"><xsl:value-of select="@displaytype"/></xsl:variable> |
| 4 | + <span localise-data-jme-context-description="part.mcq.choices"> |
| 5 | + <xsl:choose> |
| 6 | + <xsl:when test="@displaytype='radiogroup'"> |
| 7 | + <fieldset data-bind="part_aria_validity: hasWarnings, part: $data, attr: {{id: part.full_path+'-input'}}"> |
| 8 | + <legend data-bind="text: input_title" class="sr-only"></legend> |
| 9 | + <ul class="multiplechoice radiogroup" data-bind="reorder_list: {{order: part.shuffleAnswers}}, css: {{'show-cell-answer-state': showCellAnswerState, 'columns': displayColumns}}"> |
| 10 | + <xsl:variable name="cols" select="@displaycolumns"/> |
| 11 | + <xsl:if test="$cols>0"> |
| 12 | + <xsl:attribute name="style">grid-template-columns: repeat(<xsl:number value="$cols"/>,auto);</xsl:attribute> |
| 13 | + </xsl:if> |
| 14 | + <xsl:apply-templates select="choice" mode="radiogroup"/> |
| 15 | + </ul> |
| 16 | + </fieldset> |
| 17 | + </xsl:when> |
| 18 | + <xsl:when test="@displaytype='checkbox'"> |
| 19 | + <fieldset data-bind="part_aria_validity: hasWarnings, part: $data, attr: {{id: part.full_path+'-input'}}"> |
| 20 | + <legend data-bind="text: input_title" class="sr-only"></legend> |
| 21 | + <ul class="multiplechoice checkbox" data-bind="reorder_list: {{order: part.shuffleAnswers}}, css: {{'show-cell-answer-state': showCellAnswerState, 'columns': displayColumns}}"> |
| 22 | + <xsl:variable name="cols" select="@displaycolumns"/> |
| 23 | + <xsl:if test="$cols>0"> |
| 24 | + <xsl:attribute name="style">grid-template-columns: repeat(<xsl:number value="$cols"/>,auto);</xsl:attribute> |
| 25 | + </xsl:if> |
| 26 | + <xsl:apply-templates select="choice" mode="checkbox"/> |
| 27 | + </ul> |
| 28 | + </fieldset> |
| 29 | + </xsl:when> |
| 30 | + <xsl:when test="@displaytype='dropdownlist'"> |
| 31 | + <span class="multiplechoice dropdownlist" data-bind="value: studentAnswer, reorder_list: {{order: part.shuffleAnswers, leaders: 0}}, css: {{'show-cell-answer-state': showCellAnswerState}}, attr: {{title: input_title, id: part.full_path+'-input'}}, part_aria_validity: hasWarnings, part: $data"> |
| 32 | + <xsl:apply-templates select="choice" mode="dropdownlist"/> |
| 33 | + </span> |
| 34 | + </xsl:when> |
| 35 | + </xsl:choose> |
| 36 | + </span> |
| 37 | +</xsl:template> |
| 38 | +<xsl:template match="choices" mode="correctanswer"> |
| 39 | + <xsl:variable name="displaytype"><xsl:value-of select="@displaytype"/></xsl:variable> |
| 40 | + <span> |
| 41 | + <xsl:choose> |
| 42 | + <xsl:when test="@displaytype='radiogroup'"> |
| 43 | + <fieldset data-bind="attr: {{id: part.full_path+'-expected-input'}}"> |
| 44 | + <legend><localise>part.correct answer</localise></legend> |
| 45 | + <ul class="multiplechoice radiogroup" data-bind="reorder_list: {{order: part.shuffleAnswers}}"> |
| 46 | + <xsl:apply-templates select="choice" mode="radiogroup-correctanswer"/> |
| 47 | + </ul> |
| 48 | + </fieldset> |
| 49 | + </xsl:when> |
| 50 | + <xsl:when test="@displaytype='checkbox'"> |
| 51 | + <fieldset data-bind="attr: {{id: part.full_path+'-expected-input'}}"> |
| 52 | + <legend><localise>part.correct answer</localise></legend> |
| 53 | + <ul class="multiplechoice checkbox" data-bind="reorder_list: {{order: part.shuffleAnswers}}"> |
| 54 | + <xsl:apply-templates select="choice" mode="checkbox-correctanswer"/> |
| 55 | + </ul> |
| 56 | + </fieldset> |
| 57 | + </xsl:when> |
| 58 | + <xsl:when test="@displaytype='dropdownlist'"> |
| 59 | + <label> |
| 60 | + <localise>part.correct answer</localise> |
| 61 | + <span class="multiplechoice dropdownlist" data-bind="value: correctAnswer, reorder_list: {{order: part.shuffleAnswers, leaders: 0}}, attr: {{id: part.full_path+'-expected-input'}}" disabled="true"> |
| 62 | + <xsl:apply-templates select="choice" mode="dropdownlist-correctanswer"/> |
| 63 | + </span> |
| 64 | + </label> |
| 65 | + </xsl:when> |
| 66 | + </xsl:choose> |
| 67 | + </span> |
| 68 | +</xsl:template> |
| 69 | +<xsl:template match="choice" mode="radiogroup"> |
| 70 | + <xsl:variable name="path"> |
| 71 | + <xsl:apply-templates select="../.." mode="path"/> |
| 72 | + </xsl:variable> |
| 73 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 74 | + <li> |
| 75 | + <xsl:attribute name="data-bind">css: {checked: studentAnswer()==<xsl:value-of select="$choicenum"/>, correct: studentAnswer()==<xsl:value-of select="$choicenum"/> && correctAnswer()==<xsl:value-of select="$choicenum"/>}</xsl:attribute> |
| 76 | + <label> |
| 77 | + <input type="radio" class="choice" data-bind="checked: studentAnswer, disable: disabled, attr: {{name: part.path+'-choice'}}" value="{$choicenum}"/> |
| 78 | + <xsl:apply-templates select="content"/> |
| 79 | + </label> |
| 80 | + </li> |
| 81 | +</xsl:template> |
| 82 | +<xsl:template match="choice" mode="radiogroup-correctanswer"> |
| 83 | + <xsl:variable name="path"> |
| 84 | + <xsl:apply-templates select="../.." mode="path"/> |
| 85 | + </xsl:variable> |
| 86 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 87 | + <li> |
| 88 | + <label> |
| 89 | + <input type="radio" class="choice" data-bind="checked: correctAnswer()+'', attr: {{name: part.path+'-correctanswer'}}" disabled="true" value="{$choicenum}"/> |
| 90 | + <xsl:apply-templates select="content"/> |
| 91 | + </label> |
| 92 | + </li> |
| 93 | +</xsl:template> |
| 94 | +<xsl:template match="choice" mode="checkbox"> |
| 95 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 96 | + <li> |
| 97 | + <xsl:attribute name="data-bind">css: {checked: ticks[<xsl:value-of select="$choicenum"/>], correct: ticks[<xsl:value-of select="$choicenum"/>] && correctTicks()[<xsl:value-of select="$choicenum"/>]}</xsl:attribute> |
| 98 | + <label> |
| 99 | + <input type="checkbox" class="choice" data-bind="checked: ticks[{$choicenum}], disable: disabled, attr: {{name: part.path+'-choice'}}" /> |
| 100 | + <xsl:apply-templates select="content"/> |
| 101 | + </label> |
| 102 | + </li> |
| 103 | +</xsl:template> |
| 104 | +<xsl:template match="choice" mode="checkbox-correctanswer"> |
| 105 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 106 | + <li> |
| 107 | + <label> |
| 108 | + <input type="checkbox" class="choice" name="choice" data-bind="checked: correctTicks()[{$choicenum}], attr: {{name: part.path+'-correctanswer'}}" disabled="true" /> |
| 109 | + <xsl:apply-templates select="content"/> |
| 110 | + </label> |
| 111 | + </li> |
| 112 | +</xsl:template> |
| 113 | +<xsl:template match="choice" mode="dropdownlist"> |
| 114 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 115 | + <span class="dropdownlist-option" value="{$choicenum}"> |
| 116 | + <xsl:apply-templates select="content"/> |
| 117 | + </span> |
| 118 | +</xsl:template> |
| 119 | +<xsl:template match="choice" mode="dropdownlist-correctanswer"> |
| 120 | + <xsl:variable name="choicenum"><xsl:value-of select="count(preceding-sibling::choice)"/></xsl:variable> |
| 121 | + <span class="dropdownlist-option" value="{$choicenum}"> |
| 122 | + <xsl:attribute name="data-bind">css: {'checked': correctAnswer()==<xsl:value-of select="$choicenum"/>}</xsl:attribute> |
| 123 | + <xsl:apply-templates select="content"/> |
| 124 | + </span> |
| 125 | +</xsl:template> |
| 126 | +<xsl:template match="distractor"> |
| 127 | + <span><xsl:apply-templates /></span> |
| 128 | +</xsl:template> |
| 129 | +{% endraw %} |
| 130 | + |
0 commit comments