コード例 #1
0
    def save(self, *args, **kwargs):

        if not self.finalized:
            self.calculate_grade(commit=False)

        if not self.in_progress and self.is_correct or self.is_partially_correct:
            user_question_junction = self.uqj
            received_tokens = self.grade * get_token_value(
                self.question.category, self.question.difficulty)
            token_change = received_tokens - user_question_junction.tokens_received

            if token_change > 0:
                user_question_junction.tokens_received = received_tokens
                user_question_junction.save()

            Action.create_action(self.user, self.get_description(),
                                 received_tokens, Action.COMPLETE)

        super().save(*args, **kwargs)
コード例 #2
0
 def token_value(self):
     return get_token_value(self.question.category,
                            self.question.difficulty)
コード例 #3
0
 def group_token_value(total, curr):
     return get_token_value(
         curr['question__category'],
         curr['question__difficulty']) * curr['num_questions'] + total