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


Java QuestionDef.isComplex方法代码示例

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


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

示例1: answerQuestion

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
  * Attempts to save the answer at the specified FormIndex into the
  * datamodel.
  *
  * @param index
  * @param data
  * @return OK if save was successful, error if a constraint was violated.
  */
 public int answerQuestion(FormIndex index, IAnswerData data, boolean midSurvey) {
 	QuestionDef q = model.getQuestionPrompt(index).getQuestion();
     if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
         throw new RuntimeException("Non-Question object at the form index.");
     }
     TreeElement element = model.getTreeElement(index);
     boolean complexQuestion = q.isComplex();

     boolean hasConstraints = false;
     if (element.isRequired() && data == null) {
         return ANSWER_REQUIRED_BUT_EMPTY;
     } else if (!complexQuestion && !model.getForm().evaluateConstraint(index.getReference(), data)) {
         return ANSWER_CONSTRAINT_VIOLATED;
     } else if (!complexQuestion) {
         commitAnswer(element, index, data, midSurvey);
         return ANSWER_OK;
     } else if (complexQuestion && hasConstraints) {
         //TODO: itemsets: don't currently evaluate constraints for itemset/copy -- haven't figured out how handle it yet
         throw new RuntimeException("Itemsets do not currently evaluate constraints. Your constraint will not work, please remove it before proceeding.");
     } else {
     	try {
	model.getForm().copyItemsetAnswer(q, element, data, midSurvey);
} catch (InvalidReferenceException ire) {
	ire.printStackTrace();
	throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
}
     	return ANSWER_OK;
     }
 }
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:FormEntryController.java

示例2: checkQuestionConstraint

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
public int checkQuestionConstraint(IAnswerData data) {
    FormIndex index = model.getFormIndex();
    QuestionDef q = model.getQuestionPrompt(index).getQuestion();

    if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
        throw new RuntimeException("Non-Question object at the form index.");
    }

    TreeElement element = model.getTreeElement(index);

    if (element.isRequired() && data == null) {
        return ANSWER_REQUIRED_BUT_EMPTY;
    }

    // A question is complex when it has a copy tag that needs to be
    // evaluated by copying in the correct xml subtree.  XXX: The code to
    // answer complex questions is incomplete, but luckily this feature is
    // rarely used.
    boolean complexQuestion = q.isComplex();

    if (complexQuestion) {
        // TODO PLM: unsure how to check constraints of 'complex' questions 
        return ANSWER_OK;
    } else {
        if (!model.getForm().evaluateConstraint(index.getReference(), data)) {
            // constraint checking failed
            return ANSWER_CONSTRAINT_VIOLATED;
        }
        return ANSWER_OK;
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:32,代码来源:FormEntryController.java

示例3: answerQuestion

import org.javarosa.core.model.QuestionDef; //导入方法依赖的package包/类
/**
 * Attempts to save the answer at the specified FormIndex into the
 * datamodel.
 *
 * @return OK if save was successful, error if a constraint was violated.
 */
public int answerQuestion(FormIndex index, IAnswerData data) {
    QuestionDef q = model.getQuestionPrompt(index).getQuestion();

    if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
        throw new RuntimeException("Non-Question object at the form index.");
    }

    TreeElement element = model.getTreeElement(index);

    // A question is complex when it has a copy tag that needs to be
    // evaluated by copying in the correct xml subtree.  XXX: The code to
    // answer complex questions is incomplete, but luckily this feature is
    // rarely used.
    boolean complexQuestion = q.isComplex();

    boolean hasConstraints = false;

    if (element.isRequired() && data == null) {
        return ANSWER_REQUIRED_BUT_EMPTY;
    }

    if (complexQuestion) {
        if (hasConstraints) {
            //TODO: itemsets: don't currently evaluate constraints for
            //itemset/copy -- haven't figured out how handle it yet
            throw new RuntimeException("Itemsets do not currently evaluate constraints. Your constraint will not work, please remove it before proceeding.");
        } else {
            try {
                model.getForm().copyItemsetAnswer(q, element, data);
            } catch (InvalidReferenceException ire) {
                ire.printStackTrace();
                throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
            }
            q.getActionController().triggerActionsFromEvent(Action.EVENT_QUESTION_VALUE_CHANGED, model.getForm());
            return ANSWER_OK;
        }
    } else {
        if (!model.getForm().evaluateConstraint(index.getReference(), data)) {
            // constraint checking failed
            return ANSWER_CONSTRAINT_VIOLATED;
        }
        commitAnswer(element, index, data);
        q.getActionController().triggerActionsFromEvent(Action.EVENT_QUESTION_VALUE_CHANGED, model.getForm());
        return ANSWER_OK;
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:53,代码来源:FormEntryController.java


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