Skip to content
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

feat: add canvas integration plugin #8

Merged
merged 2 commits into from
Nov 23, 2021

Conversation

arslanashraf7
Copy link
Contributor

@arslanashraf7 arslanashraf7 commented Nov 4, 2021

Related Tickets:

#4

What's this PR does?

  • Migrates the canvas_integration app from edx-platform into a separate plugin

How to test?

To test this PR you will need a counterpart in the edx-platform and that part is specifically done in mitodl/edx-platform#274

  • Setup your edx-platform on the associated branch feat: Added Canvas support edx-platform#274 from here
  • Install this plugin (e.g. generate a build for this plugin with ./pants package :: and then install that into the edx-platform)
  • Restart the lms (make lms-restart)
  • Make sure to set the values for CANVAS_ACCESS_TOKEN=?, CANVAS_BASE_URL=https://mit.test.instructure.com` (You can ask me for the Token value)
    (More instruction to be added once the PR is finalized)
  • Now open a course as admin and click Instructor tab and make sure you see a Canvas tab under it
  • Click the canvas tab and test all the functionality of canvas integration (e.g listing enrollments, syncing enrollments, pushing grades)

Background context:

We had made several changes inside our for of the edx-platform where we added a Django application to support canvas integration. In the process, we made many changes in open edX's Instructor django application since we wanted to run canvas_integration inside the Instrutor tab. (More details to come)

Screenshots:

Landing page and tasks details
screencapture-localhost-18000-courses-course-v1-edX-DemoX-Demo-Course-instructor-2021-11-12-15_13_09

List Canvas Enrollments
Screenshot 2021-11-12 at 3 14 15 PM

List Canvas Assignments
Screenshot 2021-11-12 at 3 14 33 PM

@arslanashraf7 arslanashraf7 force-pushed the arslan/canvas-integration-plugin branch from 123176d to ffa1c41 Compare November 10, 2021 09:14
return results


def get_subsection_user_grades(course):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arslanashraf7 I think we can remove a lot of code around getting user's grate by assignment and use builtin- method of PersistentGrades

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed keeping the scope of this in mind, I've created a ticket to keep track of this optimization #10.

Copy link

@ziafazal ziafazal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arslanashraf7 few improvements I suggested which are not necessarily needed to be done right now but would be useful in future.

"""
session = requests.Session()
session.headers.update({
"Authorization": "Bearer {token}".format(token=settings.CANVAS_ACCESS_TOKEN)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can persist canvas credentials in encrypted field of django model instead of using them from settings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arslanashraf7 can you check with @mitodl/devops for their preference for managing the secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Currently we are injecting them from the vault https://github.com/search?q=org%3Amitodl+CANVAS_ACCESS_TOKEN&type=code. I'll talk to the ops guys if they want to go with this approach or the existing vault approach is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to keep it as a settings attribute because we can take the same approach of managing the value through the configuration template.

"name": subsection_block.display_name,
"integration_id": str(subsection_block.location),
"grading_type": "percent",
"points_possible": DEFAULT_ASSIGNMENT_POINTS,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible grade of actual subsection instead of default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be done as part of #10 since it will be easier to directly get the max weightage/score for a subsection.

"""Settings for the canvas integration plugin."""
settings.CANVAS_ACCESS_TOKEN = None
settings.CANVAS_BASE_URL = None
settings.FEATURES['ENABLE_CANVAS_INTEGRATION'] = False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default this feature should be enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the default, but do we even need a feature flag? If the plugin is installed, shouldn't that be a clear signal that it should be turned on?

Copy link
Contributor Author

@arslanashraf7 arslanashraf7 Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdpinch , We've been running the canvas behind a feature flag from when we first implemented that & I'm not sure what was the reason to keep it behind a flag but we can remove it and assume if the plugin is installed, the canvas is enabled.
The flag is used only once in the edx counterpart and we can make that check settings.INSTALLED_APPS instead of a flag. I'll remove the feature flag now unless you say otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to test on INSTALLED_APPS, but if you want to leave that for another issue & PR, I would be OK with that.

Copy link
Contributor Author

@arslanashraf7 arslanashraf7 Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt it would be better to do this in current PR and make it available at the earliest stage possible of the plugin, Updated.

@arslanashraf7
Copy link
Contributor Author

arslanashraf7 commented Nov 12, 2021

@ziafazal I've addressed feedback and responded to some comments. This is ready for review again, Could you please take a look. In addition, I've also addressed a bug regarding grades/assignments update counts that were 0 in all the cases. This might have been a regression of mitodl/edx-platform#189.

Copy link

@ziafazal ziafazal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This PR has been sitting for a while since it has taken so long for me to address other issues, get pants to actually build the plugin, and get the plugin itself working in devstack. It seems that my Canvas token is outdated, so I didn't directly test the functionality, but I finally managed to get the Canvas tab to show up and work correctly. Given the timing I think it's best to merge this as it is, and if there are any lingering bugs, those can be addressed in future PRs. I have a couple concerns though:

  1. The instructions on this PR are not complete. I had to dig around past issues/PRs to figure out that I needed to add a canvas_course_id setting to my course, which I ended up doing in Studio. That leads me to the next concern...
  2. Why is the documentation not included in this PR? Why would we add it in a future PR? This is the PR that adds the feature, so why not merge it with instructions to use the feature?

Anyway, feel free to merge this as it is and please keep those notes in mind for future PRs

@arslanashraf7
Copy link
Contributor Author

@gsidebo I'm sorry I somehow missed some details in the PR description but thanks for reviewing this PR anyway. I agree with your idea of adding the documentation along with the feature which should be followed in the oncoming PRs.
For the documentation of this plugin, I'll create a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants