Search in sources :

Example 1 with OverviewStatsBuilder

use of com.ichi2.anki.stats.OverviewStatsBuilder in project Anki-Android by ankidroid.

the class OverviewStatsBuilderTest method testInfoHtmlStringMonth.

@Test
@Config(qualifiers = "en")
public void testInfoHtmlStringMonth() {
    OverviewStatsBuilder statsTester = new OverviewStatsBuilder(new WebView(getTargetContext()), getCol(), 42L, Stats.AxisType.TYPE_MONTH);
    String HTML = statsTester.createInfoHtmlString();
    assertEquals(HTML, "<center><style>\n" + "h1, h3 { margin-bottom: 0; margin-top: 1em; text-transform: capitalize; }\n" + ".pielabel { text-align:center; padding:0px; color:white; }\n" + "body {color:#FFFFFF;}\n" + "</style><h1>Today</h1>Studied <b>0 cards</b> in <b>0 minutes</b> today<br>Again count: <b>0</b><br>Learn: <b>0</b>, review: <b>0</b>, relearn: <b>0</b>, filtered: <b>0</b><br>No mature cards were studied today<h1>1 month</h1><h3>FORECAST</h3>Total: <b>0</b> reviews<br>Average: <b>0.0</b> reviews/day<br>Due tomorrow: <b>0</b><br><h3>REVIEW COUNT</h3>Days studied: <b>0%</b> (0 of 30)<br>Total: <b>0</b> reviews<br>Average for days studied: <b>0.0</b> reviews/day<br>If you studied every day: <b>0.0</b> reviews/day<br><h3>REVIEW TIME</h3>Days studied: <b>0%</b> (0 of 30)<br>Total: <b>0</b> minutes<br>Average for days studied: <b>0.0</b> minutes/day<br>If you studied every day: <b>0.0</b> minutes/day<br>Average answer time: <b>0.0s</b> (<b>0.00</b> cards/minute)<br><h3>ADDED</h3>Total: <b>0</b> cards<br>Average: <b>0.0</b> cards/day<br><h3>INTERVALS</h3>Average interval: <b>0.0</b> hours<br>Longest interval: <b>0.0</b> hours<h3>ANSWER BUTTONS</h3>Learning: <b>0.00%</b> correct (0 of 0)<br>Young: <b>0.00%</b> correct (0 of 0)<br>Mature: <b>0.00%</b> correct (0 of 0)<h3>CARD TYPES</h3>Total cards: <b>0</b><br>Total notes: <b>0</b><br>Lowest ease: <b>0%</b><br>Average ease: <b>0%</b><br>Highest ease: <b>0%</b></center>");
}
Also used : WebView(android.webkit.WebView) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with OverviewStatsBuilder

use of com.ichi2.anki.stats.OverviewStatsBuilder in project AnkiChinaAndroid by ankichinateam.

the class OverView method loadDataBuilder.

