Simple srs refactoring
This commit is contained in:
1 parent
42c9a5095a
commit
36e5693564
1 file changed
+12
-15
+12
-15
@@ -431,23 +431,20 @@ impl DeckData {
|
||||
}
|
||||
let index = self.current_word_index.unwrap();
|
||||
|
||||
let word = &mut self.set[index];
|
||||
let word : &mut CardStatistics = &mut self.set[index];
|
||||
let old_score = word.score;
|
||||
word.update(status);
|
||||
let new_score = word.score;
|
||||
|
||||
match self.order_module.clone() {
|
||||
OrderModule::SemiRandomSRS(mut module) => {
|
||||
module.open(status, index, word.clone());
|
||||
self.order_module = OrderModule::SemiRandomSRS(module);
|
||||
match self.order_module {
|
||||
OrderModule::SemiRandomSRS(ref mut module) => {
|
||||
module.open(status, index, word);
|
||||
}
|
||||
OrderModule::RandomSRS(mut module) => {
|
||||
module.open(status, index, word.clone());
|
||||
self.order_module = OrderModule::RandomSRS(module);
|
||||
OrderModule::RandomSRS(ref mut module) => {
|
||||
module.open(status, index, word);
|
||||
}
|
||||
OrderModule::WorstWordsSRS(mut module) => {
|
||||
module.open(status, index, word.clone());
|
||||
self.order_module = OrderModule::WorstWordsSRS(module);
|
||||
OrderModule::WorstWordsSRS(ref mut module) => {
|
||||
module.open(status, index, word);
|
||||
}
|
||||
}
|
||||
update_stat_score(word, &self.state.lock().connection);
|
||||
@@ -486,7 +483,7 @@ enum OrderModule {
|
||||
}
|
||||
trait SRSModule {
|
||||
fn next(&mut self, set: &mut DeckData) -> usize;
|
||||
fn open(&mut self, status: WordOpenMode, index: usize, updated_word: CardStatistics);
|
||||
fn open(&mut self, status: WordOpenMode, index: usize, updated_word: &CardStatistics);
|
||||
fn init(&mut self, set: &mut DeckData);
|
||||
}
|
||||
#[derive(Clone)]
|
||||
@@ -514,7 +511,7 @@ impl SRSModule for RandomSRSModule {
|
||||
}
|
||||
}
|
||||
|
||||
fn open(&mut self, _: WordOpenMode, _: usize, _: CardStatistics) {}
|
||||
fn open(&mut self, _: WordOpenMode, _: usize, _: &CardStatistics) {}
|
||||
|
||||
fn init(&mut self, set: &mut DeckData) {
|
||||
self.initialized = true;
|
||||
@@ -554,7 +551,7 @@ impl SRSModule for SemiRandomSRSModule {
|
||||
|
||||
index
|
||||
}
|
||||
fn open(&mut self, _: WordOpenMode, index: usize, word: CardStatistics) {
|
||||
fn open(&mut self, _: WordOpenMode, index: usize, word: &CardStatistics) {
|
||||
let new_weight = (100.0 / word.calculated_score()).powf(2.0);
|
||||
self.last_weights
|
||||
.update_weights(&[(index, &new_weight)])
|
||||
@@ -601,7 +598,7 @@ impl SRSModule for WorstWordsSRSModule {
|
||||
}
|
||||
}
|
||||
|
||||
fn open(&mut self, _: WordOpenMode, _: usize, _: CardStatistics) {}
|
||||
fn open(&mut self, _: WordOpenMode, _: usize, _: &CardStatistics) {}
|
||||
|
||||
fn init(&mut self, _: &mut DeckData) {
|
||||
self.initialized = true;
|
||||
|
||||
Reference in new issue
Block a user