Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
27c6a28f
Unverified
Commit
27c6a28f
authored
5 years ago
by
Awais Jibran
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #22316 from edx/aj/grade-report-code-refactor
Code Refactor for Course Grade Report
parents
f4f9d294
fb4b46c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/instructor_task/config/waffle.py
+13
-2
13 additions, 2 deletions
lms/djangoapps/instructor_task/config/waffle.py
lms/djangoapps/instructor_task/tasks_helper/grades.py
+16
-12
16 additions, 12 deletions
lms/djangoapps/instructor_task/tasks_helper/grades.py
with
29 additions
and
14 deletions
lms/djangoapps/instructor_task/config/waffle.py
+
13
−
2
View file @
27c6a28f
...
...
@@ -4,10 +4,14 @@ waffle switches for the instructor_task app.
"""
from
__future__
import
absolute_import
from
openedx.core.djangoapps.waffle_utils
import
CourseWaffleFlag
,
WaffleFlagNamespace
from
openedx.core.djangoapps.waffle_utils
import
CourseWaffleFlag
,
WaffleFlagNamespace
,
WaffleSwitchNamespace
WAFFLE_NAMESPACE
=
u
'
instructor_task
'
INSTRUCTOR_TASK_WAFFLE_FLAG_NAMESPACE
=
WaffleFlagNamespace
(
name
=
WAFFLE_NAMESPACE
)
WAFFLE_SWITCHES
=
WaffleSwitchNamespace
(
name
=
WAFFLE_NAMESPACE
)
INSTRUCTOR_TASK_WAFFLE_FLAG_NAMESPACE
=
WaffleFlagNamespace
(
name
=
u
'
instructor_task
'
)
# Waffle switches
OPTIMIZE_GET_LEARNERS_FOR_COURSE
=
u
'
optimize_get_learners_for_course
'
# Course-specific flags
PROBLEM_GRADE_REPORT_VERIFIED_ONLY
=
u
'
problem_grade_report_verified_only
'
...
...
@@ -48,3 +52,10 @@ def course_grade_report_verified_only(course_id):
False otherwise.
"""
return
waffle_flags
()[
PROBLEM_GRADE_REPORT_VERIFIED_ONLY
].
is_enabled
(
course_id
)
def
optimize_get_learners_switch_enabled
():
"""
Returns True if optimize get learner switch is enabled, otherwise False.
"""
return
WAFFLE_SWITCHES
.
is_enabled
(
OPTIMIZE_GET_LEARNERS_FOR_COURSE
)
This diff is collapsed.
Click to expand it.
lms/djangoapps/instructor_task/tasks_helper/grades.py
+
16
−
12
View file @
27c6a28f
...
...
@@ -30,6 +30,7 @@ from lms.djangoapps.instructor_analytics.basic import list_problem_responses
from
lms.djangoapps.instructor_analytics.csvs
import
format_dictlist
from
lms.djangoapps.instructor_task.config.waffle
import
(
course_grade_report_verified_only
,
optimize_get_learners_switch_enabled
,
problem_grade_report_verified_only
)
from
lms.djangoapps.teams.models
import
CourseTeamMembership
...
...
@@ -38,7 +39,6 @@ from opaque_keys.edx.keys import UsageKey
from
openedx.core.djangoapps.content.block_structure.api
import
get_course_in_cache
from
openedx.core.djangoapps.course_groups.cohorts
import
bulk_cache_cohorts
,
get_cohort
,
is_course_cohorted
from
openedx.core.djangoapps.user_api.course_tag.api
import
BulkCourseTags
from
openedx.core.djangoapps.waffle_utils
import
WaffleSwitchNamespace
from
student.models
import
CourseEnrollment
from
student.roles
import
BulkRoleCache
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -48,10 +48,6 @@ from xmodule.split_test_module import get_split_user_partitions
from
.runner
import
TaskProgress
from
.utils
import
upload_csv_to_report_store
WAFFLE_NAMESPACE
=
'
instructor_task
'
WAFFLE_SWITCHES
=
WaffleSwitchNamespace
(
name
=
WAFFLE_NAMESPACE
)
OPTIMIZE_GET_LEARNERS_FOR_COURSE
=
'
optimize_get_learners_for_course
'
TASK_LOG
=
logging
.
getLogger
(
'
edx.celery.task
'
)
ENROLLED_IN_COURSE
=
'
enrolled
'
...
...
@@ -311,6 +307,20 @@ class CourseGradeReport(object):
args
=
[
iter
(
iterable
)]
*
chunk_size
return
zip_longest
(
*
args
,
fillvalue
=
fillvalue
)
def
get_enrolled_learners_for_course
(
course_id
,
verified_only
=
False
):
"""
Get enrolled learners in a course.
verified_only(bool): It indicates if we need only the verified
enrollments or all enrollments.
"""
if
optimize_get_learners_switch_enabled
():
TASK_LOG
.
info
(
u
'
%s, Creating Course Grade with optimization
'
,
task_log_message
)
return
users_for_course_v2
(
course_id
,
verified_only
=
verified_only
)
TASK_LOG
.
info
(
u
'
%s, Creating Course Grade without optimization
'
,
task_log_message
)
return
users_for_course
(
course_id
,
verified_only
=
verified_only
)
def
users_for_course
(
course_id
,
verified_only
=
False
):
"""
Get all the enrolled users in a course.
...
...
@@ -356,13 +366,7 @@ class CourseGradeReport(object):
course_id
=
context
.
course_id
task_log_message
=
u
'
{}, Task type: {}
'
.
format
(
context
.
task_info_string
,
context
.
action_name
)
verified_users_only
=
course_grade_report_verified_only
(
course_id
)
if
WAFFLE_SWITCHES
.
is_enabled
(
OPTIMIZE_GET_LEARNERS_FOR_COURSE
):
TASK_LOG
.
info
(
u
'
%s, Creating Course Grade with optimization
'
,
task_log_message
)
return
users_for_course_v2
(
course_id
,
verified_only
=
verified_users_only
)
TASK_LOG
.
info
(
u
'
%s, Creating Course Grade without optimization
'
,
task_log_message
)
batch_users
=
users_for_course
(
course_id
,
verified_only
=
verified_users_only
)
return
batch_users
return
get_enrolled_learners_for_course
(
course_id
,
verified_users_only
)
def
_user_grades
(
self
,
course_grade
,
context
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment