-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Added staff and instructor roles on ccx to all the staff and instructors of the master course plus fixed view as student masquerade and display name of ccx on coach dashboard #10877
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from __future__ import unicode_literals | ||
|
|
||
| from ccx_keys.locator import CCXLocator | ||
| from django.db import migrations | ||
|
|
||
| from lms.djangoapps.ccx.models import CustomCourseForEdX | ||
| from lms.djangoapps.ccx.utils import ( | ||
| add_master_course_staff_to_ccx, | ||
| reverse_add_master_course_staff_to_ccx | ||
| ) | ||
|
|
||
|
|
||
| def add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor): | ||
| """ | ||
| Add all staff and admin of master course to respective CCX(s). | ||
| """ | ||
| list_ccx = CustomCourseForEdX.objects.all() | ||
| for ccx in list_ccx: | ||
| ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) | ||
| add_master_course_staff_to_ccx(ccx.course, ccx_locator, ccx.display_name) | ||
|
|
||
|
|
||
| def reverse_add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor): | ||
| """ | ||
| Add all staff and admin of master course to respective CCX(s). | ||
| """ | ||
| list_ccx = CustomCourseForEdX.objects.all() | ||
| for ccx in list_ccx: | ||
| ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) | ||
| reverse_add_master_course_staff_to_ccx(ccx.course, ccx_locator, ccx.display_name) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('ccx', '0001_initial'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| add_master_course_staff_to_ccx_for_existing_ccx, | ||
| reverse_code=reverse_add_master_course_staff_to_ccx_for_existing_ccx | ||
| ) | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |
| bulk_delete_ccx_override_fields, | ||
| ) | ||
| from lms.djangoapps.ccx.utils import ( | ||
| add_master_course_staff_to_ccx, | ||
| assign_coach_role_to_ccx, | ||
| ccx_course, | ||
| ccx_students_enrolling_center, | ||
|
|
@@ -146,6 +147,9 @@ def dashboard(request, course, ccx=None): | |
| context['grading_policy_url'] = reverse( | ||
| 'ccx_set_grading_policy', kwargs={'course_id': ccx_locator}) | ||
|
|
||
| with ccx_course(ccx_locator) as course: | ||
| context['course'] = course | ||
|
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. This code adds
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.
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. Thanks - I see it now. This view uses the passed-in |
||
|
|
||
| else: | ||
| context['create_ccx_url'] = reverse( | ||
| 'create_ccx', kwargs={'course_id': course.id}) | ||
|
|
@@ -208,7 +212,7 @@ def create_ccx(request, course, ccx=None): | |
| ) | ||
|
|
||
| assign_coach_role_to_ccx(ccx_id, request.user, course.id) | ||
|
|
||
| add_master_course_staff_to_ccx(course, ccx_id, ccx.display_name) | ||
| return redirect(url) | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,9 +132,6 @@ def has_access(user, action, obj, course_key=None): | |
| if not user: | ||
| user = AnonymousUser() | ||
|
|
||
| if isinstance(course_key, CCXLocator): | ||
| course_key = course_key.to_course_locator() | ||
|
|
||
| # delegate the work to type-specific functions. | ||
| # (start with more specific types, then get more general) | ||
| if isinstance(obj, CourseDescriptor): | ||
|
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. What's the net effect of not converting
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. @doctoryes in courseware app the masquerading code which we use for viewing courseware content as staff, student , specific student, it use same cache which it stores against course_key/ccx key. So when we use this line
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. Makes sense - so this change is a bug fix.
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. yes, |
||
|
|
||
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.
question: did you test that using
ccx.courseactually works?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.
yes @giocalitri , I tested it by re-runing migration.
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 the migration be reversed?
I'm just remembering an unfortunate PR that we had to revert and it was further complicated because we couldn't revert the migrations.
@bdero may have some advice.