예제 #1
0
  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);
  }
예제 #2
0
 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);
 }
예제 #3
0
 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();
 }