lib/jldrill/model/Quiz/Strategy.rb in jldrill-0.5.1.7 vs lib/jldrill/model/Quiz/Strategy.rb in jldrill-0.6.0.1
- old
+ new
@@ -1,18 +1,20 @@
+# encoding: utf-8
require 'jldrill/model/Quiz/Statistics'
require 'jldrill/model/problems/ProblemFactory'
module JLDrill
# Strategy for choosing, promoting and demoting items in
# the quiz.
class Strategy
- attr_reader :stats
+ attr_reader :reviewStats, :forgottenStats
def initialize(quiz)
@quiz = quiz
- @stats = Statistics.new(quiz)
+ @reviewStats = Statistics.new(quiz, 4)
+ @forgottenStats = Statistics.new(quiz, 5)
end
def Strategy.newSetBin
return 0
end
@@ -30,13 +32,13 @@
end
# Returns a string showing the status of the quiz with this strategy
def status
if shouldReview?
- retVal = " #{@stats.recentAccuracy}%"
- if @stats.inTargetZone?
- retVal += " - #{(10 - @stats.timesInTargetZone)}"
+ retVal = " #{@reviewStats.recentAccuracy}%"
+ if @reviewStats.inTargetZone?
+ retVal += " - #{(10 - @reviewStats.timesInTargetZone)}"
end
elsif !forgottenSet.empty?
retVal = " Forgotten Items"
else
retVal = " New Items"
@@ -132,11 +134,11 @@
# The target zone occurs when in the last 10
# items, we have a 90% success rate or when
# we have a 90% confidence that the the items
# have a 90% chance of success.
def reviewSetKnown?
- !(10 - @stats.timesInTargetZone > 0)
+ !(10 - @reviewStats.timesInTargetZone > 0)
end
# Returns true if at least one working set full of
# items have been promoted to the review set, and
# the review set is not known to the required
@@ -242,11 +244,12 @@
end
# Create a problem for the given item at the correct level
def createProblem(item)
item.itemStats.createProblem
- @stats.startTimer(item.bin == Strategy.reviewSetBin)
+ @reviewStats.startTimer(item.bin == Strategy.reviewSetBin)
+ @forgottenStats.startTimer(item.bin == Strategy.forgottenSetBin)
# Drill at the scheduled level in the review and forgotten sets
if (item.bin == Strategy.reviewSetBin) ||
(item.bin == Strategy.forgottenSetBin)
problem = item.problem
else
@@ -266,11 +269,12 @@
contents.moveToBin(item, item.bin + 1)
else
if item.bin == 3
# Newly promoted items
item.itemStats.consecutive = 1
- @stats.learned += 1
+ @reviewStats.learned += 1
+ @forgottenStats.learned += 1
item.scheduleAll
end
# Put the item at the back of the bin
contents.bins[item.bin].delete(item)
reviewSet.push(item)
@@ -292,11 +296,12 @@
end
end
# Mark the item as having been reviewed correctly
def correct(item)
- @stats.correct(item)
+ @reviewStats.correct(item)
+ @forgottenStats.correct(item)
item.itemStats.correct
if ((item.bin == Strategy.reviewSetBin) ||
(item.bin == Strategy.forgottenSetBin))
item.schedule.correct
promote(item)
@@ -308,10 +313,11 @@
end
end
# Mark the item as having been reviewed incorrectly
def incorrect(item)
- @stats.incorrect(item)
+ @reviewStats.incorrect(item)
+ @forgottenStats.incorrect(item)
item.allIncorrect
item.itemStats.incorrect
demote(item)
end