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
f7e141b1
Commit
f7e141b1
authored
Dec 04, 2015
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove admin dashboard (AN-3351)
parent
e9a32340
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
134 deletions
+0
-134
lms/djangoapps/dashboard/views.py
+0
-87
lms/templates/admin_dashboard.html
+0
-45
lms/urls.py
+0
-2
No files found.
lms/djangoapps/dashboard/views.py
deleted
100644 → 0
View file @
e9a32340
"""View functions for the LMS Student dashboard"""
from
django.http
import
Http404
from
edxmako.shortcuts
import
render_to_response
from
django.db
import
connection
from
student.models
import
CourseEnrollment
from
django.contrib.auth.models
import
User
def
dictfetchall
(
cursor
):
'''Returns a list of all rows from a cursor as a column: result dict.
Borrowed from Django documentation'''
desc
=
cursor
.
description
table
=
[]
table
.
append
([
col
[
0
]
for
col
in
desc
])
# ensure response from db is a list, not a tuple (which is returned
# by MySQL backed django instances)
rows_from_cursor
=
cursor
.
fetchall
()
table
=
table
+
[
list
(
row
)
for
row
in
rows_from_cursor
]
return
table
def
SQL_query_to_list
(
cursor
,
query_string
):
# pylint: disable=invalid-name
"""Returns the raw result of the query"""
cursor
.
execute
(
query_string
)
raw_result
=
dictfetchall
(
cursor
)
return
raw_result
def
dashboard
(
request
):
"""
Slightly less hackish hack to show staff enrollment numbers and other
simple queries.
All queries here should be indexed and simple. Mostly, this means don't
touch courseware_studentmodule, as tempting as it may be.
"""
if
not
request
.
user
.
is_staff
:
raise
Http404
# results are passed to the template. The template knows how to render
# two types of results: scalars and tables. Scalars should be represented
# as "Visible Title": Value and tables should be lists of lists where each
# inner list represents a single row of the table
results
=
{
"scalars"
:
{},
"tables"
:
{}}
# count how many users we have
results
[
"scalars"
][
"Unique Usernames"
]
=
User
.
objects
.
filter
()
.
count
()
results
[
"scalars"
][
"Activated Usernames"
]
=
User
.
objects
.
filter
(
is_active
=
1
)
.
count
()
# count how many enrollments we have
results
[
"scalars"
][
"Total Enrollments Across All Courses"
]
=
CourseEnrollment
.
objects
.
filter
(
is_active
=
1
)
.
count
()
# establish a direct connection to the database (for executing raw SQL)
cursor
=
connection
.
cursor
()
# define the queries that will generate our user-facing tables
# table queries need not take the form of raw SQL, but do in this case since
# the MySQL backend for django isn't very friendly with group by or distinct
table_queries
=
{}
table_queries
[
"course registrations (current enrollments)"
]
=
"""
select
course_id as Course,
count(user_id) as Students
from student_courseenrollment
where is_active=1
group by course_id
order by students desc;"""
table_queries
[
"number of students in each number of classes"
]
=
"""
select registrations as 'Registered for __ Classes' ,
count(registrations) as Users
from (select count(user_id) as registrations
from student_courseenrollment
where is_active=1
group by user_id) as registrations_per_user
group by registrations;"""
# add the result for each of the table_queries to the results object
for
query
in
table_queries
.
keys
():
cursor
.
execute
(
table_queries
[
query
])
results
[
"tables"
][
query
]
=
SQL_query_to_list
(
cursor
,
table_queries
[
query
])
context
=
{
"results"
:
results
}
return
render_to_response
(
"admin_dashboard.html"
,
context
)
lms/templates/admin_dashboard.html
deleted
100644 → 0
View file @
e9a32340
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%!
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<
%
inherit
file=
"main.html"
/>
<section
class=
"container about"
>
<section
class=
"basic_stats"
>
<div
class=
"edx_summary"
>
<h2>
${_("{platform_name}-wide Summary").format(platform_name=settings.PLATFORM_NAME)}
</h2>
<table
style=
"margin-left:auto;margin-right:auto;width:50%"
>
% for key in results["scalars"]:
<tr>
<td>
${key}
</td>
<td>
${results["scalars"][key]}
</td>
</tr>
% endfor
</table>
</div>
% for table in results["tables"]:
<br/>
<div
class=
"table_display"
>
<h2>
${table}
</h2>
<table
style=
"margin-left:auto;margin-right:auto;width:50%"
>
<tr>
% for column in results["tables"][table][0]:
<td><b>
${column}
</b></td>
% endfor
</tr>
% for row in results["tables"][table][1:]:
<tr>
% for column in row:
<td>
${column}
</td>
% endfor
</tr>
% endfor
</table>
</div>
% endfor
</section>
</section>
lms/urls.py
View file @
f7e141b1
...
...
@@ -29,8 +29,6 @@ urlpatterns = (
url
(
r'^login_ajax$'
,
'student.views.login_user'
,
name
=
"login"
),
url
(
r'^login_ajax/(?P<error>[^/]*)$'
,
'student.views.login_user'
),
url
(
r'^admin_dashboard$'
,
'dashboard.views.dashboard'
),
url
(
r'^email_confirm/(?P<key>[^/]*)$'
,
'student.views.confirm_email_change'
),
url
(
r'^event$'
,
'track.views.user_track'
),
url
(
r'^performance$'
,
'performance.views.performance_log'
),
...
...
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