Skip to content

Commit 8ef2bfa

Browse files
committed
disable "Edit" button on assessed Account outcome
fixes CNVS-23842 test plan: - create two account level outcomes (A and B) - import them into two different courses - assess outcome A in one of the courses - editing/deleting outcome A should be disabled in that course and on the account level - you should still be able to delete outcome A in the course it's not assessed in - outcome B should be able to be deleted from either course or edited at the account level Change-Id: I886d6c8dd6e4456772a531d02d0c4c27c95b92c4 Reviewed-on: https://gerrit.instructure.com/84203 Reviewed-by: Tyler Pickett <tpickett@instructure.com> QA-Review: Alex Ortiz-Rosado <aortiz@instructure.com> Tested-by: Jenkins Product-Review: McCall Smith <mcsmith@instructure.com>
1 parent 8f2d153 commit 8ef2bfa

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

app/coffeescripts/views/outcomes/OutcomeView.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ define [
184184
setQuizMastery: @setQuizMastery,
185185
useForScoring: @useForScoring,
186186
isLargeRoster: ENV.IS_LARGE_ROSTER,
187-
assessedInContext: @model.outcomeLink.assessed
187+
assessedInContext: @model.outcomeLink.assessed || (@model.isNative() && @model.get('assessed'))
188188

189189
@$('input:first').focus()
190190
@screenreaderTitleFocus()

lib/api/v1/outcome.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def outcome_json(outcome, user, session, opts = {})
5959
hash['mastery_points'] = criterion[:mastery_points]
6060
hash['ratings'] = criterion[:ratings]
6161
end
62-
63-
if opts[:assessed_outcomes]
62+
if opts[:assessed_outcomes] && outcome.context_type != "Account"
6463
hash['assessed'] = opts[:assessed_outcomes].include?(outcome.id)
6564
else
6665
hash['assessed'] = outcome.assessed?

spec/apis/v1/outcomes_api_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,20 @@ def revoke_permission(account_user, permission)
284284
:format => 'json')
285285
expect(json).to eq(outcome_json(@outcome, { :calculation_method => "highest", :can_edit => true }))
286286
end
287+
288+
it "should report as assessed if assessments exist in any aligned course" do
289+
course_with_teacher(active_all: true)
290+
student_in_course(active_all: true)
291+
assignment_model({:course => @course})
292+
assess_outcome(@outcome)
293+
raw_api_call(:get, "/api/v1/outcomes/#{@outcome.id}",
294+
:controller => 'outcomes_api',
295+
:action => 'show',
296+
:id => @outcome.id.to_s,
297+
:format => 'json')
298+
json = controller.outcome_json(@outcome, @account_user, session, {assessed_outcomes: [@outcome]})
299+
expect(json["assessed"]).to be true
300+
end
287301
end
288302

289303
describe "update" do

spec/coffeescripts/views/outcomes/OutcomeViewSpec.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ define [
199199
ok not view.$('.delete_button').attr('disabled')
200200
view.remove()
201201

202+
test 'edit is disabled when viewing an assessed account outcome in its native context', ->
203+
view = createView
204+
model: newOutcome(
205+
{ 'assessed' : true, 'native' : true, 'can_edit' : true, 'can_remove' : true },
206+
{ 'assessed' : false, 'can_unlink': true}),
207+
state: 'show'
208+
ok view.$('.edit_button').length > 0
209+
ok view.$('.edit_button').attr('disabled')
210+
view.remove()
211+
202212
test 'delete button is not shown for outcomes that cannot be unlinked', ->
203213
view = createView
204214
model: newOutcome(

0 commit comments

Comments
 (0)