public void loadDataBuilder(OverviewStatsBuilder builder) {
    Timber.d("loadDataBuilder");
    Resources res = getResources();
    findTextViewById(R.id.tv_today).setText(res.getString(R.string.stats_today));
    final int minutes = (int) Math.round(builder.mTodayStats[THETIME_INDEX] / 60.0);
    final String span = res.getQuantityString(R.plurals.time_span_minutes, minutes, minutes);
    findTextViewById(R.id.tv_today_minute).setText(res.getQuantityString(R.plurals.stats_today_cards, builder.mTodayStats[CARDS_INDEX], builder.mTodayStats[CARDS_INDEX], span));
    findTextViewById(R.id.tv_today_repeat).setText(res.getString(R.string.stats_today_again_count, builder.mTodayStats[FAILED_INDEX]));
    if (builder.mTodayStats[CARDS_INDEX] > 0) {
        findTextViewById(R.id.tv_today_correct_rate).setVisibility(VISIBLE);
        findTextViewById(R.id.tv_today_correct_rate).setText(res.getString(R.string.stats_today_correct_count, builder.mTodayStats[CARDS_INDEX] - builder.mTodayStats[FAILED_INDEX], builder.mTodayStats[CARDS_INDEX], (((1 - builder.mTodayStats[FAILED_INDEX] / (float) (builder.mTodayStats[CARDS_INDEX])) * 100.0))));
    } else {
        findTextViewById(R.id.tv_today_correct_rate).setVisibility(GONE);
    }
    findTextViewById(R.id.tv_today_study).setText(res.getString(R.string.stats_today_type_breakdown, builder.mTodayStats[LRN_INDEX], builder.mTodayStats[REV_INDEX], builder.mTodayStats[RELRN_INDEX], builder.mTodayStats[FILT_INDEX]));
    if (builder.mTodayStats[MCNT_INDEX] != 0) {
        findTextViewById(R.id.tv_today_hint).setText(res.getString(R.string.stats_today_mature_cards, builder.mTodayStats[MSUM_INDEX], builder.mTodayStats[MCNT_INDEX], (builder.mTodayStats[MSUM_INDEX] / (float) (builder.mTodayStats[MCNT_INDEX]) * 100.0)));
    } else {
        findTextViewById(R.id.tv_today_hint).setText(res.getString(R.string.stats_today_no_mature_cards));
    }
    findTextViewById(R.id.description).setText(res.getString(builder.mType.descriptionId));
    OverviewStatsBuilder.OverviewStats oStats = builder.mOverViewStats;
    // FORECAST
    findTextViewById(R.id.tv_predict).setText(res.getString(R.string.stats_forecast).toUpperCase());
    findTextViewById(R.id.tv_predict_all_content).setText(res.getString(R.string.stats_overview_forecast_total, oStats.forecastTotalReviews));
    findTextViewById(R.id.tv_predict_avg_content).setText(res.getString(R.string.stats_overview_forecast_average, oStats.forecastAverageReviews));
    findTextViewById(R.id.tv_predict_deadline_content).setText(res.getString(R.string.stats_overview_forecast_due_tomorrow, oStats.forecastDueTomorrow));
    // REVIEW COUNT
    findTextViewById(R.id.tv_review).setText(res.getString(R.string.stats_review_count).toUpperCase());
    findTextViewById(R.id.tv_review_day_content).setText(oStats.daysStudied + "/" + oStats.allDays);
    findTextViewById(R.id.tv_review_day_percent).setText("(" + (int) ((float) oStats.daysStudied / (float) oStats.allDays * 100) + "%)");
    findTextViewById(R.id.tv_review_all_content).setText(res.getString(R.string.stats_overview_total_reviews, oStats.totalReviews));
    findTextViewById(R.id.tv_review_avg_content).setText(res.getString(R.string.stats_overview_reviews_per_day_studydays, oStats.reviewsPerDayOnStudyDays));
    boolean allDaysStudied = oStats.daysStudied == oStats.allDays;
    if (!allDaysStudied) {
        findTextViewById(R.id.tv_review_hint).setText(res.getString(R.string.stats_overview_reviews_per_day_all, oStats.reviewsPerDayOnAll));
        findTextViewById(R.id.tv_review_hint).setVisibility(VISIBLE);
    } else {
        findTextViewById(R.id.tv_review_hint).setVisibility(GONE);
    }
    // REVIEW TIME
    findTextViewById(R.id.tv_review_time).setText(res.getString(R.string.stats_review_time).toUpperCase());
    findTextViewById(R.id.tv_review_time_count_content).setText(oStats.daysStudied + "/" + oStats.allDays);
    findTextViewById(R.id.tv_review_time_count_percent).setText("(" + (int) ((float) oStats.daysStudied / (float) oStats.allDays * 100) + "%)");
    findTextViewById(R.id.tv_review_time_all_content).setText(res.getString(R.string.stats_overview_total_time_in_period, Math.round(oStats.totalTime)));
    findTextViewById(R.id.tv_review_time_avg_content).setText(res.getString(R.string.stats_overview_time_per_day_studydays, oStats.timePerDayOnStudyDays));
    double cardsPerMinute = oStats.totalTime == 0 ? 0 : ((double) oStats.totalReviews) / oStats.totalTime;
    double averageAnswerTime = oStats.totalReviews == 0 ? 0 : (oStats.totalTime * 60) / ((double) oStats.totalReviews);
    if (!allDaysStudied) {
        findTextViewById(R.id.tv_review_time_hint).setText(res.getString(R.string.stats_overview_time_per_day_all, oStats.timePerDayOnAll) + "," + res.getString(R.string.stats_overview_average_answer_time, averageAnswerTime, cardsPerMinute));
    } else {
        findTextViewById(R.id.tv_review_time_hint).setText(res.getString(R.string.stats_overview_average_answer_time, averageAnswerTime, cardsPerMinute));
    }
    // ADDED
    findTextViewById(R.id.tv_add).setText(res.getString(R.string.stats_added).toUpperCase());
    findTextViewById(R.id.tv_add_all_content).setText(res.getString(R.string.stats_overview_total_new_cards, oStats.totalNewCards));
    findTextViewById(R.id.tv_add_avg_content).setText(res.getString(R.string.stats_overview_new_cards_per_day, oStats.newCardsPerDay));
    // INTERVALS
    findTextViewById(R.id.tv_distance).setText(res.getString(R.string.stats_review_intervals).toUpperCase());
    findTextViewById(R.id.tv_distance_avg).setText(res.getString(R.string.stats_overview_average_interval));
    findTextViewById(R.id.tv_distance_avg_content).setText(Utils.roundedTimeSpan(getContext(), (int) Math.round(oStats.averageInterval * Stats.SECONDS_PER_DAY)));
    findTextViewById(R.id.tv_distance_max).setText(res.getString(R.string.stats_overview_longest_interval));
    findTextViewById(R.id.tv_distance_all_content).setText(Utils.roundedTimeSpan(getContext(), (int) Math.round(oStats.longestInterval * Stats.SECONDS_PER_DAY)));
    // ANSWER BUTTONS
    findTextViewById(R.id.tv_answer_button).setText(res.getString(R.string.stats_answer_buttons).toUpperCase());
    findTextViewById(R.id.tv_answer_study_content).setText(res.getString(R.string.stats_overview_answer_buttons_learn, oStats.newCardsOverview.getPercentage()));
    findTextViewById(R.id.tv_answer_study_percent).setText("(" + oStats.newCardsOverview.correct + "/" + oStats.newCardsOverview.total + ")");
    findTextViewById(R.id.tv_answer_not_familiar_content).setText(res.getString(R.string.stats_overview_answer_buttons_young, oStats.youngCardsOverview.getPercentage()));
    findTextViewById(R.id.tv_answer_not_familiar_percent).setText("(" + oStats.youngCardsOverview.correct + "/" + oStats.youngCardsOverview.total + ")");
    findTextViewById(R.id.tv_answer_familiar_content).setText(res.getString(R.string.stats_overview_answer_buttons_mature, oStats.matureCardsOverview.getPercentage()));
    findTextViewById(R.id.tv_answer_familiar_percent).setText("(" + oStats.matureCardsOverview.correct + "/" + oStats.matureCardsOverview.total + ")");
    // CARD TYPES
    findTextViewById(R.id.tv_note_type).setText(res.getString(R.string.stats_cards_types).toUpperCase());
    findTextViewById(R.id.tv_note_type_all_card).setText(R.string.stats_overview_card_types_total_cards);
    findTextViewById(R.id.tv_note_type_all_card_content).setText("" + oStats.totalCards);
    findTextViewById(R.id.tv_note_type_all).setText(R.string.stats_overview_card_types_total_notes);
    findTextViewById(R.id.tv_note_type_all_content).setText("" + oStats.totalNotes);
    findTextViewById(R.id.tv_note_low_level).setText(R.string.stats_overview_card_types_lowest_ease);
    findTextViewById(R.id.tv_note_low_level_content).setText(oStats.lowestEase + "%");
    findTextViewById(R.id.tv_note_avg_level).setText(R.string.stats_overview_card_types_average_ease);
    findTextViewById(R.id.tv_note_avg_level_content).setText(oStats.averageEase + "%");
    findTextViewById(R.id.tv_note_high_level).setText(R.string.stats_overview_card_types_highest_ease);
    findTextViewById(R.id.tv_note_high_level_content).setText(oStats.highestEase + "%");
}
Also used : OverviewStatsBuilder(com.ichi2.anki.stats.OverviewStatsBuilder) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint)

