account rubrics edited in courses should use course scale
closes OUT-4111 flag=account_level_mastery_scales test-plan: - Enable the FF, if not already - Create an account rubric with at least one attached outcome - Login as a teacher and view a course - Create an assignment - Create a mastery scale within this course that differs from the account scale - Attach the account rubric to the assignment - Note that the account rubric should not have changed - Edit the rubric within the assignment page (pencil icon) - Ensure a prompt appears noting that the course mastery scale will be used - Press confirm and note that the learning outcome criterion are now using the course mastery scale - Ensure cancelling out of the edit screen leaves the rubric unchanged and the criterion revert back to using the account scale - Edit again and ensure saving accurately updates the criterion, creates a new rubric, and does not modify the account rubric - Repeat the steps above with the FF disabled and ensure the existing behavior hasn't changed (a new course rubric should be created when saving, but it should have the same contents as the account rubric) Change-Id: Ib49168aac13f3a370bea69d719de8783500b0e97 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254290 Reviewed-by: Augusto Callejas <acallejas@instructure.com> Reviewed-by: Michael Brewer-Davis <mbd@instructure.com> QA-Review: Augusto Callejas <acallejas@instructure.com> Product-Review: Jody Sailor Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
a652d7f283
commit
7d715a0f0d
|
@ -503,7 +503,46 @@ const rubricEditing = {
|
|||
$form.find('.rubric_grading').showIf($assignPoints.length > 0 && $quizPage.length === 0)
|
||||
return $rubric
|
||||
},
|
||||
editRubric($original_rubric, url) {
|
||||
updateMasteryScale($rubric) {
|
||||
if (!ENV.MASTERY_SCALE?.outcome_proficiency) {
|
||||
return
|
||||
}
|
||||
const mastery_scale = ENV.MASTERY_SCALE.outcome_proficiency.ratings
|
||||
const mastery_points = mastery_scale.find(r => r.mastery).points
|
||||
const points_possible = mastery_scale[0].points
|
||||
$rubric.find('.criterion:not(.blank)').each(function() {
|
||||
const $criterion = $(this)
|
||||
if (!$criterion.hasClass('learning_outcome_criterion')) {
|
||||
return
|
||||
}
|
||||
|
||||
$criterion
|
||||
.find('.criterion_points')
|
||||
.val(points_possible)
|
||||
.blur()
|
||||
$criterion.find('.mastery_points').text(mastery_points)
|
||||
|
||||
const old_ratings = $criterion.find('.rating:not(.blank)')
|
||||
if (old_ratings.length < mastery_scale.length) {
|
||||
for (let i = old_ratings.length; i < mastery_scale.length; i++) {
|
||||
$criterion
|
||||
.find('.rating:not(.blank):first')
|
||||
.addClass('add_column')
|
||||
.click()
|
||||
}
|
||||
}
|
||||
|
||||
$criterion.find('.rating:not(.blank)').each(function(i) {
|
||||
const rating = ENV.MASTERY_SCALE.outcome_proficiency.ratings[i]
|
||||
if (!rating) {
|
||||
$(this).remove()
|
||||
} else {
|
||||
$(this).fillTemplateData({data: rating})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
editRubric($original_rubric, url, useMasteryScale = false) {
|
||||
let $rubric, data, $tr, $form
|
||||
$('#add_criterion_container').remove()
|
||||
rubricEditing.isEditing = true
|
||||
|
@ -522,6 +561,10 @@ const rubricEditing = {
|
|||
})
|
||||
$original_rubric.hide().after($rubric.show())
|
||||
|
||||
if (useMasteryScale) {
|
||||
rubricEditing.updateMasteryScale($rubric)
|
||||
}
|
||||
|
||||
$tr = $('#edit_rubric')
|
||||
.clone(true)
|
||||
.show()
|
||||
|
@ -930,18 +973,11 @@ rubricEditing.init = function() {
|
|||
|
||||
const $link = $(this),
|
||||
$rubric = $link.parents('.rubric'),
|
||||
prompt = I18n.t(
|
||||
'prompts.read_only_rubric',
|
||||
"You can't edit this " +
|
||||
"rubric, either because you don't have permission " +
|
||||
"or it's being used in more than one place. Any " +
|
||||
'changes you make will result in a new rubric based ' +
|
||||
'on the old rubric. Continue anyway?'
|
||||
)
|
||||
useMasteryScale = shouldUseMasteryScale($rubric)
|
||||
|
||||
if (rubricEditing.isEditing) return false
|
||||
if (!$link.hasClass('copy_edit') || confirm(prompt)) {
|
||||
rubricEditing.editRubric($rubric, $link.attr('href'))
|
||||
if (!$link.hasClass('copy_edit') || confirm(getEditRubricPrompt(useMasteryScale))) {
|
||||
rubricEditing.editRubric($rubric, $link.attr('href'), useMasteryScale)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1259,6 +1295,10 @@ rubricEditing.init = function() {
|
|||
rubricEditing.updateRubricPoints($rubric)
|
||||
rubricEditing.hideEditRubric($rubric, false)
|
||||
$rubric_dialog.dialog('close')
|
||||
// equivalent check in _rubric.html.erb
|
||||
if (!rubric.permissions?.update) {
|
||||
$rubric.find('.edit_rubric_link').addClass('copy_edit')
|
||||
}
|
||||
},
|
||||
() => {
|
||||
$rubric_dialog.loadingImage('remove')
|
||||
|
@ -1625,4 +1665,37 @@ if (
|
|||
)
|
||||
}
|
||||
|
||||
const getEditRubricPrompt = useMasteryScale => {
|
||||
if (!useMasteryScale) {
|
||||
return I18n.t(
|
||||
"You can't edit this " +
|
||||
"rubric, either because you don't have permission " +
|
||||
"or it's being used in more than one place. Any " +
|
||||
'changes you make will result in a new rubric based on the old rubric. Continue anyway?'
|
||||
)
|
||||
}
|
||||
if (ENV.context_asset_string.includes('course')) {
|
||||
return I18n.t(
|
||||
"You can't edit this " +
|
||||
"rubric, either because you don't have permission " +
|
||||
"or it's being used in more than one place. Any " +
|
||||
'changes you make will result in a new rubric. Any associated outcome criteria will use the course mastery scale. Continue anyway?'
|
||||
)
|
||||
} else {
|
||||
return I18n.t(
|
||||
"You can't edit this " +
|
||||
"rubric, either because you don't have permission " +
|
||||
"or it's being used in more than one place. Any " +
|
||||
'changes you make will result in a new rubric. Any associated outcome criteria will use the account mastery scale. Continue anyway?'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const shouldUseMasteryScale = $rubric => {
|
||||
if (!ENV.ACCOUNT_LEVEL_MASTERY_SCALES) {
|
||||
return false
|
||||
}
|
||||
return $rubric.find('.criterion').hasClass('learning_outcome_criterion')
|
||||
}
|
||||
|
||||
export default rubricEditing
|
||||
|
|
|
@ -168,6 +168,50 @@ describe "assignment rubrics" do
|
|||
expect(f('#rubrics span .rubric_total').text).to eq '8'
|
||||
end
|
||||
|
||||
context "with the account_level_mastery_scales FF enabled" do
|
||||
before :each do
|
||||
create_assignment_with_points(2)
|
||||
outcome_with_rubric(context: @course.account)
|
||||
@course.account.enable_feature!(:account_level_mastery_scales)
|
||||
@association = @rubric.associate_with(@assignment, @course, purpose: 'grading', use_for_grading: true)
|
||||
end
|
||||
|
||||
context "enabled" do
|
||||
before do
|
||||
@course.account.enable_feature!(:account_level_mastery_scales)
|
||||
proficiency = outcome_proficiency_model(@course)
|
||||
@proficiency_rating_points = proficiency.outcome_proficiency_ratings.map { |rating| round_if_whole(rating.points).to_s}
|
||||
end
|
||||
|
||||
it "should use the course mastery scale for outcome criterion when editing account rubrics within an assignment" do
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
points_before_edit = ff('tr.learning_outcome_criterion td.rating .points').map(&:text)
|
||||
f("#rubric_#{@rubric.id} .edit_rubric_link").click
|
||||
driver.switch_to.alert.accept
|
||||
wait_for_ajax_requests
|
||||
expect(ff('tr.learning_outcome_criterion td.rating .points').map(&:text).reject!(&:empty?)).to eq @proficiency_rating_points
|
||||
f('.cancel_button').click
|
||||
wait_for_ajaximations
|
||||
expect(ff('tr.learning_outcome_criterion td.rating .points').map(&:text)).to eq points_before_edit
|
||||
end
|
||||
end
|
||||
|
||||
context "disabled" do
|
||||
before do
|
||||
@course.account.disable_feature!(:account_level_mastery_scales)
|
||||
end
|
||||
|
||||
it "should not change existing outcome criterion when editing account rubrics within an assignment" do
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
points_before_edit = ff('tr.learning_outcome_criterion td.rating .points').map(&:text)
|
||||
f("#rubric_#{@rubric.id} .edit_rubric_link").click
|
||||
driver.switch_to.alert.accept
|
||||
wait_for_ajax_requests
|
||||
expect(ff('tr.learning_outcome_criterion td.rating .points').map(&:text).reject!(&:empty?)).to eq points_before_edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "should not adjust points when importing an outcome to an assignment", priority: "1", test_id: 2896223 do
|
||||
skip_if_safari(:alert)
|
||||
create_assignment_with_points(2)
|
||||
|
|
Loading…
Reference in New Issue