Search in sources :

Example 36 with Question

use of org.eyeseetea.malariacare.data.database.model.Question in project pictureapp by EyeSeeTea.

the class DynamicStockImageRadioButtonSingleQuestionView method onCheckedChanged.

@Override
public void onCheckedChanged(ImageRadioButtonOption imageRadioButton, boolean value) {
    if (value == false)
        return;
    for (int i = 0; i < answersContainer.getChildCount(); i++) {
        ImageRadioButtonOption optionView = (ImageRadioButtonOption) answersContainer.getChildAt(i);
        if (imageRadioButton != optionView && optionView.isChecked()) {
            optionView.setChecked(false);
            Question question = (Question) optionView.getTag();
            if (!question.isOutStockQuestion()) {
                notifyAnswerChanged(optionView, String.valueOf(-1));
            } else {
                List<Option> options = question.getAnswer().getOptions();
                for (Option option : options) {
                    if (option.getCode().equals(PreferencesState.getInstance().getContext().getString(R.string.false_option_id))) {
                        notifyAnsweOptionChange(optionView, option);
                    }
                }
            }
        }
    }
    Question question = (Question) imageRadioButton.getTag();
    if (!question.isOutStockQuestion()) {
        notifyAnswerChanged(imageRadioButton, String.valueOf(optionDose.get(imageRadioButton.getOption().getId_option())));
    } else {
        List<Option> options = question.getAnswer().getOptions();
        for (Option option : options) {
            if (option.getCode().equals(PreferencesState.getInstance().getContext().getString(R.string.true_option_id))) {
                notifyAnsweOptionChange(imageRadioButton, option);
            }
        }
    }
    //Setting a value for the stock question to get max total question correct
    View stockHideView = new View(context);
    stockHideView.setTag(Treatment.getDynamicStockQuestion());
    Question pqHideQuestion = Question.findByUID(context.getString(R.string.stockPqQuestionUID));
    Option falseOption = Option.findById(41l);
    Value valuePq = pqHideQuestion.getValueBySession();
    if (valuePq != null) {
        falseOption = valuePq.getOption();
    }
    notifyAnsweOptionChange(stockHideView, falseOption);
}
Also used : ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question) Option(org.eyeseetea.malariacare.data.database.model.Option) ImageRadioButtonOption(org.eyeseetea.malariacare.views.option.ImageRadioButtonOption) AKeyboardQuestionView(org.eyeseetea.malariacare.views.question.AKeyboardQuestionView) AOptionQuestionView(org.eyeseetea.malariacare.views.question.AOptionQuestionView) View(android.view.View) IQuestionView(org.eyeseetea.malariacare.views.question.IQuestionView)

Example 37 with Question

use of org.eyeseetea.malariacare.data.database.model.Question in project pictureapp by EyeSeeTea.

the class NumberRadioButtonMultiquestionView method changeTotalQuestions.

/**
     * Changing the total questions of the alternative pq questions depending on the answer provided
     */
