-
-
Notifications
You must be signed in to change notification settings - Fork 965
SAK-50907 Assignments add option to replicate the self-report rubric to the grading rubric #13229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1006,6 +1006,92 @@ ASN.disableTimesheetSetupSection = function() | |||||||||||||||||||||||||||||||||
ASN.toggleAutoAnnounceEstimate(false); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
ASN.autocompleteRubricWithSelfReport = function(event) { | ||||||||||||||||||||||||||||||||||
event.preventDefault(); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const studentRubric = document.querySelector("sakai-rubric-student"); | ||||||||||||||||||||||||||||||||||
if (!studentRubric) { | ||||||||||||||||||||||||||||||||||
console.error("sakai-rubric-student element not found"); | ||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const gradingRubric = document.querySelector("sakai-rubric-grading"); | ||||||||||||||||||||||||||||||||||
if (!gradingRubric) { | ||||||||||||||||||||||||||||||||||
console.error("sakai-rubric-grading element not found"); | ||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const evaluationDetails = []; | ||||||||||||||||||||||||||||||||||
const criterionRows = studentRubric.querySelectorAll(".criterion-row"); | ||||||||||||||||||||||||||||||||||
criterionRows.forEach(row => { | ||||||||||||||||||||||||||||||||||
const criterionId = row.id.split("_").pop(); | ||||||||||||||||||||||||||||||||||
const selectedRating = row.querySelector(".rating-item.selected"); | ||||||||||||||||||||||||||||||||||
if (selectedRating) { | ||||||||||||||||||||||||||||||||||
const selectedRatingId = selectedRating.id.split("-").pop(); | ||||||||||||||||||||||||||||||||||
evaluationDetails.push({ criterionId, selectedRatingId }); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
Comment on lines
+1024
to
+1033
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm spreading the NodeList into an array and then reducing the array. I'm using optional chaining to remove some of the variables you had introduced. |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
if (evaluationDetails.length === 0) { | ||||||||||||||||||||||||||||||||||
console.error("No evaluation details found in sakai-rubric-student"); | ||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const selectedItems = gradingRubric.querySelectorAll(".rating-item.selected"); | ||||||||||||||||||||||||||||||||||
selectedItems.forEach(item => { | ||||||||||||||||||||||||||||||||||
item.click(); | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
let totalPoints = 0; | ||||||||||||||||||||||||||||||||||
const decimalSeparator = 1.1.toLocaleString(portal.locale).substring(1, 2); | ||||||||||||||||||||||||||||||||||
evaluationDetails.forEach(detail => { | ||||||||||||||||||||||||||||||||||
const criterionRow = gradingRubric.querySelector(`#criterion_row_${detail.criterionId}`); | ||||||||||||||||||||||||||||||||||
if (criterionRow) { | ||||||||||||||||||||||||||||||||||
const ratingItem = criterionRow.querySelector(`.rating-item[data-rating-id="${detail.selectedRatingId}"]`); | ||||||||||||||||||||||||||||||||||
if (ratingItem) { | ||||||||||||||||||||||||||||||||||
ratingItem.click(); | ||||||||||||||||||||||||||||||||||
const pointsElement = ratingItem.querySelector(".points"); | ||||||||||||||||||||||||||||||||||
const pointsText = pointsElement.textContent.trim(); | ||||||||||||||||||||||||||||||||||
let points = parseFloat(pointsText.replace(",", ".")); | ||||||||||||||||||||||||||||||||||
const pointsInParentheses = pointsElement.querySelector("b"); | ||||||||||||||||||||||||||||||||||
if (pointsInParentheses) { | ||||||||||||||||||||||||||||||||||
const pointsInParenthesesText = pointsInParentheses.textContent.trim().replace(/[()]/g, ''); | ||||||||||||||||||||||||||||||||||
points = parseFloat(pointsInParenthesesText.replace(",", ".")); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
totalPoints += points; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
Comment on lines
+1047
to
+1064
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole block should go into the rubric code somewhere. It seems a bit fragile, especially selecting the bold tag to find the points in parentheses. You could move the code into rubrics and add a unit test. |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const formattedTotalPoints = totalPoints.toLocaleString(portal.locale, { maximumFractionDigits: 2 }).replace(".", decimalSeparator); | ||||||||||||||||||||||||||||||||||
const scoreGradeInput = document.querySelector("#grade"); | ||||||||||||||||||||||||||||||||||
if (scoreGradeInput) { | ||||||||||||||||||||||||||||||||||
scoreGradeInput.value = formattedTotalPoints; | ||||||||||||||||||||||||||||||||||
scoreGradeInput.dispatchEvent(new Event("keypress", { bubbles: true })); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
const studentRubricAutocompleteConfirm = document.querySelector("#student-rubric-autocomplete-confirm"); | ||||||||||||||||||||||||||||||||||
if (studentRubricAutocompleteConfirm) { | ||||||||||||||||||||||||||||||||||
studentRubricAutocompleteConfirm.classList.remove("d-none"); | ||||||||||||||||||||||||||||||||||
setTimeout(() => { | ||||||||||||||||||||||||||||||||||
studentRubricAutocompleteConfirm.classList.add("d-none"); | ||||||||||||||||||||||||||||||||||
}, 2000); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
document.addEventListener('rubric-student-rendered', function() { | ||||||||||||||||||||||||||||||||||
const studentRubricButton = document.getElementById("student-rubric-autocomplete-button"); | ||||||||||||||||||||||||||||||||||
if (studentRubricButton) { | ||||||||||||||||||||||||||||||||||
const rubricPreview = document.querySelector("sakai-rubric-criterion-preview"); | ||||||||||||||||||||||||||||||||||
if (rubricPreview) { | ||||||||||||||||||||||||||||||||||
console.debug("sakai-rubric-criterion-preview element found, hiding button"); | ||||||||||||||||||||||||||||||||||
studentRubricButton.classList.add("d-none"); | ||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||
studentRubricButton.classList.remove("d-none"); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
$(document).ready(() => { | ||||||||||||||||||||||||||||||||||
//peer-review and self-report | ||||||||||||||||||||||||||||||||||
$('body').on('rubric-association-loaded', e => { | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a brand new function, you should probably use a two space indentation. It's what we use in all the webcomponents and what we specify in our eslint config.