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();
}
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);
}
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;
}
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;
}
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);
}
Aggregations