-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Enroll the coach in the CCX on creation #10251
Conversation
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:
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. |
66b9c91
to
f6432e9
Compare
pattern = "http://[^\/]+/courses/([^\/]+)/ccx_coach" | ||
results = re.match(pattern, url) | ||
ccx_key = results.group(1) | ||
course_key = SlashSeparatedCourseKey.from_deprecated_string(ccx_key) |
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.
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
?
jenkins run quality |
a52307d
to
dd030e8
Compare
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) |
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.
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?
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.
Yup, this should be using CourseKey.from_string
instead of using SlashSeparatedCourseKey.from_deprecated_string
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.
Will do.
c766b11
to
3607756
Compare
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. |
3607756
to
f21ad82
Compare
jenkins run lettuce |
|
||
pattern = re.compile(r"http://[^\/]+/courses/([^\/]+)/ccx_coach") | ||
results = re.match(pattern, url) | ||
ccx_key = results.group(1) |
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.
@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.
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.
django.core.urlresolvers.resolve()
maybe?
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.
f21ad82
to
95339a0
Compare
|
||
# Then get the second to last segment of the path | ||
head, tail = os.path.split(path) | ||
head, ccx_key = os.path.split(head) |
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.
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'
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.
OK, that makes sense. Will do. Thanks!
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.
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.
95339a0
to
17709ec
Compare
jenkins run quality |
17709ec
to
f3cd9e6
Compare
@jamiefolsom can you update the title of this PR, as well as your commit message, to indicate what this PR is actually doing? |
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.
👍 once commit message is updated. @jamiefolsom can you make sure someone on your team provides a thumbs-up to this as well? |
f3cd9e6
to
a3a7ff2
Compare
Great, tests pass. 👍 and please feel free to merge once someone on your side has given approval. |
Hey @pdpinch -- looks like this is good to merge, after your thumbs up. |
I've reviewed this again after the roles change 👍 |
Enroll the coach in the CCX on creation
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:
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:
, and has staff access to the course (ie, can access the grading, student admin and scheduling views within the course dashboard).Fixes mitocw#36