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 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;
|
let old_score = word.score;
|
||||||
word.update(status);
|
word.update(status);
|
||||||
let new_score = word.score;
|
let new_score = word.score;
|
||||||
|
|
||||||
match self.order_module.clone() {
|
match self.order_module {
|
||||||
OrderModule::SemiRandomSRS(mut module) => {
|
OrderModule::SemiRandomSRS(ref mut module) => {
|
||||||
module.open(status, index, word.clone());
|
module.open(status, index, word);
|
||||||
self.order_module = OrderModule::SemiRandomSRS(module);
|
|
||||||
}
|
}
|
||||||
OrderModule::RandomSRS(mut module) => {
|
OrderModule::RandomSRS(ref mut module) => {
|
||||||
module.open(status, index, word.clone());
|
module.open(status, index, word);
|
||||||
self.order_module = OrderModule::RandomSRS(module);
|
|
||||||
}
|
}
|
||||||
OrderModule::WorstWordsSRS(mut module) => {
|
OrderModule::WorstWordsSRS(ref mut module) => {
|
||||||
module.open(status, index, word.clone());
|
module.open(status, index, word);
|
||||||
self.order_module = OrderModule::WorstWordsSRS(module);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_stat_score(word, &self.state.lock().connection);
|
update_stat_score(word, &self.state.lock().connection);
|
||||||
@@ -486,7 +483,7 @@ enum OrderModule {
|
|||||||
}
|
}
|
||||||
trait SRSModule {
|
trait SRSModule {
|
||||||
fn next(&mut self, set: &mut DeckData) -> usize;
|
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);
|
fn init(&mut self, set: &mut DeckData);
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[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) {
|
fn init(&mut self, set: &mut DeckData) {
|
||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
@@ -554,7 +551,7 @@ impl SRSModule for SemiRandomSRSModule {
|
|||||||
|
|
||||||
index
|
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);
|
let new_weight = (100.0 / word.calculated_score()).powf(2.0);
|
||||||
self.last_weights
|
self.last_weights
|
||||||
.update_weights(&[(index, &new_weight)])
|
.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) {
|
fn init(&mut self, _: &mut DeckData) {
|
||||||
self.initialized = true;
|
self.initialized = true;
|
||||||
|
|||||||
Reference in new issue
Block a user