def score_grouping(self, grouping: Grouping) -> float: """ Return a score for <grouping> calculated based on the answers of each student in each group in <grouping> to the questions in <self>. If there are no groups in <grouping> this score is 0.0. Otherwise, this score is determined using the following algorithm: 1. For each group in <grouping>, get the score for the members of this group calculated based on their answers to the questions in this survey. 2. Return the average of all the scores calculated in step 1. === Precondition === All students in the groups in <grouping> have an answer to all questions in this survey """ if grouping.__len__() == 0: return 0.0 list_of_score = [] for group in grouping.get_groups(): s = group.get_members() list_of_score.append(self.score_students(s)) sum = 0 for score in list_of_score: sum += score return sum / len(list_of_score)
def score_grouping(self, grouping: Grouping) -> float: """ Return a score for <grouping> calculated based on the answers of each student in each group in <grouping> to the questions in <self>. If there are no groups in <grouping> this score is 0.0. Otherwise, this score is determined using the following algorithm: 1. For each group in <grouping>, get the score for the members of this group calculated based on their answers to the questions in this survey. 2. Return the average of all the scores calculated in step 1. === Precondition === All students in the groups in <grouping> have an answer to all questions in this survey """ acc1 = 0 acc2 = 0 if grouping.__len__() == 0: return 0.0 else: for group in grouping.get_groups(): acc1 += self.score_students(group.get_members()) acc2 += 1 return acc1 / acc2