private boolean saveAnswer() { try { List<String> answers = qw.getQuestionResponses(quiz.getCurrentQuestion().getResponseOptions()); if (answers != null) { quiz.getCurrentQuestion().setUserResponses(answers); return true; } if (!quiz.getCurrentQuestion().responseExpected()) { return true; } } catch (InvalidQuizException e) { e.printStackTrace(); } return false; }
public void showQuestion() { QuizQuestion q; try { q = this.quiz.getCurrentQuestion(); } catch (InvalidQuizException e) { Toast.makeText( super.getActivity(), super.getActivity().getString(R.string.error_quiz_no_questions), Toast.LENGTH_LONG) .show(); e.printStackTrace(); return; } qText.setVisibility(View.VISIBLE); // convert in case has any html special chars qText.setText( Html.fromHtml( q.getTitle( prefs.getString( PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()))) .toString()); if (q.getProp("image") == null) { questionImage.setVisibility(View.GONE); } else { String fileUrl = course.getLocation() + q.getProp("image"); // File file = new File(fileUrl); Bitmap myBitmap = BitmapFactory.decodeFile(fileUrl); File file = new File(fileUrl); ImageView iv = (ImageView) getView().findViewById(R.id.question_image_image); iv.setImageBitmap(myBitmap); iv.setTag(file); if (q.getProp("media") == null) { OnImageClickListener oicl = new OnImageClickListener(super.getActivity(), "image/*"); iv.setOnClickListener(oicl); TextView tv = (TextView) getView().findViewById(R.id.question_image_caption); tv.setText(R.string.widget_quiz_image_caption); questionImage.setVisibility(View.VISIBLE); } else { TextView tv = (TextView) getView().findViewById(R.id.question_image_caption); tv.setText(R.string.widget_quiz_media_caption); OnMediaClickListener omcl = new OnMediaClickListener(q.getProp("media")); iv.setOnClickListener(omcl); questionImage.setVisibility(View.VISIBLE); } } if (q instanceof MultiChoice) { qw = new MultiChoiceWidget(super.getActivity(), getView(), container); } else if (q instanceof MultiSelect) { qw = new MultiSelectWidget(super.getActivity(), getView(), container); } else if (q instanceof ShortAnswer) { qw = new ShortAnswerWidget(super.getActivity(), getView(), container); } else if (q instanceof Matching) { qw = new MatchingWidget(super.getActivity(), getView(), container); } else if (q instanceof Numerical) { qw = new NumericalWidget(super.getActivity(), getView(), container); } else if (q instanceof Description) { qw = new DescriptionWidget(super.getActivity(), getView(), container); } else { return; } qw.setQuestionResponses(q.getResponseOptions(), q.getUserResponses()); this.setProgress(); this.setNav(); }