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
4ab36872
Commit
4ab36872
authored
Apr 28, 2015
by
amir-qayyum-arbisoft
Committed by
Amir Qayyum Khan
Sep 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error message in enrollment tab ccx coach dashboard
parent
d2659326
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
15 deletions
+83
-15
lms/djangoapps/ccx/tests/test_views.py
+30
-0
lms/djangoapps/ccx/views.py
+37
-10
lms/templates/ccx/coach_dashboard.html
+6
-3
lms/templates/ccx/enrollment.html
+10
-2
No files found.
lms/djangoapps/ccx/tests/test_views.py
View file @
4ab36872
...
...
@@ -79,6 +79,7 @@ def ccx_dummy_request():
@attr
(
'shard_1'
)
@ddt.ddt
class
TestCoachDashboard
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Tests for Custom Courses views.
...
...
@@ -387,6 +388,35 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
)
.
exists
()
)
@ddt.data
(
"dummy_student_id"
,
"xyz@gmail.com"
)
def
test_manage_add_single_invalid_student
(
self
,
student_id
):
"""enroll a single non valid student
"""
self
.
make_coach
()
ccx
=
self
.
make_ccx
()
course_key
=
CCXLocator
.
from_course_locator
(
self
.
course
.
id
,
ccx
.
id
)
url
=
reverse
(
'ccx_manage_student'
,
kwargs
=
{
'course_id'
:
course_key
}
)
redirect_url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
course_key
}
)
data
=
{
'student-action'
:
'add'
,
'student-id'
:
u','
.
join
([
student_id
,
]),
# pylint: disable=no-member
}
response
=
self
.
client
.
post
(
url
,
data
=
data
,
follow
=
True
)
error_message
=
'Could not find a user with name or email "{student_id}" '
.
format
(
student_id
=
student_id
)
self
.
assertContains
(
response
,
error_message
,
status_code
=
200
)
# we were redirected to our current location
self
.
assertRedirects
(
response
,
redirect_url
,
status_code
=
302
)
def
test_manage_add_single_student
(
self
):
"""enroll a single student who is a member of the class already
"""
...
...
lms/djangoapps/ccx/views.py
View file @
4ab36872
...
...
@@ -131,7 +131,7 @@ def dashboard(request, course, ccx=None):
context
[
'schedule'
]
=
json
.
dumps
(
schedule
,
indent
=
4
)
context
[
'save_url'
]
=
reverse
(
'save_ccx'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
context
[
'ccx_members'
]
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
ccx_locator
)
context
[
'ccx_members'
]
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
ccx_locator
,
is_active
=
True
)
context
[
'gradebook_url'
]
=
reverse
(
'ccx_gradebook'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
context
[
'grades_csv_url'
]
=
reverse
(
...
...
@@ -440,6 +440,30 @@ def ccx_invite(request, course, ccx=None):
return
redirect
(
url
)
def
validate_student_email
(
email
):
"""
validate student's email id
"""
error_message
=
None
try
:
validate_email
(
email
)
except
ValidationError
:
log
.
info
(
'Invalid user name or email when trying to enroll student:
%
s'
,
email
)
if
email
:
error_message
=
_
(
'Could not find a user with name or email "{email}" '
)
.
format
(
email
=
email
)
else
:
error_message
=
_
(
'Please enter a valid username or email.'
)
return
error_message
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@coach_dashboard
...
...
@@ -452,29 +476,32 @@ def ccx_student_management(request, course, ccx=None):
action
=
request
.
POST
.
get
(
'student-action'
,
None
)
student_id
=
request
.
POST
.
get
(
'student-id'
,
''
)
user
=
email
=
None
error_message
=
""
course_key
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
try
:
user
=
get_student_from_identifier
(
student_id
)
except
User
.
DoesNotExist
:
email
=
student_id
error_message
=
validate_student_email
(
email
)
if
email
and
not
error_message
:
error_message
=
_
(
'Could not find a user with name or email "{email}" '
)
.
format
(
email
=
email
)
else
:
email
=
user
.
email
error_message
=
validate_student_email
(
email
)
course_key
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
try
:
validate_email
(
email
)
if
error_message
is
None
:
if
action
==
'add'
:
# by decree, no emails sent to students added this way
# by decree, any students added this way are auto_enrolled
enroll_email
(
course_key
,
email
,
auto_enroll
=
True
,
email_students
=
False
)
elif
action
==
'revoke'
:
unenroll_email
(
course_key
,
email
,
email_students
=
False
)
e
xcept
ValidationError
:
log
.
info
(
'Invalid user name or email when trying to enroll student:
%
s'
,
email
)
e
lse
:
messages
.
error
(
request
,
error_message
)
url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
course_key
}
)
url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
course_key
})
return
redirect
(
url
)
...
...
lms/templates/ccx/coach_dashboard.html
View file @
4ab36872
...
...
@@ -22,6 +22,7 @@ from django.core.urlresolvers import reverse
<section
class=
"instructor-dashboard-content-2"
id=
"ccx-coach-dashboard-content"
>
<h1>
${_("CCX Coach Dashboard")}
</h1>
%if not ccx:
% if messages:
<ul
class=
"messages"
>
% for message in messages:
...
...
@@ -33,8 +34,6 @@ from django.core.urlresolvers import reverse
% endfor
</ul>
% endif
%if not ccx:
<section>
<form
action=
"${create_ccx_url}"
method=
"POST"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
/>
...
...
@@ -151,5 +150,9 @@ from django.core.urlresolvers import reverse
$
(
setup_tabs
);
$
(
setup_management_form
)
$
(
document
).
ready
(
function
()
{
if
(
$
(
'#ccx_std_list_messages'
).
length
)
{
$
(
'#ccx_std_list_messages'
)[
0
].
focus
();
}
});
</script>
lms/templates/ccx/enrollment.html
View file @
4ab36872
...
...
@@ -46,13 +46,21 @@
</form>
</div>
<div
class=
"member-lists-management"
style=
"float:left;width:50%"
aria-live=
"polite"
>
<div
class=
"member-lists-management"
style=
"float:left;width:50%"
>
<form
method=
"POST"
action=
"ccx_manage_student"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${ csrf_token }"
>
<div
class=
"auth-list-container active"
>
<div
class=
"member-list-widget"
>
<div
class=
"member-list"
>
<h2>
${_("Student List Management")}
</h2>
%if messages:
<label
for=
"ccx_std_list_messages"
class=
"sr"
>
${_("CCX student list management response message")}
</label>
<div
id=
"ccx_std_list_messages"
tabindex=
"-1"
class=
"request-response-error"
>
%for message in messages:
${message}
%endfor
</div>
%endif
<table>
<thead>
<tr>
...
...
@@ -66,7 +74,7 @@
<tr>
<td>
${member.user}
</td>
<td>
${member.user.email}
</td>
<td><
div
class=
"revoke"
><i
class=
"fa fa-times-circle"
aria-hidden=
"true"
></i>
Revoke access
</div
></td>
<td><
a
class=
"revoke"
><i
class=
"fa fa-times-circle"
aria-hidden=
"true"
></i>
${_("Revoke access")}
</a
></td>
</tr>
%endfor
</tbody>
...
...
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