I am trying to implement SM2 algorithm in php using this link - http://www.blueraja.com/blog/477/a-better-spaced-repetition-learning-algorithm-sm2 .
My code is as below-
<table>
<tr>
<td>Fail </td>
<td>hard </td>
<td>good </td>
<td>easy </td>
</tr>
<tr>
<td>0 </td>
<td>1.5 </td>
<td>2.5 </td>
<td>5 </td>
</tr>
<tr>
<td>
<?php
$performanceRating1 = 0;
$consecutiveCorrectAnswers1 = 0;
echo $easy1 = -0.8 + (0.28 * $performanceRating1) + (0.02 * ($performanceRating1 * $performanceRating1));
?>
</td>
<td><?php
$performanceRating2 = 1.5;
$consecutiveCorrectAnswers2 = 1;
echo $easy2 = -0.8 + (0.28 * $performanceRating2) + (0.02 * ($performanceRating2 * $performanceRating2));
echo "<br>";
echo $nextDueDay2 = 6 * (pow($easy2,($consecutiveCorrectAnswers2 -1)));
//$nextDueDate
?> </td>
<td><?php
$performanceRating3 = 2.5;
$consecutiveCorrectAnswers3 = 1;
echo $easy3 = -0.8 + (0.28 * $performanceRating3) + (0.02 * ($performanceRating3 * $performanceRating3));
echo "<br>";
echo $nextDueDay3 = 6 * (pow($easy3,($consecutiveCorrectAnswers3 -1)));
?> </td>
<td><?php
$performanceRating4 = 5;
$consecutiveCorrectAnswers4 = 1;
echo $easy4 = -0.8 + (0.28 * $performanceRating4) + (0.02 * ($performanceRating4 * $performanceRating4));
echo "<br>";
echo $nextDueDay4 = 6 * (pow($easy4,($consecutiveCorrectAnswers4 -1)));
?> </td>
</tr>
</table>
the output that I am getting is -
Fail Hard good Easy
Performance rating 0 1.5 2.5 5
Easiness -0.8 -0.335 0.025 1.1
Next Due Days 0 6 6 6
I am facing problem with calculating days value. In my code i am getting similar value for all performance rating, it should be like <1m <10m 4d for very first time.
You can get an idea of output from this existing app https://apps.ankiweb.net/
I hope i can get solution of my question.
Thanks.