Ejemplo n.º 1
0
 def __init__(self, question_id):
     schedule_list = []
     user_list = []
     scores = []
     
     answers = AnswerModel.get_question_answers(question_id)
     for a in answers:
         uid = a.userID
         scores.append((UserModel.getTrust(uid), a))
         user_list.append(a.userID)
         
     scores.sort(key=lambda tup: tup[0])
     
     # TODO: possibly change fixed percentage to variable
     # IMPORTANT: users that did not give an answer should be able to rate,
     # not sure if that will happen right now
     #
     # initial scheduler
     shift_count = len(scores) - max(1, int(len(scores) * 0.2))
     user_list = user_list[shift_count:] + user_list[0:shift_count]
     
     for x in xrange(0, len(scores)):
         a_id = scores[x][1].id
         u_id = user_list[x]
         schedule_list.append((a_id, u_id))
     
     Schedule.add_list(schedule_list)
         
 def calc_new_rating(self):
     K = UserModel.getTrust(self.user_id) / 20.0
     new_rating = AnswerModel.new_rating(self.best_answer_id, self.other_answer_id, K)
     AnswerModel.set_ranking(self.best_answer_id, new_rating[0])
     AnswerModel.set_ranking(self.other_answer_id, new_rating[1])
Ejemplo n.º 3
0
 def updateTrust(self):
     trust = UserModel.getTrust(self.user_id) + ((float(self.rating) * 25.0) - 75.0)
     UserModel.setTrust(self.user_id, trust)