-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Made coach dashboard available on ccx in addition to master course #10672
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| from student.roles import CourseCcxCoachRole | ||
| from student.models import CourseEnrollment | ||
|
|
||
| from instructor.access import allow_access | ||
| from instructor.views.api import _split_input_list | ||
| from instructor.views.gradebook_api import get_grade_book_page | ||
| from instructor.views.tools import get_student_from_identifier | ||
|
|
@@ -132,7 +133,10 @@ def dashboard(request, course, ccx=None): | |
| } | ||
|
|
||
| if ccx: | ||
| ccx_locator = CCXLocator.from_course_locator(course.id, ccx.id) | ||
| ccx_locator = CCXLocator.from_course_locator(course.id, unicode(ccx.id)) | ||
| # At this point we are done with verification that current user is ccx coach. | ||
| assign_coach_role_to_ccx(ccx_locator, request.user, course.id) | ||
|
|
||
| schedule = get_ccx_schedule(course, ccx) | ||
| grading_policy = get_override_for_ccx( | ||
| ccx, course, 'grading_policy', course.grading_policy) | ||
|
|
@@ -147,6 +151,7 @@ def dashboard(request, course, ccx=None): | |
| context['grading_policy'] = json.dumps(grading_policy, indent=4) | ||
| context['grading_policy_url'] = reverse( | ||
| 'ccx_set_grading_policy', kwargs={'course_id': ccx_locator}) | ||
|
|
||
| else: | ||
| context['create_ccx_url'] = reverse( | ||
| 'create_ccx', kwargs={'course_id': course.id}) | ||
|
|
@@ -208,9 +213,31 @@ def create_ccx(request, course, ccx=None): | |
| email_params=email_params, | ||
| ) | ||
|
|
||
| assign_coach_role_to_ccx(ccx_id, request.user, course.id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this in addition to L138?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pdpinch It is for the user who already have created ccx. In sum this is for existing ccx course, to show coach dashboard tab |
||
|
|
||
| return redirect(url) | ||
|
|
||
|
|
||
| def assign_coach_role_to_ccx(ccx_locator, user, master_course_id): | ||
| """ | ||
| Check if user has ccx_coach role on master course then assign him coach role on ccx only | ||
| if role is not already assigned. Because of this coach can open dashboard from master course | ||
| as well as ccx. | ||
| :param ccx_locator: CCX key | ||
| :param user: User to whom we want to assign role. | ||
| :param master_course_id: Master course key | ||
| """ | ||
| coach_role_on_master_course = CourseCcxCoachRole(master_course_id) | ||
| # check if user has coach role on master course | ||
| if coach_role_on_master_course.has_user(user): | ||
| # Check if user has coach role on ccx. | ||
| role = CourseCcxCoachRole(ccx_locator) | ||
| if not role.has_user(user): | ||
| # assign user role coach on ccx | ||
| with ccx_course(ccx_locator) as course: | ||
| allow_access(course, user, "ccx_coach", send_email=False) | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra line
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is ok @pdpinch because this is a global method. And we put two spaces before and after a global method or vaiable |
||
| @ensure_csrf_cookie | ||
| @cache_control(no_cache=True, no_store=True, must_revalidate=True) | ||
| @coach_dashboard | ||
|
|
||
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.
Can we address this upstream in https://github.com/edx/ccx-keys ?
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.
@pdpinch
yeah we can but then we need to hold this PR. it depends on this fix
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. Leave it as is, but let's open a PR on ccx-keys too.