当前位置: 首页>>代码示例>>Java>>正文


Java QuestionDef.getTextID方法代码示例

本文整理汇总了Java中org.javarosa.core.model.QuestionDef.getTextID方法的典型用法代码示例。如果您正苦于以下问题:Java QuestionDef.getTextID方法的具体用法?Java QuestionDef.getTextID怎么用?Java QuestionDef.getTextID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.javarosa.core.model.QuestionDef的用法示例。


在下文中一共展示了QuestionDef.getTextID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attachChoice

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice (QuestionDef q) {
	if (q.getDynamicChoices() != null) //can't attach dynamic choices because they aren't guaranteed to exist yet
		return;

	SelectChoice choice = null;

	if (index != -1 && index < q.getNumChoices()) {
		choice = q.getChoice(index);
	} else if (xmlValue != null && xmlValue.length() > 0) {
		choice = q.getChoiceForValue(xmlValue);
	}

	if (choice != null) {
		attachChoice(choice);
	} else {
		throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
				+ ".  Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:Selection.java

示例2: testAnswerConstraint

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void testAnswerConstraint(){
	IntegerData ans = new IntegerData(13);
	FormEntryController fec = fpi.getFormEntryController();
	fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());
	
	do{
		
		QuestionDef q = fpi.getCurrentQuestion();
		if(q==null || q.getTextID() == null || q.getTextID() == "")continue;
		if(q.getTextID().equals("constraint-test")){
			int response = fec.answerQuestion(ans, true);
			if(response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED){
				fail("Answer Constraint test failed.");
			}else if(response == FormEntryController.ANSWER_OK){
				break;
			}else{
				fail("Bad response from fec.answerQuestion()");
			}
		}
	}while(fec.stepToNextEvent()!=FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:FormDefTest.java

示例3: attachChoice

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice(QuestionDef q) {
    if (q.getDynamicChoices() != null) //can't attach dynamic choices because they aren't guaranteed to exist yet
        return;

    SelectChoice choice = null;

    if (index != -1 && index < q.getNumChoices()) {
        choice = q.getChoice(index);
    } else if (xmlValue != null && xmlValue.length() > 0) {
        choice = q.getChoiceForValue(xmlValue);
    }

    if (choice != null) {
        attachChoice(choice);
    } else {
        throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
                + ".  Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:Selection.java

示例4: testAnswerQuestion

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
 * Tests constraint passing and failing when using FormEntryController to
 * answer form questions.
 *
 * TODO: create test cases that test complex questions, that is, those with
 * copy tags inside of them that need to processed.
 */
@Test
public void testAnswerQuestion() {
    IntegerData ans;
    FormEntryController fec = fpi.getFormEntryController();
    fec.jumpToIndex(FormIndex.createBeginningOfFormIndex());

    do {
        // get current question
        QuestionDef q = fpi.getCurrentQuestion();

        if (q == null || q.getTextID() == null || "".equals(q.getTextID())) {
            continue;
        }

        if (q.getTextID().equals("constraint-max-label")){
            assertConstraintMaxMin(new Integer(30), null);
        } else if (q.getTextID().equals("constraint-min-label")){
            assertConstraintMaxMin(null, new Integer(10));
        } else if (q.getTextID().equals("constraint-max-or-min-label")){
            assertUnpivotable();
        } else if (q.getTextID().equals("constraint-max-and-min-label")){
            assertUnpivotable();
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:ConstraintTest.java

示例5: testAnswerConstraint

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testAnswerConstraint() {
    FormParseInit fpi = new FormParseInit("/ImageSelectTester.xhtml");
    FormEntryController fec = initFormEntry(fpi);

    do {
        QuestionDef q = fpi.getCurrentQuestion();
        if (q == null || q.getTextID() == null || "".equals(q.getTextID())) {
            continue;
        }
        if (q.getTextID().equals("constraint-test")) {
            int response = fec.answerQuestion(new IntegerData(13));
            if (response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
                fail("Answer Constraint test failed.");
            } else if (response == FormEntryController.ANSWER_OK) {
                break;
            } else {
                fail("Bad response from fec.answerQuestion()");
            }
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:FormDefTest.java

示例6: testSimilarBindConditionsAreDistinguished

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
 * Testing that two identical bind conditions, modulo the operator (=, <),
 * are treated as distict entities.  Regression test for an issue where
 * `equals` method for binary conditions wasn't taking condition type
 * (arith, bool, equality) into account.
 */
@Test
public void testSimilarBindConditionsAreDistinguished() throws Exception {
    FormParseInit fpi =
            new FormParseInit("/xform_tests/test_display_conditions_regression.xml");
    FormEntryController fec =  initFormEntry(fpi);

    boolean visibleLabelWasPresent = false;
    do {
        QuestionDef q = fpi.getCurrentQuestion();
        if (q == null || q.getTextID() == null || "".equals(q.getTextID())) {
            continue;
        }
        if (q.getTextID().equals("visible-label")) {
            visibleLabelWasPresent = true;
        }
        if (q.getTextID().equals("invisible-label")) {
            fail("Label whose display condition should be false was showing");
        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);

    if (!visibleLabelWasPresent) {
        fail("Label whose display condition should be true was not showing");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:31,代码来源:FormDefTest.java

示例7: attachChoice

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public void attachChoice(QuestionDef q) {
    if (q.getDynamicChoices() != null) {
        // can't attach dynamic choices because they aren't guaranteed to exist yet
        return;
    }

    SelectChoice choice = null;

    if (index != -1 && index < q.getNumChoices()) {
        choice = q.getChoice(index);
    } else if (xmlValue != null && xmlValue.length() > 0) {
        choice = q.getChoiceForValue(xmlValue);
    }

    if (choice != null) {
        attachChoice(choice);
    } else {
        throw new XPathTypeMismatchException("value " + xmlValue + " could not be loaded into question " + q.getTextID()
                + ".  Check to see if value " + xmlValue + " is a valid option for question " + q.getTextID() + ".");
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:22,代码来源:Selection.java

示例8: testAnswerConstraintOldText

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
@Test
public void testAnswerConstraintOldText() {
    IntegerData ans = new IntegerData(7);
    FormParseInit fpi = new FormParseInit("/ImageSelectTester.xhtml");
    FormEntryController fec = initFormEntry(fpi);
    fec.setLanguage("English");

    do {
        QuestionDef q = fpi.getCurrentQuestion();
        if (q == null || q.getTextID() == null || "".equals(q.getTextID())) {
            continue;
        }
        if (q.getTextID().equals("constraint-test")) {
            int response = fec.answerQuestion(ans);
            if (response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
                if (!"Old Constraint".equals(fec.getModel().getQuestionPrompt().getConstraintText())) {
                    fail("Old constraint message not found, instead got: "
                            + fec.getModel().getQuestionPrompt().getConstraintText());
                }
            } else if (response == FormEntryController.ANSWER_OK) {
                fail("Should have constrained");
                break;
            }
        }
        if (q.getTextID().equals("constraint-test-2")) {

            int response3 = fec.answerQuestion(new IntegerData(13));
            if (response3 == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
                if (!"New Alert".equals(fec.getModel().getQuestionPrompt().getConstraintText())) {
                    fail("New constraint message not found, instead got: "
                            + fec.getModel().getQuestionPrompt().getConstraintText());
                }
            } else if (response3 == FormEntryController.ANSWER_OK) {
                fail("Should have constrained (2)");
                break;
            }

        }
        if (q.getTextID().equals("constraint-test-3")) {

            int response4 = fec.answerQuestion(new IntegerData(13));
            if (response4 == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
                if (!"The best QB of all time: Tom Brady".equals(fec.getModel().getQuestionPrompt().getConstraintText())) {
                    fail("New constraint message not found, instead got: "
                            + fec.getModel().getQuestionPrompt().getConstraintText());
                }
            } else if (response4 == FormEntryController.ANSWER_OK) {
                fail("Should have constrained (2)");
                break;
            }

        }
    } while (fec.stepToNextEvent() != FormEntryController.EVENT_END_OF_FORM);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:55,代码来源:FormDefTest.java


注:本文中的org.javarosa.core.model.QuestionDef.getTextID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。