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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
33 deletions
+101
-33
lms/djangoapps/ccx/tests/test_views.py
+30
-0
lms/djangoapps/ccx/views.py
+37
-10
lms/templates/ccx/coach_dashboard.html
+24
-21
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():
...
@@ -79,6 +79,7 @@ def ccx_dummy_request():
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@ddt.ddt
class
TestCoachDashboard
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestCoachDashboard
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Tests for Custom Courses views.
Tests for Custom Courses views.
...
@@ -387,6 +388,35 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -387,6 +388,35 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
)
.
exists
()
)
.
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
):
def
test_manage_add_single_student
(
self
):
"""enroll a single student who is a member of the class already
"""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):
...
@@ -131,7 +131,7 @@ def dashboard(request, course, ccx=None):
context
[
'schedule'
]
=
json
.
dumps
(
schedule
,
indent
=
4
)
context
[
'schedule'
]
=
json
.
dumps
(
schedule
,
indent
=
4
)
context
[
'save_url'
]
=
reverse
(
context
[
'save_url'
]
=
reverse
(
'save_ccx'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
'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
(
context
[
'gradebook_url'
]
=
reverse
(
'ccx_gradebook'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
'ccx_gradebook'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
context
[
'grades_csv_url'
]
=
reverse
(
context
[
'grades_csv_url'
]
=
reverse
(
...
@@ -440,6 +440,30 @@ def ccx_invite(request, course, ccx=None):
...
@@ -440,6 +440,30 @@ def ccx_invite(request, course, ccx=None):
return
redirect
(
url
)
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
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@coach_dashboard
@coach_dashboard
...
@@ -452,29 +476,32 @@ def ccx_student_management(request, course, ccx=None):
...
@@ -452,29 +476,32 @@ def ccx_student_management(request, course, ccx=None):
action
=
request
.
POST
.
get
(
'student-action'
,
None
)
action
=
request
.
POST
.
get
(
'student-action'
,
None
)
student_id
=
request
.
POST
.
get
(
'student-id'
,
''
)
student_id
=
request
.
POST
.
get
(
'student-id'
,
''
)
user
=
email
=
None
user
=
email
=
None
error_message
=
""
course_key
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
try
:
try
:
user
=
get_student_from_identifier
(
student_id
)
user
=
get_student_from_identifier
(
student_id
)
except
User
.
DoesNotExist
:
except
User
.
DoesNotExist
:
email
=
student_id
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
:
else
:
email
=
user
.
email
email
=
user
.
email
error_message
=
validate_student_email
(
email
)
course_key
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
if
error_message
is
None
:
try
:
validate_email
(
email
)
if
action
==
'add'
:
if
action
==
'add'
:
# by decree, no emails sent to students added this way
# by decree, no emails sent to students added this way
# by decree, any students added this way are auto_enrolled
# by decree, any students added this way are auto_enrolled
enroll_email
(
course_key
,
email
,
auto_enroll
=
True
,
email_students
=
False
)
enroll_email
(
course_key
,
email
,
auto_enroll
=
True
,
email_students
=
False
)
elif
action
==
'revoke'
:
elif
action
==
'revoke'
:
unenroll_email
(
course_key
,
email
,
email_students
=
False
)
unenroll_email
(
course_key
,
email
,
email_students
=
False
)
e
xcept
ValidationError
:
e
lse
:
log
.
info
(
'Invalid user name or email when trying to enroll student:
%
s'
,
email
)
messages
.
error
(
request
,
error_message
)
url
=
reverse
(
url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
course_key
})
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
course_key
}
)
return
redirect
(
url
)
return
redirect
(
url
)
...
...
lms/templates/ccx/coach_dashboard.html
View file @
4ab36872
...
@@ -22,27 +22,26 @@ from django.core.urlresolvers import reverse
...
@@ -22,27 +22,26 @@ from django.core.urlresolvers import reverse
<section
class=
"instructor-dashboard-content-2"
id=
"ccx-coach-dashboard-content"
>
<section
class=
"instructor-dashboard-content-2"
id=
"ccx-coach-dashboard-content"
>
<h1>
${_("CCX Coach Dashboard")}
</h1>
<h1>
${_("CCX Coach Dashboard")}
</h1>
% if messages:
<ul
class=
"messages"
>
% for message in messages:
% if message.tags:
<li
class=
"${message.tags}"
>
${message}
</li>
% else:
<li>
${message}
</li>
% endif
% endfor
</ul>
% endif
%if not ccx:
%if not ccx:
<section>
% if messages:
<form
action=
"${create_ccx_url}"
method=
"POST"
>
<ul
class=
"messages"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
/>
% for message in messages:
<label
class=
"sr"
for=
"ccx_name"
>
${_('Name your CCX')}
</label>
% if message.tags:
<input
name=
"name"
id=
"ccx_name"
placeholder=
"${_('Name your CCX')}"
/><br/>
<li
class=
"${message.tags}"
>
${message}
</li>
<button
id=
"create-ccx"
>
Coach a new Custom Course for EdX
</button>
% else:
</form>
<li>
${message}
</li>
</section>
% endif
% endfor
</ul>
% endif
<section>
<form
action=
"${create_ccx_url}"
method=
"POST"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${csrf_token}"
/>
<label
class=
"sr"
for=
"ccx_name"
>
${_('Name your CCX')}
</label>
<input
name=
"name"
id=
"ccx_name"
placeholder=
"${_('Name your CCX')}"
/><br/>
<button
id=
"create-ccx"
>
Coach a new Custom Course for EdX
</button>
</form>
</section>
%endif
%endif
%if ccx:
%if ccx:
...
@@ -151,5 +150,9 @@ from django.core.urlresolvers import reverse
...
@@ -151,5 +150,9 @@ from django.core.urlresolvers import reverse
$
(
setup_tabs
);
$
(
setup_tabs
);
$
(
setup_management_form
)
$
(
setup_management_form
)
$
(
document
).
ready
(
function
()
{
if
(
$
(
'#ccx_std_list_messages'
).
length
)
{
$
(
'#ccx_std_list_messages'
)[
0
].
focus
();
}
});
</script>
</script>
lms/templates/ccx/enrollment.html
View file @
4ab36872
...
@@ -46,13 +46,21 @@
...
@@ -46,13 +46,21 @@
</form>
</form>
</div>
</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"
>
<form
method=
"POST"
action=
"ccx_manage_student"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${ csrf_token }"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${ csrf_token }"
>
<div
class=
"auth-list-container active"
>
<div
class=
"auth-list-container active"
>
<div
class=
"member-list-widget"
>
<div
class=
"member-list-widget"
>
<div
class=
"member-list"
>
<div
class=
"member-list"
>
<h2>
${_("Student List Management")}
</h2>
<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>
<table>
<thead>
<thead>
<tr>
<tr>
...
@@ -66,7 +74,7 @@
...
@@ -66,7 +74,7 @@
<tr>
<tr>
<td>
${member.user}
</td>
<td>
${member.user}
</td>
<td>
${member.user.email}
</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>
</tr>
%endfor
%endfor
</tbody>
</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