SAK-50907 Assignments add option to replicate the self-report rubric to the grading rubric#13229
SAK-50907 Assignments add option to replicate the self-report rubric to the grading rubric#13229st-manu wants to merge 1 commit intosakaiproject:masterfrom
Conversation
… to the grading rubric
adrianfish
left a comment
There was a problem hiding this comment.
I actually think that this should all happen on the server. It should be a service call on the rubrics service. All you are doing, effectively, is copying an evaluation to another and it would be way more reliable to do this server side, with some unit tests. Calling into the rubric web component like you have will probably break at some point in the future.
| ASN.toggleAutoAnnounceEstimate(false); | ||
| } | ||
|
|
||
| ASN.autocompleteRubricWithSelfReport = function(event) { |
There was a problem hiding this comment.
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.
| 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 }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
| 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 }); | |
| } | |
| }); | |
| const evaluationDetails = [...studentRubric.querySelectorAll(".criterion-row")].reduce(acc, row) => { | |
| const selectedRatingId = row.querySelector(".rating-item.selected")?.id.split("-").pop(); | |
| selectedRatingId && acc.push({ criterionId: row.id.split("_").pop(), selectedRatingId }); | |
| return acc; | |
| }, []); |
There was a problem hiding this comment.
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.
| 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; | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
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.
|
This PR has been automatically marked as stale due to 10 days of inactivity. It will be closed in 4 days unless there is new activity. |
|
This PR has been automatically closed due to inactivity after being marked as stale. You may simply reopen it and continue working on it. |
https://sakaiproject.atlassian.net/browse/SAK-50907
Add the option to replicate the self-report rubric to the grading rubric.

