Example #1
0
def get_achievements_group_by_language(learning_unit_year):
    achievement_grouped = {}
    all_achievements = learning_achievement.find_by_learning_unit_year(learning_unit_year)
    for achievement in all_achievements:
        key = 'achievements_{}'.format(achievement.language.code)
        achievement_grouped.setdefault(key, []).append(achievement)
    return achievement_grouped
Example #2
0
def get_achievements_group_by_language(learning_unit_year):
    achievement_grouped = {}
    all_achievements = learning_achievement.find_by_learning_unit_year(learning_unit_year)
    for achievement in all_achievements:
        key = 'achievements_{}'.format(achievement.language.code)
        achievement_grouped.setdefault(key, []).append(achievement)
    return achievement_grouped
Example #3
0
 def test_find_by_learning_unit_year(self):
     luy_achievement_fr = LearningAchievementFactory(code_name=A_CODE_NAME, learning_unit_year=self.luy,
                                                     language=self.language_fr)
     luy_achievement_en = LearningAchievementFactory(code_name=A_CODE_NAME, learning_unit_year=self.luy,
                                                     language=self.language_en)
     result = learning_achievement.find_by_learning_unit_year(self.luy)
     self.assertIn(luy_achievement_fr, result)
     self.assertIn(luy_achievement_en, result)
Example #4
0
 def test_find_by_learning_unit_year_order(self):
     luy_achievement_fr_1 = LearningAchievementFactory(code_name=A_CODE_NAME, learning_unit_year=self.luy,
                                                       language=self.language_fr)
     luy_achievement_en_1 = LearningAchievementFactory(code_name=A_CODE_NAME, learning_unit_year=self.luy,
                                                       language=self.language_en)
     luy_achievement_fr_2 = LearningAchievementFactory(code_name=A2_CODE_NAME, learning_unit_year=self.luy,
                                                       language=self.language_fr)
     # By default, OrderModel insert with the highest model + 1
     expected_result = [luy_achievement_en_1, luy_achievement_fr_1, luy_achievement_fr_2]
     result = list(learning_achievement.find_by_learning_unit_year(self.luy))
     self.assertListEqual(result, expected_result)