-
Notifications
You must be signed in to change notification settings - Fork 8
WIP - Course copy changes #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mpetrowi
wants to merge
6
commits into
main
Choose a base branch
from
mp-course-copy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
651513d
Schema changes to support course copy
mpetrowi 6eb3443
Add new lti models to support course copy
mpetrowi ae3a7ac
Add checking for LTI advantage roles when checking permissions
dspencer001 986507e
Initial support for copying lti launches
mpetrowi 24c3cb8
Fix support for lti 1.2 launches
mpetrowi 8c31074
Fix updating of lti_context on launch
mpetrowi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| module Concerns | ||
| module LtiCopySupport | ||
| extend ActiveSupport::Concern | ||
|
|
||
| def copy_lti_launch( | ||
| application_instance:, | ||
| lti_launch_id:, | ||
| source_lti_launch_id:, | ||
| secure_token: | ||
| ) | ||
| lti_launch = LtiLaunch.find(lti_launch_id) | ||
| source_lti_launch = LtiLaunch.find(source_lti_launch_id) | ||
| source_context = source_lti_launch.lti_context | ||
| if !source_context&.validate_token(secure_token) | ||
| raise Exceptions::InvalidSecureTokenError | ||
| end | ||
|
|
||
| # Copy configuration from the source lti launch to the new one | ||
|
|
||
| lti_launch.update!( | ||
| is_configured: true, | ||
| config: source_lti_launch.config, | ||
| parent: source_lti_launch, | ||
| ) | ||
| lti_launch | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| class Mutations::CopyLtiLaunchMutation < Mutations::BaseMutation | ||
| include Concerns::LtiCopySupport | ||
|
|
||
| argument :id, ID, required: true | ||
| argument :source_id, ID, required: true | ||
| argument :secure_token, String, required: true | ||
|
|
||
| field :lti_launch, Types::LtiLaunchType, null: false | ||
|
|
||
| def resolve(id:, source_id:, secure_token:) | ||
| lti_launch = copy_lti_launch( | ||
| application_instance: context[:current_application_instance], | ||
| lti_launch_id: id, | ||
| source_lti_launch_id: source_id, | ||
| secure_token: secure_token, | ||
| ) | ||
| { lti_launch: lti_launch } | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| class Types::HelloWorldMutationType < Types::BaseObject | ||
| field :create_lti_deep_link_jwt, mutation: Mutations::CreateLtiDeepLinkJwtMutation | ||
| field :copy_lti_launch, mutation: Mutations::CopyLtiLaunchMutation do | ||
| guard ->(_obj, _args, ctx) { | ||
| ctx[:current_user].admin? || | ||
| ctx[:current_user].can_author?(ctx[:jwt_context_id], ctx[:current_application_instance]) | ||
| } | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class Types::LtiLaunchType < Types::BaseObject | ||
| description "An lti launch" | ||
|
|
||
| field :id, ID, null: false | ||
| field :resource_link_id, String, null: false | ||
| field :parent_id, ID, null: true | ||
| field :config, String, null: true | ||
| field :is_configured, Boolean, null: false | ||
| field :created_at, GraphQL::Types::ISO8601DateTime, null: true | ||
| field :updated_at, GraphQL::Types::ISO8601DateTime, null: true | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| class Types::MutationType < Types::BaseObject | ||
| field :copy_lti_launch, mutation: Mutations::CopyLtiLaunchMutation do | ||
| guard ->(_obj, _args, ctx) { | ||
| ctx[:current_user].admin? || | ||
| ctx[:current_user].can_author?(ctx[:jwt_context_id], ctx[:current_application_instance]) | ||
| } | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| class Types::QueryType < Types::BaseObject | ||
| description "The root query of this schema" | ||
|
|
||
| field :lti_launch, Types::LtiLaunchType, null: false do | ||
| description "An lti launch with the given id" | ||
| argument :id, ID, required: true | ||
| guard ->(_obj, _args, ctx) { | ||
| ctx[:current_user].admin? || | ||
| ctx[:current_user].can_author?(ctx[:jwt_context_id], ctx[:current_application_instance]) | ||
| } | ||
| end | ||
|
|
||
| def lti_launch(id:) | ||
| lti_launch = LtiLaunch.find_by(id: id, application_instance_id: ctx[:current_application_instance].id) | ||
| if lti_launch.lti_context&.context_id != ctx[:jwt_context_id] | ||
| return nil | ||
| end | ||
|
|
||
| lti_launch | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it may be AA specific that accidentally got merged in upstream? I can see the method exists on the user as well, which is kinda weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it means the lti roles are teacher or admin, which I'm using to determine when the user can resolve a launch issue. There might be a better way to do this.