2020-10-27 00:50:13 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-13 04:41:44 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2017 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/>.
|
|
|
|
#
|
|
|
|
|
2017-05-04 02:27:39 +08:00
|
|
|
module Lti
|
2017-05-13 04:41:44 +08:00
|
|
|
class PrivacyLevelExpander
|
2017-05-04 04:15:23 +08:00
|
|
|
EMAIL_ONLY = %w[Person.email.primary].freeze
|
|
|
|
INLCUDE_NAME = %w[Person.name.given Person.name.full Person.name.family].freeze
|
2019-07-16 02:47:26 +08:00
|
|
|
PUBLIC = %w[Person.sourcedId CourseOffering.sourcedId]
|
2019-06-17 22:09:34 +08:00
|
|
|
.concat(EMAIL_ONLY)
|
|
|
|
.concat(INLCUDE_NAME)
|
|
|
|
.freeze
|
2017-05-04 04:15:23 +08:00
|
|
|
ANONYMOUS = %w[com.instructure.contextLabel].freeze
|
|
|
|
|
|
|
|
SUPPORTED_PARAMETERS_HASH = {
|
|
|
|
public: PUBLIC,
|
|
|
|
email_only: EMAIL_ONLY,
|
|
|
|
name_only: INLCUDE_NAME,
|
|
|
|
anonymous: ANONYMOUS
|
|
|
|
}.freeze
|
2017-05-04 02:27:39 +08:00
|
|
|
|
2024-08-20 08:56:29 +08:00
|
|
|
SUPPORTED_LEVELS = SUPPORTED_PARAMETERS_HASH.keys.map(&:to_s)
|
|
|
|
|
2017-05-13 06:02:10 +08:00
|
|
|
def initialize(placement, variable_expander)
|
2017-05-04 02:27:39 +08:00
|
|
|
@placement = placement
|
2017-05-13 06:02:10 +08:00
|
|
|
@variable_expander = variable_expander
|
2017-05-04 02:27:39 +08:00
|
|
|
end
|
|
|
|
|
2017-05-13 06:02:10 +08:00
|
|
|
def expanded_variables!(var_hash)
|
|
|
|
@variable_expander.expand_variables!(var_hash).merge(parameter_hash)
|
2017-05-04 02:27:39 +08:00
|
|
|
end
|
|
|
|
|
2017-05-04 04:15:23 +08:00
|
|
|
def supported_parameters
|
2017-05-13 06:02:10 +08:00
|
|
|
SUPPORTED_PARAMETERS_HASH[:anonymous] | SUPPORTED_PARAMETERS_HASH[@variable_expander.tool.workflow_state.to_sym]
|
2017-05-04 04:15:23 +08:00
|
|
|
end
|
|
|
|
|
2017-05-04 02:27:39 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def parameter_hash
|
2017-05-13 06:02:10 +08:00
|
|
|
@variable_expander.enabled_capability_params(supported_parameters)
|
2017-05-04 02:27:39 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|