Search in sources :

Example 1 with Question

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

the class DynamicTabAdapter method goToLastQuestion.

private void goToLastQuestion() {
    navigationController.first();
    Value value = null;
    do {
        next();
        Question question = navigationController.getCurrentQuestion();
        value = question.getValueBySession();
        skipReminder();
    } while (value != null && !isDone(value));
    notifyDataSetChanged();
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 2 with Question

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

the class DynamicTabAdapter method finishOrNext.

/**
     * Advance to the next question with delay applied or finish survey according to question and
     * value.
     */
public void finishOrNext() {
    try {
        System.out.println(Session.getMalariaSurvey().getValuesFromDB().toString());
        System.out.println(Session.getStockSurvey().getValuesFromDB().toString());
    } catch (Exception e) {
    }
    if (Validation.hasErrors()) {
        Validation.showErrors();
        isClicked = false;
        return;
    }
    if (navigationController.getCurrentQuestion().hasCompulsoryNotAnswered()) {
        UIMessagesStrategy.getInstance().showCompulsoryUnansweredToast();
        isClicked = false;
        return;
    }
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            Question question = navigationController.getCurrentQuestion();
            Value value = question.getValueBySession();
            if (isDone(value)) {
                navigationController.isMovingToForward = false;
                if (!wasPatientTested() || !BuildConfig.reviewScreen) {
                    surveyShowDone();
                } else {
                    DashboardActivity.dashboardActivity.showReviewFragment();
                    hideKeyboard(PreferencesState.getInstance().getContext());
                    isClicked = false;
                }
                return;
            }
            next();
        }
    }, 750);
}
Also used : Value(org.eyeseetea.malariacare.data.database.model.Value) Handler(android.os.Handler) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 3 with Question

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

the class RelationsIdCsvDB method getQuestionIdRelationCsvDB.

static HashMap<Long, Question> getQuestionIdRelationCsvDB(Context context) throws IOException {
    HashMap<Long, Question> questionFK = new HashMap<>();
    List<Question> questions = Question.getAllQuestions();
    List<Long> csvIds = new ArrayList<>();
    CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.QUESTIONS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
    String[] idToAdd;
    while ((idToAdd = reader.readNext()) != null) {
        csvIds.add(Long.parseLong(idToAdd[0]));
    }
    for (int i = 0; i < questions.size() && i < csvIds.size(); i++) {
        questionFK.put(csvIds.get(i), questions.get(i));
    }
    return questionFK;
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) CSVReader(com.opencsv.CSVReader) ArrayList(java.util.ArrayList) Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 4 with Question

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

the class PopulateRow method populateQuestion.

static Question populateQuestion(String[] line, HashMap<Long, Header> headerFK, HashMap<Long, Answer> answerFK, @Nullable Question question) {
    if (question == null) {
        question = new Question();
    }
    question.setCode(line[1]);
    question.setDe_name(line[2]);
    question.setHelp_text(line[3]);
    question.setForm_name(line[4]);
    question.setUid(line[5]);
    question.setOrder_pos(Integer.valueOf(line[6]));
    question.setNumerator_w(Float.valueOf(line[7]));
    question.setDenominator_w(Float.valueOf(line[8]));
    question.setHeader(headerFK.get(Long.valueOf(line[9])));
    if (!line[10].equals("")) {
        question.setAnswer(answerFK.get(Long.valueOf(line[10])));
    }
    question.setOutput(Integer.valueOf(line[12]));
    question.setTotalQuestions(Integer.valueOf(line[13]));
    question.setVisible(Integer.valueOf(line[14]));
    if (line.length > 15 && !line[15].equals("")) {
        question.setPath((line[15]));
    }
    if (line.length > 16 && !line[16].equals("")) {
        question.setCompulsory(Integer.valueOf(line[16]));
    } else {
        question.setCompulsory(Question.QUESTION_NOT_COMPULSORY);
    }
    return question;
}
Also used : Question(org.eyeseetea.malariacare.data.database.model.Question)

Example 5 with Question

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

the class ImageRadioButtonOption 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);
    mCounter.setText(counterTextValue + counterValue);
    mCounter.setVisibility(View.VISIBLE);
}
Also used : Question(org.eyeseetea.malariacare.data.database.model.Question)

Aggregations

Question (org.eyeseetea.malariacare.data.database.model.Question)65 Option (org.eyeseetea.malariacare.data.database.model.Option)17 Value (org.eyeseetea.malariacare.data.database.model.Value)16 CSVReader (com.opencsv.CSVReader)12 InputStreamReader (java.io.InputStreamReader)12 ArrayList (java.util.ArrayList)9 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)7 View (android.view.View)5 Answer (org.eyeseetea.malariacare.data.database.model.Answer)5 Match (org.eyeseetea.malariacare.data.database.model.Match)5 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)4 DataValueExtended (org.eyeseetea.malariacare.data.sync.importer.models.DataValueExtended)4 ImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)4 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 ScrollView (android.widget.ScrollView)3 TableRow (android.widget.TableRow)3 Drug (org.eyeseetea.malariacare.data.database.model.Drug)3 OptionAttribute (org.eyeseetea.malariacare.data.database.model.OptionAttribute)3 QuestionRelation (org.eyeseetea.malariacare.data.database.model.QuestionRelation)3