Exemple #1
0
 def test_list_may_enroll(self):
     may_enroll = list_may_enroll(self.course_key, ['email'])
     self.assertEqual(len(may_enroll), len(self.students_who_may_enroll) - len(self.users))
     email_adresses = [student.email for student in self.students_who_may_enroll]
     for student in may_enroll:
         self.assertEqual(student.keys(), ['email'])
         self.assertIn(student['email'], email_adresses)
Exemple #2
0
 def test_list_may_enroll(self):
     may_enroll = list_may_enroll(self.course_key, ['email'])
     self.assertEqual(len(may_enroll), len(self.students_who_may_enroll) - len(self.users))
     email_adresses = [student.email for student in self.students_who_may_enroll]
     for student in may_enroll:
         self.assertEqual(student.keys(), ['email'])
         self.assertIn(student['email'], email_adresses)
def upload_may_enroll_csv(_xmodule_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
    yet, and store using a `ReportStore`.
    """
    start_time = time()
    start_date = datetime.now(UTC)
    num_reports = 1
    task_progress = TaskProgress(action_name, num_reports, start_time)
    current_step = {'step': 'Calculating info about students who may enroll'}
    task_progress.update_task_state(extra_meta=current_step)

    # Compute result table and format it
    query_features = task_input.get('features')
    student_data = list_may_enroll(course_id, query_features)
    header, rows = format_dictlist(student_data, query_features)

    task_progress.attempted = task_progress.succeeded = len(rows)
    task_progress.skipped = task_progress.total - task_progress.attempted

    rows.insert(0, header)

    current_step = {'step': 'Uploading CSV'}
    task_progress.update_task_state(extra_meta=current_step)

    # Perform the upload
    upload_csv_to_report_store(rows, 'may_enroll_info', course_id, start_date)

    return task_progress.update_task_state(extra_meta=current_step)
Exemple #4
0
def upload_may_enroll_csv(_xmodule_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
    yet, and store using a `ReportStore`.
    """
    start_time = time()
    start_date = datetime.now(UTC)
    num_reports = 1
    task_progress = TaskProgress(action_name, num_reports, start_time)
    current_step = {'step': 'Calculating info about students who may enroll'}
    task_progress.update_task_state(extra_meta=current_step)

    # Compute result table and format it
    query_features = task_input.get('features')
    student_data = list_may_enroll(course_id, query_features)
    header, rows = format_dictlist(student_data, query_features)

    task_progress.attempted = task_progress.succeeded = len(rows)
    task_progress.skipped = task_progress.total - task_progress.attempted

    rows.insert(0, header)

    current_step = {'step': 'Uploading CSV'}
    task_progress.update_task_state(extra_meta=current_step)

    # Perform the upload
    upload_csv_to_report_store(rows, 'may_enroll_info', course_id, start_date)

    return task_progress.update_task_state(extra_meta=current_step)