コード例 #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 loadCatalogInfos(DatabaseUtil dbUtil) {
   // load catalog list menu
   Cursor catalogCursor = null;
   int answeredQuetions = 0;
   // set catalog menus
   for (Catalog catalog : exam.getCatalogs()) {
     catalogCursor = dbUtil.fetchAnswer(catalog.getIndex());
     answeredQuetions = 0;
     while (catalogCursor.moveToNext()) {
       Integer qid = catalogCursor.getInt(1);
       String answers = catalogCursor.getString(3);
       if (qid != null && answers != null && answers.length() > 0) {
         answeredQuetions++;
       }
     }
     List<Question> qList = catalog.getQuestions();
     Integer totalQuestions = qList.size();
     catalogInfos.add(
         new CatalogInfo(
             catalog.getIndex(), catalog.getDesc(), 1, totalQuestions, answeredQuetions));
     catalogCursor.close();
   }
 }
コード例 #3
0
 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();
 }