Skip to content

Commit

Permalink
when auto-submitting a part because the input blurred, do show feedba…
Browse files Browse the repository at this point in the history
…ck if the user was clicking inside that part
  • Loading branch information
christianp committed Oct 15, 2024
1 parent 96a3261 commit 258f9cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion themes/default/files/scripts/part-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
if(!p.question.exam.settings.autoSubmit) {
return;
}
var clicking_inside = pd.clicking_inside;

setTimeout(function() {
if(!pd.will_autoSubmit) {
Expand All @@ -578,7 +579,7 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
return;
}
}
pd.controls.submit(true);
pd.controls.submit(!clicking_inside);
}, 100);
},
submit: function(auto) {
Expand Down Expand Up @@ -636,6 +637,16 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
}
};

this.pointerdown = function(e) {
pd.clicking_inside = true;
return true;
}

this.pointerup = function(e) {
pd.clicking_inside = false;
return true;
}

p.xml.setAttribute('jme-context-description',p.name);
p.xml.setAttribute('path',p.path);
p.xml.setAttribute('isgap',p.isGap);
Expand Down
2 changes: 1 addition & 1 deletion themes/default/templates/xslt/part.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</xsl:variable>
<xsl:element name="{$tag}">
<xsl:attribute name="class">part <xsl:value-of select="$clear"/> type-<xsl:value-of select="@type"/> <xsl:value-of select="$block"/><xsl:if test="parent::steps"> step</xsl:if><xsl:if test="parent::gaps"> gap</xsl:if></xsl:attribute>
<xsl:attribute name="data-bind">with: question.display.getPart('<xsl:value-of select="@path" />'), visible: question.display.getPart('<xsl:value-of select="@path" />').visible, css: {dirty: question.display.getPart('<xsl:value-of select="@path" />').isDirty, 'has-name': question.display.getPart('<xsl:value-of select="@path" />').showName(), answered: answered(), dirty: isDirty(), 'has-feedback-messages': hasFeedbackMessages()}, event: {focusin: focusin, focusout: focusout}</xsl:attribute>
<xsl:attribute name="data-bind">with: question.display.getPart('<xsl:value-of select="@path" />'), visible: question.display.getPart('<xsl:value-of select="@path" />').visible, css: {dirty: question.display.getPart('<xsl:value-of select="@path" />').isDirty, 'has-name': question.display.getPart('<xsl:value-of select="@path" />').showName(), answered: answered(), dirty: isDirty(), 'has-feedback-messages': hasFeedbackMessages()}, event: {focusin: focusin, focusout: focusout}, event: {pointerdown: pointerdown, pointerup: pointerup}</xsl:attribute>
<xsl:attribute name="data-part-path"><xsl:value-of select="@path" /></xsl:attribute>
<xsl:attribute name="data-jme-context-description"><xsl:value-of select="@jme-context-description" /></xsl:attribute>
<xsl:if test="$inline='false'"><h3 class="partheader" data-bind="visible: showName(), latex: name"></h3></xsl:if>
Expand Down

0 comments on commit 258f9cc

Please sign in to comment.