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

Enroll the coach in the CCX on creation #10251

Merged
merged 1 commit into from
Oct 27, 2015

Conversation

jamiefolsom
Copy link
Contributor

Problem
When a CCX coach first accesses the course, and clicks CCX Coach link on the dashboard, she is invited to give her CCX course a name, and doing so creates the CCX course.

Two things that should happen at that point don't, namely:

  • The coach is not enrolled in the CCX course;
  • The coach is not granted staff access to the course. EDIT: the scope of this PR has narrowed, and now no longer includes a solution for this problem.

Solution
This PR fixes those issues at the time that the CCX course is created, by enrolling the coach in the course. and granting that coach staff access to the course.

How to test

Assuming that CCX is enabled:

  1. While logged out, register as a new user.
  2. As a logged-in instructor:
    • Visit the membership view in the LMS
    • Add the new user created in the first step as a CCX coach.
  3. As the logged-in new user:
    • Refresh your dashboard.
    • Visit the CCX coach tab
    • Give your CCX course a name and click create.
    • Note that the new user is present in the list of enrolled users., and has staff access to the course (ie, can access the grading, student admin and scheduling views within the course dashboard).

Fixes mitocw#36

@openedx-webhooks
Copy link

Thanks for the pull request, @jamiefolsom! I've created OSPR-884 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here.
We can't start reviewing your pull request until you've added yourself to the AUTHORS file . Please see the CONTRIBUTING file for more information.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U needs triage labels Oct 19, 2015
@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch from 66b9c91 to f6432e9 Compare October 19, 2015 15:20
pattern = "http://[^\/]+/courses/([^\/]+)/ccx_coach"
results = re.match(pattern, url)
ccx_key = results.group(1)
course_key = SlashSeparatedCourseKey.from_deprecated_string(ccx_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't be using this syntax anymore, I don't think. @dianakhuang could you hlep out here? Shouldn't it just be CourseKey.from_string?

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Oct 19, 2015
@giocalitri
Copy link
Contributor

jenkins run quality

@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch 4 times, most recently from a52307d to dd030e8 Compare October 21, 2015 14:44
pattern = re.compile(r"http://[^\/]+/courses/([^\/]+)/ccx_coach")
results = re.match(pattern, url)
ccx_key = results.group(1)
course_key = SlashSeparatedCourseKey.from_deprecated_string(ccx_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't be using this syntax anymore, I don't think. @dianakhuang could you help out here? Shouldn't it just be CourseKey.from_string?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, this should be using CourseKey.from_string instead of using SlashSeparatedCourseKey.from_deprecated_string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch 2 times, most recently from c766b11 to 3607756 Compare October 21, 2015 19:51
@jamiefolsom
Copy link
Contributor Author

All checks pass apart from bokchoy, which appears to be an unrelated failure. Still hunting for a better way to get the CCX identifier from a URL, which I need to do in the views test suite.

@jamiefolsom
Copy link
Contributor Author

jenkins run lettuce


pattern = re.compile(r"http://[^\/]+/courses/([^\/]+)/ccx_coach")
results = re.match(pattern, url)
ccx_key = results.group(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

@ormsbee could you do a quick drive-by here? I don't think regular expressions can possibly be the best way to get the ccx key out of this URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

django.core.urlresolvers.resolve() maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @ormsbee! I think misunderstood @sarina. I thought there was a convention within the platform for accessing the course key. Having looked at the issue and your proposed improvement, I think I've got a solution, using urlparse and os.path if that works for you guys. Pushing a commit now. Thanks!

@openedx-webhooks openedx-webhooks added community manager review and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 22, 2015
@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch from f21ad82 to 95339a0 Compare October 23, 2015 16:44

# Then get the second to last segment of the path
head, tail = os.path.split(path)
head, ccx_key = os.path.split(head)
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason I suggested you use resolve() when parsing URLs is that it's going to be more robust than manually parsing it yourself, especially if we decide to move URLs around. As a somewhat silly example, say we try to run this on Windows, where the path separator is a \ instead of a /. If you're parsing a URL, you might as well use exactly Django's logic for doing so.

>>> from django.core.urlresolvers import resolve
>>> resolver = resolve("/courses/ccx-v1:DavidsonNext+Cal_APccx_Edge+3T2015+ccx@114/ccx_coach")
>>> resolver.kwargs['course_id']
'ccx-v1:DavidsonNext+Cal_APccx_Edge+3T2015+ccx@114'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, that makes sense. Will do. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I still need to parse the path out of the url using urlparse, otherwise resolve(url) returns a 404 (since the url contains http://testserver/). But with that done, resolve(path) works nicely on the path. Thanks for your help with this, @ormsbee and @sarina. I just pushed a change for your review.

@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch from 95339a0 to 17709ec Compare October 23, 2015 18:52
@jamiefolsom
Copy link
Contributor Author

jenkins run quality

@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch from 17709ec to f3cd9e6 Compare October 26, 2015 15:11
@jamiefolsom
Copy link
Contributor Author

@sarina @ormsbee @pdpinch FYI, after some discussion of desirable coach permissions, narrowed the scope of the PR; now we don't grant staff access to the coach.

@sarina
Copy link
Contributor

sarina commented Oct 26, 2015

@jamiefolsom can you update the title of this PR, as well as your commit message, to indicate what this PR is actually doing?

@jamiefolsom jamiefolsom changed the title Enroll the coach and grant her staff access to the CCX on creation Enroll the coach in the CCX on creation Oct 26, 2015
@jamiefolsom
Copy link
Contributor Author

Hi @sarina, absolutely.

Make the course URL pattern more generic.

Comment newly added functionality.

Fix quality issues.

Address two lint errors, with regex and variable naming.

Changed how we access course_key and course_id.

Replace another instance of self.course.id.to_deprecated_string()

Remove unused import, add missing one.

Improve how the ccx key is extracted from the URL

Use resolve() instead of os.path to get the course_id.

Remove the granting of staff access to coaches.
@sarina
Copy link
Contributor

sarina commented Oct 26, 2015

👍 once commit message is updated.

@jamiefolsom can you make sure someone on your team provides a thumbs-up to this as well?

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed community manager review labels Oct 26, 2015
@jamiefolsom jamiefolsom force-pushed the fix/jf/enroll-coach-on-create-ccx branch from f3cd9e6 to a3a7ff2 Compare October 26, 2015 15:59
@jamiefolsom
Copy link
Contributor Author

Sure, will do. @pdpinch, all checks appear to be passing. I just amended the commit message per @sarina's request and rebased again, though, so maybe when this is all green again, you could take another look? Thanks!

@sarina
Copy link
Contributor

sarina commented Oct 26, 2015

Great, tests pass. 👍 and please feel free to merge once someone on your side has given approval.

@openedx-webhooks openedx-webhooks added open edx community review and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Oct 26, 2015
@jamiefolsom
Copy link
Contributor Author

Hey @pdpinch -- looks like this is good to merge, after your thumbs up.

@pdpinch
Copy link
Contributor

pdpinch commented Oct 27, 2015

I've reviewed this again after the roles change 👍

pdpinch added a commit that referenced this pull request Oct 27, 2015
@pdpinch pdpinch merged commit cda95d7 into openedx:master Oct 27, 2015
@pdpinch pdpinch deleted the fix/jf/enroll-coach-on-create-ccx branch October 27, 2015 16:44
@jamiefolsom
Copy link
Contributor Author

Cool, thanks @pdpinch and @sarina!

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

Successfully merging this pull request may close these issues.

When creating a CCX, automatically enroll the coach
7 participants