Ejemplo n.º 1
0
def voucher_and_partial_matches(voucher_and_user_client):
    """
    Returns a voucher with partial matching CourseRuns
    """
    voucher = voucher_and_user_client.voucher
    company = CompanyFactory()
    course_run_1 = CourseRunFactory(
        start_date=datetime.combine(voucher.course_start_date_input,
                                    datetime.min.time(),
                                    tzinfo=pytz.UTC),
        live=True,
    )
    course_run_2 = CourseRunFactory(
        course__readable_id=voucher.course_id_input, live=True)
    course_run_3 = CourseRunFactory(course__title=voucher.course_title_input,
                                    live=True)
    course_run_4 = CourseRunFactory(
        course__readable_id=f"{voucher.course_id_input}-noise", live=True)
    course_run_5 = CourseRunFactory(
        course__title=f"{voucher.course_title_input}-noise", live=True)
    return SimpleNamespace(
        **vars(voucher_and_user_client),
        company=company,
        partial_matches=[
            course_run_1,
            course_run_2,
            course_run_3,
            course_run_4,
            course_run_5,
        ],
    )
Ejemplo n.º 2
0
    def create_audited_passed_enrolled_again_failed(self):
        """Make course passed and user retaking/auditing the course again"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        course = Course.objects.get(title='Digital Learning 200')
        CourseCertificateSignatoriesFactory.create(course=course)

        course_run = CourseRunFactory(course=course, edx_course_key='course-passed')
        set_course_run_past(course_run)
        call_command(
            "alter_data", 'set_to_passed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key, '--grade', '80', '--audit'
        )
        final_grade = FinalGrade.objects.filter(
            course_run__course__title='Digital Learning 200', user=self.user
        ).first()
        CourseRunGradingStatus.objects.create(course_run=final_grade.course_run, status='complete')

        course_run = CourseRunFactory(course=course, edx_course_key='course-failed')
        set_course_run_past(course_run)
        call_command(
            "alter_data", 'set_to_failed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key, '--grade', '10', '--audit'
        )

        course_run = CourseRunFactory(course=course, edx_course_key='course-offered')
        set_course_run_future(course_run)
        call_command(
            'alter_data', 'set_to_offered', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key,
        )
Ejemplo n.º 3
0
 def test_course_serialization_format(self):
     """
     Tests that a user's course enrollments are serialized in a specific format
     """
     for program_enrollment in (self.non_fa_program_enrollment,
                                self.fa_program_enrollment):
         program = program_enrollment.program
         # Generate a new course run on an existing course, and create an unverified enrollment in it
         existing_course = program.course_set.first()
         new_course_run = CourseRunFactory(course=existing_course)
         self.unverified_enroll(self.user, course_run=new_course_run)
         # Generate a new course with only unverified course run enrollments
         unver_course, unver_course_runs = self.generate_course_with_runs(
             program,
             course_params=dict(title='Unverified Course'),
             course_run_count=2)
         for course_run in unver_course_runs:
             self.unverified_enroll(self.user, course_run=course_run)
         # Serialize the program enrollment and make sure each course is serialized properly
         serialized_program_user = UserProgramSearchSerializer.serialize(
             program_enrollment)
         serialized_enrollments = serialized_program_user['courses']
         assert len(serialized_enrollments) == 2
         # A course with a mix of verified and unverified course runs should be serialized as verified
         assert self.is_course_serialized_with_status(
             serialized_enrollments, existing_course, is_verified=True)
         # A course with a mix of all unverified course runs should be serialized as unverified
         assert self.is_course_serialized_with_status(
             serialized_enrollments, unver_course, is_verified=False)
Ejemplo n.º 4
0
    def create_paid_enrolled_currently_with_future_run(self):
        """Make paid and enrolled with offered currently and a future run """
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        course = Course.objects.get(title='Digital Learning 200')
        course_run_current = CourseRunFactory(course=course)
        call_command(
            "alter_data", 'set_to_enrolled', '--username', 'staff',
            '--course-run-key', course_run_current.edx_course_key
        )

        course_run_future = CourseRunFactory(course=course)
        call_command(
            "alter_data", 'set_to_enrolled', '--username', 'staff',
            '--course-run-key', course_run_future.edx_course_key,
            '--in-future'
        )
Ejemplo n.º 5
0
    def two_no_show_exam_attempts(self):
        """Passed and later failed course, and two exam attempts"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)

        course = Course.objects.get(title='Digital Learning 200')
        course_run = CourseRunFactory(course=course, edx_course_key='course-passed')
        call_command(
            "alter_data", 'set_to_passed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )

        ExamProfileFactory.create(status='success', profile=self.user.profile)
        # run 1
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # run 2
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # another offered
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
        call_command(
            "alter_data", 'set_to_offered', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-failed')
        call_command(
            "alter_data", 'set_to_failed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key, '--audit',
        )
Ejemplo n.º 6
0
def voucher_and_exact_match(voucher_and_user_client):
    """
    Returns a voucher with and an exact matching and partial matching CourseRuns
    """
    voucher = voucher_and_user_client.voucher
    exact_match = CourseRunFactory(
        start_date=datetime.combine(voucher.course_start_date_input,
                                    datetime.min.time(),
                                    tzinfo=pytz.UTC),
        course__readable_id=voucher.course_id_input,
        course__title=voucher.course_title_input,
        live=True,
    )
    return SimpleNamespace(
        **vars(voucher_and_user_client),
        company=CompanyFactory(),
        exact_match=exact_match,
    )
Ejemplo n.º 7
0
    def create_exams(self, current, edx_passed, exam_passed, new_offering, can_schedule, future_exam, need_to_pay):
        """Create an exam and mark it and the related course as passed or not passed"""
        # pylint: disable-msg=too-many-arguments
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        course = Course.objects.get(title='Digital Learning 200')
        if current:
            course_run = CourseRunFactory(course=course)
            call_command(
                "alter_data", 'set_to_enrolled', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key
            )
            FinalGradeFactory.create(
                user=self.user, course_run=course_run, grade=0.8 if edx_passed else 0.2, passed=True
            )
        else:
            if edx_passed:
                call_command(
                    "alter_data", 'set_to_passed', '--username', 'staff',
                    '--course-title', 'Digital Learning 200', '--grade', '75',
                )
            else:
                call_command(
                    "alter_data", 'set_to_failed', '--username', 'staff',
                    '--course-title', 'Digital Learning 200', '--grade', '45',
                )
            course_run = course.courserun_set.first()

        ExamProfileFactory.create(status='success', profile=self.user.profile)
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True
        )
        LineFactory.create(
            order__status=Order.FULFILLED,
            course_key=course_run
        )

        ProctoredExamGradeFactory.create(
            user=self.user,
            course=course,
            exam_run=exam_run,
            passed=exam_passed,
            percentage_grade=0.8 if exam_passed else 0.3
        )
        if new_offering:
            CourseRunFactory.create(course=course)

        if can_schedule:
            exam_run = ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=False,
                authorized=True,
                course=course
            )
            ExamAuthorizationFactory.create(
                user=self.user, course=course, exam_run=exam_run, status='success',
            )

        if future_exam:
            ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=True,
                authorized=True,
                course=course
            )
        if need_to_pay:
            exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
            ExamAuthorizationFactory.create(
                user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True
            )
            ProctoredExamGradeFactory.create(
                user=self.user,
                course=course,
                exam_run=exam_run,
                passed=False,
                percentage_grade=0.3
            )