Skip to content

Commit

Permalink
SAK-41465 Fixed override selector (sakaiproject#6629)
Browse files Browse the repository at this point in the history
SAK-41464 Fixed Forums rubric grading
SAK-41470 Fixed attribute name
  • Loading branch information
adrianfish authored and Miguel Pellicer committed Mar 11, 2019
1 parent 0234b0b commit d4f398d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,28 +239,28 @@ export class SakaiRubricCriteriaGrading extends SakaiElement {
var criterion = this.criteria.filter(c => c.id == criterionId)[0];
var rating = criterion.ratings.filter(r => r.id == ratingId)[0];

criterion.selectedvalue = rating.points;
criterion.selectedRatingId = rating.id;
criterion.pointoverride = rating.points.toString();

var criterionRow = this.querySelector(`#criterion_row_${criterion.id}`);
var ratingElements = criterionRow.querySelectorAll('.rating-item');
var clickedRatingElement = this.querySelector(`#rating-item-${ratingId}`);
if (clickedRatingElement.classList.contains("selected")) {
clickedRatingElement.classList.remove("selected");
criterion.selectedvalue = 0;
criterion.selectedRatingId = "";
criterion.pointoverride = "0";
} else {
var ratingElements = this.querySelectorAll(`#criterion_row_${criterion.id} .rating-item`);
ratingElements.forEach(i => i.classList.remove('selected'));
clickedRatingElement.classList.add("selected");
criterion.selectedvalue = rating.points;
criterion.selectedRatingId = rating.id;
criterion.pointoverride = rating.points.toString();
}

var pointsInput = this.querySelector(`#rbcs-${this.evaluatedItemId}-${this.entityId}-criterion-override-${criterionId}`);
if (pointsInput) {
pointsInput.value = rating.points;
}
var selector
= `#rbcs-${this.evaluatedItemId.replace(/./g, "\\.")}-${this.entityId.replace(/./g, "\\.")}-criterion-override-${criterionId}`;
var overrideInput = this.querySelector(selector);
if (overrideInput) overrideInput.value = rating.points;

// Whenever a rating is clicked, either to select or deselect, it cancels out any override so we
// remove the strike out from the clicked points value
this.querySelector(`#points-display-${criterionId}`).classList.remove("strike");

var detail = { evaluatedItemId: this.evaluatedItemId, entityId: this.entityId, criterionId: criterionId, value: criterion.selectedvalue };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,6 @@ export class SakaiRubricGrading extends SakaiElement {
}
}

customElements.define("sakai-rubric-grading", SakaiRubricGrading);
try {
customElements.define("sakai-rubric-grading", SakaiRubricGrading);
} catch (error) { /* That's okay */ }
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function toPoint(id)
e.stopPropagation();
var itemId = $(e.target).parent().attr("itemId");
var itemId = $(e.target).parent().attr("item-id");
var gradeField = $('.adjustedScore' + itemId);
if (gradeField) {
gradeField.val(e.detail.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function downloadAll(url){
$('body').on('total-points-updated', function (e) {
e.stopPropagation();
var itemId = e.target.parentElement.getAttribute("itemid");
var itemId = e.target.parentElement.getAttribute("item-id");
var points = e.detail.value;
Expand Down

0 comments on commit d4f398d

Please sign in to comment.