Skip to content

Commit

Permalink
Merge pull request #10533 from edx/cdodge/adjust-report-task-routing
Browse files Browse the repository at this point in the history
change 'routing' for some reports which go to potentially backlogged …
  • Loading branch information
chrisndodge committed Nov 6, 2015
2 parents 10ed76a + 4216eaf commit ee29e11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lms/djangoapps/instructor_task/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def calculate_students_features_csv(entry_id, xmodule_instance_args):
return run_main_task(entry_id, task_fn, action_name)


@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable
@task(base=BaseInstructorTask) # pylint: disable=not-callable
def enrollment_report_features_csv(entry_id, xmodule_instance_args):
"""
Compute student profile information for a course and upload the
Expand All @@ -216,7 +216,7 @@ def enrollment_report_features_csv(entry_id, xmodule_instance_args):
return run_main_task(entry_id, task_fn, action_name)


@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable
@task(base=BaseInstructorTask) # pylint: disable=not-callable
def exec_summary_report_csv(entry_id, xmodule_instance_args):
"""
Compute executive summary report for a course and upload the
Expand All @@ -228,7 +228,7 @@ def exec_summary_report_csv(entry_id, xmodule_instance_args):
return run_main_task(entry_id, task_fn, action_name)


@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable
@task(base=BaseInstructorTask) # pylint: disable=not-callable
def course_survey_report_csv(entry_id, xmodule_instance_args):
"""
Compute the survey report for a course and upload the
Expand All @@ -240,7 +240,7 @@ def course_survey_report_csv(entry_id, xmodule_instance_args):
return run_main_task(entry_id, task_fn, action_name)


@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable
@task(base=BaseInstructorTask) # pylint: disable=not-callable
def proctored_exam_results_csv(entry_id, xmodule_instance_args):
"""
Compute proctored exam results report for a course and upload the
Expand Down
12 changes: 7 additions & 5 deletions lms/djangoapps/instructor_task/tasks_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,12 +1327,15 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t
survey_fields.sort()

user_survey_answers = OrderedDict()
survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id)
survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id).select_related('user')

for survey_field_record in survey_answers_for_course:
user_id = survey_field_record.user.id
if user_id not in user_survey_answers.keys():
user_survey_answers[user_id] = {}
user_survey_answers[user_id] = {
'username': survey_field_record.user.username,
'email': survey_field_record.user.email
}

user_survey_answers[user_id][survey_field_record.field_name] = survey_field_record.field_value

Expand All @@ -1343,9 +1346,8 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t
for user_id in user_survey_answers.keys():
row = []
row.append(user_id)
user_obj = User.objects.get(id=user_id)
row.append(user_obj.username)
row.append(user_obj.email)
row.append(user_survey_answers[user_id].get('username', ''))
row.append(user_survey_answers[user_id].get('email', ''))
for survey_field in survey_fields:
row.append(user_survey_answers[user_id].get(survey_field, ''))
csv_rows.append(row)
Expand Down

0 comments on commit ee29e11

Please sign in to comment.