2011-02-01 09:57:29 +08:00
|
|
|
#
|
2017-04-28 03:39:07 +08:00
|
|
|
# Copyright (C) 2011 - present Instructure, Inc.
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
class OutcomesController < ApplicationController
|
2012-09-18 01:20:13 +08:00
|
|
|
include Api::V1::Outcome
|
2017-02-09 01:08:10 +08:00
|
|
|
before_action :require_context, :except => [:build_outcomes]
|
2011-09-27 12:54:24 +08:00
|
|
|
add_crumb(proc { t "#crumbs.outcomes", "Outcomes" }, :except => [:destroy, :build_outcomes]) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_outcomes_path }
|
2017-02-09 01:08:10 +08:00
|
|
|
before_action { |c| c.active_tab = "outcomes" }
|
|
|
|
before_action :rich_content_service_config, only: [:show, :index]
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def index
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :read)
|
|
|
|
return unless tab_enabled?(@context.class::TAB_OUTCOMES)
|
2015-03-18 05:51:52 +08:00
|
|
|
log_asset_access([ "outcomes", @context ], "outcomes", "other")
|
2012-09-18 01:20:13 +08:00
|
|
|
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
@root_outcome_group = @context.root_outcome_group
|
2015-03-18 05:51:52 +08:00
|
|
|
if (common_core_group_id = Setting.get(AcademicBenchmark.common_core_setting_key, nil))
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
common_core_group_id = common_core_group_id.to_i
|
|
|
|
common_core_group_url = polymorphic_path([:api_v1, :global, :outcome_group], :id => common_core_group_id)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
|
|
|
js_env(:ROOT_OUTCOME_GROUP => outcome_group_json(@root_outcome_group, @current_user, session),
|
|
|
|
:CONTEXT_URL_ROOT => polymorphic_path([@context]),
|
|
|
|
:ACCOUNT_CHAIN_URL => polymorphic_path([:api_v1, @context, :account_chain]),
|
|
|
|
# Don't display state standards if in the context of a Course. Only at Account level.
|
|
|
|
:STATE_STANDARDS_URL => @context.is_a?(Course) ? nil : api_v1_global_redirect_path,
|
|
|
|
:COMMON_CORE_GROUP_ID => common_core_group_id,
|
|
|
|
:COMMON_CORE_GROUP_URL => common_core_group_url,
|
|
|
|
:PERMISSIONS => {
|
2015-08-07 02:03:43 +08:00
|
|
|
:manage_outcomes => @context.grants_right?(@current_user, session, :manage_outcomes),
|
2016-10-26 05:29:25 +08:00
|
|
|
:manage_rubrics => @context.grants_right?(@current_user, session, :manage_rubrics),
|
|
|
|
:manage_courses => @context.grants_right?(@current_user, session, :manage_courses)
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
})
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2012-09-18 01:20:13 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def show
|
2013-03-06 01:49:02 +08:00
|
|
|
if @context.respond_to?(:large_roster?) && @context.large_roster?
|
|
|
|
flash[:notice] = t "#application.notices.page_disabled_for_course", "That page has been disabled for this course"
|
|
|
|
redirect_to named_context_url(@context, :context_outcomes_path)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
learning outcomes refactor
This list is *NOT* complete, some items may have snuck in that I forgot
to note, and/or some of the noted items may not be completely functional
yet.
Specs need to be written around a lot of this, other specs will no doubt
need to be fixed.
Some things, particularly around LearningOutcomeGroups will need data
migrations that aren't there yet.
* remove LearningOutcome.non_rubric_outcomes? and replace with false
where invoked
* remove LearningOutcome.enabled? and replace with true where invoked
* remove never-taken branches
* remove the shared/aligned_outcomes partial and it's supporting
javascript, since it's now empty
* remove js handler for add_outcome_alignment_link and supporting
method since it only occurred in never-taken branches
* mix LearningOutcomeContext into Course and Account
* replace LearningOutcomeGroup.default_for(context) with
LearningOutcomeContext#root_outcome_group
* rename LearningOutcome#content_tags to LearningOutcome#alignments
* rename LearningOutcomeGroup#content_tags to
LearningOutcomeGroup#child_links, and properly restrict
* remove ContentTag[Alignment]#rubric_association_id, add
ContentTag[Alignment]#has_rubric_association? that looks at the
presence of the content's rubric_association_id
* condition off the assignment having a rubric_association rather than
filtering tags by has_rubric_association (which just looks back at
the assignment). all or none of the assignment's alignments are
forced to have the association (via the assignment). this was true in
practice before, is now codified (and more efficient)
* rename AssessmentQuestionBank#learning_outcome_tags to
AssessmentQuestionBank#learning_outcome_alignments
* rename Assignment#learning_outcome_tags to
Assignment#learning_outcome_alignments
* rename Rubric#learning_outcome_tags to
Rubric#learning_outcome_alignments
* move/rename (Course|Account)#learning_outcome_tags to
LearningOutcomeContext#learning_outcome_links
* move/rename Account#learning_outcomes (corrected) and
Course#learning_outcomes to
LearningOutcomeContext#linked_learning_outcomes
* move/rename Account#created_learning_outcomes and
Course#created_learning_outcomes to
LearningOutcomeContext#created_learning_outcomes
* clarify and correct usage of linked_learning_outcomes vs.
created_learning_outcomes
* move/rename (Account|Account)#learning_outcome_groups to
LearningOutcomeContext#learning_outcome_groups
* remove unused Account#associated_learning_outcomes
* just remove one link to a learning outcome when deleting
* merge Account#has_outcomes?, Course#has_outcomes? and
Course#has_outcomes into LearningOutcomeContext#has_outcomes?, add a
use in Context#active_record_types
* kill LearningOutcomeGroup#root_learning_outcome_group (unused)
* rename LearningOutcomeResult#content_tag to
LearningOutcomeResult#alignment
* kill unused (and broken) OutcomesController#add_outcome_group
* kill unused OutcomesController#update_outcomes_for_asset
* kill unused OutcomesController#outcomes_for_asset
* remove unused (outside specs, correct specs)
AssessmentQuestionBank#outcomes=
* remove unused ContentTag#learning_outcome_content
* replace ContentTag.learning_outcome_tags_for(asset) (only ever called
with asset=an assignment) with call to
Assignment#learning_outcome_alignments
* remove unused ContentTag.not_rubric
* remove (now) unused ContentTag.include_outcome
* remove unused LearningOutcome#learning_outcome_group_associations
* avoid explicit use of ContentTag in outcome-related specs
* replace LearningOutcomeGroup#learning_outcome_tags with
LearningOutcomeGroup#child_outcome_links (and only use for outcome
links; not tags for child groups)
* split ContentTag#create_outcome_result into
Submission#create_outcome_result,
QuizSubmission#create_outcome_result, and
RubricAssessment#create_outcome_result. fix some bugs along the way
* refactor ContentTag.outcome_tags_for_banks and some code from
QuizSubmission#(track_outcomes|update_outcomes_for_assessment_questions)
into QuizSubmission#questions_and_alignments
* refactor RubricAssociation#update_outcome_relations and
Rubric#update_alignments into LearningOutcome.update_alignments
* don't use ContentTag#rubric_association with outcome alignments; use
the tag's content's rubric_association in its place (they should have
been equal anyways)
* refactor LearningOutcome.available_in_context and
@context.root_outcome_group.sorted_all_outcomes (only time
sorted_all_outcomes is used) into
LearningOutcomeContext#available_outcomes and
LearningOutcomeContext#available_outcome
* overhaul LearningOutcomeGroup#sorted_content and rename to
LearningOutcomeGroup#sorted_children. it not returns ContentTags
(outcome links) and LearningOutcomeGroups, vs. LearningOutcomes and
LearningOutcomeGroups; fix usages appropriately
* fix UI for arranging/deleting outcome links and groups within a group
to refer to the outcome link rather than the outcome
Change-Id: I85d99f2634f7206332cb1f5d5ea575b428988d4b
Reviewed-on: https://gerrit.instructure.com/12590
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jacob Fugal <jacob@instructure.com>
2012-07-13 01:16:13 +08:00
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:id])
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
log_asset_access(@outcome, "outcomes", "outcomes")
|
|
|
|
|
|
|
|
codes = [@context].map(&:asset_string)
|
|
|
|
if @context.is_a?(Account)
|
|
|
|
if @context == @outcome.context
|
|
|
|
codes = "all"
|
|
|
|
else
|
2016-08-30 23:34:03 +08:00
|
|
|
codes = @context.all_courses.pluck(:id).map{|id| "course_#{id}"}
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
@alignments = @outcome.alignments.active.for_context(@context)
|
|
|
|
add_crumb(@outcome.short_description, named_context_url(@context, :context_outcome_url, @outcome.id))
|
|
|
|
@results = @outcome.learning_outcome_results.for_context_codes(codes).custom_ordering(params[:sort]).paginate(:page => params[:page], :per_page => 10)
|
2015-01-16 02:24:34 +08:00
|
|
|
|
|
|
|
js_env({
|
|
|
|
:PERMISSIONS => {
|
|
|
|
:manage_outcomes => @context.grants_right?(@current_user, session, :manage_outcomes)
|
|
|
|
}
|
|
|
|
})
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2011-05-04 07:28:29 +08:00
|
|
|
|
|
|
|
def details
|
learning outcomes refactor
This list is *NOT* complete, some items may have snuck in that I forgot
to note, and/or some of the noted items may not be completely functional
yet.
Specs need to be written around a lot of this, other specs will no doubt
need to be fixed.
Some things, particularly around LearningOutcomeGroups will need data
migrations that aren't there yet.
* remove LearningOutcome.non_rubric_outcomes? and replace with false
where invoked
* remove LearningOutcome.enabled? and replace with true where invoked
* remove never-taken branches
* remove the shared/aligned_outcomes partial and it's supporting
javascript, since it's now empty
* remove js handler for add_outcome_alignment_link and supporting
method since it only occurred in never-taken branches
* mix LearningOutcomeContext into Course and Account
* replace LearningOutcomeGroup.default_for(context) with
LearningOutcomeContext#root_outcome_group
* rename LearningOutcome#content_tags to LearningOutcome#alignments
* rename LearningOutcomeGroup#content_tags to
LearningOutcomeGroup#child_links, and properly restrict
* remove ContentTag[Alignment]#rubric_association_id, add
ContentTag[Alignment]#has_rubric_association? that looks at the
presence of the content's rubric_association_id
* condition off the assignment having a rubric_association rather than
filtering tags by has_rubric_association (which just looks back at
the assignment). all or none of the assignment's alignments are
forced to have the association (via the assignment). this was true in
practice before, is now codified (and more efficient)
* rename AssessmentQuestionBank#learning_outcome_tags to
AssessmentQuestionBank#learning_outcome_alignments
* rename Assignment#learning_outcome_tags to
Assignment#learning_outcome_alignments
* rename Rubric#learning_outcome_tags to
Rubric#learning_outcome_alignments
* move/rename (Course|Account)#learning_outcome_tags to
LearningOutcomeContext#learning_outcome_links
* move/rename Account#learning_outcomes (corrected) and
Course#learning_outcomes to
LearningOutcomeContext#linked_learning_outcomes
* move/rename Account#created_learning_outcomes and
Course#created_learning_outcomes to
LearningOutcomeContext#created_learning_outcomes
* clarify and correct usage of linked_learning_outcomes vs.
created_learning_outcomes
* move/rename (Account|Account)#learning_outcome_groups to
LearningOutcomeContext#learning_outcome_groups
* remove unused Account#associated_learning_outcomes
* just remove one link to a learning outcome when deleting
* merge Account#has_outcomes?, Course#has_outcomes? and
Course#has_outcomes into LearningOutcomeContext#has_outcomes?, add a
use in Context#active_record_types
* kill LearningOutcomeGroup#root_learning_outcome_group (unused)
* rename LearningOutcomeResult#content_tag to
LearningOutcomeResult#alignment
* kill unused (and broken) OutcomesController#add_outcome_group
* kill unused OutcomesController#update_outcomes_for_asset
* kill unused OutcomesController#outcomes_for_asset
* remove unused (outside specs, correct specs)
AssessmentQuestionBank#outcomes=
* remove unused ContentTag#learning_outcome_content
* replace ContentTag.learning_outcome_tags_for(asset) (only ever called
with asset=an assignment) with call to
Assignment#learning_outcome_alignments
* remove unused ContentTag.not_rubric
* remove (now) unused ContentTag.include_outcome
* remove unused LearningOutcome#learning_outcome_group_associations
* avoid explicit use of ContentTag in outcome-related specs
* replace LearningOutcomeGroup#learning_outcome_tags with
LearningOutcomeGroup#child_outcome_links (and only use for outcome
links; not tags for child groups)
* split ContentTag#create_outcome_result into
Submission#create_outcome_result,
QuizSubmission#create_outcome_result, and
RubricAssessment#create_outcome_result. fix some bugs along the way
* refactor ContentTag.outcome_tags_for_banks and some code from
QuizSubmission#(track_outcomes|update_outcomes_for_assessment_questions)
into QuizSubmission#questions_and_alignments
* refactor RubricAssociation#update_outcome_relations and
Rubric#update_alignments into LearningOutcome.update_alignments
* don't use ContentTag#rubric_association with outcome alignments; use
the tag's content's rubric_association in its place (they should have
been equal anyways)
* refactor LearningOutcome.available_in_context and
@context.root_outcome_group.sorted_all_outcomes (only time
sorted_all_outcomes is used) into
LearningOutcomeContext#available_outcomes and
LearningOutcomeContext#available_outcome
* overhaul LearningOutcomeGroup#sorted_content and rename to
LearningOutcomeGroup#sorted_children. it not returns ContentTags
(outcome links) and LearningOutcomeGroups, vs. LearningOutcomes and
LearningOutcomeGroups; fix usages appropriately
* fix UI for arranging/deleting outcome links and groups within a group
to refer to the outcome link rather than the outcome
Change-Id: I85d99f2634f7206332cb1f5d5ea575b428988d4b
Reviewed-on: https://gerrit.instructure.com/12590
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jacob Fugal <jacob@instructure.com>
2012-07-13 01:16:13 +08:00
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:outcome_id])
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :read)
|
|
|
|
|
|
|
|
@outcome.tie_to(@context)
|
|
|
|
render :json => @outcome.as_json(
|
|
|
|
:methods => :artifacts_count_for_tied_context,
|
|
|
|
:user_content => %w(description))
|
2011-05-04 07:28:29 +08:00
|
|
|
end
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def outcome_results
|
learning outcomes refactor
This list is *NOT* complete, some items may have snuck in that I forgot
to note, and/or some of the noted items may not be completely functional
yet.
Specs need to be written around a lot of this, other specs will no doubt
need to be fixed.
Some things, particularly around LearningOutcomeGroups will need data
migrations that aren't there yet.
* remove LearningOutcome.non_rubric_outcomes? and replace with false
where invoked
* remove LearningOutcome.enabled? and replace with true where invoked
* remove never-taken branches
* remove the shared/aligned_outcomes partial and it's supporting
javascript, since it's now empty
* remove js handler for add_outcome_alignment_link and supporting
method since it only occurred in never-taken branches
* mix LearningOutcomeContext into Course and Account
* replace LearningOutcomeGroup.default_for(context) with
LearningOutcomeContext#root_outcome_group
* rename LearningOutcome#content_tags to LearningOutcome#alignments
* rename LearningOutcomeGroup#content_tags to
LearningOutcomeGroup#child_links, and properly restrict
* remove ContentTag[Alignment]#rubric_association_id, add
ContentTag[Alignment]#has_rubric_association? that looks at the
presence of the content's rubric_association_id
* condition off the assignment having a rubric_association rather than
filtering tags by has_rubric_association (which just looks back at
the assignment). all or none of the assignment's alignments are
forced to have the association (via the assignment). this was true in
practice before, is now codified (and more efficient)
* rename AssessmentQuestionBank#learning_outcome_tags to
AssessmentQuestionBank#learning_outcome_alignments
* rename Assignment#learning_outcome_tags to
Assignment#learning_outcome_alignments
* rename Rubric#learning_outcome_tags to
Rubric#learning_outcome_alignments
* move/rename (Course|Account)#learning_outcome_tags to
LearningOutcomeContext#learning_outcome_links
* move/rename Account#learning_outcomes (corrected) and
Course#learning_outcomes to
LearningOutcomeContext#linked_learning_outcomes
* move/rename Account#created_learning_outcomes and
Course#created_learning_outcomes to
LearningOutcomeContext#created_learning_outcomes
* clarify and correct usage of linked_learning_outcomes vs.
created_learning_outcomes
* move/rename (Account|Account)#learning_outcome_groups to
LearningOutcomeContext#learning_outcome_groups
* remove unused Account#associated_learning_outcomes
* just remove one link to a learning outcome when deleting
* merge Account#has_outcomes?, Course#has_outcomes? and
Course#has_outcomes into LearningOutcomeContext#has_outcomes?, add a
use in Context#active_record_types
* kill LearningOutcomeGroup#root_learning_outcome_group (unused)
* rename LearningOutcomeResult#content_tag to
LearningOutcomeResult#alignment
* kill unused (and broken) OutcomesController#add_outcome_group
* kill unused OutcomesController#update_outcomes_for_asset
* kill unused OutcomesController#outcomes_for_asset
* remove unused (outside specs, correct specs)
AssessmentQuestionBank#outcomes=
* remove unused ContentTag#learning_outcome_content
* replace ContentTag.learning_outcome_tags_for(asset) (only ever called
with asset=an assignment) with call to
Assignment#learning_outcome_alignments
* remove unused ContentTag.not_rubric
* remove (now) unused ContentTag.include_outcome
* remove unused LearningOutcome#learning_outcome_group_associations
* avoid explicit use of ContentTag in outcome-related specs
* replace LearningOutcomeGroup#learning_outcome_tags with
LearningOutcomeGroup#child_outcome_links (and only use for outcome
links; not tags for child groups)
* split ContentTag#create_outcome_result into
Submission#create_outcome_result,
QuizSubmission#create_outcome_result, and
RubricAssessment#create_outcome_result. fix some bugs along the way
* refactor ContentTag.outcome_tags_for_banks and some code from
QuizSubmission#(track_outcomes|update_outcomes_for_assessment_questions)
into QuizSubmission#questions_and_alignments
* refactor RubricAssociation#update_outcome_relations and
Rubric#update_alignments into LearningOutcome.update_alignments
* don't use ContentTag#rubric_association with outcome alignments; use
the tag's content's rubric_association in its place (they should have
been equal anyways)
* refactor LearningOutcome.available_in_context and
@context.root_outcome_group.sorted_all_outcomes (only time
sorted_all_outcomes is used) into
LearningOutcomeContext#available_outcomes and
LearningOutcomeContext#available_outcome
* overhaul LearningOutcomeGroup#sorted_content and rename to
LearningOutcomeGroup#sorted_children. it not returns ContentTags
(outcome links) and LearningOutcomeGroups, vs. LearningOutcomes and
LearningOutcomeGroups; fix usages appropriately
* fix UI for arranging/deleting outcome links and groups within a group
to refer to the outcome link rather than the outcome
Change-Id: I85d99f2634f7206332cb1f5d5ea575b428988d4b
Reviewed-on: https://gerrit.instructure.com/12590
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jacob Fugal <jacob@instructure.com>
2012-07-13 01:16:13 +08:00
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:outcome_id])
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :read)
|
|
|
|
|
|
|
|
codes = [@context].map(&:asset_string)
|
|
|
|
if @context.is_a?(Account)
|
|
|
|
if @context == @outcome.context
|
|
|
|
codes = "all"
|
|
|
|
else
|
2016-08-30 23:34:03 +08:00
|
|
|
codes = @context.all_courses.pluck(:id).map{|id| "course_#{id}"}
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
@results = @outcome.learning_outcome_results.for_context_codes(codes).custom_ordering(params[:sort])
|
|
|
|
render :json => Api.paginate(@results, self, polymorphic_url([@context, :outcome_results]))
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def user_outcome_results
|
|
|
|
user_id = params[:user_id]
|
|
|
|
if @context.is_a?(User)
|
|
|
|
@user = @context
|
|
|
|
elsif @context.is_a?(Course)
|
|
|
|
@user = @context.users.find(user_id)
|
|
|
|
else
|
2016-01-15 23:08:10 +08:00
|
|
|
@user = @context.all_users.find_by!(id: user_id)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
|
|
|
return unless authorized_action(@context, @current_user, :manage)
|
|
|
|
|
|
|
|
if @user == @context
|
|
|
|
@outcomes = LearningOutcome.has_result_for(@user).active
|
|
|
|
else
|
|
|
|
@outcomes = @context.available_outcomes
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
@results = LearningOutcomeResult.for_user(@user).for_outcome_ids(@outcomes.map(&:id)) #.for_context_codes(@codes)
|
|
|
|
@results_for_outcome = @results.group_by(&:learning_outcome_id)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def list
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@account_contexts = @context.associated_accounts rescue []
|
|
|
|
@current_outcomes = @context.linked_learning_outcomes
|
|
|
|
@outcomes = Canvas::ICU.collate_by(@context.available_outcomes, &:title)
|
|
|
|
if params[:unused]
|
|
|
|
@outcomes -= @current_outcomes
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
render :json => @outcomes.map{ |o| o.as_json(methods: :cached_context_short_name) }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
# as in, add existing outcome from another context to this context
|
|
|
|
def add_outcome
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@account_contexts = @context.associated_accounts.uniq rescue []
|
|
|
|
codes = @account_contexts.map(&:asset_string)
|
|
|
|
@outcome = LearningOutcome.for_context_codes(codes).find(params[:learning_outcome_id])
|
|
|
|
@group = @context.learning_outcome_groups.find(params[:learning_outcome_group_id])
|
|
|
|
# this is silly. there should be different actions for moving a link
|
|
|
|
# (adopt_outcome_link) and adding a new link (add_outcome). as is, you
|
|
|
|
# can't add a second link to the same outcome under a new group. but just
|
|
|
|
# refactoring the model layer for now...
|
2016-12-16 03:25:16 +08:00
|
|
|
if outcome_link = @group.child_outcome_links.where(content_id: @outcome.id).first
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
@group.adopt_outcome_link(outcome_link)
|
|
|
|
else
|
|
|
|
@group.add_outcome(@outcome)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
render :json => @outcome.as_json(:methods => :cached_context_short_name, :permissions => {:user => @current_user, :session => session})
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def align
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:outcome_id])
|
|
|
|
@asset = @context.find_asset(params[:asset_string])
|
|
|
|
mastery_type = @asset.is_a?(Assignment) ? "points" : "none"
|
|
|
|
@alignment = @outcome.align(@asset, @context, :mastery_type => mastery_type) if @asset
|
|
|
|
render :json => @alignment.as_json(:include => :learning_outcome)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def alignment_redirect
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :read)
|
|
|
|
|
|
|
|
@outcome = @context.available_outcome(params[:outcome_id].to_i)
|
|
|
|
@alignment = @outcome.alignments.find(params[:id])
|
|
|
|
content_tag_redirect(@context, @alignment, :context_outcomes_url)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def remove_alignment
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@outcome = @context.available_outcome(params[:outcome_id].to_i)
|
2015-01-16 02:24:34 +08:00
|
|
|
@outcome.remove_alignment(params[:id], @context)
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
render :json => @alignment.as_json(:include => :learning_outcome)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def outcome_result
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:outcome_id])
|
|
|
|
@result = @outcome.learning_outcome_results.find(params[:id])
|
|
|
|
|
|
|
|
return unless authorized_action(@result.context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
if @result.artifact.is_a?(Submission)
|
|
|
|
@submission = @result.artifact
|
|
|
|
redirect_to named_context_url(@result.context, :context_assignment_submission_url, @submission.assignment_id, @submission.user_id)
|
|
|
|
elsif @result.artifact.is_a?(RubricAssessment) && @result.artifact.artifact && @result.artifact.artifact.is_a?(Submission)
|
|
|
|
@submission = @result.artifact.artifact
|
|
|
|
redirect_to named_context_url(@result.context, :context_assignment_submission_url, @submission.assignment_id, @submission.user_id)
|
|
|
|
elsif @result.artifact.is_a?(Quizzes::QuizSubmission) && @result.associated_asset
|
|
|
|
@submission = @result.artifact
|
2016-01-12 23:19:41 +08:00
|
|
|
@asset = @result.associated_asset
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
if @submission.attempt <= @result.attempt
|
|
|
|
@submission_version = @submission
|
|
|
|
else
|
|
|
|
@submission_version = @submission.submitted_attempts.detect{|s| s.attempt >= @result.attempt }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2016-01-12 23:19:41 +08:00
|
|
|
if @asset.is_a?(Quizzes::Quiz) && @result.alignment && @result.alignment.content_type == 'AssessmentQuestionBank'
|
|
|
|
# anchor to first question in aligned bank
|
|
|
|
question_bank_id = @result.alignment.content_id
|
|
|
|
first_aligned_question = Quizzes::QuizQuestion.where(quiz_id: @asset.id)
|
|
|
|
.joins(:assessment_question)
|
|
|
|
.where(assessment_questions: { assessment_question_bank_id: question_bank_id })
|
|
|
|
.order(:position)
|
|
|
|
.first
|
|
|
|
anchor = first_aligned_question ? "question_#{first_aligned_question.id}" : nil
|
|
|
|
elsif @asset.is_a? AssessmentQuestion
|
|
|
|
question = @submission.quiz_data.detect{|q| q['assessment_question_id'] == @asset.data[:id] }
|
|
|
|
question_id = (question && question['id']) || @asset.data[:id]
|
|
|
|
anchor = "question_#{question_id}"
|
|
|
|
end
|
|
|
|
redirect_to named_context_url(
|
|
|
|
@result.context, :context_quiz_history_url, @submission.quiz_id,
|
|
|
|
:quiz_submission_id => @submission.id,
|
|
|
|
:version => @submission_version.version_number,
|
|
|
|
:anchor => anchor)
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
else
|
|
|
|
flash[:error] = "Unrecognized artifact type: #{@result.try(:artifact_type) || 'nil'}"
|
|
|
|
redirect_to named_context_url(@context, :context_outcome_url, @outcome.id)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def reorder_alignments
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@outcome = @context.linked_learning_outcomes.find(params[:outcome_id])
|
|
|
|
@alignments = @outcome.reorder_alignments(@context, params[:order].split(","))
|
|
|
|
render :json => @alignments.map{ |a| a.as_json(include: :learning_outcome) }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def create
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
if params[:learning_outcome_group_id].present?
|
|
|
|
@outcome_group = @context.learning_outcome_groups.find(params[:learning_outcome_group_id])
|
|
|
|
end
|
|
|
|
@outcome_group ||= @context.root_outcome_group
|
2016-11-08 22:38:30 +08:00
|
|
|
@outcome = @context.created_learning_outcomes.build(learning_outcome_params)
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
if @outcome.save
|
|
|
|
@outcome_group.add_outcome(@outcome)
|
|
|
|
flash[:notice] = t :successful_outcome_creation, "Outcome successfully created!"
|
|
|
|
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
|
|
|
|
format.json { render :json => @outcome }
|
|
|
|
else
|
|
|
|
flash[:error] = t :failed_outcome_creation, "Outcome creation failed"
|
|
|
|
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
|
|
|
|
format.json { render :json => @outcome.errors, :status => :bad_request }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def update
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
@outcome = @context.created_learning_outcomes.find(params[:id])
|
|
|
|
|
|
|
|
respond_to do |format|
|
2016-11-08 22:38:30 +08:00
|
|
|
if @outcome.update_attributes(learning_outcome_params)
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
flash[:notice] = t :successful_outcome_update, "Outcome successfully updated!"
|
|
|
|
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
|
|
|
|
format.json { render :json => @outcome }
|
|
|
|
else
|
|
|
|
flash[:error] = t :failed_outcome_update, "Outcome update failed"
|
|
|
|
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
|
|
|
|
format.json { render :json => @outcome.errors, :statue => :bad_request }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def destroy
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage_outcomes)
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
# TODO: params[:id] is overloaded to be either a native outcome id or
|
|
|
|
# the id of a link to a foreign outcome. therefore it's possible to
|
|
|
|
# intend to delete a link to a foreign but accidentally delete a
|
|
|
|
# completely unrelated native outcome. needs to be decoupled.
|
|
|
|
if params[:id].present? && @outcome = @context.created_learning_outcomes.where(id: params[:id]).first
|
|
|
|
@outcome.destroy
|
|
|
|
flash[:notice] = t :successful_outcome_delete, "Outcome successfully deleted"
|
|
|
|
format.json { render :json => @outcome }
|
|
|
|
elsif params[:id].present? && @link = @context.learning_outcome_links.where(id: params[:id]).first
|
|
|
|
@link.destroy
|
|
|
|
flash[:notice] = t :successful_outcome_removal, "Outcome successfully removed"
|
|
|
|
format.json { render :json => @link.learning_outcome }
|
|
|
|
else
|
|
|
|
flash[:notice] = t :missing_outcome, "Couldn't find that learning outcome"
|
|
|
|
format.json { render :json => {:errors => {:base => t(:missing_outcome, "Couldn't find that learning outcome")}}, :status => :bad_request }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
Cleanup the outcomes controller a bit to make it easier to read through
This cleans up the code, reorganizes it a bit, updates some stale
comments, adds some new comments, and follows the 'return unless
authorized' pattern which replaces the deeply nested if blocks. So
something like this:
Instead of:
def my_method
if authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
if authorized_action(@context, @current_user, :write)
code_line 3
end
end
end
We get:
def my_method
return unless authorized_action(@context, @current_user, :read)
code_line 1
code_line 2
return unless authorized_action(@context, @current_user, :write)
code_line 3
end
Fixes CNVS-16963
Test Plan:
Make sure that all of this works:
- Create an outcome group
- Create an outcome in that group
- Create more groups and outcomes and make sure they can be
connected
- An outcome can belong to more than one group
- Edit an outcome
- Delete an outcome
Make sure that the above all fail when unauthorized
Change-Id: I31c8791cb1bbbe004462b0720f221eded0e95932
Reviewed-on: https://gerrit.instructure.com/44633
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
2014-11-18 08:54:03 +08:00
|
|
|
format.html { redirect_to named_context_url(@context, :context_outcomes_url) }
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
2016-01-05 03:31:13 +08:00
|
|
|
|
|
|
|
protected
|
|
|
|
def rich_content_service_config
|
2016-03-18 04:04:13 +08:00
|
|
|
rce_js_env(:basic)
|
2016-01-05 03:31:13 +08:00
|
|
|
end
|
2016-11-08 22:38:30 +08:00
|
|
|
|
|
|
|
def learning_outcome_params
|
2017-01-13 04:24:07 +08:00
|
|
|
params.require(:learning_outcome).permit(:description, :short_description, :title, :display_name, :vendor_guid)
|
2016-11-08 22:38:30 +08:00
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|