Esempio n. 1
0
 def _create_subsection_grade(self, user_id, course_key, usage_key):
     """
     Given a user_id, course_key, and subsection usage_key,
     creates a new ``PersistentSubsectionGrade``.
     """
     course = get_course(course_key, depth=None)
     subsection = course.get_child(usage_key)
     if not subsection:
         raise Exception('Subsection with given usage_key does not exist.')
     user = USER_MODEL.objects.get(id=user_id)
     course_data = CourseData(user, course=course)
     subsection_grade = CreateSubsectionGrade(subsection, course_data.structure, {}, {})
     return subsection_grade.update_or_create_model(user, force_update_subsections=True)
Esempio n. 2
0
def _create_subsection_grade(user_id, course_key, usage_key):
    """
    Given a user_id, course_key, and subsection usage_key,
    creates a new ``PersistentSubsectionGrade``.
    """
    from lms.djangoapps.courseware.courses import get_course
    from django.contrib.auth import get_user_model
    course = get_course(course_key, depth=None)
    subsection = course.get_child(usage_key)
    if not subsection:
        raise Exception('Subsection with given usage_key does not exist.')
    user = get_user_model().objects.get(id=user_id)
    subsection_grade = CreateSubsectionGrade(subsection, course_data.CourseData(user, course=course).structure, {}, {})
    return subsection_grade.update_or_create_model(user, force_update_subsections=True)
Esempio n. 3
0
 def _create_subsection_grade(self, user_id, course_key, usage_key):
     """
     Given a user_id, course_key, and subsection usage_key,
     creates a new ``PersistentSubsectionGrade``.
     """
     course = get_course(course_key, depth=None)
     subsection = course.get_child(usage_key)
     if not subsection:
         raise Exception('Subsection with given usage_key does not exist.')
     user = USER_MODEL.objects.get(id=user_id)
     course_data = CourseData(user, course=course)
     subsection_grade = CreateSubsectionGrade(subsection,
                                              course_data.structure, {}, {})
     return subsection_grade.update_or_create_model(
         user, force_update_subsections=True)
Esempio n. 4
0
 def setUp(self):
     super(TestGradesBulkAPIView, self).setUp()
     self.client.login(username=self.global_staff.username, password=self.password)
     self.course_structure = get_course_blocks(self.global_staff, self.course.location)
     self.subsection_grade_factory = SubsectionGradeFactory(self.global_staff, self.course, self.course_structure)
     
     
     with mock_get_score(1, 2):
         self.created_grade = CreateSubsectionGrade(
                 self.section,
                 self.course_structure,
                 self.subsection_grade_factory._submissions_scores,
                 self.subsection_grade_factory._csm_scores,
             )
Esempio n. 5
0
 def _create_subsection_grade(self, user, course, subsection):
     course_data = CourseData(user, course=course)
     subsection_grade = CreateSubsectionGrade(subsection, course_data.structure, {}, {})
     return subsection_grade.update_or_create_model(user, force_update_subsections=True)
Esempio n. 6
0
 def _create_subsection_grade(self, user, course, subsection):
     course_data = CourseData(user, course=course)
     subsection_grade = CreateSubsectionGrade(subsection,
                                              course_data.structure, {}, {})
     return subsection_grade.update_or_create_model(
         user, force_update_subsections=True)