Skip to content

Commit

Permalink
SAK-43222 Support i18n decimal separators in Rubrics. (sakaiproject#7942
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Feb 26, 2020
1 parent 16c46df commit d015a82
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class SakaiRubricCriteriaGrading extends RubricsElement {
<div class="rating-item ${this.selectedRatings.includes(r.id) ? "selected" : ""}" data-rating-id="${r.id}" id="rating-item-${r.id}" data-criterion-id="${c.id}" @click="${this.toggleRating}">
<h5 class="criterion-item-title">${r.title}</h5>
<p>${r.description}</p>
<span class="points" data-points="${r.points}">${r.points} <sr-lang key="points">Points</sr-lang></span>
<span class="points" data-points="${r.points}">${r.points.toLocaleString(portal.locale)} <sr-lang key="points">Points</sr-lang></span>
</div>
`)}
</div>
Expand Down Expand Up @@ -119,7 +119,7 @@ export class SakaiRubricCriteriaGrading extends RubricsElement {
<div class="rubric-totals" style="margin: 10px 0px 10px 0px;">
<input type="hidden" aria-labelledby="${tr("total")}" id="rbcs-${this.evaluatedItemId}-${this.entityId}-totalpoints" name="rbcs-${this.evaluatedItemId}-${this.entityId}-totalpoints" .value="${this.totalPoints}">
<div class="total-points">
<sr-lang key="total">Total</sr-lang>: <strong id="sakai-rubrics-total-points">${this.totalPoints}</strong>
<sr-lang key="total">Total</sr-lang>: <strong id="sakai-rubrics-total-points">${this.totalPoints.toLocaleString(portal.locale)}</strong>
</div>
</div>
Expand Down Expand Up @@ -335,7 +335,7 @@ export class SakaiRubricCriteriaGrading extends RubricsElement {
updateTotalPoints() {

this.calculateTotalPointsFromCriteria();
var detail = { evaluatedItemId: this.evaluatedItemId, entityId: this.entityId, value: this.totalPoints };
var detail = { evaluatedItemId: this.evaluatedItemId, entityId: this.entityId, value: this.totalPoints.toLocaleString(portal.locale) };
this.dispatchEvent(new CustomEvent('total-points-updated', {detail: detail, bubbles: true, composed: true}));

this.updateStateDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class SakaiRubricCriteriaReadonly extends RubricsElement {
<div class="cr-table">
<div class="cr-table-row">
${c.ratings.map(r => html`
<div tabindex="0" title="${tr("rating_title")}: ${r.title}. ${tr("rating_description")}: ${r.description}. ${tr("point_value")}: ${r.points}" class="rating-item" id="rating_item_${r.id}" on-save-ratings="saveRatings" @on-delete-rating="${this.deleteCriterionRating}">
<div tabindex="0" title="${tr("rating_title")}: ${r.title}. ${tr("rating_description")}: ${r.description}. ${tr("point_value")}: ${r.points.toLocaleString(portal.locale)}" class="rating-item" id="rating_item_${r.id}" on-save-ratings="saveRatings" @on-delete-rating="${this.deleteCriterionRating}">
<h5 class="criterion-item-title">${r.title}</h5>
<p>${r.description}</p>
<span class="points">${r.points} Points</span>
<span class="points">${r.points.toLocaleString(portal.locale)} ${tr("points")}</span>
</div>
`)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SakaiRubricCriteria extends RubricsElement {
</p>
</div>
<span class="points">
${r.points} <sr-lang key="points">Points</sr-lang>
${r.points.toLocaleString(portal.locale)} <sr-lang key="points">Points</sr-lang>
</span>
<div class="add-criterion-item">
Expand Down Expand Up @@ -172,7 +172,7 @@ export class SakaiRubricCriteria extends RubricsElement {
if (r.id == e.detail.id) {
r.title = e.detail.title;
r.description = e.detail.description;
r.points = e.detail.points;
r.points = parseFloat(e.detail.points);
r.new = false;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SakaiRubricCriterionPreview extends RubricsElement {
<p>${r.description}</p>
</div>
<span class="points">
${r.points} <sr-lang key="points">Points</sr-lang>
${r.points.toLocaleString(portal.locale)} <sr-lang key="points">Points</sr-lang>
</span>
</div>
`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export class SakaiRubricCriterionStudent extends RubricsElement {

return {
criteria: { type: Array},
totalPoints: { type: Number },
totalPoints: Number,
rubricAssociation: { attribute: "rubric-association", type: Object },
evaluationDetails: { attribute: "evaluation-details", type: Array },
preview: { type: Boolean },
preview: Boolean,
entityId: { attribute: "entity-id", type: String },
};
}
Expand Down Expand Up @@ -64,7 +64,7 @@ export class SakaiRubricCriterionStudent extends RubricsElement {
<div class="rating-item student ${r.selected ? "selected" : ""}" id="rating-item-${r.id}">
<h5 class="criterion-item-title">${r.title}</h5>
<p>${r.description}</p>
<span class="points">${r.points} Points</span>
<span class="points">${r.points.toLocaleString(portal.locale)} Points</span>
</div>
`)}
</div>
Expand All @@ -88,7 +88,7 @@ export class SakaiRubricCriterionStudent extends RubricsElement {
</div>
${!this.preview ? html`
<div class="rubric-totals" style="margin-bottom: 5px;">
<div class="total-points">Total: <strong>${this.totalPoints}</strong></div>
<div class="total-points"><sr-lang key="total">Total</sr-lang>: <strong>${this.totalPoints.toLocaleString(portal.locale)}</strong></div>
</div>
` : html``}
`;
Expand Down Expand Up @@ -139,7 +139,7 @@ export class SakaiRubricCriterionStudent extends RubricsElement {
return false;
}

if ((pointoverride || pointoverride === 0) && (parseInt(pointoverride) !== parseInt(selected))) {
if ((pointoverride || pointoverride === 0) && (parseFloat(pointoverride) !== parseFloat(selected))) {
return true;
} else {
return false;
Expand All @@ -151,9 +151,9 @@ export class SakaiRubricCriterionStudent extends RubricsElement {
this.totalPoints = this.criteria.reduce((a, c) => {

if (c.pointoverride) {
return a + parseInt(c.pointoverride);
return a + parseFloat(c.pointoverride);
} else if (c.selectedvalue) {
return a + parseInt(c.selectedvalue);
return a + parseFloat(c.selectedvalue);
} else {
return a;
}
Expand All @@ -168,7 +168,7 @@ export class SakaiRubricCriterionStudent extends RubricsElement {
return '';
}

if ((ovrdvl || ovrdvl === 0) && (parseInt(ovrdvl) !== parseInt(selected))) {
if ((ovrdvl || ovrdvl === 0) && (parseFloat(ovrdvl) !== parseFloat(selected))) {
return 'strike';
} else {
return '';
Expand Down

0 comments on commit d015a82

Please sign in to comment.