Example #1
0
  private double calculateScorePart(int i, boolean enableLogging) {
    double score = 0.0;
    double partWeight, scaledQCount, avgLevel, scaledCorrectRatio;
    /** Calculate the normalized Number of words in current part */
    partWeight = QQUtils.PartWeight100[i] / 100;
    avgLevel = QParts.get(i).getAvgLevel();
    scaledQCount =
        QQUtils.sCurve(QParts.get(i).getNumCorrect(), QQUtils.Juz2SaturationQCount * partWeight);
    scaledQCount += 1;
    scaledCorrectRatio = QQUtils.sCurve(QParts.get(i).getCorrectRatio(), 1);

    score = 100 * partWeight * avgLevel * scaledQCount * scaledCorrectRatio;
    if (QQUtils.QQDebug == 1 && QParts.get(i).getNumCorrect() > 0 && enableLogging)
      Log.d(
          "["
              + i
              + "] S= "
              + new DecimalFormat("##.##")
                  .format(100 * partWeight * avgLevel * scaledQCount * scaledCorrectRatio)
              + "::pW="
              + new DecimalFormat("##.##").format(partWeight)
              + " av="
              + new DecimalFormat("##.##").format(avgLevel)
              + " sC="
              + new DecimalFormat("##.##").format(scaledQCount)
              + " sR="
              + new DecimalFormat("##.##").format(scaledCorrectRatio));
    return score;
  }
Example #2
0
  public CharSequence getDownScore(int CurrentPart) {
    double currentPartScore, currentPartScoreDown;
    double partWeight, avgLevel, scaledQCount, scaledCorrectRatio;
    int numCorrect, numQuestions, downScore;

    /**
     * Find the difference between the current and the to-be-decremented score The difference comes
     * from the current part only. The current is calculated normally, while the DOWN is calculated
     * manually as below
     */
    currentPartScore = calculateScorePart(CurrentPart, false);

    /** Calculate the normalized Number of words in current part + UP */
    numCorrect = QParts.get(CurrentPart).getNumCorrect();
    numQuestions = QParts.get(CurrentPart).getNumQuestions();
    partWeight = QQUtils.PartWeight100[CurrentPart] / 100;

    avgLevel = QParts.get(CurrentPart).getAvgLevel();
    scaledQCount =
        QQUtils.sCurve(
            QParts.get(CurrentPart).getNumCorrect(), QQUtils.Juz2SaturationQCount * partWeight);
    scaledQCount += 1;
    scaledCorrectRatio = QQUtils.sCurve(((float) numCorrect) / ((float) numQuestions + 1), 1);

    currentPartScoreDown = 100 * partWeight * avgLevel * scaledQCount * scaledCorrectRatio;
    downScore = (int) Math.round(currentPartScore - currentPartScoreDown);
    if (QQUtils.QQDebug == 1 && downScore == 0) {
      Log.d(
          "[0Down] Sd= "
              + new DecimalFormat("##.##")
                  .format(100 * partWeight * avgLevel * scaledQCount * scaledCorrectRatio)
              + "::pW="
              + new DecimalFormat("##.##").format(partWeight)
              + " av="
              + new DecimalFormat("##.##").format(avgLevel)
              + " sC="
              + new DecimalFormat("##.##").format(scaledQCount)
              + " sR="
              + new DecimalFormat("##.##").format(scaledCorrectRatio));
    }
    return String.valueOf(downScore);
  }
  protected void startDownload(String destination) {

    List<PendingDownload> pendingDownloads = SerenityApplication.getPendingDownloads();
    PendingDownload pendingDownload = new PendingDownload();
    String filename = info.getTitle() + "." + info.getContainer();
    pendingDownload.setFilename(filename);
    pendingDownload.setUrl(info.getDirectPlayUrl());

    pendingDownloads.add(pendingDownload);
    int pos = pendingDownloads.size() - 1;

    try {
      DSInterface downloadService = MainActivity.getDsInterface();
      downloadService.addFileDownloadlist(info.getDirectPlayUrl(), destination, filename, pos);
      Toast.makeText(
              context,
              context.getString(R.string.starting_download_of_) + info.getTitle(),
              Toast.LENGTH_LONG)
          .show();
    } catch (Exception ex) {
      Log.e("Unable to download " + info.getTitle() + "." + info.getContainer());
    }
  }
