Exemple #1
0
 def setUp(self):
     super(TestGradeUcursosExportView, self).setUp()
     self.grade_factory = CourseGradeFactory()
     with patch('student.models.cc.User.save'):
         # staff user
         self.client_instructor = Client()
         self.client_student = Client()
         self.client_anonymous = Client()
         self.user_instructor = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**',
             is_staff=True)
         role = CourseInstructorRole(self.course.id)
         role.add_users(self.user_instructor)
         self.client_instructor.login(
             username='******', password='******')
         self.student = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         self.student_2 = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         # Enroll the student in the course
         CourseEnrollmentFactory(
             user=self.student, course_id=self.course.id, mode='honor')
         CourseEnrollmentFactory(
             user=self.student_2, course_id=self.course.id, mode='honor')
         self.client_student.login(
             username='******', password='******')
Exemple #2
0
    def make_instructor(self):
        """
        create staff instructor
        """
        instructor = AdminFactory.create(password="******")
        role = CourseInstructorRole(self.course.id)
        role.add_users(instructor)

        return instructor
Exemple #3
0
    def test_get_access_roles(self):
        """
            Test get access roles in course (staff and instructor)
        """
        roles = views.get_access_roles(text_type(self.course.id))
        self.assertEqual(len(roles), 1)

        # Add instructor user to the course
        instructor = UserFactory.create(password="******")
        role = CourseInstructorRole(self.course.id)
        role.add_users(instructor)
        roles = views.get_access_roles(text_type(self.course.id))
        self.assertEqual(len(roles), 2)
Exemple #4
0
 def setUp(self):
     super(TestGradeUcursosView, self).setUp()
     self.grade_factory = CourseGradeFactory()
     with patch('student.models.cc.User.save'):
         # staff user
         self.client_instructor = Client()
         self.client_student = Client()
         self.client_anonymous = Client()
         self.user_instructor = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**',
             is_staff=True)
         role = CourseInstructorRole(self.course.id)
         role.add_users(self.user_instructor)
         self.client_instructor.login(
             username='******', password='******')
         self.student = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         self.student_2 = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         # Enroll the student in the course
         CourseEnrollmentFactory(
             user=self.student, course_id=self.course.id, mode='honor')
         CourseEnrollmentFactory(
             user=self.student_2, course_id=self.course.id, mode='honor')
         self.client_student.login(
             username='******', password='******')
         # Create and Enroll data researcher user
         self.data_researcher_user = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         CourseEnrollmentFactory(
             user=self.data_researcher_user,
             course_id=self.course.id, mode='audit')
         CourseAccessRoleFactory(
             course_id=self.course.id,
             user=self.data_researcher_user,
             role='data_researcher',
             org=self.course.id.org
         )
         self.client_data_researcher = Client()
         self.assertTrue(self.client_data_researcher.login(username='******', password='******'))
Exemple #5
0
    def test_course_deletion_with_keep_instructors(self):
        """
        Tests that deleting course with keep-instructors option do not remove instructors from course.
        """
        instructor_user = User.objects.create(username='******',
                                              email='*****@*****.**')
        self.assertIsNotNone(instructor_user)

        # Add and verify instructor role for the course
        instructor_role = CourseInstructorRole(self.course.id)
        instructor_role.add_users(instructor_user)
        self.assertTrue(instructor_role.has_user(instructor_user))

        # Verify the course we are about to delete exists in the modulestore
        self.assertIsNotNone(modulestore().get_course(self.course.id))

        with mock.patch(self.YESNO_PATCH_LOCATION, return_value=True):
            call_command('delete_course', 'TestX/TS01/2015_Q1',
                         '--keep-instructors')

        self.assertIsNone(modulestore().get_course(self.course.id))
        self.assertTrue(instructor_role.has_user(instructor_user))
Exemple #6
0
 def setUp(self):
     super(TestXblockCompletionView, self).setUp()
     self.course = CourseFactory.create(
         org='mss',
         course='999',
         display_name='2021',
         emit_signals=True)
     aux = CourseOverview.get_from_id(self.course.id)
     with self.store.bulk_operations(self.course.id, emit_signals=False):
         self.chapter = ItemFactory.create(
             parent_location=self.course.location,
             category="chapter",
         )
         self.section = ItemFactory.create(
             parent_location=self.chapter.location,
             category="sequential",
         )
         self.subsection = ItemFactory.create(
             parent_location=self.section.location,
             category="vertical",
         )
         self.items = [
             ItemFactory.create(
                 parent_location=self.subsection.location,
                 category="problem"
             )
             for __ in range(3)
         ]
     with patch('student.models.cc.User.save'):
         # staff user
         self.client_instructor = Client()
         self.client_student = Client()
         self.user_instructor = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**',
             is_staff=True)
         role = CourseInstructorRole(self.course.id)
         role.add_users(self.user_instructor)
         self.client_instructor.login(
             username='******', password='******')
         self.student = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         # Enroll the student in the course
         CourseEnrollmentFactory(
             user=self.student, course_id=self.course.id, mode='honor')
         self.client_student.login(
             username='******', password='******')
         # Create and Enroll data researcher user
         self.data_researcher_user = UserFactory(
             username='******',
             password='******',
             email='*****@*****.**')
         CourseEnrollmentFactory(
             user=self.data_researcher_user,
             course_id=self.course.id, mode='audit')
         CourseAccessRoleFactory(
             course_id=self.course.id,
             user=self.data_researcher_user,
             role='data_researcher',
             org=self.course.id.org
         )
         self.client_data_researcher = Client()
         self.assertTrue(self.client_data_researcher.login(username='******', password='******'))