def survey_fill(request): ans = SurveyAnswer() orig_survey = Survey.objects.get(id=request.POST['survey_id']) ans.orig_survey = orig_survey ans.save() questions = orig_survey.question_set.all() for question in questions: qc = request.POST['question'+str(question.id)] qa = QuestionAnswer() qa.answer = Choice.objects.get(id=int(qc)) qa.survey_answer = ans qa.save() ans.save() return render(request, 'survey-complete.html', {})
def t075_QuestionAnswer(self): """QuestionAnswer""" L.i("QuestionAnswerTestData load start") L.i(" building the questionAnswer list") c = 0 for el in TestData.listQuestionAnswer: qa = QuestionAnswer(body=el['body'], rating=el['rating'], dateTime=self.parseDateTime(el['dateTime']), relatedTo=None, who=random.choice(self.users)) self.questionAnswers.append(qa) qa.save() L.i(" Dataloaded #{0}".format(c)) c += 1 L.i(" questionAnswer list built") L.i(" cross linking") for i in xrange(len(self.questionAnswers)): self.questionAnswers[i].relatedTo = \ random.choice( self.questionAnswers[0:i] + self.questionAnswers[(i+1):]) L.i(" cross linking ended") L.i("QuestionAnswerTestData load ended") return True
def t075_QuestionAnswer(self): """QuestionAnswer""" L.i("QuestionAnswerTestData load start") L.i(" building the questionAnswer list") c = 0 for el in TestData.listQuestionAnswer: qa = QuestionAnswer( body = el['body'], rating = el['rating'], dateTime = self.parseDateTime(el['dateTime']), relatedTo = None, who = random.choice(self.users) ) self.questionAnswers.append(qa) qa.save() L.i(" Dataloaded #{0}".format(c)); c+=1; L.i(" questionAnswer list built") L.i(" cross linking") for i in xrange(len(self.questionAnswers)): self.questionAnswers[i].relatedTo = \ random.choice( self.questionAnswers[0:i] + self.questionAnswers[(i+1):]) L.i(" cross linking ended") L.i("QuestionAnswerTestData load ended") return True