use of com.instructure.candroid.interfaces.QuizPostMultipleDropdown in project instructure-android by instructure.
the class QuizSubmissionQuestionListRecyclerAdapter method addMultipleDropdown.
private void addMultipleDropdown(final QuizSubmissionQuestion baseItem, QuizMultipleDropdownViewHolder holder, int position, int courseColor) {
addAnsweredQuestion(baseItem);
QuizMultipleDropdownBinder.bind(holder, baseItem, courseColor, position, shouldLetAnswer, getContext(), embeddedWebViewCallback, webViewClientCallback, new QuizPostMultipleDropdown() {
@Override
public void postMultipleDropdown(final long questionId, HashMap<String, Long> answers) {
QuizManager.postQuizQuestionMultipleDropdown(quizSubmission, questionId, answers, true, new StatusCallback<QuizSubmissionQuestionResponse>() {
@Override
public void onResponse(@NonNull Response<QuizSubmissionQuestionResponse> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
if (type == ApiType.CACHE)
return;
QuizSubmissionQuestionResponse quizSubmissionQuestionResponse = response.body();
if (quizSubmissionQuestionResponse.getQuizSubmissionQuestions() != null) {
for (QuizSubmissionQuestion question : quizSubmissionQuestionResponse.getQuizSubmissionQuestions()) {
if (baseItem.getId() == question.getId()) {
baseItem.setAnswer(question.getAnswer());
}
}
// make sure each answer has a match
int numAnswers = 0;
// API returns a LinkedTreeMap
for (String map : ((LinkedTreeMap<String, String>) baseItem.getAnswer()).values()) {
if (map != null && !map.equals("null")) {
numAnswers++;
}
}
if (numAnswers == ((LinkedTreeMap<String, String>) baseItem.getAnswer()).size()) {
addAnsweredQuestion(questionId);
} else {
removeAnsweredQuestion(questionId);
}
}
}
});
}
}, flagStateCallback);
}
Aggregations