public void loadQuiz() { if (this.quiz == null) { this.quiz = new Quiz(); this.quiz.load( quizContent, prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())); } if (this.isOnResultsPage) { this.showResults(); } else { // determine availability if (this.quiz.getAvailability() == Quiz.AVAILABILITY_ALWAYS) { this.showQuestion(); } else if (this.quiz.getAvailability() == Quiz.AVAILABILITY_SECTION) { // check to see if all previous section activities have been completed DbHelper db = DbHelper.getInstance(getActivity()); long userId = db.getUserId(SessionManager.getUsername(getActivity())); boolean completed = db.isPreviousSectionActivitiesCompleted(course, activity, userId); if (completed) { this.showQuestion(); } else { ViewGroup vg = (ViewGroup) getView().findViewById(activity.getActId()); vg.removeAllViews(); vg.addView(View.inflate(getView().getContext(), R.layout.widget_quiz_unavailable, null)); TextView tv = (TextView) getView().findViewById(R.id.quiz_unavailable); tv.setText(R.string.widget_quiz_unavailable_section); } } else if (this.quiz.getAvailability() == Quiz.AVAILABILITY_COURSE) { // check to see if all previous course activities have been completed DbHelper db = DbHelper.getInstance(getActivity()); long userId = db.getUserId(SessionManager.getUsername(getActivity())); boolean completed = db.isPreviousCourseActivitiesCompleted(course, activity, userId); if (completed) { this.showQuestion(); } else { ViewGroup vg = (ViewGroup) getView().findViewById(activity.getActId()); vg.removeAllViews(); vg.addView(View.inflate(getView().getContext(), R.layout.widget_quiz_unavailable, null)); TextView tv = (TextView) getView().findViewById(R.id.quiz_unavailable); tv.setText(R.string.widget_quiz_unavailable_course); } } } }