public void resetQuestion() {
   // set saved answer to choices
   List<Choice> answerChoices = new ArrayList<Choice>();
   for (Choice choice : question.getChoices()) {
     if (answers.indexOf(choice.getLabel()) != -1) {
       choice.setSelect(true);
     } else {
       choice.setSelect(false);
     }
     answerChoices.add(choice);
   }
   question.setChoices(answerChoices);
 }
 public void saveAnswer() {
   DatabaseUtil dbUtil = new DatabaseUtil(mContext);
   dbUtil.open();
   List<Choice> choices = question.getChoices();
   answers.setLength(0);
   for (Choice choice : choices) {
     if (choice.isSelect()) {
       answers.append(choice.getLabel());
     }
   }
   // save answers
   if (answers.length() == 0) {
     dbUtil.deleteAnswer(cId, qId);
   } else {
     dbUtil.saveAnswer(dbUtil, cId, qId, question.getQuestionid(), answers.toString());
   }
   dbUtil.close();
 }
 public void loadAnswer() {
   DatabaseUtil dbUtil = new DatabaseUtil(mContext);
   dbUtil.open();
   Cursor cursor = dbUtil.fetchAnswer(cId, qId);
   answers.setLength(0);
   while (cursor.moveToNext()) {
     answers.append(cursor.getString(3));
   }
   Log.i(LOG_TAG, "answers:" + answers.toString());
   // load pending questions
   pendQuestions.clear();
   for (Catalog catalog : exam.getCatalogs()) {
     List<Question> questions = catalog.getQuestions();
     for (Question question : questions) {
       Cursor cursor2 = dbUtil.fetchAnswer(catalog.getIndex(), question.getIndex());
       if (cursor2.moveToNext()) {
         continue;
       }
       cursor2.close();
       pendQuestions.add(question);
     }
   }
   dbUtil.close();
 }
  public void changeComponents() {
    if (exam.getCatalogs().size() > 1) {
      Catalog catalog = ExamParse.getCatalog(exam, cId);
      catalogsTV.setText(
          String.valueOf(cId)
              + ". "
              + catalog.getName()
              + "(Q"
              + String.valueOf(1)
              + " - "
              + "Q"
              + String.valueOf(ExamParse.getMaxQuestion(exam, cId))
              + ")");
    } else {
      // set catalogsTV invisible
    }

    // change question content
    String questionHint =
        "Q"
            + String.valueOf(question.getIndex())
            + " ("
            + mContext.getResources().getString(R.string.msg_question_score)
            + ":"
            + String.valueOf(question.getScore())
            + ")\n";
    questionTV.setText(questionHint + question.getContent());

    // change choices
    if (choiceAdapter == null) {
      choiceAdapter =
          new ChoiceAdapter(
              mContext, question.getChoices(), question.getType(), answers.toString());
      listView.setAdapter(choiceAdapter);
    } else {
      choiceAdapter.refresh(question.getChoices());
    }

    Drawable firstImg = getResources().getDrawable(R.drawable.ic_first_question_64);
    Drawable backImg = getResources().getDrawable(R.drawable.ic_back_64);
    backArrow.setImageDrawable(qId == 1 ? firstImg : backImg);

    String pendNumString =
        mContext.getResources().getString(R.string.label_tv_waiting)
            + "("
            + Integer.valueOf(pendQuestions.size())
            + ")";
    pendQueNumber.setText(pendNumString);

    Drawable lastImg = getResources().getDrawable(R.drawable.ic_last_question_64);
    Drawable nextImg = getResources().getDrawable(R.drawable.ic_next_64);
    nextArrow.setImageDrawable(qId == ExamParse.getMaxQuestion(exam, cId) ? lastImg : nextImg);
  }