private void changeTotalQuestions() {
    Question pqQuestion = Question.findByUID(context.getString(R.string.pqQuestionUID));
    Question actQuestion = Question.findByUID(context.getString(R.string.alternativePqQuestionUID));
    Question alternativePqQuestion = Question.findByUID(context.getString(R.string.alternativePqQuestionUID));
    Value actValue = null;
    Value pqValue = null;
    List<Value> values = Session.getMalariaSurvey().getValuesFromDB();
    for (Value sValue : values) {
        if (sValue.getQuestion() == null) {
            continue;
        }
        if (sValue.getQuestion().equals(actQuestion)) {
            actValue = sValue;
            break;
        }
        if (sValue.getQuestion().getUid().equals(pqQuestion.getUid())) {
            pqValue = sValue;
            break;
        }
    }
    if ((actValue == null || actValue.getOption().getName().equals(PreferencesState.getInstance().getContext().getString(R.string.yes_option_identifier))) || (pqValue == null || Float.parseFloat(pqValue.getValue()) > 0)) {
        alternativePqQuestion.setTotalQuestions(8);
    } else {
        alternativePqQuestion.setTotalQuestions(9);
    }
    alternativePqQuestion.save();
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 38 with Question

use of org.eyeseetea.malariacare.data.database.model.Question in project pictureapp by EyeSeeTea.

the class ImageOptionView method setCounter.

public void setCounter(Question question) {
    Question optionCounter = question.findCounterByOption(mOption);
    if (optionCounter == null) {
        return;
    }
    String counterValue = optionCounter.getQuestionValueBySession();
    if (counterValue == null || counterValue.isEmpty()) {
        return;
    }
    String counterTextValue = getContext().getResources().getString(R.string.option_counter);
    mOptionCounterTextView.setText(counterTextValue + counterValue);
    mOptionCounterTextView.setVisibility(View.VISIBLE);
}
Also used : Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 39 with Question

use of org.eyeseetea.malariacare.data.database.model.Question in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method saveTextValue.

public void saveTextValue(View view, String newValue, boolean moveToNextQuestion) {
    Question question = (Question) view.getTag();
    question.saveValuesText(newValue);
    if (moveToNextQuestion) {
        navigationController.isMovingToForward = true;
        finishOrNext();
    } else {
        showOrHideChildren(question);
    }
}
Also used : Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 40 with Question

use of org.eyeseetea.malariacare.data.database.model.Question in project pictureapp by EyeSeeTea.

the class DynamicTabAdapter method showOrHideChildren.

/**
     * Hide or show the childen question from a given question,  if is necessary  it reloads the
     * children questions values or refreshing the children questions answer component
     *
     * this code will be delete when DynamicTabAdapter refactoring will be completed
     *
     * @param question is the parent question
     */
private void showOrHideChildren(Question question) {
    if (!question.hasChildren()) {
        return;
    }
    for (int i = 0, j = tableLayout.getChildCount(); i < j; i++) {
        View view = tableLayout.getChildAt(i);
        if (view instanceof TableRow) {
            TableRow row = (TableRow) view;
            View targetView = row.getChildAt(0);
            if (targetView instanceof IMultiQuestionView || targetView instanceof IQuestionView) {
                Question rowQuestion = (Question) targetView.getTag();
                if (rowQuestion == null) {
                    continue;
                }
                List<Question> questionChildren = question.getChildren();
                if (questionChildren != null && questionChildren.size() > 0) {
                    for (Question childQuestion : questionChildren) {
                        //if the table row question is child of the modified question...
                        toggleChild(row, rowQuestion, childQuestion);
                    }
                }
            }
        }
    }
}
Also used : IQuestionView(org.eyeseetea.malariacare.views.question.IQuestionView) TableRow(android.widget.TableRow) IMultiQuestionView(org.eyeseetea.malariacare.views.question.IMultiQuestionView) Question(org.eyeseetea.malariacare.data.database.model.Question) AKeyboardQuestionView(org.eyeseetea.malariacare.views.question.AKeyboardQuestionView) ImageView(android.widget.ImageView) AOptionQuestionView(org.eyeseetea.malariacare.views.question.AOptionQuestionView) View(android.view.View) INavigationQuestionView(org.eyeseetea.malariacare.views.question.INavigationQuestionView) IQuestionView(org.eyeseetea.malariacare.views.question.IQuestionView) ImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView) CustomTextView(org.eyeseetea.sdk.presentation.views.CustomTextView) ListView(android.widget.ListView) IMultiQuestionView(org.eyeseetea.malariacare.views.question.IMultiQuestionView) DynamicStockImageRadioButtonSingleQuestionView(org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView) IImageQuestionView(org.eyeseetea.malariacare.views.question.IImageQuestionView) NumberRadioButtonMultiquestionView(org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView) ScrollView(android.widget.ScrollView)

Aggregations

Question (org.eyeseetea.malariacare.data.database.model.Question)58 Option (org.eyeseetea.malariacare.data.database.model.Option)15 Value (org.eyeseetea.malariacare.data.database.model.Value)15 CSVReader (com.opencsv.CSVReader)11 InputStreamReader (java.io.InputStreamReader)11 ArrayList (java.util.ArrayList)7 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)7 View (android.view.View)6 Answer (org.eyeseetea.malariacare.data.database.model.Answer)5 Match (org.eyeseetea.malariacare.data.database.model.Match)5 ImageRadioButtonOption (org.eyeseetea.malariacare.views.option.ImageRadioButtonOption)5 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)5 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)5 DynamicStockImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)5 TableRow (android.widget.TableRow)4 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)4 IImageQuestionView (org.eyeseetea.malariacare.views.question.IImageQuestionView)4 IMultiQuestionView (org.eyeseetea.malariacare.views.question.IMultiQuestionView)4 NumberRadioButtonMultiquestionView (org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView)4 ImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)4