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
82e31d53
Commit
82e31d53
authored
Jan 07, 2013
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hookup CourseEnrollmentAllowed to lms/djangoapps/courseware/access.py
parent
97fb0544
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
lms/djangoapps/courseware/access.py
+6
-0
lms/djangoapps/instructor/views.py
+10
-9
No files found.
lms/djangoapps/courseware/access.py
View file @
82e31d53
...
...
@@ -5,6 +5,8 @@ like DISABLE_START_DATES"""
import
logging
import
time
import
student.models
from
django.conf
import
settings
from
xmodule.course_module
import
CourseDescriptor
...
...
@@ -124,6 +126,10 @@ def _has_access_course_desc(user, course, action):
debug
(
"Allow: in enrollment period"
)
return
True
# if user is in CourseEnrollmentAllowed with right course_id then can also enroll
if
user
is
not
None
and
student
.
models
.
CourseEnrollmentAllowed
.
objects
.
filter
(
email
=
user
.
email
,
course_id
=
course
.
id
):
return
True
# otherwise, need staff access
return
_has_staff_access_to_descriptor
(
user
,
course
)
...
...
lms/djangoapps/instructor/views.py
View file @
82e31d53
...
...
@@ -335,24 +335,25 @@ def instructor_dashboard(request, course_id):
elif
action
==
'Enroll student'
:
student
=
request
.
POST
.
get
(
'enstudent'
,
''
)
datatable
=
{}
try
:
nce
=
CourseEnrollment
(
user
=
User
.
objects
.
get
(
email
=
student
),
course_id
=
course_id
)
nce
.
save
()
msg
+=
"Enrolled student with email '
%
s'"
%
student
except
Exception
as
err
:
msg
+=
"Error! Failed to enroll student with email '
%
s'
\n
"
%
student
msg
+=
str
(
err
)
+
'
\n
'
ret
=
_do_enroll_students
(
course
,
course_id
,
student
)
datatable
=
ret
[
'datatable'
]
elif
action
==
'Un-enroll student'
:
student
=
request
.
POST
.
get
(
'enstudent'
,
''
)
datatable
=
{}
isok
=
False
cea
=
CourseEnrollmentAllowed
.
objects
.
filter
(
course_id
=
course_id
,
email
=
student
)
if
cea
:
cea
.
delete
()
msg
+=
"Un-enrolled student with email '
%
s'"
%
student
isok
=
True
try
:
nce
=
CourseEnrollment
.
objects
.
get
(
user
=
User
.
objects
.
get
(
email
=
student
),
course_id
=
course_id
)
nce
.
delete
()
msg
+=
"Un-enrolled student with email '
%
s'"
%
student
except
Exception
as
err
:
if
not
isok
:
msg
+=
"Error! Failed to un-enroll student with email '
%
s'
\n
"
%
student
msg
+=
str
(
err
)
+
'
\n
'
...
...
@@ -582,7 +583,7 @@ def get_student_grade_summary_data(request, course, course_id, get_grades=True,
if
get_grades
:
gradeset
=
grades
.
grade
(
student
,
request
,
course
,
keep_raw_scores
=
get_raw_scores
)
#
log.debug('student={0}, gradeset={1}'.format(student,gradeset))
log
.
debug
(
'student={0}, gradeset={1}'
.
format
(
student
,
gradeset
))
if
get_raw_scores
:
student_grades
=
[
score
.
earned
for
score
in
gradeset
[
'raw_scores'
]]
else
:
...
...
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