Inter-app API cleanup for Grades

This commit is contained in:
Nimisha Asthagiri
2019-04-28 22:09:54 -04:00
parent a943a2cb63
commit eb0791ec89
58 changed files with 259 additions and 158 deletions

View File

@@ -22,10 +22,12 @@ from six import text_type
from course_modes.models import CourseMode
from courseware.models import StudentModule
from eventtracking import tracker
from lms.djangoapps.grades.constants import ScoreDatabaseTableEnum
from lms.djangoapps.grades.events import STATE_DELETED_EVENT_TYPE
from lms.djangoapps.grades.signals.handlers import disconnect_submissions_signal_receiver
from lms.djangoapps.grades.signals.signals import PROBLEM_RAW_SCORE_CHANGED
from lms.djangoapps.grades.api import (
constants as grades_constants,
events as grades_events,
signals as grades_signals,
disconnect_submissions_signal_receiver,
)
from lms.djangoapps.instructor.message_types import (
AccountCreationAndEnrollment,
AddBetaTester,
@@ -298,16 +300,16 @@ def reset_student_attempts(course_id, student, module_state_key, requesting_user
if delete_module:
module_to_reset.delete()
create_new_event_transaction_id()
set_event_transaction_type(STATE_DELETED_EVENT_TYPE)
set_event_transaction_type(grades_events.STATE_DELETED_EVENT_TYPE)
tracker.emit(
unicode(STATE_DELETED_EVENT_TYPE),
unicode(grades_events.STATE_DELETED_EVENT_TYPE),
{
'user_id': unicode(student.id),
'course_id': unicode(course_id),
'problem_id': unicode(module_state_key),
'instructor_id': unicode(requesting_user.id),
'event_transaction_id': unicode(get_event_transaction_id()),
'event_transaction_type': unicode(STATE_DELETED_EVENT_TYPE),
'event_transaction_type': unicode(grades_events.STATE_DELETED_EVENT_TYPE),
}
)
if not submission_cleared:
@@ -351,7 +353,7 @@ def _fire_score_changed_for_block(
if block and block.has_score:
max_score = block.max_score()
if max_score is not None:
PROBLEM_RAW_SCORE_CHANGED.send(
grades_signals.PROBLEM_RAW_SCORE_CHANGED.send(
sender=None,
raw_earned=0,
raw_possible=max_score,
@@ -362,7 +364,7 @@ def _fire_score_changed_for_block(
score_deleted=True,
only_if_higher=False,
modified=datetime.now().replace(tzinfo=pytz.UTC),
score_db_table=ScoreDatabaseTableEnum.courseware_student_module,
score_db_table=grades_constants.ScoreDatabaseTableEnum.courseware_student_module,
)

View File

@@ -7,7 +7,7 @@ from six import text_type
from capa.tests.response_xml_factory import StringResponseXMLFactory
from courseware.tests.factories import StudentModuleFactory
from lms.djangoapps.grades.tasks import compute_all_grades_for_course
from lms.djangoapps.grades.api import task_compute_all_grades_for_course
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
@@ -73,7 +73,7 @@ class TestGradebook(SharedModuleStoreTestCase):
course_id=self.course.id,
module_state_key=item.location
)
compute_all_grades_for_course.apply_async(kwargs={'course_key': text_type(self.course.id)})
task_compute_all_grades_for_course.apply_async(kwargs={'course_key': text_type(self.course.id)})
self.response = self.client.get(reverse(
'spoc_gradebook',

View File

@@ -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.course_grade_factory import CourseGradeFactory
from lms.djangoapps.grades.api import CourseGradeFactory
from lms.djangoapps.instructor.views.api import require_level
from xmodule.modulestore.django import modulestore

View File

@@ -43,7 +43,7 @@ from lms.djangoapps.certificates.models import (
GeneratedCertificate
)
from lms.djangoapps.courseware.module_render import get_module_by_usage_id
from lms.djangoapps.grades.config.waffle import WRITABLE_GRADEBOOK, waffle_flags
from lms.djangoapps.grades.api import is_writable_gradebook_enabled
from openedx.core.djangoapps.course_groups.cohorts import DEFAULT_COHORT_NAME, get_course_cohorts, is_course_cohorted
from openedx.core.djangoapps.django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, CourseDiscussionSettings
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@@ -594,7 +594,7 @@ def _section_student_admin(course, access):
kwargs={'course_id': unicode(course_key)}),
'spoc_gradebook_url': reverse('spoc_gradebook', kwargs={'course_id': unicode(course_key)}),
}
if waffle_flags()[WRITABLE_GRADEBOOK].is_enabled(course_key) and settings.WRITABLE_GRADEBOOK_URL:
if is_writable_gradebook_enabled(course_key) and settings.WRITABLE_GRADEBOOK_URL:
section_data['writable_gradebook_url'] = urljoin(settings.WRITABLE_GRADEBOOK_URL, '/' + text_type(course_key))
return section_data