Exemplo n.º 1
0
 def setUp(self):
     super(GradesModelTestCase, self).setUp()
     self.course_key = CourseLocator(org='some_org',
                                     course='some_course',
                                     run='some_run')
     self.locator_a = BlockUsageLocator(course_key=self.course_key,
                                        block_type='problem',
                                        block_id='block_id_a')
     self.locator_b = BlockUsageLocator(course_key=self.course_key,
                                        block_type='problem',
                                        block_id='block_id_b')
     self.record_a = BlockRecord(self.locator_a, 1, 10)
     self.record_b = BlockRecord(self.locator_b, 1, 10)
Exemplo n.º 2
0
 def test_with_persisted_block(self, persisted_block_r_possible,
                               block_r_possible, weight):
     block = self._create_block(block_r_possible)
     block_record = BlockRecord(block.location, 0,
                                persisted_block_r_possible, False)
     self._verify_score_result(block_record, block, weight,
                               persisted_block_r_possible)
Exemplo n.º 3
0
 def test_with_persisted_block(self, persisted_block_value, block_value):
     block = self._create_block(block_value)
     block_record = BlockRecord(block.location, 0, 0, persisted_block_value)
     self.assertEquals(
         scores._get_graded_from_block(block_record, block),
         block_record.graded,  # persisted value takes precedence
     )
Exemplo n.º 4
0
 def _get_visible_blocks(self):
     """
     Returns the list of visible blocks.
     """
     return [
         BlockRecord(location, score.weight, score.raw_possible,
                     score.graded)
         for location, score in self.problem_scores.iteritems()
     ]
Exemplo n.º 5
0
 def setUp(self):
     super(GradesModelTestCase, self).setUp()
     self.course_key = CourseLocator(org='some_org',
                                     course='some_course',
                                     run='some_run')
     self.locator_a = BlockUsageLocator(course_key=self.course_key,
                                        block_type='problem',
                                        block_id='block_id_a')
     self.locator_b = BlockUsageLocator(course_key=self.course_key,
                                        block_type='problem',
                                        block_id='block_id_b')
     self.record_a = BlockRecord(locator=self.locator_a,
                                 weight=1,
                                 raw_possible=10,
                                 graded=False)
     self.record_b = BlockRecord(locator=self.locator_b,
                                 weight=1,
                                 raw_possible=10,
                                 graded=True)
Exemplo n.º 6
0
 def _get_visible_blocks(self):
     """
     Returns the list of visible blocks.
     """
     return [
         BlockRecord(location, weight, score.possible)
         for location, (
             score,
             weight) in self.locations_to_weighted_scores.iteritems()
     ]
Exemplo n.º 7
0
 def test_serialization(self, weight, max_score, block_key):
     """
     Tests serialization of a BlockRecord using the _asdict() method.
     """
     record = BlockRecord(block_key, weight, max_score)
     expected = OrderedDict([
         ("locator", block_key),
         ("weight", weight),
         ("max_score", max_score),
     ])
     self.assertEqual(expected, record._asdict())
Exemplo n.º 8
0
 def test_serialization(self, weight, raw_possible, block_key, graded):
     """
     Tests serialization of a BlockRecord using the _asdict() method.
     """
     record = BlockRecord(block_key, weight, raw_possible, graded)
     expected = OrderedDict([
         ("locator", block_key),
         ("weight", weight),
         ("raw_possible", raw_possible),
         ("graded", graded),
     ])
     self.assertEqual(expected, record._asdict())
Exemplo n.º 9
0
 def test_creation(self):
     """
     Tests creation of a BlockRecord.
     """
     weight = 1
     max_score = 10
     record = BlockRecord(
         self.locator_a,
         weight,
         max_score,
     )
     self.assertEqual(record.locator, self.locator_a)
Exemplo n.º 10
0
 def test_creation(self):
     """
     Tests creation of a BlockRecord.
     """
     weight = 1
     raw_possible = 10
     record = BlockRecord(
         self.locator_a,
         weight,
         raw_possible,
         graded=False,
     )
     self.assertEqual(record.locator, self.locator_a)
Exemplo n.º 11
0
 def _create_persisted_block(self, persisted_block_value):
     """
     Creates and returns a minimal BlockRecord object with the give values.
     """
     if persisted_block_value.exists:
         return BlockRecord(
             self.location,
             persisted_block_value.weight,
             persisted_block_value.raw_possible,
             persisted_block_value.graded,
         )
     else:
         return None
Exemplo n.º 12
0
    def save(self, student, subsection, course):
        """
        Persist the SubsectionGrade.
        """
        visible_blocks = [
            BlockRecord(location, weight, score.possible)
            for location, (score, weight) in self.locations_to_weighted_scores.iteritems()
        ]

        PersistentSubsectionGrade.save_grade(
            user_id=student.id,
            usage_key=self.location,
            course_version=getattr(course, 'course_version', None),
            subtree_edited_timestamp=subsection.subtree_edited_on,
            earned_all=self.all_total.earned,
            possible_all=self.all_total.possible,
            earned_graded=self.graded_total.earned,
            possible_graded=self.graded_total.possible,
            visible_blocks=visible_blocks,
        )
Exemplo n.º 13
0
 def test_with_persisted_block(self, persisted_block_value, block_value):
     block = self._create_block(block_value)
     block_record = BlockRecord(block.location, 0, 0, persisted_block_value)
     assert scores._get_graded_from_block(block_record,
                                          block) == block_record.graded