示例#1
0
 def setup(self, db):
     self.site = Site.objects.first()
     self.course_overview = CourseOverviewFactory()
     self.users = [UserFactory(), UserFactory()]
     self.course_access_roles = [
         CourseAccessRoleFactory(user=self.users[0],
                                 course_id=self.course_overview.id,
                                 role='staff'),
         CourseAccessRoleFactory(user=self.users[1],
                                 course_id=self.course_overview.id,
                                 role='administrator'),
     ]
     self.serializer = GeneralCourseDataSerializer(
         instance=self.course_overview)
     self.expected_fields = [
         'course_id',
         'course_name',
         'course_code',
         'org',
         'start_date',
         'end_date',
         'self_paced',
         'staff',
         'metrics',
     ]
示例#2
0
    def setup(self, db):
        self.course_overview = CourseOverviewFactory()
        self.users = [UserFactory(), UserFactory()]

        self.course_access_roles = [
            CourseAccessRoleFactory(user=self.users[0],
                                    course_id=self.course_overview.id,
                                    role='staff'),
            CourseAccessRoleFactory(user=self.users[1],
                                    course_id=self.course_overview.id,
                                    role='administrator'),
        ]
        self.serializer = CourseDetailsSerializer(
            instance=self.course_overview)

        self.expected_fields = [
            'course_id',
            'course_name',
            'course_code',
            'org',
            'start_date',
            'end_date',
            'self_paced',
            'staff',
            'average_progress',
            'learners_enrolled',
            'average_days_to_complete',
            'users_completed',
        ]
示例#3
0
    def setup(self, db):
        self.today = datetime.date(2018, 6, 1)
        self.course_overview = CourseOverviewFactory()
        if OPENEDX_RELEASE == GINKGO:
            self.course_enrollments = [
                CourseEnrollmentFactory(course_id=self.course_overview.id)
                for i in range(4)
            ]
        else:
            self.course_enrollments = [
                CourseEnrollmentFactory(course=self.course_overview)
                for i in range(4)
            ]

        if organizations_support_sites():
            self.my_site = SiteFactory(domain='my-site.test')
            self.my_site_org = OrganizationFactory(sites=[self.my_site])
            OrganizationCourseFactory(organization=self.my_site_org,
                                      course_id=str(self.course_overview.id))
            for ce in self.course_enrollments:
                UserOrganizationMappingFactory(user=ce.user,
                                               organization=self.my_site_org)

        self.course_access_roles = [
            CourseAccessRoleFactory(
                user=self.course_enrollments[i].user,
                course_id=self.course_enrollments[i].course_id,
                role=role,
            ) for i, role in enumerate(self.COURSE_ROLES)
        ]

        # create student modules for yesterday and today
        for day in [prev_day(self.today), self.today]:
            self.student_modules = [
                StudentModuleFactory(course_id=ce.course_id,
                                     student=ce.user,
                                     created=ce.created,
                                     modified=as_datetime(day))
                for ce in self.course_enrollments
            ]

        self.cert_days_to_complete = [10, 20, 30]
        self.expected_avg_cert_days_to_complete = 20
        self.generated_certificates = [
            GeneratedCertificateFactory(
                user=self.course_enrollments[i].user,
                course_id=self.course_enrollments[i].course_id,
                created_date=(self.course_enrollments[i].created +
                              datetime.timedelta(days=days)),
            ) for i, days in enumerate(self.cert_days_to_complete)
        ]
    def setup(self, db):
        self.today = datetime.date(2018, 6, 1)
        self.course_overview = CourseOverviewFactory()
        self.course_enrollments = [
            CourseEnrollmentFactory(course_id=self.course_overview.id)
            for i in range(4)
        ]

        self.course_access_roles = [
            CourseAccessRoleFactory(
                user=self.course_enrollments[i].user,
                course_id=self.course_enrollments[i].course_id,
                role=role,
            ) for i, role in enumerate(self.COURSE_ROLES)
        ]

        # create student modules for yesterday and today
        for day in [prev_day(self.today), self.today]:
            self.student_modules = [
                StudentModuleFactory(course_id=ce.course_id,
                                     student=ce.user,
                                     created=ce.created,
                                     modified=as_datetime(day))
                for ce in self.course_enrollments
            ]

        self.cert_days_to_complete = [10, 20, 30]
        self.expected_avg_cert_days_to_complete = 20
        self.generated_certificates = [
            GeneratedCertificateFactory(
                user=self.course_enrollments[i].user,
                course_id=self.course_enrollments[i].course_id,
                created_date=(self.course_enrollments[i].created +
                              datetime.timedelta(days=days)),
            ) for i, days in enumerate(self.cert_days_to_complete)
        ]