Example 3 with OverviewStatsBuilder

use of com.ichi2.anki.stats.OverviewStatsBuilder in project Anki-Android by ankidroid.

the class OverviewStatsBuilderTest method testInfoHtmlStringLife.

@Test
@Config(qualifiers = "en")
public void testInfoHtmlStringLife() {
    OverviewStatsBuilder statsTester = new OverviewStatsBuilder(new WebView(getTargetContext()), getCol(), 42L, Stats.AxisType.TYPE_LIFE);
    String HTML = statsTester.createInfoHtmlString();
    assertEquals(HTML, "<center><style>\n" + "h1, h3 { margin-bottom: 0; margin-top: 1em; text-transform: capitalize; }\n" + ".pielabel { text-align:center; padding:0px; color:white; }\n" + "body {color:#FFFFFF;}\n" + "</style><h1>Today</h1>Studied <b>0 cards</b> in <b>0 minutes</b> today<br>Again count: <b>0</b><br>Learn: <b>0</b>, review: <b>0</b>, relearn: <b>0</b>, filtered: <b>0</b><br>No mature cards were studied today<h1>deck life</h1><h3>FORECAST</h3>Total: <b>0</b> reviews<br>Average: <b>0.0</b> reviews/day<br>Due tomorrow: <b>0</b><br><h3>REVIEW COUNT</h3>Days studied: <b>0%</b> (0 of 1)<br>Total: <b>0</b> reviews<br>Average for days studied: <b>0.0</b> reviews/day<br>If you studied every day: <b>0.0</b> reviews/day<br><h3>REVIEW TIME</h3>Days studied: <b>0%</b> (0 of 1)<br>Total: <b>0</b> minutes<br>Average for days studied: <b>0.0</b> minutes/day<br>If you studied every day: <b>0.0</b> minutes/day<br>Average answer time: <b>0.0s</b> (<b>0.00</b> cards/minute)<br><h3>ADDED</h3>Total: <b>0</b> cards<br>Average: <b>0.0</b> cards/day<br><h3>INTERVALS</h3>Average interval: <b>0.0</b> hours<br>Longest interval: <b>0.0</b> hours<h3>ANSWER BUTTONS</h3>Learning: <b>0.00%</b> correct (0 of 0)<br>Young: <b>0.00%</b> correct (0 of 0)<br>Mature: <b>0.00%</b> correct (0 of 0)<h3>CARD TYPES</h3>Total cards: <b>0</b><br>Total notes: <b>0</b><br>Lowest ease: <b>0%</b><br>Average ease: <b>0%</b><br>Highest ease: <b>0%</b></center>");
}
Also used : WebView(android.webkit.WebView) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with OverviewStatsBuilder