Example #4
0
  /** @return An array of weights for studied parts to sum up to QQUtils.DAILYQUIZ_QPERPART_COUNT */
  public int[] getDailyQuizStudyPartsWeights(String dailyRandom) {
    int sparse[] = new int[QQUtils.DAILYQUIZ_PARTS_COUNT];
    int totalStudyWeight = (int) Math.ceil((double) getTotalStudyLength() / QQUtils.Juz2AvgWords);
    int Wn, WnX100_remainder = 0, WnX100;

    /*Fill array as: [0, 0, W1, 0, W2, ..]*/
    for (int i = 0; i < QQUtils.DAILYQUIZ_PARTS_COUNT; i++) {
      // Skip Al-Fatiha
      if (QParts.get(i + 1).getLength() == 0) sparse[i] = 0;
      else {
        WnX100 =
            QQUtils.DAILYQUIZ_QPERPART_COUNT
                * QQUtils.PartWeight100[i + 1]
                / totalStudyWeight; // Weight with scaling of 100
        if (Integer.valueOf(dailyRandom.charAt(i)) > 4) {
          Wn = (int) Math.ceil((WnX100 + WnX100_remainder) / (float) 100);
          if (Wn > 0) {
            sparse[i] = Wn;
            WnX100_remainder += WnX100 - 100;
          } else {
            sparse[i] = 0;
            WnX100_remainder += WnX100;
          }
        } else {
          Wn = (int) Math.round((WnX100 + WnX100_remainder) / (float) 100);
          if (Wn > 0) {
            sparse[i] = Wn;
            WnX100_remainder += WnX100 - 100;
          } else {
            sparse[i] = 0;
            WnX100_remainder += WnX100;
          }
        }
      }
    }

    /*Check if W1:Wn sum to DAILYQUIZ_QPERPART_COUNT*/
    int sum = 0;
    for (int i = 0; i < QQUtils.DAILYQUIZ_PARTS_COUNT; i++) sum += sparse[i];
    int sumCorrection = QQUtils.DAILYQUIZ_QPERPART_COUNT - sum;

    /*Apply correction (due to approx) to last selection*/
    for (int i = QQUtils.DAILYQUIZ_PARTS_COUNT - 1; i >= 0; i--) {
      if (sparse[i] != 0) {
        sparse[i] += sumCorrection;
        break;
      }
    }

    Log.i(
        "DailyQuizStudyPartsWeights:: "
            + sparse[0]
            + sparse[1]
            + sparse[2]
            + sparse[3]
            + sparse[4]
            + sparse[5]
            + sparse[6]
            + sparse[7]
            + sparse[8]
            + sparse[9]
            + sparse[10]
            + sparse[11]
            + sparse[12]
            + sparse[13]
            + sparse[14]
            + sparse[15]
            + sparse[16]
            + sparse[17]
            + sparse[18]
            + sparse[19]
            + sparse[20]
            + sparse[21]
            + sparse[22]
            + sparse[23]
            + sparse[24]
            + sparse[25]
            + sparse[26]
            + sparse[27]
            + sparse[28]
            + sparse[29]
            + sparse[30]
            + sparse[31]
            + sparse[32]
            + sparse[33]
            + sparse[34]
            + sparse[35]
            + sparse[36]
            + sparse[37]
            + sparse[38]
            + sparse[39]
            + sparse[40]
            + sparse[41]
            + sparse[42]
            + sparse[43]
            + sparse[44]
            + sparse[45]
            + sparse[46]
            + sparse[47]
            + " "
            + sparse[48]);

    return sparse;
  }