Skip to content

Commit

Permalink
SAK-34033 handle QTI 1.2 import with Cognero-generated multiple choice (
Browse files Browse the repository at this point in the history
  • Loading branch information
ottenhoff authored and adrianfish committed Sep 10, 2019
1 parent 8b54416 commit ab2e0e6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<!-- Respondus single correct answer -->
<xsl:for-each select="//respcondition">
<xsl:if test="setvar/@varname='que_score' and setvar/@action='Set'">
<xsl:value-of select="setvar"/><!-- if not single adds innocuous '0' -->
<xsl:value-of select="setvar"/><!-- if not single adds innocuous '0' -->
</xsl:if>
<xsl:if test="setvar/@varname='SCORE' and setvar/@action='Set'">
<xsl:value-of select="setvar"/>
</xsl:if>
</xsl:for-each>
</score>
Expand Down Expand Up @@ -128,6 +131,19 @@
<xsl:if test="displayfeedback/@linkrefid='Correct'">
<itemAnswerCorrectLabel type="list"><xsl:value-of select="conditionvar/varequal"/></itemAnswerCorrectLabel>
</xsl:if>
<!-- Found in SAK-34033 Cognero -->
<xsl:if test="setvar/@varname='SCORE' and setvar/@action='Set'">
<xsl:variable name="tempIdentVal">
<xsl:value-of select="conditionvar/varequal"/>
</xsl:variable>
<itemAnswerCorrectLabel type="list">
<xsl:for-each select="//response_lid//flow_label/response_label">
<xsl:if test="@ident = $tempIdentVal">
<xsl:number value="position()" format="A" />
</xsl:if>
</xsl:for-each>
</itemAnswerCorrectLabel>
</xsl:if>
</xsl:for-each>
<!-- alternate for Respondus questions -->
<xsl:for-each select="//respcondition">
Expand All @@ -153,7 +169,7 @@
</xsl:for-each>

<!-- answers -->
<xsl:for-each select="//presentation//response_lid/render_choice/response_label/material/mattext" >
<xsl:for-each select="//presentation//response_lid/render_choice//response_label/material/mattext" >
<itemAnswer type="list"><xsl:apply-templates mode="itemRichText" /></itemAnswer>
</xsl:for-each>
<xsl:for-each select="//respcondition/conditionvar/*[name()='or']/varequal">
Expand All @@ -166,6 +182,9 @@
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:if test="//itemmetadata/qmd_renderingtype='Text entry' and //itemmetadata/qmd_responsetype='Single'">
<itemFibAnswer type="list"><xsl:value-of select="//respcondition/conditionvar/varequal"/></itemFibAnswer>
</xsl:if>
<!-- feedback -->

<xsl:for-each select="//itemfeedback">
Expand Down Expand Up @@ -283,6 +302,8 @@
<xsl:when test=".//render_choice and @title='Multiple Correct Single Selection'">Multiple Correct Single Selection</xsl:when>
<xsl:when test=".//render_choice and @title='Multiple Choice'">Multiple Choice</xsl:when>
<xsl:when test=".//render_choice and @title='Matrix Choices Survey'">Matrix Choice</xsl:when>
<xsl:when test=".//qmd_renderingtype='Choice' and .//qmd_responsetype='Single'">Multiple Choice</xsl:when>
<xsl:when test=".//qmd_renderingtype='Choice' and .//qmd_responsetype='Multiple'">Multiple Correct Answer</xsl:when>
<xsl:otherwise>Short Answers/Essay</xsl:otherwise>
</xsl:choose>
</itemIntrospect>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,9 +1879,8 @@ private void addTextAndAnswers(ItemFacade item, Map itemMap)
itemText.setItem(item.getData());
itemText.setSequence( Long.valueOf(i + 1));

List answerScoreList = new ArrayList(); //--mustansar
List sList = (List) itemMap.get("answerScore"); //--mustansar
answerScoreList = sList == null ? answerScoreList : sList; //--mustansar
List<String> sList = (List) itemMap.get("answerScore");
List<String> answerScoreList = sList == null ? new ArrayList<>() : sList;
HashSet answerSet = new HashSet();
char answerLabel = 'A';
for (int a = 0; a < answerList.size(); a++)
Expand Down Expand Up @@ -1951,7 +1950,7 @@ private void addTextAndAnswers(ItemFacade item, Map itemMap)
long index = answer.getSequence().longValue();
index = index - 1L;
int indexInteger = Long.valueOf(index).intValue();
String strPCredit = (String) answerScoreList.get(indexInteger);
String strPCredit = answerScoreList.contains(indexInteger) ? answerScoreList.get(indexInteger) : "0";
double fltPCredit = Double.parseDouble(strPCredit);
Double pCredit = (fltPCredit/(item.getScore().doubleValue()))*100;
if (pCredit.isNaN()){
Expand Down

0 comments on commit ab2e0e6

Please sign in to comment.