Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b1751e70
Commit
b1751e70
authored
Feb 08, 2016
by
Your Name
Committed by
Attiya Ishaque
Feb 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User automatically registered to course.
parent
c51bcdbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
15 deletions
+83
-15
common/djangoapps/student/views.py
+21
-15
common/test/acceptance/pages/lms/instructor_dashboard.py
+26
-0
common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py
+36
-0
No files found.
common/djangoapps/student/views.py
View file @
b1751e70
...
...
@@ -1775,6 +1775,7 @@ def create_account_with_params(request, params):
log
.
error
(
u'Unable to send activation email to user from "
%
s"'
,
from_address
,
exc_info
=
True
)
else
:
registration
.
activate
()
_enroll_user_in_pending_courses
(
user
)
# Enroll student in any pending courses
# Immediately after a user creates an account, we log them in. They are only
# logged in until they close the browser. They can't log in again until they click
...
...
@@ -1804,6 +1805,25 @@ def create_account_with_params(request, params):
return
new_user
def
_enroll_user_in_pending_courses
(
student
):
"""
Enroll student in any pending courses he/she may have.
"""
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
email
=
student
.
email
)
for
cea
in
ceas
:
if
cea
.
auto_enroll
:
enrollment
=
CourseEnrollment
.
enroll
(
student
,
cea
.
course_id
)
manual_enrollment_audit
=
ManualEnrollmentAudit
.
get_manual_enrollment_by_email
(
student
.
email
)
if
manual_enrollment_audit
is
not
None
:
# get the enrolled by user and reason from the ManualEnrollmentAudit table.
# then create a new ManualEnrollmentAudit table entry for the same email
# different transition state.
ManualEnrollmentAudit
.
create_manual_enrollment_audit
(
manual_enrollment_audit
.
enrolled_by
,
student
.
email
,
ALLOWEDTOENROLL_TO_ENROLLED
,
manual_enrollment_audit
.
reason
,
enrollment
)
@csrf_exempt
def
create_account
(
request
,
post_override
=
None
):
"""
...
...
@@ -2000,21 +2020,7 @@ def activate_account(request, key):
already_active
=
False
# Enroll student in any pending courses he/she may have if auto_enroll flag is set
student
=
User
.
objects
.
filter
(
id
=
regs
[
0
]
.
user_id
)
if
student
:
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
email
=
student
[
0
]
.
email
)
for
cea
in
ceas
:
if
cea
.
auto_enroll
:
enrollment
=
CourseEnrollment
.
enroll
(
student
[
0
],
cea
.
course_id
)
manual_enrollment_audit
=
ManualEnrollmentAudit
.
get_manual_enrollment_by_email
(
student
[
0
]
.
email
)
if
manual_enrollment_audit
is
not
None
:
# get the enrolled by user and reason from the ManualEnrollmentAudit table.
# then create a new ManualEnrollmentAudit table entry for the same email
# different transition state.
ManualEnrollmentAudit
.
create_manual_enrollment_audit
(
manual_enrollment_audit
.
enrolled_by
,
student
[
0
]
.
email
,
ALLOWEDTOENROLL_TO_ENROLLED
,
manual_enrollment_audit
.
reason
,
enrollment
)
_enroll_user_in_pending_courses
(
regs
[
0
]
.
user
)
resp
=
render_to_response
(
"registration/activation_complete.html"
,
...
...
common/test/acceptance/pages/lms/instructor_dashboard.py
View file @
b1751e70
...
...
@@ -678,6 +678,7 @@ class MembershipPageAutoEnrollSection(PageObject):
auto_enroll_browse_button_selector
=
'.auto_enroll_csv .file-browse input.file_field#browseBtn'
auto_enroll_upload_button_selector
=
'.auto_enroll_csv button[name="enrollment_signup_button"]'
batch_enrollment_selector
=
'.batch-enrollment'
NOTIFICATION_ERROR
=
'error'
NOTIFICATION_WARNING
=
'warning'
NOTIFICATION_SUCCESS
=
'confirmation'
...
...
@@ -750,6 +751,31 @@ class MembershipPageAutoEnrollSection(PageObject):
self
.
q
(
css
=
self
.
auto_enroll_browse_button_selector
)
.
results
[
0
]
.
send_keys
(
file_path
)
self
.
click_upload_file_button
()
def
fill_enrollment_batch_text_box
(
self
,
email
):
"""
Fill in the form with the provided email and submit it.
"""
email_selector
=
"{} >p>textarea"
.
format
(
self
.
batch_enrollment_selector
)
enrollment_button
=
"{} .enrollment-button[data-action='enroll']"
.
format
(
self
.
batch_enrollment_selector
)
# Fill the email addresses after the email selector is visible.
self
.
wait_for_element_visibility
(
email_selector
,
'Email field is visible'
)
self
.
q
(
css
=
email_selector
)
.
fill
(
email
)
# Verify enrollment button is present before clicking
EmptyPromise
(
lambda
:
self
.
q
(
css
=
enrollment_button
)
.
present
,
"Enrollment button"
)
.
fulfill
()
self
.
q
(
css
=
enrollment_button
)
.
click
()
def
get_notification_text
(
self
):
"""
Check notification div is visible and have message.
"""
notification_selector
=
'{} .request-response'
.
format
(
self
.
batch_enrollment_selector
)
self
.
wait_for_element_visibility
(
notification_selector
,
'Notification div is visible'
)
return
self
.
q
(
css
=
"{} h3"
.
format
(
notification_selector
))
.
text
class
SpecialExamsPageAllowanceSection
(
PageObject
):
"""
...
...
common/test/acceptance/tests/lms/test_lms_instructor_dashboard.py
View file @
b1751e70
...
...
@@ -21,6 +21,7 @@ from ...pages.lms.dashboard import DashboardPage
from
...pages.lms.problem
import
ProblemPage
from
...pages.lms.track_selection
import
TrackSelectionPage
from
...pages.lms.pay_and_verify
import
PaymentAndVerificationFlow
,
FakePaymentPage
from
...pages.lms.login_and_register
import
CombinedLoginAndRegisterPage
from
common.test.acceptance.tests.helpers
import
disable_animations
from
...fixtures.certificates
import
CertificateConfigFixture
...
...
@@ -58,6 +59,9 @@ class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest):
self
.
log_in_as_instructor
()
instructor_dashboard_page
=
self
.
visit_instructor_dashboard
()
self
.
auto_enroll_section
=
instructor_dashboard_page
.
select_membership
()
.
select_auto_enroll_section
()
# Initialize the page objects
self
.
register_page
=
CombinedLoginAndRegisterPage
(
self
.
browser
,
start_page
=
"register"
)
self
.
dashboard_page
=
DashboardPage
(
self
.
browser
)
def
test_browse_and_upload_buttons_are_visible
(
self
):
"""
...
...
@@ -68,6 +72,38 @@ class AutoEnrollmentWithCSVTest(BaseInstructorDashboardTest):
self
.
assertTrue
(
self
.
auto_enroll_section
.
is_file_attachment_browse_button_visible
())
self
.
assertTrue
(
self
.
auto_enroll_section
.
is_upload_button_visible
())
def
test_enroll_unregister_student
(
self
):
"""
Scenario: On the Membership tab of the Instructor Dashboard, Batch Enrollment div is visible.
Given that I am on the Membership tab on the Instructor Dashboard
Then I enter the email and enroll it.
Logout the current page.
And Navigate to the registration page and register the student.
Then I see the course which enrolled the student.
"""
username
=
"test_{uuid}"
.
format
(
uuid
=
self
.
unique_id
[
0
:
6
])
email
=
"{user}@example.com"
.
format
(
user
=
username
)
self
.
auto_enroll_section
.
fill_enrollment_batch_text_box
(
email
)
self
.
assertIn
(
'Successfully sent enrollment emails to the following users. '
'They will be enrolled once they register:'
,
self
.
auto_enroll_section
.
get_notification_text
()
)
LogoutPage
(
self
.
browser
)
.
visit
()
self
.
register_page
.
visit
()
self
.
register_page
.
register
(
email
=
email
,
password
=
"123456"
,
username
=
username
,
full_name
=
"Test User"
,
terms_of_service
=
True
,
country
=
"US"
,
favorite_movie
=
"Harry Potter"
,
)
course_names
=
self
.
dashboard_page
.
wait_for_page
()
.
available_courses
self
.
assertEquals
(
len
(
course_names
),
1
)
self
.
assertIn
(
self
.
course_info
[
"display_name"
],
course_names
)
def
test_clicking_file_upload_button_without_file_shows_error
(
self
):
"""
Scenario: Clicking on the upload button without specifying a CSV file results in error.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment