binary sm2 functional refactor

date dictates revision

by Timar

HTML

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartist.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartist-plugin-axistitle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartist-plugin-pointlabels.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.0/ramda.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css">
    <div id="all-charts" class="chart-container">

    </div>


<div id="anychart" style="width: 500px; height: 400px;"></div>

CSS

.chart-container {
  width: 100%;
  margin: auto;
}
.ct-series-a .ct-line, .ct-series-a .ct-point {
  stroke: yellow !important;
}
.ct-series-b .ct-line, .ct-series-b .ct-point {
  stroke: orange !important;
}
.ct-series-c .ct-line, .ct-series-c .ct-point {
  stroke: red !important;
}
.ct-series-d .ct-line, .ct-series-d .ct-point {
  stroke: purple !important;
}

JavaScript

// https://cdn.jsdelivr.net/gh/eu81273/jsfiddle-console/console.js
 //TODO: First review correct = increase


// TODO: only allow specific amount of cards to be active at one time. this hsould of course also adjust based on the user.
//       Maybe check the ratio of consecutiveCorrect new Cards. if all new cards have a 'positive ratio', than new cards are accepable,
//       since the user is doing well on consective tests. if consectuvie correct has a bad ratio across all new words, focus on repetition of new words.
//       pseudo: var amountOFNewCardsPossible =  count(newCards).with('consecutive correct > 3') / count(newCards).with('totalwrong' > 3)
//       should result in a number of newCards and if new Cards are being still introduced.

//TODO: Premature review: New interval should be: (last review + days since) * easinessfactor , Easinessfactor should be increased by root distance to target reviewDate ie. if target review was 10Days, but has been reviewed prematurely after 1 day. Distance = (1/10)**2
// Easiness = easiness + (FormulaResult) * Distance

/*
Glossary:
New Card/Word: A word that has been newly introduced and is not yet matured. The unit for the interval timer is minutes.

Mature Card/Word: A card that has been correctly answered {newWordCutoff} many times, and is no longer a "New Card". This changes the Interval unit to days instead of minutes.


*/
//TODO: Allow for passingg full config  to algorithm to compare different ones.
//TODO: When interval in minutes, correct answer factor should be 5
const CFS = {
  // how many consecutive correct answers does it take to mature a card
  newWordCutoff: 5
}

class Word {
  constructor(word) {
    this.word = word;
    this.easiness = 2.5;
    this.consecutiveCorrectAnswers = 0;
    this.totalCorrectAnswers = 0;
    this.totalWrongAnswers = 0;
    this.totalAnswers = 0;
    this.lastRevisionDate = 0;
    this.revisionInterval = 1;
    this.nextRevisionDate = 0;
    this.revisions = [];
   ...