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
a301abd5
Commit
a301abd5
authored
Aug 22, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enrollment hack for allowing Berkeley to add their students.
parent
45f516cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletions
+44
-1
lms/djangoapps/courseware/views.py
+42
-0
lms/urls.py
+2
-1
No files found.
lms/djangoapps/courseware/views.py
View file @
a301abd5
...
...
@@ -393,3 +393,45 @@ def instructor_dashboard(request, course_id):
context
=
{
'course'
:
course
,
'staff_access'
:
True
,}
return
render_to_response
(
'courseware/instructor_dashboard.html'
,
context
)
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
def
enroll_students
(
request
,
course_id
):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'staff'
)
''' Allows a staff member to enroll students in a course.
This is a short-term hack for Berkeley courses launching fall
2012. In the long term, we would like functionality like this, but
we would like both the instructor and the student to agree. Right
now, this allows any instructor to add students to their course,
which we do not want.
It is poorly written and poorly tested, but it's designed to be
stripped out.
'''
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'staff'
)
existing_students
=
[
ce
.
user
.
email
for
ce
in
CourseEnrollment
.
objects
.
filter
(
course_id
=
course_id
)]
print
request
.
POST
if
'new_students'
in
request
.
POST
:
new_students
=
request
.
POST
[
'new_students'
]
.
split
(
'
\n
'
)
else
:
new_students
=
[]
new_students
=
[
s
.
strip
()
for
s
in
new_students
]
added_students
=
[]
rejected_students
=
[]
for
student
in
new_students
:
try
:
nce
=
CourseEnrollment
(
user
=
User
.
objects
.
get
(
email
=
student
),
course_id
=
course_id
)
nce
.
save
()
added_students
.
append
(
student
)
except
:
rejected_students
.
append
(
student
)
return
render_to_response
(
"enroll_students.html"
,
{
'course'
:
course_id
,
'existing_students'
:
existing_students
,
'added_students'
:
added_students
,
'rejected_students'
:
rejected_students
,
'debug'
:
new_students
})
lms/urls.py
View file @
a301abd5
...
...
@@ -154,7 +154,8 @@ if settings.COURSEWARE_ENABLED:
'courseware.views.gradebook'
,
name
=
'gradebook'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/grade_summary$'
,
'courseware.views.grade_summary'
,
name
=
'grade_summary'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/enroll_students$'
,
'courseware.views.enroll_students'
,
name
=
'enroll_students'
),
)
# discussion forums live within courseware, so courseware must be enabled first
...
...
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