diff --git a/lms/djangoapps/courseware/tests/test_block_render.py b/lms/djangoapps/courseware/tests/test_block_render.py index 465089caed..78a6cd8d37 100644 --- a/lms/djangoapps/courseware/tests/test_block_render.py +++ b/lms/djangoapps/courseware/tests/test_block_render.py @@ -1918,7 +1918,7 @@ class TestAnonymousStudentId(SharedModuleStoreTestCase, LoginEnrollmentTestCase) descriptor=descriptor, student_data=Mock(spec=FieldData, name='student_data'), course_id=course_id, - track_function=Mock(name='track_function'), # Track Function + track_function=Mock(name='track_function'), # Track Function request_token='request_token', course=self.course, ) diff --git a/lms/djangoapps/instructor_task/api_helper.py b/lms/djangoapps/instructor_task/api_helper.py index b346b9700d..50718580ae 100644 --- a/lms/djangoapps/instructor_task/api_helper.py +++ b/lms/djangoapps/instructor_task/api_helper.py @@ -128,9 +128,9 @@ def generate_already_running_error_message(task_type): return message -def _get_xmodule_instance_args(request, task_id): +def _get_xblock_instance_args(request, task_id): """ - Calculate parameters needed for instantiating xmodule instances. + Calculate parameters needed for instantiating xblock instances. The `request_info` will be passed to a tracking log function, to provide information about the source of the task request. @@ -143,10 +143,10 @@ def _get_xmodule_instance_args(request, task_id): 'host': request.META['SERVER_NAME'], } - xmodule_instance_args = {'request_info': request_info, - 'task_id': task_id, - } - return xmodule_instance_args + xblock_instance_args = {'request_info': request_info, + 'task_id': task_id, + } + return xblock_instance_args def _supports_rescore(descriptor): @@ -460,7 +460,7 @@ def submit_task(request, task_type, task_class, course_key, task_input, task_key # make sure all data has been committed before handing off task to celery. task_id = instructor_task.task_id - task_args = [instructor_task.id, _get_xmodule_instance_args(request, task_id)] + task_args = [instructor_task.id, _get_xblock_instance_args(request, task_id)] try: task_class.apply_async(task_args, task_id=task_id) @@ -494,7 +494,7 @@ def schedule_task(request, task_type, course_key, task_input, task_key, schedule instructor_task = InstructorTask.create(course_key, task_type, task_key, task_input, request.user) task_id = instructor_task.task_id - task_args = _get_xmodule_instance_args(request, task_id) + task_args = _get_xblock_instance_args(request, task_id) log.info(f"Creating a task schedule associated with instructor task '{instructor_task.id}' and due after " f"'{schedule}'") InstructorTaskSchedule.objects.create( diff --git a/lms/djangoapps/instructor_task/tasks.py b/lms/djangoapps/instructor_task/tasks.py index 61a933b5a6..f142b90cc4 100644 --- a/lms/djangoapps/instructor_task/tasks.py +++ b/lms/djangoapps/instructor_task/tasks.py @@ -4,12 +4,12 @@ running state of a course. At present, these tasks all operate on StudentModule objects in one way or another, so they share a visitor architecture. Each task defines an "update function" that -takes a module_descriptor, a particular StudentModule object, and xmodule_instance_args. +takes a module_descriptor, a particular StudentModule object, and xblock_instance_args. A task may optionally specify a "filter function" that takes a query for StudentModule objects, and adds additional filter clauses. -A task also passes through "xmodule_instance_args", that are used to provide +A task also passes through "xblock_instance_args", that are used to provide information to our code that instantiates xmodule instances. The task definition then calls the traversal function, passing in the three arguments @@ -56,7 +56,7 @@ TASK_LOG = logging.getLogger('edx.celery.task') @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def rescore_problem(entry_id, xmodule_instance_args): +def rescore_problem(entry_id, xblock_instance_args): """Rescores a problem in a course, for all students or one specific student. `entry_id` is the id value of the InstructorTask entry that corresponds to this task. @@ -71,12 +71,12 @@ def rescore_problem(entry_id, xmodule_instance_args): problem submission should be rescored. If not specified, all problem submissions for the problem will be rescored. - `xmodule_instance_args` provides information needed by _get_module_instance_for_task() - to instantiate an xmodule instance. + `xblock_instance_args` provides information needed by _get_module_instance_for_task() + to instantiate an xblock instance. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('rescored') - update_fcn = partial(rescore_problem_module_state, xmodule_instance_args) + update_fcn = partial(rescore_problem_module_state, xblock_instance_args) visit_fcn = partial(perform_module_state_update, update_fcn, None) return run_main_task(entry_id, visit_fcn, action_name) @@ -84,13 +84,13 @@ def rescore_problem(entry_id, xmodule_instance_args): @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def override_problem_score(entry_id, xmodule_instance_args): +def override_problem_score(entry_id, xblock_instance_args): """ Overrides a specific learner's score on a problem. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('overridden') - update_fcn = partial(override_score_module_state, xmodule_instance_args) + update_fcn = partial(override_score_module_state, xblock_instance_args) visit_fcn = partial(perform_module_state_update, update_fcn, None) return run_main_task(entry_id, visit_fcn, action_name) @@ -98,7 +98,7 @@ def override_problem_score(entry_id, xmodule_instance_args): @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def reset_problem_attempts(entry_id, xmodule_instance_args): +def reset_problem_attempts(entry_id, xblock_instance_args): """Resets problem attempts to zero for a particular problem for all students in a course. `entry_id` is the id value of the InstructorTask entry that corresponds to this task. @@ -109,19 +109,19 @@ def reset_problem_attempts(entry_id, xmodule_instance_args): 'problem_url': the full URL to the problem to be rescored. (required) - `xmodule_instance_args` provides information needed by _get_module_instance_for_task() - to instantiate an xmodule instance. + `xblock_instance_args` provides information needed by _get_module_instance_for_task() + to instantiate an xblock instance. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('reset') - update_fcn = partial(reset_attempts_module_state, xmodule_instance_args) + update_fcn = partial(reset_attempts_module_state, xblock_instance_args) visit_fcn = partial(perform_module_state_update, update_fcn, None) return run_main_task(entry_id, visit_fcn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def delete_problem_state(entry_id, xmodule_instance_args): +def delete_problem_state(entry_id, xblock_instance_args): """Deletes problem state entirely for all students on a particular problem in a course. `entry_id` is the id value of the InstructorTask entry that corresponds to this task. @@ -132,19 +132,19 @@ def delete_problem_state(entry_id, xmodule_instance_args): 'problem_url': the full URL to the problem to be rescored. (required) - `xmodule_instance_args` provides information needed by _get_module_instance_for_task() - to instantiate an xmodule instance. + `xblock_instance_args` provides information needed by _get_module_instance_for_task() + to instantiate an xblock instance. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('deleted') - update_fcn = partial(delete_problem_module_state, xmodule_instance_args) + update_fcn = partial(delete_problem_module_state, xblock_instance_args) visit_fcn = partial(perform_module_state_update, update_fcn, None) return run_main_task(entry_id, visit_fcn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def send_bulk_course_email(entry_id, _xmodule_instance_args): +def send_bulk_course_email(entry_id, _xblock_instance_args): """Sends emails to recipients enrolled in a course. `entry_id` is the id value of the InstructorTask entry that corresponds to this task. @@ -155,8 +155,8 @@ def send_bulk_course_email(entry_id, _xmodule_instance_args): 'email_id': the full URL to the problem to be rescored. (required) - `_xmodule_instance_args` provides information needed by _get_module_instance_for_task() - to instantiate an xmodule instance. This is unused here. + `_xblock_instance_args` provides information needed by _get_module_instance_for_task() + to instantiate an xblock instance. This is unused here. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('emailed') @@ -169,20 +169,20 @@ def send_bulk_course_email(entry_id, _xmodule_instance_args): base=BaseInstructorTask, ) @set_code_owner_attribute -def calculate_problem_responses_csv(entry_id, xmodule_instance_args): +def calculate_problem_responses_csv(entry_id, xblock_instance_args): """ Compute student answers to a given problem and upload the CSV to an S3 bucket for download. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('generated') - task_fn = partial(ProblemResponses.generate, xmodule_instance_args) + task_fn = partial(ProblemResponses.generate, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def calculate_grades_csv(entry_id, xmodule_instance_args): +def calculate_grades_csv(entry_id, xblock_instance_args): """ Grade a course and push the results to an S3 bucket for download. """ @@ -190,16 +190,16 @@ def calculate_grades_csv(entry_id, xmodule_instance_args): action_name = gettext_noop('graded') TASK_LOG.info( "Task: %s, InstructorTask ID: %s, Task type: %s, Preparing for task execution", - xmodule_instance_args.get('task_id'), entry_id, action_name + xblock_instance_args.get('task_id'), entry_id, action_name ) - task_fn = partial(CourseGradeReport.generate, xmodule_instance_args) + task_fn = partial(CourseGradeReport.generate, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def calculate_problem_grade_report(entry_id, xmodule_instance_args): +def calculate_problem_grade_report(entry_id, xblock_instance_args): """ Generate a CSV for a course containing all students' problem grades and push the results to an S3 bucket for download. @@ -208,54 +208,54 @@ def calculate_problem_grade_report(entry_id, xmodule_instance_args): action_name = gettext_noop('problem distribution graded') TASK_LOG.info( "Task: %s, InstructorTask ID: %s, Task type: %s, Preparing for task execution", - xmodule_instance_args.get('task_id'), entry_id, action_name + xblock_instance_args.get('task_id'), entry_id, action_name ) - task_fn = partial(ProblemGradeReport.generate, xmodule_instance_args) + task_fn = partial(ProblemGradeReport.generate, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def calculate_students_features_csv(entry_id, xmodule_instance_args): +def calculate_students_features_csv(entry_id, xblock_instance_args): """ Compute student profile information for a course and upload the CSV to an S3 bucket for download. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('generated') - task_fn = partial(upload_students_csv, xmodule_instance_args) + task_fn = partial(upload_students_csv, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def course_survey_report_csv(entry_id, xmodule_instance_args): +def course_survey_report_csv(entry_id, xblock_instance_args): """ Compute the survey report for a course and upload the generated report to an S3 bucket for download. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('generated') - task_fn = partial(upload_course_survey_report, xmodule_instance_args) + task_fn = partial(upload_course_survey_report, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def proctored_exam_results_csv(entry_id, xmodule_instance_args): +def proctored_exam_results_csv(entry_id, xblock_instance_args): """ Compute proctored exam results report for a course and upload the CSV for download. """ action_name = 'generating_proctored_exam_results_report' - task_fn = partial(upload_proctored_exam_results_report, xmodule_instance_args) + task_fn = partial(upload_proctored_exam_results_report, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def calculate_may_enroll_csv(entry_id, xmodule_instance_args): +def calculate_may_enroll_csv(entry_id, xblock_instance_args): """ Compute information about invited students who have not enrolled in a given course yet and upload the CSV to an S3 bucket for @@ -263,13 +263,13 @@ def calculate_may_enroll_csv(entry_id, xmodule_instance_args): """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. action_name = gettext_noop('generated') - task_fn = partial(upload_may_enroll_csv, xmodule_instance_args) + task_fn = partial(upload_may_enroll_csv, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def generate_certificates(entry_id, xmodule_instance_args): +def generate_certificates(entry_id, xblock_instance_args): """ Grade students and generate certificates. """ @@ -277,68 +277,68 @@ def generate_certificates(entry_id, xmodule_instance_args): action_name = gettext_noop('certificates generated') TASK_LOG.info( "Task: %s, InstructorTask ID: %s, Task type: %s, Preparing for task execution", - xmodule_instance_args.get('task_id'), entry_id, action_name + xblock_instance_args.get('task_id'), entry_id, action_name ) - task_fn = partial(generate_students_certificates, xmodule_instance_args) + task_fn = partial(generate_students_certificates, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def cohort_students(entry_id, xmodule_instance_args): +def cohort_students(entry_id, xblock_instance_args): """ Cohort students in bulk, and upload the results. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. # An example of such a message is: "Progress: {action} {succeeded} of {attempted} so far" action_name = gettext_noop('cohorted') - task_fn = partial(cohort_students_and_upload, xmodule_instance_args) + task_fn = partial(cohort_students_and_upload, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def generate_anonymous_ids_for_course(entry_id, xmodule_instance_args): +def generate_anonymous_ids_for_course(entry_id, xblock_instance_args): """ Generate a CSV of anonymize IDs for enrolled learner for course. """ # Translators: This is a past-tense verb that is inserted into task progress messages as {action}. # An example of such a message is: "Progress: {action} {succeeded} of {attempted} so far" action_name = gettext_noop('generate_anonymized_id') - task_fn = partial(generate_anonymous_ids, xmodule_instance_args) + task_fn = partial(generate_anonymous_ids, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def export_ora2_data(entry_id, xmodule_instance_args): +def export_ora2_data(entry_id, xblock_instance_args): """ Generate a CSV of ora2 responses and push it to S3. """ action_name = gettext_noop('generated') - task_fn = partial(upload_ora2_data, xmodule_instance_args) + task_fn = partial(upload_ora2_data, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def export_ora2_submission_files(entry_id, xmodule_instance_args): +def export_ora2_submission_files(entry_id, xblock_instance_args): """ Download all submission files, generate csv downloads list, put all this into zip archive and push it to S3. """ action_name = gettext_noop('compressed') - task_fn = partial(upload_ora2_submission_files, xmodule_instance_args) + task_fn = partial(upload_ora2_submission_files, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) @shared_task(base=BaseInstructorTask) @set_code_owner_attribute -def export_ora2_summary(entry_id, xmodule_instance_args): +def export_ora2_summary(entry_id, xblock_instance_args): """ Generate a CSV of ora2/student summaries and push it to S3. """ action_name = gettext_noop('generated') - task_fn = partial(upload_ora2_summary, xmodule_instance_args) + task_fn = partial(upload_ora2_summary, xblock_instance_args) return run_main_task(entry_id, task_fn, action_name) diff --git a/lms/djangoapps/instructor_task/tasks_helper/certs.py b/lms/djangoapps/instructor_task/tasks_helper/certs.py index 28f51d06a1..8ea80cce6a 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/certs.py +++ b/lms/djangoapps/instructor_task/tasks_helper/certs.py @@ -26,7 +26,7 @@ log = logging.getLogger(__name__) def generate_students_certificates( - _xmodule_instance_args, _entry_id, course_id, task_input, action_name): + _xblock_instance_args, _entry_id, course_id, task_input, action_name): """ For a given `course_id`, generate certificates for only students present in 'students' key in task_input json column, otherwise generate certificates for all enrolled students. diff --git a/lms/djangoapps/instructor_task/tasks_helper/enrollments.py b/lms/djangoapps/instructor_task/tasks_helper/enrollments.py index ada2bd45ee..0309b7883a 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/enrollments.py +++ b/lms/djangoapps/instructor_task/tasks_helper/enrollments.py @@ -18,7 +18,7 @@ TASK_LOG = logging.getLogger('edx.celery.task') FILTERED_OUT_ROLES = ['staff', 'instructor', 'finance_admin', 'sales_admin'] -def upload_may_enroll_csv(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): +def upload_may_enroll_csv(_xblock_instance_args, _entry_id, course_id, task_input, action_name): """ For a given `course_id`, generate a CSV file containing information about students who may enroll but have not done so @@ -50,7 +50,7 @@ def upload_may_enroll_csv(_xmodule_instance_args, _entry_id, course_id, task_inp return task_progress.update_task_state(extra_meta=current_step) -def upload_students_csv(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): +def upload_students_csv(_xblock_instance_args, _entry_id, course_id, task_input, action_name): """ For a given `course_id`, generate a CSV file containing profile information for all students that are enrolled, and store using a diff --git a/lms/djangoapps/instructor_task/tasks_helper/grades.py b/lms/djangoapps/instructor_task/tasks_helper/grades.py index 561bc0873e..5358af3708 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/grades.py +++ b/lms/djangoapps/instructor_task/tasks_helper/grades.py @@ -80,14 +80,14 @@ class _CourseGradeReportContext: boundaries. """ - def __init__(self, _xmodule_instance_args, _entry_id, course_id, _task_input, action_name): + def __init__(self, _xblock_instance_args, _entry_id, course_id, _task_input, action_name): self.task_info_string = ( 'Task: {task_id}, ' 'InstructorTask ID: {entry_id}, ' 'Course: {course_id}, ' 'Input: {task_input}' ).format( - task_id=_xmodule_instance_args.get('task_id') if _xmodule_instance_args is not None else None, + task_id=_xblock_instance_args.get('task_id') if _xblock_instance_args is not None else None, entry_id=_entry_id, course_id=course_id, task_input=_task_input, @@ -171,8 +171,8 @@ class _ProblemGradeReportContext: boundaries. """ - def __init__(self, _xmodule_instance_args, _entry_id, course_id, _task_input, action_name): - task_id = _xmodule_instance_args.get('task_id') if _xmodule_instance_args is not None else None + def __init__(self, _xblock_instance_args, _entry_id, course_id, _task_input, action_name): + task_id = _xblock_instance_args.get('task_id') if _xblock_instance_args is not None else None self.task_info_string = ( 'Task: {task_id}, ' 'InstructorTask ID: {entry_id}, ' @@ -513,12 +513,12 @@ class CourseGradeReport(GradeReportBase): USER_BATCH_SIZE = 100 @classmethod - def generate(cls, _xmodule_instance_args, _entry_id, course_id, _task_input, action_name): + def generate(cls, _xblock_instance_args, _entry_id, course_id, _task_input, action_name): """ Public method to generate a grade report. """ with modulestore().bulk_operations(course_id): - context = _CourseGradeReportContext(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name) + context = _CourseGradeReportContext(_xblock_instance_args, _entry_id, course_id, _task_input, action_name) if use_on_disk_grade_reporting(course_id): # AU-926 return TempFileCourseGradeReport(context)._generate() # pylint: disable=protected-access else: @@ -712,12 +712,12 @@ class ProblemGradeReport(GradeReportBase): """ @classmethod - def generate(cls, _xmodule_instance_args, _entry_id, course_id, _task_input, action_name): + def generate(cls, _xblock_instance_args, _entry_id, course_id, _task_input, action_name): """ Public method to generate a grade report. """ with modulestore().bulk_operations(course_id): - context = _ProblemGradeReportContext(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name) + context = _ProblemGradeReportContext(_xblock_instance_args, _entry_id, course_id, _task_input, action_name) if use_on_disk_grade_reporting(course_id): # AU-926 return TempFileProblemGradeReport(context)._generate() # pylint: disable=protected-access else: @@ -960,7 +960,7 @@ class ProblemResponses: return student_data, student_data_keys_list @classmethod - def generate(cls, _xmodule_instance_args, _entry_id, course_id, task_input, action_name): + def generate(cls, _xblock_instance_args, _entry_id, course_id, task_input, action_name): """ For a given `course_id`, generate a CSV file containing all student answers to a given problem, and store using a `ReportStore`. diff --git a/lms/djangoapps/instructor_task/tasks_helper/misc.py b/lms/djangoapps/instructor_task/tasks_helper/misc.py index e2d303a9b1..85a5d4e136 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/misc.py +++ b/lms/djangoapps/instructor_task/tasks_helper/misc.py @@ -39,7 +39,7 @@ from .utils import ( TASK_LOG = logging.getLogger('edx.celery.task') -def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name): +def upload_course_survey_report(_xblock_instance_args, _entry_id, course_id, _task_input, action_name): """ For a given `course_id`, generate a html report containing the survey results for a course. """ @@ -97,7 +97,7 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t return task_progress.update_task_state(extra_meta=current_step) -def upload_proctored_exam_results_report(_xmodule_instance_args, _entry_id, course_id, _task_input, action_name): +def upload_proctored_exam_results_report(_xblock_instance_args, _entry_id, course_id, _task_input, action_name): """ For a given `course_id`, generate a CSV file containing information about proctored exam results, and store using a `ReportStore`. @@ -165,7 +165,7 @@ def _get_csv_file_content(csv_file): return csv_content -def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements +def cohort_students_and_upload(_xblock_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements """ Within a given course, cohort students in bulk, then upload the results using a `ReportStore`. @@ -273,33 +273,33 @@ def cohort_students_and_upload(_xmodule_instance_args, _entry_id, course_id, tas def upload_ora2_data( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name + _xblock_instance_args, _entry_id, course_id, _task_input, action_name ): """ Collect ora2 responses and upload them to S3 as a CSV """ return _upload_ora2_data_common( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name, + _xblock_instance_args, _entry_id, course_id, _task_input, action_name, 'data', OraAggregateData.collect_ora2_data ) def upload_ora2_summary( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name + _xblock_instance_args, _entry_id, course_id, _task_input, action_name ): """ Collect ora2/student summaries and upload them to file storage as a CSV """ return _upload_ora2_data_common( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name, + _xblock_instance_args, _entry_id, course_id, _task_input, action_name, 'summary', OraAggregateData.collect_ora2_summary ) def _upload_ora2_data_common( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name, + _xblock_instance_args, _entry_id, course_id, _task_input, action_name, report_name, csv_gen_func ): """ @@ -313,7 +313,7 @@ def _upload_ora2_data_common( fmt = 'Task: {task_id}, InstructorTask ID: {entry_id}, Course: {course_id}, Input: {task_input}' task_info_string = fmt.format( - task_id=_xmodule_instance_args.get('task_id') if _xmodule_instance_args is not None else None, + task_id=_xblock_instance_args.get('task_id') if _xblock_instance_args is not None else None, entry_id=_entry_id, course_id=course_id, task_input=_task_input @@ -399,7 +399,7 @@ def _task_step(task_progress, task_info_string, action_name): def upload_ora2_submission_files( - _xmodule_instance_args, _entry_id, course_id, _task_input, action_name + _xblock_instance_args, _entry_id, course_id, _task_input, action_name ): """ Creates zip archive with submission files in three steps: @@ -418,7 +418,7 @@ def upload_ora2_submission_files( fmt = 'Task: {task_id}, InstructorTask ID: {entry_id}, Course: {course_id}, Input: {task_input}' task_info_string = fmt.format( - task_id=_xmodule_instance_args.get('task_id') if _xmodule_instance_args is not None else None, + task_id=_xblock_instance_args.get('task_id') if _xblock_instance_args is not None else None, entry_id=_entry_id, course_id=course_id, task_input=_task_input @@ -481,7 +481,7 @@ def upload_ora2_submission_files( return UPDATE_STATUS_SUCCEEDED -def generate_anonymous_ids(_xmodule_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements +def generate_anonymous_ids(_xblock_instance_args, _entry_id, course_id, task_input, action_name): # lint-amnesty, pylint: disable=too-many-statements """ Generate a 2-column CSV output of user-id, anonymized-user-id """ @@ -503,7 +503,7 @@ def generate_anonymous_ids(_xmodule_instance_args, _entry_id, course_id, task_in task_info_string_format = 'Task: {task_id}, InstructorTask ID: {entry_id}, Course: {course_id}, Input: {task_input}' task_info_string = task_info_string_format.format( - task_id=_xmodule_instance_args.get('task_id') if _xmodule_instance_args is not None else None, + task_id=_xblock_instance_args.get('task_id') if _xblock_instance_args is not None else None, entry_id=_entry_id, course_id=course_id, task_input=task_input diff --git a/lms/djangoapps/instructor_task/tasks_helper/module_state.py b/lms/djangoapps/instructor_task/tasks_helper/module_state.py index 96112e112a..ddec49cf8a 100644 --- a/lms/djangoapps/instructor_task/tasks_helper/module_state.py +++ b/lms/djangoapps/instructor_task/tasks_helper/module_state.py @@ -39,7 +39,7 @@ def perform_module_state_update(update_fcn, filter_fcn, _entry_id, course_id, ta The student modules are fetched for update the `update_fcn` is called on each StudentModule that passes the resulting filtering. It is passed four arguments: the module_descriptor for the module pointed to by the module_state_key, the particular StudentModule to update, the - xmodule_instance_args, and the task_input being passed through. If the value returned by the + xblock_instance_args, and the task_input being passed through. If the value returned by the update function evaluates to a boolean True, the update is successful; False indicates the update on the particular student module failed. A raised exception indicates a fatal condition -- that no other student modules should be considered. @@ -110,7 +110,7 @@ def perform_module_state_update(update_fcn, filter_fcn, _entry_id, course_id, ta @outer_atomic -def rescore_problem_module_state(xmodule_instance_args, module_descriptor, student_module, task_input): +def rescore_problem_module_state(xblock_instance_args, module_descriptor, student_module, task_input): ''' Takes an XModule descriptor and a corresponding StudentModule object, and performs rescoring on the student's problem submission. @@ -136,7 +136,7 @@ def rescore_problem_module_state(xmodule_instance_args, module_descriptor, stude course_id, student, module_descriptor, - xmodule_instance_args, + xblock_instance_args, grade_bucket_type='rescore', course=course ) @@ -208,7 +208,7 @@ def rescore_problem_module_state(xmodule_instance_args, module_descriptor, stude @outer_atomic -def override_score_module_state(xmodule_instance_args, module_descriptor, student_module, task_input): +def override_score_module_state(xblock_instance_args, module_descriptor, student_module, task_input): ''' Takes an XModule descriptor and a corresponding StudentModule object, and performs an override on the student's problem score. @@ -233,7 +233,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen course_id, student, module_descriptor, - xmodule_instance_args, + xblock_instance_args, course=course ) @@ -288,7 +288,7 @@ def override_score_module_state(xmodule_instance_args, module_descriptor, studen @outer_atomic -def reset_attempts_module_state(xmodule_instance_args, _module_descriptor, student_module, _task_input): +def reset_attempts_module_state(xblock_instance_args, _module_descriptor, student_module, _task_input): """ Resets problem attempts to zero for specified `student_module`. @@ -306,7 +306,7 @@ def reset_attempts_module_state(xmodule_instance_args, _module_descriptor, stude student_module.save() # get request-related tracking information from args passthrough, # and supplement with task-specific information: - track_function = _get_track_function_for_task(student_module.student, xmodule_instance_args) + track_function = _get_track_function_for_task(student_module.student, xblock_instance_args) event_info = {"old_attempts": old_number_of_attempts, "new_attempts": 0} track_function('problem_reset_attempts', event_info) update_status = UPDATE_STATUS_SUCCEEDED @@ -315,7 +315,7 @@ def reset_attempts_module_state(xmodule_instance_args, _module_descriptor, stude @outer_atomic -def delete_problem_module_state(xmodule_instance_args, _module_descriptor, student_module, _task_input): +def delete_problem_module_state(xblock_instance_args, _module_descriptor, student_module, _task_input): """ Delete the StudentModule entry. @@ -324,19 +324,19 @@ def delete_problem_module_state(xmodule_instance_args, _module_descriptor, stude student_module.delete() # get request-related tracking information from args passthrough, # and supplement with task-specific information: - track_function = _get_track_function_for_task(student_module.student, xmodule_instance_args) + track_function = _get_track_function_for_task(student_module.student, xblock_instance_args) track_function('problem_delete_state', {}) return UPDATE_STATUS_SUCCEEDED -def _get_module_instance_for_task(course_id, student, module_descriptor, xmodule_instance_args=None, +def _get_module_instance_for_task(course_id, student, module_descriptor, xblock_instance_args=None, grade_bucket_type=None, course=None): """ Fetches a StudentModule instance for a given `course_id`, `student` object, and `module_descriptor`. - `xmodule_instance_args` is used to provide information for creating a track function and an XQueue callback. + `xblock_instance_args` is used to provide information for creating a track function and an XQueue callback. These are passed, along with `grade_bucket_type`, to get_block_for_descriptor_internal, which sidesteps - the need for a Request object when instantiating an xmodule instance. + the need for a Request object when instantiating an xblock instance. """ # reconstitute the problem's corresponding XModule: field_data_cache = FieldDataCache.cache_for_descriptor_descendents(course_id, student, module_descriptor) @@ -344,8 +344,8 @@ def _get_module_instance_for_task(course_id, student, module_descriptor, xmodule # get request-related tracking information from args passthrough, and supplement with task-specific # information: - request_info = xmodule_instance_args.get('request_info', {}) if xmodule_instance_args is not None else {} - task_info = {"student": student.username, "task_id": _get_task_id_from_xmodule_args(xmodule_instance_args)} + request_info = xblock_instance_args.get('request_info', {}) if xblock_instance_args is not None else {} + task_info = {"student": student.username, "task_id": _get_task_id_from_xblock_args(xblock_instance_args)} def make_track_function(): ''' @@ -371,7 +371,7 @@ def _get_module_instance_for_task(course_id, student, module_descriptor, xmodule ) -def _get_track_function_for_task(student, xmodule_instance_args=None, source_page='x_module_task'): +def _get_track_function_for_task(student, xblock_instance_args=None, source_page='x_module_task'): """ Make a tracking function that logs what happened. @@ -381,18 +381,18 @@ def _get_track_function_for_task(student, xmodule_instance_args=None, source_pag """ # get request-related tracking information from args passthrough, and supplement with task-specific # information: - request_info = xmodule_instance_args.get('request_info', {}) if xmodule_instance_args is not None else {} - task_info = {'student': student.username, 'task_id': _get_task_id_from_xmodule_args(xmodule_instance_args)} + request_info = xblock_instance_args.get('request_info', {}) if xblock_instance_args is not None else {} + task_info = {'student': student.username, 'task_id': _get_task_id_from_xblock_args(xblock_instance_args)} return lambda event_type, event: task_track(request_info, task_info, event_type, event, page=source_page) -def _get_task_id_from_xmodule_args(xmodule_instance_args): - """Gets task_id from `xmodule_instance_args` dict, or returns default value if missing.""" - if xmodule_instance_args is None: +def _get_task_id_from_xblock_args(xblock_instance_args): + """Gets task_id from `xblock_instance_args` dict, or returns default value if missing.""" + if xblock_instance_args is None: return UNKNOWN_TASK_ID else: - return xmodule_instance_args.get('task_id', UNKNOWN_TASK_ID) + return xblock_instance_args.get('task_id', UNKNOWN_TASK_ID) def _get_modules_to_update(course_id, usage_keys, student_identifier, filter_fcn, override_score_task=False): diff --git a/lms/djangoapps/instructor_task/tests/test_api_helper.py b/lms/djangoapps/instructor_task/tests/test_api_helper.py index 45df5a241a..f143294501 100644 --- a/lms/djangoapps/instructor_task/tests/test_api_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_api_helper.py @@ -116,8 +116,8 @@ class ScheduledBulkEmailInstructorTaskTests(InstructorTaskCourseTestCase): assert expected_task_args == actual_task_args self._verify_log_messages(expected_messages, log) - @patch("lms.djangoapps.instructor_task.api_helper._get_xmodule_instance_args", side_effect=Exception("boom!")) - def test_create_scheduled_instructor_task_expect_failure(self, mock_get_xmodule_instance_args): + @patch("lms.djangoapps.instructor_task.api_helper._get_xblock_instance_args", side_effect=Exception("boom!")) + def test_create_scheduled_instructor_task_expect_failure(self, mock_get_xblock_instance_args): """ A test to verify that we will mark a task as `FAILED` if a failure occurs during the creation of the task schedule. diff --git a/lms/djangoapps/instructor_task/tests/test_tasks.py b/lms/djangoapps/instructor_task/tests/test_tasks.py index e6a342bfc8..4c66f7271c 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks.py @@ -78,7 +78,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): ) return instructor_task - def _get_xmodule_instance_args(self): + def _get_block_instance_args(self): """ Calculate dummy values for parameters needed for instantiating xmodule instances. """ @@ -97,7 +97,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): self.current_task.update_state = Mock() if expected_failure_message is not None: self.current_task.update_state.side_effect = TestTaskFailure(expected_failure_message) - task_args = [entry_id, self._get_xmodule_instance_args()] + task_args = [entry_id, self._get_block_instance_args()] with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') as mock_get_task: mock_get_task.return_value = self.current_task @@ -107,7 +107,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): """Check that a task_class fails when celery doesn't provide a current_task.""" task_entry = self._create_input_entry() with pytest.raises(ValueError): - task_class(task_entry.id, self._get_xmodule_instance_args()) + task_class(task_entry.id, self._get_block_instance_args()) def _test_undefined_course(self, task_class): """Run with celery, but with no course defined.""" @@ -293,8 +293,8 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks): del mock_instance.set_score with patch( 'lms.djangoapps.instructor_task.tasks_helper.module_state.get_block_for_descriptor_internal' - ) as mock_get_module: - mock_get_module.return_value = mock_instance + ) as mock_get_block: + mock_get_block.return_value = mock_instance with pytest.raises(UpdateProblemModuleStateError): self._run_task_with_mock_celery(override_problem_score, task_entry.id, task_entry.task_id) # check values stored in table: @@ -339,8 +339,8 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks): task_entry = self._create_input_entry(score=0) with patch( 'lms.djangoapps.instructor_task.tasks_helper.module_state.get_block_for_descriptor_internal' - ) as mock_get_module: - mock_get_module.return_value = mock_instance + ) as mock_get_block: + mock_get_block.return_value = mock_instance mock_instance.max_score = MagicMock(return_value=99999.0) mock_instance.weight = 99999.0 self._run_task_with_mock_celery(override_problem_score, task_entry.id, task_entry.task_id) @@ -425,8 +425,8 @@ class TestRescoreInstructorTask(TestInstructorTasks): mock_instance = MagicMock() del mock_instance.rescore_problem del mock_instance.rescore - with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_block_for_descriptor_internal') as mock_get_module: # lint-amnesty, pylint: disable=line-too-long - mock_get_module.return_value = mock_instance + with patch('lms.djangoapps.instructor_task.tasks_helper.module_state.get_block_for_descriptor_internal') as mock_get_block: # lint-amnesty, pylint: disable=line-too-long + mock_get_block.return_value = mock_instance with pytest.raises(UpdateProblemModuleStateError): self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) # check values stored in table: @@ -475,8 +475,8 @@ class TestRescoreInstructorTask(TestInstructorTasks): task_entry = self._create_input_entry() with patch( 'lms.djangoapps.instructor_task.tasks_helper.module_state.get_block_for_descriptor_internal' - ) as mock_get_module: - mock_get_module.return_value = mock_instance + ) as mock_get_block: + mock_get_block.return_value = mock_instance self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self.assert_task_output( @@ -671,10 +671,10 @@ class TestOra2ResponsesInstructorTask(TestInstructorTasks): def test_ora2_runs_task(self): task_entry = self._create_input_entry() - task_xmodule_args = self._get_xmodule_instance_args() + task_xblock_args = self._get_block_instance_args() with patch('lms.djangoapps.instructor_task.tasks.run_main_task') as mock_main_task: - export_ora2_data(task_entry.id, task_xmodule_args) + export_ora2_data(task_entry.id, task_xblock_args) action_name = gettext_noop('generated') assert mock_main_task.call_count == 1 @@ -701,10 +701,10 @@ class TestOra2ExportSubmissionFilesInstructorTask(TestInstructorTasks): def test_ora2_runs_task(self): task_entry = self._create_input_entry() - task_xmodule_args = self._get_xmodule_instance_args() + task_xblock_args = self._get_block_instance_args() with patch('lms.djangoapps.instructor_task.tasks.run_main_task') as mock_main_task: - export_ora2_submission_files(task_entry.id, task_xmodule_args) + export_ora2_submission_files(task_entry.id, task_xblock_args) action_name = gettext_noop('compressed') assert mock_main_task.call_count == 1 @@ -731,10 +731,10 @@ class TestOra2SummaryInstructorTask(TestInstructorTasks): def test_ora2_runs_task(self): task_entry = self._create_input_entry() - task_xmodule_args = self._get_xmodule_instance_args() + task_xblock_args = self._get_block_instance_args() with patch('lms.djangoapps.instructor_task.tasks.run_main_task') as mock_main_task: - export_ora2_summary(task_entry.id, task_xmodule_args) + export_ora2_summary(task_entry.id, task_xblock_args) action_name = gettext_noop('generated') assert mock_main_task.call_count == 1