Calculate a participants bonus.

def bonus(self, participant=None):
        """Calculate a participants bonus."""
        if participant is None:
            raise(ValueError("You must specify the participant to \
                              calculate the bonus."))
        participant_id = participant.uniqueid
        key = participant_id[0:5]

        nodes = Node.query.join(Node.network)\
                    .filter(and_(Node.participant_id == participant_id,
                                 Network.role == "experiment"))\
                    .all()

        if len(nodes) == 0:
            self.log("Participant has 0 nodes - cannot calculate bonus!", key)
            return 0
        self.log("calculating bonus...", key)
        score = [node.score for node in nodes]
        average = float(sum(score)) / float(len(score))
        bonus = round(max(0.0, ((average - 0.5) * 2)) * self.bonus_payment, 2)
        self.log("bonus calculated, returning {}".format(bonus), key)
        return bonus