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
e5c95808
Commit
e5c95808
authored
Jan 05, 2013
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list/add/delete instructors on instructor dashboard
parent
16b91cf7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
7 deletions
+67
-7
lms/djangoapps/courseware/access.py
+10
-4
lms/djangoapps/instructor/views.py
+47
-3
lms/templates/courseware/instructor_dashboard.html
+10
-0
No files found.
lms/djangoapps/courseware/access.py
View file @
e5c95808
...
@@ -171,13 +171,19 @@ def _has_access_course_desc(user, course, action):
...
@@ -171,13 +171,19 @@ def _has_access_course_desc(user, course, action):
return
_dispatch
(
checkers
,
action
,
user
,
course
)
return
_dispatch
(
checkers
,
action
,
user
,
course
)
def
_get_access_group_name_course_desc
(
course
,
action
):
def
_get_access_group_name_course_desc
(
course
,
action
):
'''
'''
Return name of group which gives staff access to course. Only understands action = 'staff'
Return name of group which gives staff access to course. Only understands action = 'staff'
and 'instructor'
'''
'''
if
not
action
==
'staff'
:
if
action
==
'staff'
:
return
[]
return
_course_staff_group_name
(
course
.
location
)
return
_course_staff_group_name
(
course
.
location
)
elif
action
==
'instructor'
:
return
_course_instructor_group_name
(
course
.
location
)
return
[]
def
_has_access_error_desc
(
user
,
descriptor
,
action
):
def
_has_access_error_desc
(
user
,
descriptor
,
action
):
"""
"""
...
...
lms/djangoapps/instructor/views.py
View file @
e5c95808
...
@@ -94,11 +94,17 @@ def instructor_dashboard(request, course_id):
...
@@ -94,11 +94,17 @@ def instructor_dashboard(request, course_id):
return
response
return
response
def
get_staff_group
(
course
):
def
get_staff_group
(
course
):
staffgrp
=
get_access_group_name
(
course
,
'staff'
)
return
get_group
(
course
,
'staff'
)
def
get_instructor_group
(
course
):
return
get_group
(
course
,
'instructor'
)
def
get_group
(
course
,
groupname
):
grpname
=
get_access_group_name
(
course
,
groupname
)
try
:
try
:
group
=
Group
.
objects
.
get
(
name
=
staffgrp
)
group
=
Group
.
objects
.
get
(
name
=
grpname
)
except
Group
.
DoesNotExist
:
except
Group
.
DoesNotExist
:
group
=
Group
(
name
=
staffgrp
)
# create the group
group
=
Group
(
name
=
grpname
)
# create the group
group
.
save
()
group
.
save
()
return
group
return
group
...
@@ -239,6 +245,16 @@ def instructor_dashboard(request, course_id):
...
@@ -239,6 +245,16 @@ def instructor_dashboard(request, course_id):
datatable
[
'title'
]
=
'List of Staff in course {0}'
.
format
(
course_id
)
datatable
[
'title'
]
=
'List of Staff in course {0}'
.
format
(
course_id
)
track
.
views
.
server_track
(
request
,
'list-staff'
,
{},
page
=
'idashboard'
)
track
.
views
.
server_track
(
request
,
'list-staff'
,
{},
page
=
'idashboard'
)
elif
'List course instructors'
in
action
:
group
=
get_instructor_group
(
course
)
msg
+=
'Instructor group = {0}'
.
format
(
group
.
name
)
log
.
debug
(
'instructor grp={0}'
.
format
(
group
.
name
))
uset
=
group
.
user_set
.
all
()
datatable
=
{
'header'
:
[
'Username'
,
'Full name'
]}
datatable
[
'data'
]
=
[[
x
.
username
,
x
.
profile
.
name
]
for
x
in
uset
]
datatable
[
'title'
]
=
'List of Instructors in course {0}'
.
format
(
course_id
)
track
.
views
.
server_track
(
request
,
'list-instructors'
,
{},
page
=
'idashboard'
)
elif
action
==
'Add course staff'
:
elif
action
==
'Add course staff'
:
uname
=
request
.
POST
[
'staffuser'
]
uname
=
request
.
POST
[
'staffuser'
]
try
:
try
:
...
@@ -253,6 +269,20 @@ def instructor_dashboard(request, course_id):
...
@@ -253,6 +269,20 @@ def instructor_dashboard(request, course_id):
user
.
groups
.
add
(
group
)
user
.
groups
.
add
(
group
)
track
.
views
.
server_track
(
request
,
'add-staff {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
track
.
views
.
server_track
(
request
,
'add-staff {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
elif
action
==
'Add instructor'
:
uname
=
request
.
POST
[
'instructor'
]
try
:
user
=
User
.
objects
.
get
(
username
=
uname
)
except
User
.
DoesNotExist
:
msg
+=
'<font color="red">Error: unknown username "{0}"</font>'
.
format
(
uname
)
user
=
None
if
user
is
not
None
:
group
=
get_instructor_group
(
course
)
msg
+=
'<font color="green">Added {0} to instructor group = {1}</font>'
.
format
(
user
,
group
.
name
)
log
.
debug
(
'staffgrp={0}'
.
format
(
group
.
name
))
user
.
groups
.
add
(
group
)
track
.
views
.
server_track
(
request
,
'add-instructor {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
elif
action
==
'Remove course staff'
:
elif
action
==
'Remove course staff'
:
uname
=
request
.
POST
[
'staffuser'
]
uname
=
request
.
POST
[
'staffuser'
]
try
:
try
:
...
@@ -267,6 +297,20 @@ def instructor_dashboard(request, course_id):
...
@@ -267,6 +297,20 @@ def instructor_dashboard(request, course_id):
user
.
groups
.
remove
(
group
)
user
.
groups
.
remove
(
group
)
track
.
views
.
server_track
(
request
,
'remove-staff {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
track
.
views
.
server_track
(
request
,
'remove-staff {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
elif
action
==
'Remove instructor'
:
uname
=
request
.
POST
[
'instructor'
]
try
:
user
=
User
.
objects
.
get
(
username
=
uname
)
except
User
.
DoesNotExist
:
msg
+=
'<font color="red">Error: unknown username "{0}"</font>'
.
format
(
uname
)
user
=
None
if
user
is
not
None
:
group
=
get_instructor_group
(
course
)
msg
+=
'<font color="green">Removed {0} from instructor group = {1}</font>'
.
format
(
user
,
group
.
name
)
log
.
debug
(
'instructorgrp={0}'
.
format
(
group
.
name
))
user
.
groups
.
remove
(
group
)
track
.
views
.
server_track
(
request
,
'remove-instructor {0}'
.
format
(
user
),
{},
page
=
'idashboard'
)
#----------------------------------------
#----------------------------------------
# forum administration
# forum administration
...
...
lms/templates/courseware/instructor_dashboard.html
View file @
e5c95808
...
@@ -173,6 +173,16 @@ function goto( mode)
...
@@ -173,6 +173,16 @@ function goto( mode)
<hr
width=
"40%"
style=
"align:left"
>
<hr
width=
"40%"
style=
"align:left"
>
%endif
%endif
%if admin_access:
<hr
width=
"40%"
style=
"align:left"
>
<p>
<input
type=
"submit"
name=
"action"
value=
"List course instructors"
>
<p>
<input
type=
"text"
name=
"instructor"
>
<input
type=
"submit"
name=
"action"
value=
"Remove instructor"
>
<input
type=
"submit"
name=
"action"
value=
"Add instructor"
>
<hr
width=
"40%"
style=
"align:left"
>
%endif
%if settings.MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD'] and admin_access:
%if settings.MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD'] and admin_access:
<p>
<p>
<input
type=
"submit"
name=
"action"
value=
"Reload course from XML files"
>
<input
type=
"submit"
name=
"action"
value=
"Reload course from XML files"
>
...
...
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