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
56676d82
Commit
56676d82
authored
Sep 22, 2017
by
Nimisha Asthagiri
Committed by
GitHub
Sep 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16077 from edx/naa/grades-refactor
Grades: move out of temporary new folder
parents
75c22f56
22edaf7d
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
76 additions
and
81 deletions
+76
-81
common/djangoapps/student/tests/tests.py
+3
-3
common/djangoapps/student/views.py
+1
-1
lms/djangoapps/ccx/views.py
+1
-1
lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py
+1
-1
lms/djangoapps/certificates/queue.py
+1
-1
lms/djangoapps/certificates/signals.py
+1
-1
lms/djangoapps/certificates/tests/test_signals.py
+1
-1
lms/djangoapps/courseware/tests/test_submitting_problems.py
+1
-1
lms/djangoapps/courseware/tests/test_views.py
+9
-9
lms/djangoapps/courseware/views/index.py
+1
-1
lms/djangoapps/courseware/views/views.py
+1
-1
lms/djangoapps/gating/tests/test_integration.py
+1
-1
lms/djangoapps/grades/api/views.py
+1
-1
lms/djangoapps/grades/course_data.py
+1
-1
lms/djangoapps/grades/course_grade.py
+0
-0
lms/djangoapps/grades/course_grade_factory.py
+3
-3
lms/djangoapps/grades/new/__init__.py
+0
-0
lms/djangoapps/grades/signals/handlers.py
+7
-8
lms/djangoapps/grades/subsection_grade.py
+1
-1
lms/djangoapps/grades/subsection_grade_factory.py
+0
-0
lms/djangoapps/grades/tasks.py
+5
-6
lms/djangoapps/grades/tests/integration/test_access.py
+1
-1
lms/djangoapps/grades/tests/test_course_data.py
+3
-4
lms/djangoapps/grades/tests/test_grades.py
+5
-6
lms/djangoapps/grades/tests/test_new.py
+12
-13
lms/djangoapps/grades/tests/test_tasks.py
+4
-4
lms/djangoapps/grades/tests/utils.py
+3
-3
lms/djangoapps/instructor/tests/test_enrollment.py
+1
-1
lms/djangoapps/instructor/views/gradebook_api.py
+1
-1
lms/djangoapps/instructor_task/tasks_helper/grades.py
+1
-1
lms/djangoapps/instructor_task/tests/test_integration.py
+1
-1
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
+3
-3
lms/djangoapps/lti_provider/tasks.py
+1
-1
No files found.
common/djangoapps/student/tests/tests.py
View file @
56676d82
...
...
@@ -105,7 +105,7 @@ class CourseEndingTest(TestCase):
)
cert_status
=
{
'status'
:
'generating'
,
'grade'
:
'0.67'
,
'mode'
:
'honor'
}
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
patch_persisted_grade
.
return_value
=
Mock
(
percent
=
1.0
)
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
,
course_mode
),
...
...
@@ -244,7 +244,7 @@ class CourseEndingTest(TestCase):
else
:
cert_status
=
{
'status'
:
'generating'
,
'mode'
:
'honor'
}
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
patch_persisted_grade
.
return_value
=
Mock
(
percent
=
persisted_grade
)
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
,
course_mode
),
...
...
@@ -277,7 +277,7 @@ class CourseEndingTest(TestCase):
course_mode
=
'honor'
cert_status
=
{
'status'
:
'generating'
,
'mode'
:
'honor'
}
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read'
)
as
patch_persisted_grade
:
patch_persisted_grade
.
return_value
=
None
self
.
assertEqual
(
_cert_info
(
user
,
course
,
cert_status
,
course_mode
),
...
...
common/djangoapps/student/views.py
View file @
56676d82
...
...
@@ -67,7 +67,7 @@ from django_comment_common.models import assign_role
from
edxmako.shortcuts
import
render_to_response
,
render_to_string
from
eventtracking
import
tracker
from
lms.djangoapps.commerce.utils
import
EcommerceService
# pylint: disable=import-error
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
# pylint: disable=import-error
# Note that this lives in LMS, so this dependency should be refactored.
from
notification_prefs.views
import
enable_notifications
...
...
lms/djangoapps/ccx/views.py
View file @
56676d82
...
...
@@ -48,7 +48,7 @@ from lms.djangoapps.ccx.utils import (
parse_date
,
prep_course_for_grading
)
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.instructor.enrollment
import
enroll_email
,
get_email_params
from
lms.djangoapps.instructor.views.api
import
_split_input_list
from
lms.djangoapps.instructor.views.gradebook_api
import
get_grade_book_page
...
...
lms/djangoapps/certificates/management/commands/fix_ungraded_certs.py
View file @
56676d82
...
...
@@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand
from
certificates.models
import
GeneratedCertificate
from
courseware
import
courses
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
log
=
logging
.
getLogger
(
__name__
)
...
...
lms/djangoapps/certificates/queue.py
View file @
56676d82
...
...
@@ -21,7 +21,7 @@ from certificates.models import (
certificate_status_for_student
)
from
course_modes.models
import
CourseMode
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
student.models
import
CourseEnrollment
,
UserProfile
from
xmodule.modulestore.django
import
modulestore
...
...
lms/djangoapps/certificates/signals.py
View file @
56676d82
...
...
@@ -13,7 +13,7 @@ from certificates.models import (
GeneratedCertificate
)
from
certificates.tasks
import
generate_certificate
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
openedx.core.djangoapps.certificates.api
import
auto_certificate_generation_enabled
from
openedx.core.djangoapps.certificates.config
import
waffle
...
...
lms/djangoapps/certificates/tests/test_signals.py
View file @
56676d82
...
...
@@ -11,7 +11,7 @@ from certificates.models import (
GeneratedCertificate
,
CertificateStatuses
,
)
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.tests.utils
import
mock_passing_grade
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
openedx.core.djangoapps.certificates.config
import
waffle
...
...
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
56676d82
...
...
@@ -28,7 +28,7 @@ from capa.tests.response_xml_factory import (
from
course_modes.models
import
CourseMode
from
courseware.models
import
BaseStudentModuleHistory
,
StudentModule
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
openedx.core.djangoapps.credit.api
import
get_credit_requirement_status
,
set_credit_requirements
from
openedx.core.djangoapps.credit.models
import
CreditCourse
,
CreditProvider
from
openedx.core.djangoapps.user_api.tests.factories
import
UserCourseTagFactory
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
56676d82
...
...
@@ -42,7 +42,7 @@ from django.test.utils import override_settings
from
lms.djangoapps.commerce.utils
import
EcommerceService
# pylint: disable=import-error
from
lms.djangoapps.grades.config.waffle
import
waffle
as
grades_waffle
from
lms.djangoapps.grades.config.waffle
import
ASSUME_ZERO_GRADE_IF_ABSENT
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.tests.utils
import
mock_get_score
from
milestones.tests.utils
import
MilestonesTestCaseMixin
from
opaque_keys.edx.keys
import
CourseKey
...
...
@@ -1399,7 +1399,7 @@ class ProgressPageTests(ProgressPageBaseTests):
self
.
course
.
save
()
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
,
'section_breakdown'
:
[],
'grade_breakdown'
:
{}}
...
...
@@ -1442,7 +1442,7 @@ class ProgressPageTests(ProgressPageBaseTests):
# Enable certificate generation for this course
certs_api
.
set_cert_generation_enabled
(
self
.
course
.
id
,
True
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
,
'section_breakdown'
:
[],
'grade_breakdown'
:
{}}
...
...
@@ -1504,7 +1504,7 @@ class ProgressPageTests(ProgressPageBaseTests):
'lms.djangoapps.verify_student.models.SoftwareSecurePhotoVerification.user_is_verified'
)
as
user_verify
:
user_verify
.
return_value
=
user_verified
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
...
...
@@ -1548,7 +1548,7 @@ class ProgressPageTests(ProgressPageBaseTests):
self
.
course
.
save
()
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
...
...
@@ -1568,7 +1568,7 @@ class ProgressPageTests(ProgressPageBaseTests):
"http://www.example.com/certificate.pdf"
,
"honor"
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
,
'section_breakdown'
:
[],
'grade_breakdown'
:
{}}
...
...
@@ -1586,7 +1586,7 @@ class ProgressPageTests(ProgressPageBaseTests):
self
.
assertTrue
(
self
.
client
.
login
(
username
=
user
.
username
,
password
=
'test'
))
CourseEnrollmentFactory
(
user
=
user
,
course_id
=
self
.
course
.
id
,
mode
=
CourseMode
.
AUDIT
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
,
'section_breakdown'
:
[],
'grade_breakdown'
:
{}}
...
...
@@ -2090,7 +2090,7 @@ class GenerateUserCertTests(ModuleStoreTestCase):
status
=
CertificateStatuses
.
generating
,
mode
=
'verified'
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summary
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
}
...
...
@@ -2111,7 +2111,7 @@ class GenerateUserCertTests(ModuleStoreTestCase):
mode
=
'verified'
)
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
as
mock_create
:
course_grade
=
mock_create
.
return_value
course_grade
.
passed
=
True
course_grade
.
summay
=
{
'grade'
:
'Pass'
,
'percent'
:
0.75
}
...
...
lms/djangoapps/courseware/views/index.py
View file @
56676d82
...
...
@@ -24,7 +24,7 @@ from edxmako.shortcuts import render_to_response, render_to_string
from
lms.djangoapps.courseware.exceptions
import
CourseAccessRedirect
from
lms.djangoapps.experiments.utils
import
get_experiment_user_metadata_context
from
lms.djangoapps.gating.api
import
get_entrance_exam_score_ratio
,
get_entrance_exam_usage_key
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
openedx.core.djangoapps.crawlers.models
import
CrawlersConfig
from
openedx.core.djangoapps.lang_pref
import
LANGUAGE_KEY
from
openedx.core.djangoapps.monitoring_utils
import
set_custom_metrics_for_course_key
...
...
lms/djangoapps/courseware/views/views.py
View file @
56676d82
...
...
@@ -63,7 +63,7 @@ from lms.djangoapps.ccx.custom_exception import CCXLocatorValidationException
from
lms.djangoapps.ccx.utils
import
prep_course_for_grading
from
lms.djangoapps.courseware.exceptions
import
CourseAccessRedirect
,
Redirect
from
lms.djangoapps.experiments.utils
import
get_experiment_user_metadata_context
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.instructor.enrollment
import
uses_shib
from
lms.djangoapps.instructor.views.api
import
require_global_staff
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
...
...
lms/djangoapps/gating/tests/test_integration.py
View file @
56676d82
...
...
@@ -7,7 +7,7 @@ from milestones.tests.utils import MilestonesTestCaseMixin
from
nose.plugins.attrib
import
attr
from
lms.djangoapps.courseware.access
import
has_access
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.tests.utils
import
answer_problem
from
openedx.core.djangolib.testing.utils
import
get_mock_request
from
openedx.core.lib.gating
import
api
as
gating_api
...
...
lms/djangoapps/grades/api/views.py
View file @
56676d82
...
...
@@ -15,7 +15,7 @@ from lms.djangoapps.ccx.utils import prep_course_for_grading
from
lms.djangoapps.courseware
import
courses
from
lms.djangoapps.courseware.exceptions
import
CourseAccessRedirect
from
lms.djangoapps.grades.api.serializers
import
GradingPolicySerializer
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
openedx.core.lib.api.view_utils
import
DeveloperErrorViewMixin
,
view_auth_classes
from
student.roles
import
CourseStaffRole
...
...
lms/djangoapps/grades/
new/
course_data.py
→
lms/djangoapps/grades/course_data.py
View file @
56676d82
...
...
@@ -2,7 +2,7 @@ from lms.djangoapps.course_blocks.api import get_course_blocks
from
openedx.core.djangoapps.content.block_structure.api
import
get_block_structure_manager
from
xmodule.modulestore.django
import
modulestore
from
.
.
transformer
import
GradesTransformer
from
.transformer
import
GradesTransformer
class
CourseData
(
object
):
...
...
lms/djangoapps/grades/
new/
course_grade.py
→
lms/djangoapps/grades/course_grade.py
View file @
56676d82
File moved
lms/djangoapps/grades/
new/
course_grade_factory.py
→
lms/djangoapps/grades/course_grade_factory.py
View file @
56676d82
...
...
@@ -6,11 +6,11 @@ import dogstats_wrapper as dog_stats_api
from
openedx.core.djangoapps.signals.signals
import
COURSE_GRADE_CHANGED
,
COURSE_GRADE_NOW_PASSED
from
..config
import
assume_zero_if_absent
,
should_persist_grades
from
..config.waffle
import
WRITE_ONLY_IF_ENGAGED
,
waffle
from
..models
import
PersistentCourseGrade
,
VisibleBlocks
from
.config
import
assume_zero_if_absent
,
should_persist_grades
from
.config.waffle
import
WRITE_ONLY_IF_ENGAGED
,
waffle
from
.course_data
import
CourseData
from
.course_grade
import
CourseGrade
,
ZeroCourseGrade
from
.models
import
PersistentCourseGrade
,
VisibleBlocks
log
=
getLogger
(
__name__
)
...
...
lms/djangoapps/grades/new/__init__.py
deleted
100644 → 0
View file @
75c22f56
lms/djangoapps/grades/signals/handlers.py
View file @
56676d82
...
...
@@ -4,11 +4,9 @@ Grades related signals.
from
contextlib
import
contextmanager
from
logging
import
getLogger
from
courseware.model_data
import
get_score
,
set_score
from
crum
import
get_current_user
from
django.dispatch
import
receiver
from
xblock.scorable
import
ScorableXBlockMixin
,
Score
from
courseware.model_data
import
get_score
,
set_score
from
eventtracking
import
tracker
from
lms.djangoapps.instructor_task.tasks_helper.module_state
import
GRADES_OVERRIDE_EVENT_TYPE
from
openedx.core.djangoapps.course_groups.signals.signals
import
COHORT_MEMBERSHIP_UPDATED
...
...
@@ -23,12 +21,8 @@ from track.event_transaction_utils import (
set_event_transaction_type
)
from
util.date_utils
import
to_timestamp
from
xblock.scorable
import
ScorableXBlockMixin
,
Score
from
..config.waffle
import
waffle
,
WRITE_ONLY_IF_ENGAGED
from
..constants
import
ScoreDatabaseTableEnum
from
..new.course_grade_factory
import
CourseGradeFactory
from
..scores
import
weighted_score
from
..tasks
import
RECALCULATE_GRADE_DELAY
,
recalculate_subsection_grade_v3
from
.signals
import
(
PROBLEM_RAW_SCORE_CHANGED
,
PROBLEM_WEIGHTED_SCORE_CHANGED
,
...
...
@@ -36,6 +30,11 @@ from .signals import (
SUBSECTION_SCORE_CHANGED
,
SUBSECTION_OVERRIDE_CHANGED
,
)
from
..config.waffle
import
waffle
,
WRITE_ONLY_IF_ENGAGED
from
..constants
import
ScoreDatabaseTableEnum
from
..course_grade_factory
import
CourseGradeFactory
from
..scores
import
weighted_score
from
..tasks
import
RECALCULATE_GRADE_DELAY
,
recalculate_subsection_grade_v3
log
=
getLogger
(
__name__
)
...
...
lms/djangoapps/grades/
new/
subsection_grade.py
→
lms/djangoapps/grades/subsection_grade.py
View file @
56676d82
...
...
@@ -11,7 +11,7 @@ from lms.djangoapps.grades.scores import get_score, possibly_scored
from
xmodule
import
block_metadata_utils
,
graders
from
xmodule.graders
import
AggregatedScore
,
ShowCorrectness
from
.
.
config.waffle
import
WRITE_ONLY_IF_ENGAGED
,
waffle
from
.config.waffle
import
WRITE_ONLY_IF_ENGAGED
,
waffle
log
=
getLogger
(
__name__
)
...
...
lms/djangoapps/grades/
new/
subsection_grade_factory.py
→
lms/djangoapps/grades/subsection_grade_factory.py
View file @
56676d82
File moved
lms/djangoapps/grades/tasks.py
View file @
56676d82
...
...
@@ -8,17 +8,16 @@ import six
from
celery
import
task
from
celery_utils.logged_task
import
LoggedTask
from
celery_utils.persist_on_failure
import
PersistOnFailureTask
from
courseware.model_data
import
get_score
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ValidationError
from
django.db.utils
import
DatabaseError
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
opaque_keys.edx.locator
import
CourseLocator
from
courseware.model_data
import
get_score
from
lms.djangoapps.course_blocks.api
import
get_course_blocks
from
lms.djangoapps.courseware
import
courses
from
lms.djangoapps.grades.config.models
import
ComputeGradesSetting
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
opaque_keys.edx.locator
import
CourseLocator
from
openedx.core.djangoapps.monitoring_utils
import
set_custom_metric
,
set_custom_metrics_for_course_key
from
student.models
import
CourseEnrollment
from
submissions
import
api
as
sub_api
...
...
@@ -28,11 +27,11 @@ from xmodule.modulestore.django import modulestore
from
.config.waffle
import
ESTIMATE_FIRST_ATTEMPTED
,
DISABLE_REGRADE_ON_POLICY_CHANGE
,
waffle
from
.constants
import
ScoreDatabaseTableEnum
from
.course_grade_factory
import
CourseGradeFactory
from
.exceptions
import
DatabaseNotReadyError
from
.new.course_grade_factory
import
CourseGradeFactory
from
.new.subsection_grade_factory
import
SubsectionGradeFactory
from
.services
import
GradesService
from
.signals.signals
import
SUBSECTION_SCORE_CHANGED
from
.subsection_grade_factory
import
SubsectionGradeFactory
from
.transformer
import
GradesTransformer
log
=
getLogger
(
__name__
)
...
...
lms/djangoapps/grades/tests/integration/test_access.py
View file @
56676d82
...
...
@@ -14,7 +14,7 @@ from xmodule.modulestore.django import modulestore
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
...
new.
subsection_grade_factory
import
SubsectionGradeFactory
from
...subsection_grade_factory
import
SubsectionGradeFactory
class
GradesAccessIntegrationTest
(
ProblemSubmissionTestMixin
,
SharedModuleStoreTestCase
):
...
...
lms/djangoapps/grades/tests/test_course_data.py
View file @
56676d82
"""
Tests for CourseData utility class.
"""
from
mock
import
patch
from
lms.djangoapps.course_blocks.api
import
get_course_blocks
from
mock
import
patch
from
openedx.core.djangoapps.content.block_structure.api
import
get_course_in_cache
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
..
new.
course_data
import
CourseData
from
..course_data
import
CourseData
class
CourseDataTest
(
ModuleStoreTestCase
):
...
...
@@ -37,7 +36,7 @@ class CourseDataTest(ModuleStoreTestCase):
'location'
:
self
.
course
.
location
,
}
@patch
(
'lms.djangoapps.grades.
new.
course_data.get_course_blocks'
)
@patch
(
'lms.djangoapps.grades.course_data.get_course_blocks'
)
def
test_fill_course_data
(
self
,
mock_get_blocks
):
"""
Tests to ensure that course data is fully filled with just a single input.
...
...
lms/djangoapps/grades/tests/test_grades.py
View file @
56676d82
...
...
@@ -6,11 +6,10 @@ import datetime
import
itertools
import
ddt
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
lms.djangoapps.course_blocks.api
import
get_course_blocks
from
mock
import
patch
from
nose.plugins.attrib
import
attr
from
openedx.core.djangoapps.content.block_structure.factory
import
BlockStructureFactory
from
openedx.core.djangolib.testing.utils
import
get_mock_request
from
student.models
import
CourseEnrollment
...
...
@@ -20,8 +19,8 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
..
new.
course_grade_factory
import
CourseGradeFactory
from
..
new.
subsection_grade_factory
import
SubsectionGradeFactory
from
..course_grade_factory
import
CourseGradeFactory
from
..subsection_grade_factory
import
SubsectionGradeFactory
from
.utils
import
answer_problem
...
...
@@ -80,7 +79,7 @@ class TestGradeIteration(SharedModuleStoreTestCase):
self
.
assertIsNone
(
course_grade
.
letter_grade
)
self
.
assertEqual
(
course_grade
.
percent
,
0.0
)
@patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.create'
)
@patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.create'
)
def
test_grading_exception
(
self
,
mock_course_grade
):
"""Test that we correctly capture exception messages that bubble up from
grading. Note that we only see errors at this level if the grading
...
...
lms/djangoapps/grades/tests/test_new.py
View file @
56676d82
...
...
@@ -8,14 +8,13 @@ import itertools
import
ddt
import
pytz
from
django.conf
import
settings
from
mock
import
patch
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
courseware.access
import
has_access
from
courseware.tests.test_submitting_problems
import
ProblemSubmissionTestMixin
from
django.conf
import
settings
from
lms.djangoapps.course_blocks.api
import
get_course_blocks
from
lms.djangoapps.grades.config.tests.utils
import
persistent_grades_feature_flags
from
mock
import
patch
from
openedx.core.djangolib.testing.utils
import
get_mock_request
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
...
...
@@ -25,12 +24,12 @@ from xmodule.modulestore.tests.utils import TEST_DATA_DIR
from
xmodule.modulestore.xml_importer
import
import_course_from_xml
from
..config.waffle
import
ASSUME_ZERO_GRADE_IF_ABSENT
,
WRITE_ONLY_IF_ENGAGED
,
waffle
from
..course_data
import
CourseData
from
..course_grade
import
CourseGrade
,
ZeroCourseGrade
from
..course_grade_factory
import
CourseGradeFactory
from
..models
import
PersistentSubsectionGrade
from
..new.course_data
import
CourseData
from
..new.course_grade
import
CourseGrade
,
ZeroCourseGrade
from
..new.course_grade_factory
import
CourseGradeFactory
from
..new.subsection_grade
import
SubsectionGrade
,
ZeroSubsectionGrade
from
..new.subsection_grade_factory
import
SubsectionGradeFactory
from
..subsection_grade
import
SubsectionGrade
,
ZeroSubsectionGrade
from
..subsection_grade_factory
import
SubsectionGradeFactory
from
.utils
import
mock_get_score
,
mock_get_submissions_score
...
...
@@ -248,7 +247,7 @@ class TestCourseGradeFactory(GradeTestBase):
@ddt.data
(
True
,
False
)
def
test_iter_force_update
(
self
,
force_update
):
base_string
=
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory.{}'
base_string
=
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory.{}'
desired_method_name
=
base_string
.
format
(
'update'
if
force_update
else
'create'
)
undesired_method_name
=
base_string
.
format
(
'create'
if
force_update
else
'update'
)
with
patch
(
desired_method_name
)
as
desired_call
:
...
...
@@ -295,11 +294,11 @@ class TestSubsectionGradeFactory(ProblemSubmissionTestMixin, GradeTestBase):
created, saved, then fetched on re-request.
"""
with
patch
(
'lms.djangoapps.grades.
new.
subsection_grade.PersistentSubsectionGrade.create_grade'
,
'lms.djangoapps.grades.subsection_grade.PersistentSubsectionGrade.create_grade'
,
wraps
=
PersistentSubsectionGrade
.
create_grade
)
as
mock_create_grade
:
with
patch
(
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory._get_bulk_cached_grade'
,
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory._get_bulk_cached_grade'
,
wraps
=
self
.
subsection_grade_factory
.
_get_bulk_cached_grade
)
as
mock_get_bulk_cached_grade
:
with
self
.
assertNumQueries
(
14
):
...
...
@@ -412,7 +411,7 @@ class ZeroGradeTest(GradeTestBase):
Creates a zero course grade and ensures that null scores aren't included in the section problem scores.
"""
with
waffle
()
.
override
(
ASSUME_ZERO_GRADE_IF_ABSENT
,
active
=
assume_zero_enabled
):
with
patch
(
'lms.djangoapps.grades.
new.
subsection_grade.get_score'
,
return_value
=
None
):
with
patch
(
'lms.djangoapps.grades.subsection_grade.get_score'
,
return_value
=
None
):
course_data
=
CourseData
(
self
.
request
.
user
,
structure
=
self
.
course_structure
)
chapter_grades
=
ZeroCourseGrade
(
self
.
request
.
user
,
course_data
)
.
chapter_grades
for
chapter
in
chapter_grades
:
...
...
@@ -744,7 +743,7 @@ class TestCourseGradeLogging(ProblemSubmissionTestMixin, SharedModuleStoreTestCa
course_id
=
self
.
course
.
id
,
enabled_for_course
=
True
):
with
patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.log'
)
as
log_mock
:
with
patch
(
'lms.djangoapps.grades.course_grade_factory.log'
)
as
log_mock
:
# read, but not persisted
self
.
_create_course_grade_and_check_logging
(
grade_factory
.
create
,
log_mock
.
info
,
u'Update'
)
...
...
lms/djangoapps/grades/tests/test_tasks.py
View file @
56676d82
...
...
@@ -253,7 +253,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
self
.
assertGreater
(
len
(
PersistentSubsectionGrade
.
bulk_read_grades
(
self
.
user
.
id
,
self
.
course
.
id
)),
0
)
@patch
(
'lms.djangoapps.grades.signals.signals.SUBSECTION_SCORE_CHANGED.send'
)
@patch
(
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory.update'
)
@patch
(
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory.update'
)
def
test_retry_first_time_only
(
self
,
mock_update
,
mock_course_signal
):
"""
Ensures that a task retry completes after a one-time failure.
...
...
@@ -264,7 +264,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
self
.
assertEquals
(
mock_course_signal
.
call_count
,
1
)
@patch
(
'lms.djangoapps.grades.tasks.recalculate_subsection_grade_v3.retry'
)
@patch
(
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory.update'
)
@patch
(
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory.update'
)
def
test_retry_on_integrity_error
(
self
,
mock_update
,
mock_retry
):
"""
Ensures that tasks will be retried if IntegrityErrors are encountered.
...
...
@@ -347,7 +347,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
@patch
(
'lms.djangoapps.grades.tasks.log'
)
@patch
(
'lms.djangoapps.grades.tasks.recalculate_subsection_grade_v3.retry'
)
@patch
(
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory.update'
)
@patch
(
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory.update'
)
def
test_log_unknown_error
(
self
,
mock_update
,
mock_retry
,
mock_log
):
"""
Ensures that unknown errors are logged before a retry.
...
...
@@ -360,7 +360,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
@patch
(
'lms.djangoapps.grades.tasks.log'
)
@patch
(
'lms.djangoapps.grades.tasks.recalculate_subsection_grade_v3.retry'
)
@patch
(
'lms.djangoapps.grades.
new.
subsection_grade_factory.SubsectionGradeFactory.update'
)
@patch
(
'lms.djangoapps.grades.subsection_grade_factory.SubsectionGradeFactory.update'
)
def
test_no_log_known_error
(
self
,
mock_update
,
mock_retry
,
mock_log
):
"""
Ensures that known errors are not logged before a retry.
...
...
lms/djangoapps/grades/tests/utils.py
View file @
56676d82
...
...
@@ -16,8 +16,8 @@ def mock_passing_grade(grade_pass='Pass', percent=0.75, ):
"""
Mock the grading function to always return a passing grade.
"""
with
patch
(
'lms.djangoapps.grades.
new.
course_grade.CourseGrade._compute_letter_grade'
)
as
mock_letter_grade
:
with
patch
(
'lms.djangoapps.grades.
new.
course_grade.CourseGrade._compute_percent'
)
as
mock_percent_grade
:
with
patch
(
'lms.djangoapps.grades.course_grade.CourseGrade._compute_letter_grade'
)
as
mock_letter_grade
:
with
patch
(
'lms.djangoapps.grades.course_grade.CourseGrade._compute_percent'
)
as
mock_percent_grade
:
mock_letter_grade
.
return_value
=
grade_pass
mock_percent_grade
.
return_value
=
percent
yield
...
...
@@ -28,7 +28,7 @@ def mock_get_score(earned=0, possible=1, first_attempted=datetime(2000, 1, 1, 0,
"""
Mocks the get_score function to return a valid grade.
"""
with
patch
(
'lms.djangoapps.grades.
new.
subsection_grade.get_score'
)
as
mock_score
:
with
patch
(
'lms.djangoapps.grades.subsection_grade.get_score'
)
as
mock_score
:
mock_score
.
return_value
=
ProblemScore
(
raw_earned
=
earned
,
raw_possible
=
possible
,
...
...
lms/djangoapps/instructor/tests/test_enrollment.py
View file @
56676d82
...
...
@@ -17,7 +17,7 @@ from opaque_keys.edx.locator import CourseLocator
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
courseware.models
import
StudentModule
from
grades.
new.
subsection_grade_factory
import
SubsectionGradeFactory
from
grades.subsection_grade_factory
import
SubsectionGradeFactory
from
grades.tests.utils
import
answer_problem
from
lms.djangoapps.ccx.tests.factories
import
CcxFactory
from
lms.djangoapps.course_blocks.api
import
get_course_blocks
...
...
lms/djangoapps/instructor/views/gradebook_api.py
View file @
56676d82
...
...
@@ -12,7 +12,7 @@ from opaque_keys.edx.keys import CourseKey
from
courseware.courses
import
get_course_with_access
from
edxmako.shortcuts
import
render_to_response
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.instructor.views.api
import
require_level
from
xmodule.modulestore.django
import
modulestore
...
...
lms/djangoapps/instructor_task/tasks_helper/grades.py
View file @
56676d82
...
...
@@ -17,7 +17,7 @@ from instructor_analytics.basic import list_problem_responses
from
instructor_analytics.csvs
import
format_dictlist
from
lms.djangoapps.grades.context
import
grading_context
,
grading_context_for_course
from
lms.djangoapps.grades.models
import
PersistentCourseGrade
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.teams.models
import
CourseTeamMembership
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
openedx.core.djangoapps.content.block_structure.api
import
get_course_in_cache
...
...
lms/djangoapps/instructor_task/tests/test_integration.py
View file @
56676d82
...
...
@@ -20,7 +20,7 @@ from nose.plugins.attrib import attr
from
capa.responsetypes
import
StudentInputError
from
capa.tests.response_xml_factory
import
CodeResponseXMLFactory
,
CustomResponseXMLFactory
from
courseware.model_data
import
StudentModule
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.instructor_task.api
import
(
submit_delete_problem_state_for_all_students
,
submit_rescore_problem_for_all_students
,
...
...
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
View file @
56676d82
...
...
@@ -135,7 +135,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
self
.
assertDictContainsSubset
({
'attempted'
:
num_students
,
'succeeded'
:
num_students
,
'failed'
:
0
},
result
)
@patch
(
'lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'
)
@patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.iter'
)
@patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.iter'
)
def
test_grading_failure
(
self
,
mock_grades_iter
,
_mock_current_task
):
"""
Test that any grading errors are properly reported in the
...
...
@@ -312,7 +312,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
)
@patch
(
'lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'
)
@patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.iter'
)
@patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.iter'
)
def
test_unicode_in_csv_header
(
self
,
mock_grades_iter
,
_mock_current_task
):
"""
Tests that CSV grade report works if unicode in headers.
...
...
@@ -762,7 +762,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
])
@patch
(
'lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'
)
@patch
(
'lms.djangoapps.grades.
new.
course_grade_factory.CourseGradeFactory.iter'
)
@patch
(
'lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.iter'
)
@ddt.data
(
u'Cannot grade student'
,
''
)
def
test_grading_failure
(
self
,
error_message
,
mock_grades_iter
,
_mock_current_task
):
"""
...
...
lms/djangoapps/lti_provider/tasks.py
View file @
56676d82
...
...
@@ -11,7 +11,7 @@ from opaque_keys.edx.keys import CourseKey
import
lti_provider.outcomes
as
outcomes
from
lms
import
CELERY_APP
from
lms.djangoapps.grades.
new.
course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.course_grade_factory
import
CourseGradeFactory
from
lms.djangoapps.grades.signals.signals
import
PROBLEM_WEIGHTED_SCORE_CHANGED
from
lti_provider.models
import
GradedAssignment
from
lti_provider.views
import
parse_course_and_usage_keys
...
...
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