예제 #1
0
 def update_score(self):
     fills = UserFillQuiz.objects.raw(
         'SELECT fill_id, answer::JSON, score::JSON FROM "PsyMap_userfillquiz" WHERE quiz_id=%s', (self.quiz_id,)
     )
     cursor = connection.cursor()
     quiz = QService.get_questionnaire(self.xml_path, quiz_id=self.quiz_id)
     for f in fills:
         score = quiz.score(f.answer)
         score = dict_to_hstore(dict(score))  # convert json string to hstore string
         cursor.execute('UPDATE "PsyMap_userfillquiz" SET score=%s::HSTORE WHERE fill_id=%s', (score, f.fill_id))
예제 #2
0
 def get_questionnaire(self):
     try:
         return QService.get_questionnaire(self.xml_path, quiz_id=self.quiz_id)
     finally:
         QService.set_norm(self.quiz_id, self.get_norm())