def test_clones_questions_in_the_questionnaire_with_their_order_objects(self): question3 = Question.objects.create(text='B. Number of cases tested', UID=Question.next_uid(), answer_type='Number') question4 = Question.objects.create(text='C. Number of cases positive', UID=Question.next_uid(), answer_type='Number') QuestionGroupOrder.objects.create(order=1, question_group=self.parent10, question=self.primary_question) QuestionGroupOrder.objects.create(order=2, question_group=self.parent10, question=self.question1) QuestionGroupOrder.objects.create(order=3, question_group=self.parent10, question=self.question2) QuestionGroupOrder.objects.create(order=4, question_group=self.parent120, question=question3) QuestionGroupOrder.objects.create(order=5, question_group=self.parent120, question=question4) self.assertEqual(5, Question.objects.all().count()) self.parent10.question.add(question3, question4, self.question1, self.question1) new, old = QuestionnaireClonerService(self.questionnaire).clone() self.assertEqual(5, Question.objects.all().count()) self.assertEqual(5, len(old.get_all_questions())) self.assertEqual(5, len(new.get_all_questions()))
def save(self, commit=True): question = super(QuestionForm, self).save(commit=False) question.UID = Question.next_uid() if commit: question.save() self._save_options_if_multichoice(question) return question
def test_get_next_uid_given_given_largest_uid_is_9th(self): Question.objects.create(text='question 3', UID='C00009', answer_type='Number') self.assertEqual('00010', Question.next_uid())
def test_get_next_uid_given_given_largest_uid_question(self): self.assertEqual('00004', Question.next_uid())
def setUp(self): self.questionnaire = Questionnaire.objects.create( name="JRF 2013 Core English", status=Questionnaire.FINALIZED, year=2013) self.section_1 = Section.objects.create( title= "Reported Cases of Selected Vaccine Preventable Diseases (VPDs)", order=1, questionnaire=self.questionnaire, name="Reported Cases") self.section_2 = Section.objects.create( title="Cured Cases of Measles", order=1, questionnaire=self.questionnaire, name="Cured Cases") self.sub_section1 = SubSection.objects.create( title="Reported cases for the year 2013", order=1, section=self.section_1) self.sub_section2 = SubSection.objects.create( title="Reported cases for the year", order=2, section=self.section_1) self.sub_section3 = SubSection.objects.create( title="Reported cures 2014", order=1, section=self.section_2) self.sub_section4 = SubSection.objects.create(title="Reported cures", order=2, section=self.section_2) self.primary_question = Question.objects.create( text='Disease', UID='C00003', answer_type='MultiChoice', is_primary=True) self.option = QuestionOption.objects.create( text="Measles", question=self.primary_question, UID="QO1") self.option2 = QuestionOption.objects.create( text="TB", question=self.primary_question, UID="QO2") self.question1 = Question.objects.create( text='B. Number of cases tested', UID='C00004', answer_type='Number') self.question2 = Question.objects.create( text='C. Number of cases positive', instructions=""" Include only those cases found positive for the infectious agent. """, UID='C00005', answer_type='Number') self.parent10 = QuestionGroup.objects.create( subsection=self.sub_section1, order=1) self.parent12 = QuestionGroup.objects.create( subsection=self.sub_section1, order=2) self.question3 = Question.objects.create( text='B. Number of cases tested', UID=Question.next_uid(), answer_type='Number') self.question4 = Question.objects.create( text='C. Number of cases positive', UID=Question.next_uid(), answer_type='Number') QuestionGroupOrder.objects.create(order=1, question_group=self.parent10, question=self.primary_question) QuestionGroupOrder.objects.create(order=2, question_group=self.parent10, question=self.question1) QuestionGroupOrder.objects.create(order=3, question_group=self.parent10, question=self.question2) QuestionGroupOrder.objects.create(order=4, question_group=self.parent12, question=self.question3) QuestionGroupOrder.objects.create(order=5, question_group=self.parent12, question=self.question4) self.parent10.question.add(self.question3, self.question4, self.question2, self.question1, self.primary_question) self.client = Client() self.user, self.country = self.create_user_with_no_permissions() self.assign('can_view_users', self.user) self.client.login(username=self.user.username, password='******')
def setUp(self): self.questionnaire = Questionnaire.objects.create(name="JRF 2013 Core English", status=Questionnaire.FINALIZED, year=2013) self.section_1 = Section.objects.create(title="Reported Cases of Selected Vaccine Preventable Diseases (VPDs)", order=1, questionnaire=self.questionnaire, name="Reported Cases") self.section_2 = Section.objects.create(title="Cured Cases of Measles", order=1, questionnaire=self.questionnaire, name="Cured Cases") self.sub_section1 = SubSection.objects.create(title="Reported cases for the year 2013", order=1, section=self.section_1) self.sub_section2 = SubSection.objects.create(title="Reported cases for the year", order=2, section=self.section_1) self.sub_section3 = SubSection.objects.create(title="Reported cures 2014", order=1, section=self.section_2) self.sub_section4 = SubSection.objects.create(title="Reported cures", order=2, section=self.section_2) self.primary_question = Question.objects.create(text='Disease', UID='C00003', answer_type='MultiChoice', is_primary=True) self.option = QuestionOption.objects.create(text="Measles", question=self.primary_question, UID="QO1") self.option2 = QuestionOption.objects.create(text="TB", question=self.primary_question, UID="QO2") self.question1 = Question.objects.create(text='B. Number of cases tested', UID='C00004', answer_type='Number') self.question2 = Question.objects.create(text='C. Number of cases positive', instructions=""" Include only those cases found positive for the infectious agent. """, UID='C00005', answer_type='Number') self.parent10 = QuestionGroup.objects.create(subsection=self.sub_section1, order=1) self.parent12 = QuestionGroup.objects.create(subsection=self.sub_section1, order=2) self.question3 = Question.objects.create(text='B. Number of cases tested', UID=Question.next_uid(), answer_type='Number') self.question4 = Question.objects.create(text='C. Number of cases positive', UID=Question.next_uid(), answer_type='Number') QuestionGroupOrder.objects.create(order=1, question_group=self.parent10, question=self.primary_question) QuestionGroupOrder.objects.create(order=2, question_group=self.parent10, question=self.question1) QuestionGroupOrder.objects.create(order=3, question_group=self.parent10, question=self.question2) QuestionGroupOrder.objects.create(order=4, question_group=self.parent12, question=self.question3) QuestionGroupOrder.objects.create(order=5, question_group=self.parent12, question=self.question4) self.parent10.question.add(self.question3, self.question4, self.question2, self.question1, self.primary_question) self.client = Client() self.user, self.country = self.create_user_with_no_permissions() self.assign('can_view_users', self.user) self.client.login(username=self.user.username, password='******')