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
406daa51
Commit
406daa51
authored
Oct 05, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move get_grades management command from student to grades app.
parent
ce1eb237
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
lms/djangoapps/grades/management/__init__.py
+0
-0
lms/djangoapps/grades/management/commands/__init__.py
+0
-0
lms/djangoapps/grades/management/commands/get_grades.py
+14
-6
No files found.
lms/djangoapps/grades/management/__init__.py
0 → 100644
View file @
406daa51
lms/djangoapps/grades/management/commands/__init__.py
0 → 100644
View file @
406daa51
common/djangoapps/student
/management/commands/get_grades.py
→
lms/djangoapps/grades
/management/commands/get_grades.py
View file @
406daa51
...
...
@@ -19,12 +19,15 @@ import csv
class
RequestMock
(
RequestFactory
):
"""
Class to create a mock request.
"""
def
request
(
self
,
**
request
):
"Construct a generic request object."
request
=
RequestFactory
.
request
(
self
,
**
request
)
handler
=
BaseHandler
()
handler
.
load_middleware
()
for
middleware_method
in
handler
.
_request_middleware
:
for
middleware_method
in
handler
.
_request_middleware
:
# pylint: disable=protected-access
if
middleware_method
(
request
):
raise
Exception
(
"Couldn't create request mock object - "
"request middleware returned a response"
)
...
...
@@ -32,6 +35,9 @@ class RequestMock(RequestFactory):
class
Command
(
BaseCommand
):
"""
Management command for get_grades
"""
help
=
"""
Generate a list of grades for all students
...
...
@@ -69,7 +75,7 @@ class Command(BaseCommand):
raise
CommandError
(
"File {0} already exists"
.
format
(
options
[
'output'
]))
STATUS_INTERVAL
=
100
status_interval
=
100
# parse out the course into a coursekey
if
options
[
'course'
]:
...
...
@@ -106,26 +112,28 @@ class Command(BaseCommand):
print
"Grading students"
for
count
,
student
in
enumerate
(
enrolled_students
):
count
+=
1
if
count
%
STATUS_INTERVAL
==
0
:
if
count
%
status_interval
==
0
:
# Print a status update with an approximation of
# how much time is left based on how long the last
# interval took
diff
=
datetime
.
datetime
.
now
()
-
start
timeleft
=
diff
*
(
total
-
count
)
/
STATUS_INTERVAL
timeleft
=
diff
*
(
total
-
count
)
/
status_interval
hours
,
remainder
=
divmod
(
timeleft
.
seconds
,
3600
)
minutes
,
__
=
divmod
(
remainder
,
60
)
print
"{0}/{1} completed ~{2:02}:{3:02}m remaining"
.
format
(
count
,
total
,
hours
,
minutes
)
start
=
datetime
.
datetime
.
now
()
request
.
user
=
student
grade
=
course_grades
.
summary
(
student
,
request
,
course
)
grade
=
course_grades
.
summary
(
student
,
course
)
if
not
header
:
header
=
[
section
[
'label'
]
for
section
in
grade
[
u'section_breakdown'
]]
rows
.
append
([
"email"
,
"username"
,
"certificate-grade"
,
"grade"
]
+
header
)
percents
=
{
section
[
'label'
]:
section
[
'percent'
]
for
section
in
grade
[
u'section_breakdown'
]}
row_percents
=
[
percents
[
label
]
for
label
in
header
]
if
student
.
username
in
cert_grades
:
rows
.
append
([
student
.
email
,
student
.
username
,
cert_grades
[
student
.
username
],
grade
[
'percent'
]]
+
row_percents
)
rows
.
append
(
[
student
.
email
,
student
.
username
,
cert_grades
[
student
.
username
],
grade
[
'percent'
]]
+
row_percents
,
)
else
:
rows
.
append
([
student
.
email
,
student
.
username
,
"N/A"
,
grade
[
'percent'
]]
+
row_percents
)
with
open
(
options
[
'output'
],
'wb'
)
as
f
:
...
...
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