use of com.ichi2.anki.stats.OverviewStatsBuilder in project Anki-Android by ankidroid.

the class OverviewStatsBuilderTest method testInfoHtmlStringYear.

@Test
@Config(qualifiers = "en")
public void testInfoHtmlStringYear() {
    OverviewStatsBuilder statsTester = new OverviewStatsBuilder(new WebView(getTargetContext()), getCol(), 42L, Stats.AxisType.TYPE_YEAR);
    String HTML = statsTester.createInfoHtmlString();
    assertEquals(HTML, "<center><style>\n" + "h1, h3 { margin-bottom: 0; margin-top: 1em; text-transform: capitalize; }\n" + ".pielabel { text-align:center; padding:0px; color:white; }\n" + "body {color:#FFFFFF;}\n" + "</style><h1>Today</h1>Studied <b>0 cards</b> in <b>0 minutes</b> today<br>Again count: <b>0</b><br>Learn: <b>0</b>, review: <b>0</b>, relearn: <b>0</b>, filtered: <b>0</b><br>No mature cards were studied today<h1>1 year</h1><h3>FORECAST</h3>Total: <b>0</b> reviews<br>Average: <b>0.0</b> reviews/day<br>Due tomorrow: <b>0</b><br><h3>REVIEW COUNT</h3>Days studied: <b>0%</b> (0 of 365)<br>Total: <b>0</b> reviews<br>Average for days studied: <b>0.0</b> reviews/day<br>If you studied every day: <b>0.0</b> reviews/day<br><h3>REVIEW TIME</h3>Days studied: <b>0%</b> (0 of 365)<br>Total: <b>0</b> minutes<br>Average for days studied: <b>0.0</b> minutes/day<br>If you studied every day: <b>0.0</b> minutes/day<br>Average answer time: <b>0.0s</b> (<b>0.00</b> cards/minute)<br><h3>ADDED</h3>Total: <b>0</b> cards<br>Average: <b>0.0</b> cards/day<br><h3>INTERVALS</h3>Average interval: <b>0.0</b> hours<br>Longest interval: <b>0.0</b> hours<h3>ANSWER BUTTONS</h3>Learning: <b>0.00%</b> correct (0 of 0)<br>Young: <b>0.00%</b> correct (0 of 0)<br>Mature: <b>0.00%</b> correct (0 of 0)<h3>CARD TYPES</h3>Total cards: <b>0</b><br>Total notes: <b>0</b><br>Lowest ease: <b>0%</b><br>Average ease: <b>0%</b><br>Highest ease: <b>0%</b></center>");
}
Also used : WebView(android.webkit.WebView) RobolectricTest(com.ichi2.anki.RobolectricTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

WebView (android.webkit.WebView)3 RobolectricTest (com.ichi2.anki.RobolectricTest)3 Test (org.junit.Test)3 Config (org.robolectric.annotation.Config)3 SuppressLint (android.annotation.SuppressLint)1 Resources (android.content.res.Resources)1 OverviewStatsBuilder (com.ichi2.anki.stats.OverviewStatsBuilder)1