Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2011-01-07 23:33:32 (GMT)
committer Michael Stone <michael@laptop.org>2011-01-08 01:20:52 (GMT)
commit0f3df5c58d6c255200502af5defe7ef51f285ac8 (patch)
treed091d1c87daa12b317aa30e8f097dd139c7c52a4
parent111526860d92edbe87a2d88db40f62c4de1e4d3f (diff)
Abstract out the period at which the problems advance.
This is in preparation for the next commit, which introduces UI controls to govern the period.
-rw-r--r--arithmetic.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/arithmetic.py b/arithmetic.py
index a9611b4..b6acb4b 100644
--- a/arithmetic.py
+++ b/arithmetic.py
@@ -137,6 +137,7 @@ class ArithmeticActivity(groupthink.sugar_tools.GroupActivity):
self._logger = logging.getLogger('arithmetic-activity')
self.starttime = 0
self.endtime = 0
+ self.period = 10
self.secondsleft = ""
self.question = ""
self.answer = ""
@@ -278,7 +279,7 @@ class ArithmeticActivity(groupthink.sugar_tools.GroupActivity):
# so that everyone gets the same questions. Synchronize
# clocks to make sure that people are seeing the same
# questions at the same time, and establish that question N
- # will start at time starttime + (10 * N). This requires a
+ # will start at time starttime + (period * N). This requires a
# passable attempt at clock synchronization, but then the
# clients can cease communicating with each other (forever!)
# and still know what question to pop up when.
@@ -357,14 +358,14 @@ class ArithmeticActivity(groupthink.sugar_tools.GroupActivity):
self.solve(answer, incorrect)
def start_countdown(self):
- self.secondsleft = 10
+ self.secondsleft = self.period
gobject.timeout_add(1000, self.onesecond_cb)
self.countdownlabel.set_markup('Time until next question: <span size="xx-large">%s</span>s' % self.secondsleft)
def onesecond_cb(self):
elapsed_time = self.timer.time() - self.cloud.startpoint.get_value()
- curr_index = int(math.floor(elapsed_time/10))
- time_to_next = 10 - (elapsed_time - (10*curr_index))
+ curr_index = int(math.floor(elapsed_time/self.period))
+ time_to_next = self.period - (elapsed_time - (self.period*curr_index))
self.secondsleft = int(math.ceil(time_to_next))
self.countdownlabel.set_markup('Time until next question: <span size="xx-large">%s</span>s' % self.secondsleft)
if curr_index != self._question_index: