2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2011 Instructure, Inc.
|
|
|
|
#
|
|
|
|
# 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 RubricsController < ApplicationController
|
|
|
|
before_filter :require_context
|
|
|
|
before_filter { |c| c.active_tab = "rubrics" }
|
|
|
|
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
include Api::V1::Outcome
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def index
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage)
|
|
|
|
js_env :ROOT_OUTCOME_GROUP => get_root_outcome
|
|
|
|
@rubric_associations = @context.rubric_associations.bookmarked.include_rubric.to_a
|
2014-02-12 23:57:25 +08:00
|
|
|
@rubric_associations = Canvas::ICU.collate_by(@rubric_associations.select(&:rubric_id).uniq(&:rubric_id)) { |r| r.rubric.title }
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
@rubrics = @rubric_associations.map(&:rubric)
|
|
|
|
@context.is_a?(User) ? render(:action => 'user_index') : render
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def show
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
return unless authorized_action(@context, @current_user, :manage)
|
2014-01-24 05:15:45 +08:00
|
|
|
if (id = params[:id]) =~ Api::ID_REGEX
|
2013-11-27 02:24:24 +08:00
|
|
|
js_env :ROOT_OUTCOME_GROUP => get_root_outcome
|
|
|
|
@rubric_association = @context.rubric_associations.bookmarked.find_by_rubric_id(params[:id])
|
|
|
|
raise ActiveRecord::RecordNotFound unless @rubric_association
|
|
|
|
@actual_rubric = @rubric_association.rubric
|
|
|
|
else
|
|
|
|
raise ActiveRecord::RecordNotFound
|
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
def create
|
|
|
|
update
|
|
|
|
end
|
|
|
|
|
|
|
|
# This controller looks yucky (and is yucky) because it handles a funky logic.
|
|
|
|
# If you try to update a rubric that is being used in more than one place,
|
|
|
|
# instead of updating that rubric this will create a new rubric based on
|
|
|
|
# the old rubric and return that one instead. If you pass it a rubric_association_id
|
|
|
|
# parameter, then it will point the rubric_association to the new rubric
|
|
|
|
# instead of the old one.
|
|
|
|
def update
|
|
|
|
params[:rubric_association] ||= {}
|
|
|
|
@association_object = RubricAssociation.get_association_object(params[:rubric_association])
|
|
|
|
params[:rubric][:user] = @current_user if params[:rubric]
|
2013-02-16 01:04:07 +08:00
|
|
|
if (!@association_object || authorized_action(@association_object, @current_user, :read)) && authorized_action(@context, @current_user, :manage_rubrics)
|
2012-02-24 08:29:59 +08:00
|
|
|
@association = @context.rubric_associations.find_by_id(params[:rubric_association_id]) if params[:rubric_association_id].present?
|
2014-01-23 01:54:27 +08:00
|
|
|
@association_object ||= @association.association_object if @association
|
|
|
|
params[:rubric_association][:association_object] = @association_object
|
2011-02-01 09:57:29 +08:00
|
|
|
params[:rubric_association][:update_if_existing] = params[:action] == 'update'
|
2011-11-11 00:44:12 +08:00
|
|
|
skip_points_update = !!(params[:skip_updating_points_possible] =~ /true/i)
|
|
|
|
params[:rubric_association][:skip_updating_points_possible] = skip_points_update
|
2011-02-01 09:57:29 +08:00
|
|
|
@rubric = @association.rubric if params[:id] && @association && (@association.rubric_id == params[:id].to_i || (@association.rubric && @association.rubric.migration_id == "cloned_from_#{params[:id]}"))
|
2012-02-24 08:29:59 +08:00
|
|
|
@rubric ||= @context.rubrics.find_by_id(params[:id]) if params[:id].present?
|
2011-02-01 09:57:29 +08:00
|
|
|
@association = nil unless @association && @rubric && @association.rubric_id == @rubric.id
|
|
|
|
params[:rubric_association][:id] = @association.id if @association
|
|
|
|
# Update the rubric if you can
|
2012-02-24 08:29:59 +08:00
|
|
|
# Better specify params[:rubric_association_id] if you want it to update an existing association
|
2011-02-01 09:57:29 +08:00
|
|
|
|
|
|
|
# If this is a brand new rubric OR if the rubric isn't editable,
|
|
|
|
# then create a new rubric
|
|
|
|
if !@rubric || (@rubric.will_change_with_update?(params[:rubric]) && !@rubric.grants_right?(@current_user, session, :update))
|
|
|
|
original_rubric_id = @rubric && @rubric.id
|
|
|
|
@rubric = @context.rubrics.build
|
|
|
|
@rubric.rubric_id = original_rubric_id
|
|
|
|
@rubric.user = @current_user
|
|
|
|
end
|
|
|
|
if params[:rubric] && (@rubric.grants_right?(@current_user, session, :update) || (@association && @association.grants_right?(@current_user, session, :update))) #authorized_action(@rubric, @current_user, :update)
|
clean up some rubric assessment requests stuff
refs CNVS-7414
first, start at RubricsController#assessments. there is no route for it,
so remove the action and it's view. The rubric_association partial was
only used from that view, so remove it as well. Then in
RubricAssessmentController and RubricAssociationsController #create,
note that nothing ever provides an invitations param, so remove that,
and cascade down to removing or simplifying a few other methods
(particularly RubricAssociation#invite_assessors, which created users
in a bad way, and RubricAssociation#invite_assessor, which never
assigned assessor_asset, which will shortly be non-null, and is
obviously never used cause that column is never null in production).
Finally, fix some specs to properly create rubric assessments since
the (bad) helper methods are now gone.
test plan:
* specs
* basic regression test around using rubrics for grading and
peer reviews
Change-Id: Ibd7713d9fc1f847d49c47b95d8c51ce28fa41e92
Reviewed-on: https://gerrit.instructure.com/23412
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-08-17 01:42:29 +08:00
|
|
|
@association = @rubric.update_with_association(@current_user, params[:rubric], @context, params[:rubric_association])
|
2011-02-01 09:57:29 +08:00
|
|
|
@rubric = @association.rubric if @association
|
|
|
|
end
|
2011-11-11 00:44:12 +08:00
|
|
|
json_res = {}
|
|
|
|
json_res[:rubric] = @rubric.as_json(:methods => :criteria, :include_root => false, :permissions => {:user => @current_user, :session => session}) if @rubric
|
|
|
|
json_res[:rubric_association] = @association.as_json(:include_root => false, :include => [:rubric_assessments, :assessment_requests], :methods => :assessor_name, :permissions => {:user => @current_user, :session => session}) if @association
|
|
|
|
json_res[:rubric_association][:skip_updating_points_possible] = skip_points_update if json_res && json_res[:rubric_association]
|
2013-08-23 06:22:14 +08:00
|
|
|
render :json => json_res
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2011-05-27 07:50:06 +08:00
|
|
|
@rubric = RubricAssociation.find_by_rubric_id_and_context_id_and_context_type(params[:id], @context.id, @context.class.to_s, :include => :rubric).rubric
|
2011-02-01 09:57:29 +08:00
|
|
|
if authorized_action(@rubric, @current_user, :delete_associations)
|
2011-05-27 07:50:06 +08:00
|
|
|
@rubric.destroy_for(@context)
|
2013-08-23 06:22:14 +08:00
|
|
|
render :json => @rubric
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
update "find outcome" interface across canvas.
fixes #11556
when searching for an outcome on question bank,
rubric, quiz, assignment, and discussion pages,
use the new outcome interface.
this commit also adds the following features to the
find outcome dialog:
* option to turn off import of account groups;
* option to add a "set mastery at" input to the
outcome detail pane;
* option to add a "use for scoring" checkbox to
outcome detail pane.
test plan:
* attempt to add/align/whatever an outcome on the
quiz, question bank, assignment, rubic, and discussion
pages; verify that:
- new outcome find dialog is used;
- when an outcome is selected, a mastery level text box
or "use for scoring" checkbox is displayed as
appropriate;
- only outcomes in the current context are displayed;
- on import, the outcome displays;
- outcome groups cannot be imported;
- there are no regressions.
Change-Id: I2439a4287738385e31cdaff18879d4692a4b7cec
Reviewed-on: https://gerrit.instructure.com/15083
Reviewed-by: Mark Ericksen <marke@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
2012-11-06 02:43:42 +08:00
|
|
|
# Internal: Find and format the given context's root outcome group.
|
|
|
|
#
|
|
|
|
# Returns a JSON outcome object or nil.
|
|
|
|
def get_root_outcome
|
|
|
|
root_outcome = if @context.respond_to?(:root_outcome_group)
|
|
|
|
@context.root_outcome_group
|
|
|
|
elsif @context.respond_to?(:account)
|
|
|
|
@context.account.root_outcome_group
|
|
|
|
end
|
|
|
|
|
|
|
|
return nil if root_outcome.nil?
|
|
|
|
outcome_group_json(root_outcome, @current_user, session)
|
|
|
|
end
|
|
|
|
protected :get_root_outcome
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|