Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mayer <christian.mayer@student.tugraz.at>2010-05-16 16:04:44 (GMT)
committer Christian Mayer <christian.mayer@student.tugraz.at>2010-05-16 16:04:44 (GMT)
commit738fbfcc6ce11553c01fb53c2fa62d2d3a0f8d26 (patch)
tree1ae5b8d0551351f611ccec7fb2530270cd5e78a1
parenta81e49e26d6e40c4182b66d1ff2e2a1ac8880369 (diff)
parent4d4362ee90b887c85ebfd98c7e8d4014c624151a (diff)
Merge branch 'master' of git://git.sugarlabs.org/rp/mainline into mainline
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/ReckonPrimerActivity.py93
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/activity/activity-reckonprimer.svg118
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/activity/activity.info18
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/coach.py85
-rw-r--r--ReckonPrimer.activity/collection.py175
-rw-r--r--ReckonPrimer.activity/data/Collection.data282
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/display.py689
-rw-r--r--ReckonPrimer.activity/exercises/__init__.py2
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/exercises/exaddsimp.py13
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/exercises/exercise.py75
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/exercises/expassten.py8
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/exercises/extimesdiv.py424
-rw-r--r--ReckonPrimer.activity/exstore.py220
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/functions.py56
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/img/addsub_simp.jpgbin1322 -> 1322 bytes
-rw-r--r--ReckonPrimer.activity/img/collection.pngbin2838 -> 3197 bytes
-rw-r--r--ReckonPrimer.activity/img/exercise.pngbin2842 -> 3485 bytes
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/img/passten.jpgbin982 -> 982 bytes
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/img/times_div.jpgbin1396 -> 1396 bytes
-rw-r--r--ReckonPrimer.activity/learner.py41
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/session.py12
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/setup.py0
-rw-r--r--ReckonPrimer.activity/task.py21
-rw-r--r--[-rwxr-xr-x]ReckonPrimer.activity/timer.py24
24 files changed, 1327 insertions, 1029 deletions
diff --git a/ReckonPrimer.activity/ReckonPrimerActivity.py b/ReckonPrimer.activity/ReckonPrimerActivity.py
index 1975bb0..20f2e1d 100755..100644
--- a/ReckonPrimer.activity/ReckonPrimerActivity.py
+++ b/ReckonPrimer.activity/ReckonPrimerActivity.py
@@ -5,7 +5,9 @@ import pygtk
import gtk
from sugar.activity import activity
+#from sugar.activity.widgets import * # needs a more recent Sugar (see below)
from sugar.datastore import datastore
+#from sugar.graphics.toolbarbox import ToolbarBox # needs recent Sugar
from sugar import profile
from session import Session
#from toolbar import Toolbar
@@ -13,22 +15,39 @@ from session import Session
class ReckonPrimerActivity(activity.Activity):
def __init__(self, handle):
-
+
activity.Activity.__init__(self, handle)
- toolbox = activity.ActivityToolbox(self)
- self.set_toolbox(toolbox)
- toolbox.show()
- #toolbar = Toolbar(self)
- #toolbar.show()
-
+# toolbox = activity.ActivityToolbox(self)
+# self.set_toolbox(toolbox)
+# toolbox.show()
+# toolbar = Toolbar(self)
+# toolbar.show()
+ # the source below needs a more recent version of Sugar
+ # advantage would be: free to more freely name "activity" etc
+ #toolbar_box = ToolbarBox()
+ #self.set_toolbar_box(toolbar_box)
+ #toolbar_box.toolbar.insert(ActivityButton(self), -1)
+ #toolbar_box.toolbar.insert(TitleEntry(self), -1)
+
+ #share_button = ShareButton(self)
+ #toolbar_box.toolbar.insert(share_button, -1)
+ #toolbar_box.toolbar.insert(KeepButton(self), -1)
+
+ #separator = gtk.SeparatorToolItem()
+ #separator.props.draw = False
+ #separator.set_expand(True)
+ #toolbar_box.toolbar.insert(separator, -1)
+ #toolbar_box.toolbar.insert(StopButton(self), -1)
+ #toolbar_box.show_all()
+
file_location = activity.get_activity_root() + \
- "/data/reckonprimer_report.txt"
+ "/data/reckonprimer_report.txt"
file_handle = open(file_location, 'w')
file_handle.write("Report: " + profile.get_nick_name() + \
- strftime(" %Y-%m-%d %H:%M:%S") + "\n")
+ strftime(" %Y-%m-%d %H:%M:%S") + "\n")
file_handle.close()
-
+
title = "Report: " + profile.get_nick_name() + \
strftime(" %Y-%m-%d %H:%M:%S")
mime = "text/plain"
@@ -36,54 +55,52 @@ class ReckonPrimerActivity(activity.Activity):
"/data/reckonprimer_report.txt"
favorite = "1"
tags = "ReckonPrimer"
-
+
journal_object = datastore.create()
journal_object.metadata['title'] = title
journal_object.metadata['mime_type'] = mime
- journal_object.file_path = file_path
+ journal_object.file_path = file_path
journal_object.metadata['keep'] = favorite
journal_object.metadata['tags'] = tags
- journal_object.metadata['icon-color'] = '#AFD600,#5B615C'
+ journal_object.metadata['icon-color'] = '#AFD600,#5B615C'
datastore.write( journal_object )
journal_object.destroy()
-
- #BEGIN LPCHANGE
- self._session = Session("xo-user-name", self)
- self.run_session()
-
- def run_session(self):
- self._session.run()
- def can_close(self):
- self._session.close()
- return True
-#END LPCHANGE
-
-
+ self.run_session()
+
+
+ def run_session(self):
+ session = Session("xo-user-name", self)
+ session.run()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ReckonPrimer.activity/activity/activity-reckonprimer.svg b/ReckonPrimer.activity/activity/activity-reckonprimer.svg
index de219f8..15af196 100755..100644
--- a/ReckonPrimer.activity/activity/activity-reckonprimer.svg
+++ b/ReckonPrimer.activity/activity/activity-reckonprimer.svg
@@ -1,108 +1,10 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="55"
- height="55"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- sodipodi:docname="activity-reckonprimer.svg">
- <metadata
- id="metadata9">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs7">
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 27.5 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="55 : 27.5 : 1"
- inkscape:persp3d-origin="27.5 : 18.333333 : 1"
- id="perspective11" />
- </defs>
- <sodipodi:namedview
- inkscape:window-height="949"
- inkscape:window-width="1280"
- inkscape:pageshadow="2"
- inkscape:pageopacity="0.0"
- guidetolerance="10.0"
- gridtolerance="10.0"
- objecttolerance="10.0"
- borderopacity="1.0"
- bordercolor="#666666"
- pagecolor="#ffffff"
- id="base"
- showgrid="false"
- inkscape:zoom="14.927835"
- inkscape:cx="27.5"
- inkscape:cy="27.5"
- inkscape:window-x="0"
- inkscape:window-y="25"
- inkscape:current-layer="svg2" />
- <rect
- x="5.5359116"
- y="5.3349447"
- width="45"
- height="45"
- style="fill:#ffffff;stroke:#666666;stroke-width:3.5"
- id="rect4" />
- <text
- xml:space="preserve"
- style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="28.068371"
- y="26.931629"
- id="text2412"><tspan
- sodipodi:role="line"
- id="tspan2414"
- x="28.068371"
- y="26.931629" /></text>
- <text
- xml:space="preserve"
- style="font-size:18px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="17.28315"
- y="10.38536"
- id="text2420"><tspan
- sodipodi:role="line"
- id="tspan2422"
- x="17.28315"
- y="10.38536" /><tspan
- sodipodi:role="line"
- id="tspan2424"
- x="17.28315"
- y="32.885361">10</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:18px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="21.101521"
- y="32.357735"
- id="text2426"><tspan
- sodipodi:role="line"
- id="tspan2428"
- x="21.101521"
- y="32.357735" /></text>
- <text
- xml:space="preserve"
- style="font-size:18px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
- x="31.95373"
- y="42.74102"
- id="text2430"><tspan
- sodipodi:role="line"
- id="tspan2432"
- x="31.95373"
- y="42.74102" /></text>
-</svg>
+<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#010101">
+ <!ENTITY fill_color "#FFFFFF">
+]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px">
+ <rect id="rect4" x="5.536" y="5.335" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="45" height="45"/>
+ <line id="_x31_" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" x1="20" y1="15" x2="20" y2="40.326"/>
+ <path id="_x30_" fill="none" stroke="&stroke_color;" stroke-width="3.5" d="M34.99,16.959c2.041,0,2.031,5.096,2.031,5.096
+ s-0.008,6.031,0,11.126c0.01,5.094-2.031,5.094-2.031,5.094s-2.91,0-4.832,0c-2.088,0-2.088-5.094-2.088-5.094s0-6.566,0-11.392
+ s2.031-4.828,2.031-4.828L34.99,16.959L34.99,16.959L34.99,16.959z"/>
+</svg>
diff --git a/ReckonPrimer.activity/activity/activity.info b/ReckonPrimer.activity/activity/activity.info
index 36b696c..a72b601 100755..100644
--- a/ReckonPrimer.activity/activity/activity.info
+++ b/ReckonPrimer.activity/activity/activity.info
@@ -1,9 +1,9 @@
-[Activity]
-name = ReckonPrimer
-bundle_id = org.laptop.ReckonPrimerActivity
-class = ReckonPrimerActivity.ReckonPrimerActivity
-icon = activity-reckonprimer
-activity_version = 6
-host_version = 1
-show_launcher = yes
-
+[Activity]
+name = ReckonPrimer
+bundle_id = org.laptop.ReckonPrimerActivity
+class = reckonprimeractivity.ReckonPrimerActivity
+icon = activity-reckonprimer
+activity_version = 6
+host_version = 1
+show_launcher = yes
+
diff --git a/ReckonPrimer.activity/coach.py b/ReckonPrimer.activity/coach.py
index 861bb0b..8c276fc 100755..100644
--- a/ReckonPrimer.activity/coach.py
+++ b/ReckonPrimer.activity/coach.py
@@ -3,61 +3,50 @@
import os
import pprint
import pickle
+from collection import Collection
from display import Display
class Coach:
- """ The coach supervises the Learner. Presently he only
- manages the selection of Exercises. """
- print('in coach, class definition')
-
- _learnmode = None
+ """ The coach supervises the selection of exercises. """
def __init__(self):
- #print("in coach.__init__")
- self._ex = None # the learner can change the settings of _this_ exerc
- self.load_configuration_file()
-
- def load_configuration_file(self):
- try:
- configuration_file = open('data/learnmode.cfg', 'rb')
- self._learnmode = pickle.load(configuration_file)
- configuration_file.close()
- except:
- configuration_file = []
-
- def register(self, sess, dis, collect, learner):
+ self._selected_tree_position = None
+ self._selected_object = None
+ self._current_exercise = None
+
+ def register(self, sess, dis, exstore, learner):
self._sess = sess
self._dis = dis
- self._collect = collect
+ self._exstore = exstore
self._learner = learner
- print('in coach.register, exaddsimp =', self._collect.select(0))
- print('in coach.register, exaddsimp._display =', self._collect.select(0)._display._testvar)
- print('in coach.register, expassten =', self._collect.select(1))
- print('in coach.register, expassten._display =', self._collect.select(1)._display._testvar)
- print('in coach.register, extimesdiv=', self._collect.select(2))
- print('in coach.register, extimesdiv._display=', self._collect.select(2)._display._testvar)
def request_exercise(self):
- """ This preliminary version just lets the Learner select. """
- #print("in coach.request_exercise")
- self._dis.offer_coll_to_learner(self._collect)
- # calls back with notify('exerc-selected'... OR 'switch-to-setts'
-
- def get_learnmode(self):
- return(self._learnmode)
-
- def exercise_selected(self, key):
- self._dis.init_calc()
- self._ex = self._collect.select(key)
-
- self._learner.start_calcs(self._ex)
-
- def switch_to_settings(self, key):
- self._ex = self._collect.select(key)
- self._dis.init_calc()
- self._dis.offer_setting(self._ex)
-
- def settings_done(self, settings):
- self._ex.update_setting(settings)
- self._dis.init_calc()
- self._learner.start_calcs(self._ex)
+ # Called to load the exstore into the tree
+ # This preliminary version just lets the Learner select.
+ self._exstore.offer_coll_to_learner()
+
+ def get_selected_object(self, pos):
+ # Returns the object (task, collection) of a given tree position
+ self._selected_tree_position = pos
+ self._selected_object = self._exstore._root.get_object_by_tupel(pos)
+ return self._selected_object
+
+ def switch_to_settings(self):
+ # Load selected exercise
+ self._current_exercise = self._exstore.get_exercise(self._selected_object)
+ # Show settings
+ self._dis.offer_setting(self._current_exercise)
+
+ def settings_done(self, sett):
+ # Load selected exercise
+ self._current_exercise.update_setting(sett)
+ # Start calculations with user defined settings
+ self._learner.start_calcs(self._current_exercise)
+
+ def exercise_selected(self):
+ # Reload selected exercise (without settings manipulation)
+ self._selected_object = self._exstore._root.get_object_by_tupel(self._selected_tree_position)
+ self._current_exercise = self._exstore.get_exercise(self._selected_object)
+ # Start calculations
+ self._learner.start_calcs(self._current_exercise)
+
diff --git a/ReckonPrimer.activity/collection.py b/ReckonPrimer.activity/collection.py
index fddada6..094aee3 100644
--- a/ReckonPrimer.activity/collection.py
+++ b/ReckonPrimer.activity/collection.py
@@ -3,117 +3,141 @@
'''
date: 07.01.2010
description: test class "collection" to test our new idea for saving all tasks
+TODO: needs to be refactored - especially def insert_object()
'''
import gtk
import pickle
import os
-
+from task import Task
class Collection:
""" The root and the non-leaf nodes of the ExStore._data.
The leafs are of type Task.
"""
- __data = None # TODO transfer from here to Display.treestore and back.
+ _data = None # TODO transfer from here to Display.treestore and back.
# Transfer is presently done via pickle -- REPLACE this?!?
- __title = None
- __description = None
- __pic = None
+ _title = None
+ _description = None
+ _pic = None
def __init__(self, title, descript, icon, data):
- """
- def __init__(self, title, description, pic):
- self.__data = []
- self.__title = title
- self.__description = description
- self.__pic = pic
- """
- self.__title = title
- self.__description = descript
- self.__pic = icon
- #gtk.gdk.pixbuf_new_from_file("collection.png")
- self.__data = data
-
- def getData(self):
- return self.__data
-
- def setData(self, data):
- self.__data = data
-
- def getTitle(self):
- return self.__title
-
- def setTitle(self, title):
- self.__title = title
-
- def getDescription(self):
- return self.__description
-
- def setDescription(self, description):
- self.__description = description
-
- ''' keep for need, TODO icon reformatting icon to string
+ self._title = title
+ self._description = descript
+ self._pic = icon
+ self._data = data
+
+ def get_data(self):
+ return self._data
+
+ def set_data(self, data):
+ self._data = data
+
+ def get_title(self):
+ return self._title
+
+ def set_title(self, title):
+ self._title = title
+
+ def get_description(self):
+ return self._description
+
+ def set_description(self, description):
+ self._description = description
+
+ ''' keep for need, TODO icon reformatting icon to string
def getPic(self):
- return self.__pic
-
+ return self._pic
+
def setPic(self, pic):
- self.__pic = pic
+ self._pic = pic
'''
- def insert_object(self, obj, pos):
+ def insert_object(self, obj, pos, pos_spec):
+ """ Handles the insertion of dropped objects in list and pickle. """
root = self.get_data_from_pickle()
- list = root.getData()
-
+ list = root.get_data()
+ #attach at the end - if drop occured in some area beneath the widget
if (pos == None):
- list.append(obj) # sonderfall ganz hinten einfügen
+ list.append(obj)
+
+ #if object was edited or used
+ elif(pos_spec == "edit"):
+ for i in range(len(pos)):
+ try:
+ if isinstance(list[pos[i]], Collection):
+ if (i == (len(pos)-1)):
+ list.insert(pos[i], obj)
+ else:
+ list = list[pos[i]].get_data()
+ else:
+ list.insert(pos[i], obj)
+ except IndexError:
+ list.append(obj)
+
+ #for drag and drop
else:
- max = len(pos)
for i in range(len(pos)):
try:
if isinstance(list[pos[i]], Collection):
- list = list[pos[i]].getData()
- if (i == (max - 1)):
+ if ((pos_spec == gtk.TREE_VIEW_DROP_BEFORE) and
+ (i == (len(pos)-1))):
+ list.insert(pos[i], obj)
+ elif((pos_spec == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE) and
+ (i == (len(pos)-1))):
+ list = list[pos[i]].get_data()
+ list.append(obj)
+ elif((pos_spec == gtk.TREE_VIEW_DROP_INTO_OR_AFTER) and
+ (i == (len(pos)-1))):
+ list = list[pos[i]].get_data()
list.append(obj)
+ elif((pos_spec == gtk.TREE_VIEW_DROP_AFTER) and
+ (i == (len(pos)-1))):
+ list.insert(pos[i]+1, obj)
+ else:
+ list = list[pos[i]].get_data()
else:
- list.insert(pos[i], obj)
+ if ((pos_spec == gtk.TREE_VIEW_DROP_BEFORE or
+ pos_spec == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE) and
+ (i == (len(pos)-1))):
+ list.append(obj)
+ elif((pos_spec == gtk.TREE_VIEW_DROP_AFTER) or
+ (pos_spec == gtk.TREE_VIEW_DROP_INTO_OR_AFTER) and
+ (i == (len(pos)-1))):
+ list.insert(pos[i]+1, obj)
+ else:
+ list.append(obj)
except IndexError:
- list.append(obj) # wenn in eigener collection verschoben wird, wurde ja element schon gelöscht daher passt index nicht mehr
+ list.append(obj) #exception to handle IndexError
self.set_data_in_pickle(root)
-
def get_object(self, pos):
+ """ Deletes and returns an object from list """
root = self.get_data_from_pickle()
-
- list = root.getData()
-
- # find object and return it to insert it in collection
+ list = root.get_data()
+ #find object and return it to insert it in collection
for i in range(len(pos)):
if isinstance(list[pos[i]], Collection):
- obj = list[pos[i]]
- list = list[pos[i]].getData()
+ obj = pos[i]
+ if i < (len(pos)-1):
+ list = list[pos[i]].get_data()
else:
- obj = list[pos[i]]
-
- list = root.getData()
- max = len(pos)
-
- # find object and delete it in current collection
- for i in range(len(pos)):
- if isinstance(list[pos[i]], Collection):
- if (i == (max - 1)):
- #collection löschen (evt. abfrage ob wirklich gelöscht werden soll inkl. kinder)
- list.remove(obj)
- else:
- list = list[pos[i]].getData()
- else:
- #task löschen
- list.remove(obj)
-
+ obj = pos[i]
+ #delete object in list but return it
+ obj = list.pop(obj)
self.set_data_in_pickle(root)
return obj
+ def get_object_by_tupel(self, tupel):
+ """ get n-th element given with a n-tupel """
+ el = self
+ for n in tupel:
+ el = el.get_data()[n]
+ return el
+
def get_data_from_pickle(self):
+ """ Returns data from pickle file """
path = os.path.join(os.getcwd(), "data/Collection.data")
f = open(path, "rb")
root = pickle.load(f)
@@ -121,7 +145,12 @@ class Collection:
return root
def set_data_in_pickle(self, root):
+ """ Sets data in pickle file """
path = os.path.join(os.getcwd(), "data/Collection.data")
f = open(path, "wb")
pickle.dump(root, f)
f.close()
+
+ def get_selected_object(self, sel):
+ print("selection: " + len(sel))
+ return \ No newline at end of file
diff --git a/ReckonPrimer.activity/data/Collection.data b/ReckonPrimer.activity/data/Collection.data
index ff8f3a7..d2291bf 100644
--- a/ReckonPrimer.activity/data/Collection.data
+++ b/ReckonPrimer.activity/data/Collection.data
@@ -2,133 +2,243 @@
Collection
p0
(dp1
-S'_Collection__description'
+S'_data'
p2
-S"hier sind alle 1x1-Reihen mit 'in'"
-p3
-sS'_Collection__pic'
+(lp3
+(icollection
+Collection
p4
-NsS'_Collection__data'
-p5
+(dp5
+g2
(lp6
(icollection
Collection
p7
(dp8
g2
-g3
-sg4
-Nsg5
(lp9
-(itask
-Task
+sS'_pic'
p10
-(dp11
-S'_eval'
+NsS'_title'
+p11
+S'Add Sub: + & -'
p12
-(lp13
-sS'_sett'
+sS'_description'
+p13
+S"hier sind alle 1x1-Reihen mit 'in'"
p14
-(dp15
-S'min'
-p16
-I2
-sS'max'
-p17
-I2
-sS'*'
+sba(icollection
+Collection
+p15
+(dp16
+g2
+(lp17
+(itask
+Task
p18
-I01
-sS'title'
-p19
-S'template extimesdiv'
+(dp19
+S'_eval'
p20
-sS'shuffle_all'
-p21
-I00
-sS'MAX'
+(lp21
+sS'_sett'
p22
-I100
-sS'*commute'
-p23
-I01
-sS'MIN'
+(dp23
+S'min'
p24
-I10
-sS'descript'
+I0
+sS'=input'
p25
-S'multiplication, division and "in" from 2 to 19 and 20 to 190. '
-p26
-sS'cut-max'
+(lp26
+I1
+aI3
+aI5
+asS'cut-max'
p27
I01
-sS'topic'
+sS'_+_=_'
p28
-S'times_div'
+I01
+sS'title'
p29
-sS'shuffle_inner'
+S'template exaddsimp'
p30
-I01
-sS'calclines'
+sS'MAX'
p31
-I1
-sS'in'
+I30
+sS'+'
p32
I01
-sS':'
+sS'MIN'
p33
-I00
-sS'remainder'
+I20
+sS'descript'
p34
+S'addition and subtraction without carry, i.e. without passing the 10 barrier. '
+p35
+sS'input='
+p36
+(lp37
+I1
+aI3
+aI5
+asS'topic'
+p38
+S'addsub_simp'
+p39
+sS'calclines'
+p40
+I1
+sS'-'
+p41
+I01
+sS'max'
+p42
+I1
+sS'_=_+_'
+p43
I00
+sS'shuffle'
+p44
+I01
sS'icon'
-p35
+p45
Nssba(itask
Task
-p36
-(dp37
-g12
-(lp38
-sg14
-(dp39
-g16
-I3
-sg17
-I3
-sg18
-I01
-sg19
+p46
+(dp47
g20
-sg21
-I00
+(lp48
sg22
-I100
-sg23
-I01
-sg24
-I10
-sg25
-g26
+(dp49
+g24
+I2
sg27
I01
-sg28
-g29
-sg30
+sS'newline'
+p50
I01
+sg29
+S'template expassten'
+p51
+sS'shuffle_all'
+p52
+I00
sg31
-I1
+I150
sg32
I01
sg33
+I10
+sg34
+S'addition and subtraction with carry, i.e. with passing the 10 barrier. '
+p53
+sg38
+S'passten'
+p54
+sg40
+I1
+sg41
+I00
+sg42
+I2
+sS'input'
+p55
+(lp56
+I3
+asS'shuffle_inner'
+p57
I00
+sg45
+Nssba(itask
+Task
+p58
+(dp59
+g20
+(lp60
+sg22
+(dp61
+g24
+I2
+sg42
+I2
+sS'*'
+p62
+I00
+sg29
+S'template extimesdiv'
+p63
+sg52
+I00
+sg31
+I50
+sS'*commute'
+p64
+I00
+sg33
+I10
sg34
+S'multiplication, division and "in" from 2 to 19 and 20 to 190. '
+p65
+sS'vadd'
+p66
+I0
+sg38
+S'times_div'
+p67
+sS'factors'
+p68
+(lp69
+I2
+aI4
+asg57
I00
-sg35
-NssbasS'_Collection__title'
-p40
-S'einzeln * in'
-p41
-sbasg40
-S"'*' und 'in' Reihen"
-p42
+sg40
+I1
+sS'in'
+p70
+I00
+sg27
+I01
+sS':'
+p71
+I01
+sS'remainder'
+p72
+I00
+sS'vmult'
+p73
+I1
+sg45
+Nssbasg10
+Nsg11
+S'Times Division: x & in'
+p74
+sg13
+g14
+sba(icollection
+Collection
+p75
+(dp76
+g2
+(lp77
+sg10
+Nsg11
+S'Pass Ten: ->10'
+p78
+sg13
+g14
+sbasg10
+Nsg11
+S'Templates'
+p79
+sg13
+S'Hier finden Sie alle verf\xc3\xbcgbaren Templates'
+p80
+sbasg10
+Nsg11
+S'root = invisible node'
+p81
+sg13
+S'aber ben\xc3\xb6tigt zum richtigen speichern/lesen'
+p82
sb. \ No newline at end of file
diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py
index a4b2bb4..6ec3737 100755..100644
--- a/ReckonPrimer.activity/display.py
+++ b/ReckonPrimer.activity/display.py
@@ -7,30 +7,36 @@ import pango
import time
import gobject
from timer import Timer
+from collection import Collection
+from exstore import ExStore
from sugar import profile
from sugar.graphics import style
from sugar.activity import activity
-#BEGIN LPCHANGE
-from sugar.datastore import datastore
-import os
-#END LPCHANGE
class Display:
- """
+ """print "root: ", self._root
Definition and manipulation of all GUI-elemts.
Exception (redesign?): def define_buttons in classes derived from Exercise.
"""
- print("in display, class definition")
- # DnD for gtk_tree in
+ #print("in display, class definition")
+ #DnD: Allowed targets
TARGETS = [
('pixbuf', gtk.TARGET_SAME_WIDGET, 0),
('text', gtk.TARGET_SAME_WIDGET, 1)
]
- def __init__(self, window):
+ def __init__(self, window):
+ self._drag_and_drop = False # set true to enable drag and drop
+ self._coll = None # object holding current data from ExStore
+ self._root = None # relates _data to _coll
+ self._data = None # list of current data from ExStore
+ self._selected = None #Tuple containing position of selected object
+ self._from = None # dragposition on treeview
+ self._to = None # dropposition on treeview
+ self._to_spec = None # specific for dropposition
self._permanent_gui_elements(window)
+ self.total_calcs = 0 #number of calculations in one exercise
self.errors = 0
- self._ex = None # needed for feedback_table etc
# TODO: imprive information hiding
self._sett = None # setting updated by callbacks during input
self.running = False # switch settings_/feedback_table TODO rename
@@ -38,13 +44,14 @@ class Display:
# and Collection.select_exerc_callback
self._testvar = 'FOUND'
+
def register(self, sess, co, learner, exstore):
"""register _after_ Session and Coach have been instantiated"""
self._sess = sess
self._co = co
self._learner = learner
- self._exstore = exstore
-
+ self.current_exercisestore = exstore
+
def _permanent_gui_elements(self, window):
# The display is partitioned as follows
#
@@ -57,20 +64,22 @@ class Display:
#2| | OR |
# | | settings_table |
#3+-------------------------+ OR |
- # | | feedback_table |
- #4| empty for calcs etc | |
- # | | |
+ # | | exercise_table |
+ #4| calcs, | (incliding feedback |
+ # | info_table, etc | _table |
#5+-------------------------+------------------------+
self.main_window = window # Save the sugar main window
-
+
# whole window with 5 lines and 2 columns
self.table = gtk.Table(5, 2, True)
+ self.table.set_row_spacings(2)
+ self.table.set_col_spacings(2)
self.main_window.set_canvas(self.table)
-
+
self.log_buffer = gtk.TextBuffer()
self.tag_table = self.log_buffer.get_tag_table()
-
+
self.error_tag = gtk.TextTag("error") # tag for errors
self.error_tag.set_property("foreground", "blue")
self.tag_table.add(self.error_tag)
@@ -96,27 +105,83 @@ class Display:
self.table.attach(self.scrolled_window, 0, 1, 0, 3)
self.log_view.show()
self.scrolled_window.show()
-
-
+ # make empty lines such that all calcs are entered at bottom
+ for i in range(1,21):
+ end_iterator = self.log_buffer.get_end_iter()
+ self.log_buffer.insert(end_iterator, "\n")
+ self.log_view.scroll_mark_onscreen(self.log_buffer.get_insert())
+
# 3 tables as overlays with same 15 lines and 6 columns
- self.settings_table = gtk.Table (14, 9, True)
+ self.exercise_table = gtk.Table(14, 9, True)
+ self.exercise_table.set_row_spacings(2)
+ self.exercise_table.set_col_spacings(2)
self.exstore_table = gtk.Table(14, 9, True)
- self.gtk_tree() #-->self.treeview
- #@# self.exstore_table.attach(self.treeview, 0, 9, 0, 13)
- #@# self.treeview.show()
- self.feedback_table = gtk.Table (14, 9, True)
-
+ self.exstore_table.set_row_spacings(2)
+ self.exstore_table.set_col_spacings(2)
+ self.settings_table = gtk.Table(14, 9, True)
+ self.settings_table.set_row_spacings(2)
+ self.settings_table.set_col_spacings(2)
+ #feedback_table
+ self.feedback_table = gtk.Table (3, 12, True)
+ self.feedback_table.set_row_spacings(2)
+ self.feedback_table.set_col_spacings(2)
+ # info_table is showen in the left_bottom area
+ self.info_table = gtk.Table(7, 20, True)
+ #title
+ self.label0 = gtk.Label("Title: ")
+ self.label0.modify_font(pango.FontDescription("sans bold 12"))
+ self.label0.set_alignment(0, 0.5)
+ self.info_table.attach(self.label0, 1, 10, 0, 1)
+ self.label0.show()
+ self._title_buffer = gtk.TextBuffer()
+ self._title = gtk.TextView(self._title_buffer)
+ self._title.modify_font(pango.FontDescription('sans 12'))
+ self._title.set_editable(False)
+ self._title.set_cursor_visible(False)
+ self.info_table.attach(self._title, 1, 19, 1, 2)
+ self._title.show()
+ #description
+ self.label1 = gtk.Label("Description: ")
+ self.label1.modify_font(pango.FontDescription("sans bold 12"))
+ self.label1.set_alignment(0, 0.5)
+ self.info_table.attach(self.label1, 1, 10, 2, 3)
+ self.label1.show()
+ self._desc_buffer = gtk.TextBuffer()
+ self._desc = gtk.TextView(self._desc_buffer)
+ self._desc.modify_font(pango.FontDescription('sans 12'))
+ self._desc.set_editable(False)
+ self._desc.set_cursor_visible(False)
+ self.desc_scrolled_window = gtk.ScrolledWindow()
+ self.desc_scrolled_window.set_policy(gtk.POLICY_NEVER,
+ gtk.POLICY_ALWAYS)
+ self.info_table.attach(self.desc_scrolled_window, 1, 19, 3, 6)
+ self.desc_scrolled_window.add(self._desc)
+ self._desc.set_wrap_mode(gtk.WRAP_WORD)
+ self._desc.show()
+ self.desc_scrolled_window.show()
+ #calculations
+ self.ex_name_label = gtk.Label("Calculations: ")
+ self.ex_name_label.modify_font(pango.FontDescription("sans bold 12"))
+ self.ex_name_label.set_alignment(0, 0.5)
+ self.info_table.attach(self.ex_name_label, 1, 7, 6, 7)
+ #self.ex_name_label.show()
+ self.ex_num_label = gtk.Label("")
+ self.ex_num_label.modify_font(pango.FontDescription("sans 12"))
+ self.info_table.attach(self.ex_num_label, 7, 9, 6, 7)
+ self.ex_num_label.show()
# Insert the 3 tables into the right half of the screen
- self.table.attach(self.settings_table, 1, 2, 0, 5)
+ self.table.attach(self.exercise_table, 1, 2, 0, 5)
self.table.attach(self.exstore_table, 1, 2, 0, 5)
- self.table.attach(self.feedback_table, 1, 2, 0, 5)
-
+ self.table.attach(self.settings_table, 1, 2, 0, 5)
+ self.table.attach(self.info_table, 0, 1, 3, 5)
+ self.exercise_table.attach(self.feedback_table, 0, 9, 11, 13)
# show all tables, scrolled_window already shown above
- self.settings_table_show() # treat uniformly <>!
self.exstore_table.show() # treat uniformly !
- self.feedback_table.show() # treat uniformly !
+ self.settings_table_show() # treat uniformly <>!
+ self.info_table.show()
+ self.feedback_table_init()
self.table.show() # since all other tables have been inserted
-
+
def update_time(self):
minutes, seconds = divmod(self.stopwatch.elapsed, 60)
if(minutes < 10 and seconds < 10):
@@ -130,173 +195,192 @@ class Display:
self.stopwatch_label.set_label(time)
self.stopwatch_label.queue_draw()
return True
-
+
def settings_table_show(self): # rename to .._permanent
""" Initialize all permanent gui-elements in settings_table. """
+ #finish/exit button
+ self.sfb2_butt = gtk.Button(None, gtk.STOCK_STOP)
+ self.sfb2_butt.connect("clicked", self.release_feedb_to_sett_callback)
+ self.exercise_table.attach(self.sfb2_butt, 0, 9, 14, 15)
+ self.sfb2_alignment = self.sfb2_butt.get_children()[0]
+ self.sfb2_hbox = self.sfb2_alignment.get_children()[0]
+ self.sfb2_image, self.sfb2_label = self.sfb2_hbox.get_children()
+ self.sfb2_label.set_label("Back")
+ self.sfb2_butt.hide() # only show() if running calcs
# button releasing settings_table and coach.notify('setting-done',..)
- self.see_butt = gtk.Button(None, gtk.STOCK_GO_FORWARD)
- self.see_butt.connect("clicked", self.release_sett_callback)
+ self.see_butt = gtk.Button(None, gtk.STOCK_APPLY) #GO_FORWARD
+ self.see_butt.connect("clicked", self.release_sett_callback)
#self.settings_table.attach(self.see_butt, 0, 5, 14, 15)
- self.settings_table.attach(self.see_butt, 0, 8, 13, 14)
+ self.settings_table.attach(self.see_butt, 0, 7, 14, 15)
self.see_alignment = self.see_butt.get_children()[0]
self.see_hbox = self.see_alignment.get_children()[0]
self.see_image, self.see_label = self.see_hbox.get_children()
- self.see_label.set_label("settings_table")
+ self.see_label.set_label("Start")
self.see_butt.show()
# button switching from settings_table to collect_table
- self.sec_butt = gtk.Button("")
+ self.sec_butt = gtk.Button()
+ self.sec_butt = gtk.Button(None, gtk.STOCK_CANCEL) #GO_BACK
self.sec_butt.connect("clicked", self.switch_setts_to_coll_callback)
- #self.settings_table.attach(self.sec_butt, 5, 6, 14, 15)
- self.settings_table.attach(self.sec_butt, 8, 9, 13, 14)
+ self.settings_table.attach(self.sec_butt, 7, 9, 14, 15)
self.sec_alignment = self.sec_butt.get_children()[0]
- self.sec_butt.show()
+ self.sec_hbox = self.sec_alignment.get_children()[0]
+ self.sec_image, self.sec_label = self.sec_hbox.get_children()
+ self.sec_label.set_label("")
+ self.sec_butt.show()
def switch_setts_to_coll_callback(self, widget):
""" Switch from settings_table to exstore_table. """
- self.settings_table.hide()
+ #trigger update from pickle to show the correct number of calcs
+ self._co._exstore.reload()
+ # Rebuild settings_table to get rid of the buttons
+ self.settings_table.destroy()
+ self.settings_table = gtk.Table(14, 9, True)
+ self.settings_table.set_row_spacings(2)
+ self.settings_table.set_col_spacings(2)
+ self.table.attach(self.settings_table, 1, 2, 0, 5)
+ self.settings_table_show()
self.exstore_table.show()
+ self.info_table.show()
- def feedback_table_show(self):
+ def feedback_table_init(self):
"""RENAME to draw_feedback_screen"""
# Section for stopwatch
self.stopwatch = Timer()
- self.stopwatch_label = gtk.Label("00:00")
+ self.stopwatch_label = gtk.Label()#"00:00")
self.stopwatch_label.modify_font(pango.FontDescription("sans 16"))
- #self.feedback_table.attach(self.stopwatch_label, 3, 5, 12, 13)
- self.feedback_table.attach(self.stopwatch_label, 4, 6, 12, 13)
-
+ #self.feedback_table.attach(self.stopwatch_label, 5, 6, 12, 13)
+ self.feedback_table.attach(self.stopwatch_label, 10, 12, 2, 3)
+
# Section for nickname
- self.name = profile.get_nick_name()
- self.name_label = gtk.Label(self.name)
- self.name_label.modify_font(pango.FontDescription("sans 16"))
+ #self.name = profile.get_nick_name()
+ #self.name_label = gtk.Label(self.name)
+ #self.name_label.modify_font(pango.FontDescription("sans 16"))
#self.feedback_table.attach(self.name_label, 0, 6, 13, 14)
- self.feedback_table.attach(self.name_label, 0, 9, 13, 14)
-
+ #self.feedback_table.attach(self.name_label, 0, 9, 13, 14)
+
# Section for progress bar
self.progressbar = gtk.ProgressBar(adjustment=None)
-
+
# Color for progress bar
style = self.progressbar.get_style()
style.bg[gtk.STATE_PRELIGHT] = gtk.gdk.color_parse("green")
self.progressbar.set_style (style)
- self.progressbar.set_fraction(0)
- self.feedback_table.attach(self.progressbar, 0, 9, 8, 9)
+ self.progressbar.set_fraction(0)
+ self.feedback_table.attach(self.progressbar, 0, 12, 0, 1)
# Labels for progress bar
self.progress0 = gtk.Label("0")
self.progress0.modify_font(pango.FontDescription("sans 16"))
- self.feedback_table.attach(self.progress0, 0, 1, 9, 10 )
-
+ self.feedback_table.attach(self.progress0, 0, 1, 1, 2)
+
# Labels for status update
self.correct_count = 0
self.correct_counter = gtk.Label(str(self.correct_count))
self.correct_counter.modify_font(pango.FontDescription("sans 16"))
-
+
# Ugly code for label color
attr = pango.AttrList()
fg_color = pango.AttrForeground(0, 65535, 0, 0, 6)
- attr.insert(fg_color)
+ attr.insert(fg_color)
self.correct_counter.set_attributes(attr)
- #self.feedback_table.attach(self.correct_counter, 2, 4, 9, 10 )
- self.feedback_table.attach(self.correct_counter, 3, 5, 9, 10 )
-
+ #self.feedback_table.attach(self.correct_counter, 2, 4, 9, 10 )
+ self.feedback_table.attach(self.correct_counter, 6, 7, 1, 2)
+
self.false_count = 0
self.false_counter = gtk.Label(str(self.false_count))
self.false_counter.modify_font(pango.FontDescription("sans 16"))
-
+
# Ugly code for label color
attr = pango.AttrList()
fg_color = pango.AttrForeground(0, 0, 65535, 0, 6)
- attr.insert(fg_color)
+ attr.insert(fg_color)
self.false_counter.set_attributes(attr)
-
+
#self.feedback_table.attach(self.false_counter, 2, 4, 10, 11 )
- self.feedback_table.attach(self.false_counter, 3, 5, 10, 11 )
-
+ self.feedback_table.attach(self.false_counter, 6, 7, 2, 3)
+
self.stopwatch_label.show()
gobject.timeout_add(1000, self.update_time)
- self.name_label.show()
+ #self.name_label.show()
self.progressbar.show()
self.progress0.show()
self.correct_counter.show()
self.false_counter.show()
-
- self.total_calcs = self._ex.count()
- self.progress_total = gtk.Label(str(self.total_calcs))
+
+ self.progress_total = gtk.Label('')
self.progress_total.modify_font(pango.FontDescription("sans 16"))
- #self.feedback_table.attach(self.progress_total, 5, 6, 9, 10 )
- self.feedback_table.attach(self.progress_total, 8, 9, 9, 10 )
+ self.feedback_table.attach(self.progress_total, 10, 12, 1, 2)
self.progress_total.show()
-
- self.sfb_butt = gtk.Button(None, gtk.STOCK_STOP)
- self.sfb_butt.connect("clicked", self.release_feedb_callback)
- self.feedback_table.attach(self.sfb_butt, 0, 9, 13, 14)
- self.sfb_alignment = self.sfb_butt.get_children()[0]
- self.sfb_hbox = self.sfb_alignment.get_children()[0]
- self.sfb_image, self.sfb_label = self.sfb_hbox.get_children()
- self.sfb_label.set_label("feedback_table")
- self.sfb_butt.show()
-
+
+ def feedback_table_show(self):
+ #reset running feedback
+ self.correct_count = 0
+ self.correct_counter.set_label('0')
+ self.false_count = 0
+ self.false_counter.set_label('0')
+ #reset timer
+ self.stopwatch_label.set_label('00:00')
+ self.stopwatch.reset()
+ #load current feedback to ui
+ self.total_calcs = self._co._current_exercise.count()+1
+ self.progress_total.set_label(str(self.total_calcs))
+ self.feedback_table.show()
+
def feedback_table_hide(self):
self.progressbar.set_fraction(0)
- self.stopwatch_label.hide()
- self.name_label.hide()
- self.progressbar.hide()
- self.progress0.hide()
- self.correct_counter.hide()
- self.false_counter.hide()
- self.progress_total.hide()
- self.sfb_butt.hide()
-
- def offer_setting(self,ex):
+ self.feedback_table.hide()
+
+ def offer_setting(self, ex):
""" Prepare display for update of settings. """
- self._ex = ex #WN.LV either drop this or self.current_exercise
- #BEGIN LPCHANGE
- self.protocol_settings_string()
- #END LPCHANGE
-
- self._sett = self._ex.get_setting() #WN.LV make _sett local
-
- self.current_exercise = ex #WN.LV either drop this or self._ex
- print('in display.offer_setting, topic=', self._sett['topic'])
- self.current_exercise.define_buttons()
- self.current_exercise.set_buttons(self._sett)
- self.settings_table.show()
-
+ ex.define_buttons()
+ ex.set_buttons(ex.get_setting())
+
def release_feedb_callback(self, widget):
- """ """
+ """ Exit calcs to main menu = exstore """
+ self.protocol('----------------------------------------', 0, 'OK')
+ #print('in display.release_feedb_callback')
+ self.calc_table.destroy()
+ self.feedback_table_hide()
+ self.info_table.show()
+ self.exercise_table.hide()
+ self.exstore_table.show()
+
+ def release_feedb_to_sett_callback(self, widget):
+ """ Exit calcs to settings """
self.protocol('----------------------------------------', 0, 'OK')
- print('in display.release_feedb_callback')
+ #print('in display.release_feedb_callback')
self.calc_table.destroy()
self.feedback_table_hide()
- self.exstore_table.show() # from here the next user-interactions
+ self.exercise_table.hide()
+ self.settings_table.show()
def release_sett_callback(self, widget):
""" Start calcs with these settings (probably updated). """
- print('in display.release_sett_callback')
- self._co.settings_done(self._ex._sett)
+ #print('display: release_sett_callback: start from settings screen')
+ self._co.settings_done(self._co._current_exercise.get_setting())
self.settings_table.hide()
- #self.exstore_table.hide()
+ self.exercise_table.show()
self.feedback_table_show()
-
+ self.sfb2_butt.show()
+ self.sfb_butt.hide()
+ self.info_table.hide()
- def init_calc(self):
+ '''def init_calc(self):
"""
prepares for calculations from 1 setting.
for instance, a calculation might be on 1 ore more lines.
"""
- #self._mode = "learner"
- print("in display.init_calc")
+ print("display: init_calc: onBtnClick")
# make empty lines such that all calcs are entered at bottom
for i in range(1,21):
end_iterator = self.log_buffer.get_end_iter()
- self.log_buffer.insert(end_iterator, "\n")
+ self.log_buffer.insert(end_iterator, "\n")
self.log_view.scroll_mark_onscreen(self.log_buffer.get_insert())
-
+ '''
def destroy_box(self):
self.calculation_box.destroy()
-
+
def protocol(self, full_line, errors, feedback):
end_iterator = self.log_buffer.get_end_iter()
@@ -304,16 +388,14 @@ class Display:
self.log_buffer.insert_with_tags_by_name(end_iterator, "\n" + full_line, "correct" )
elif ( feedback == 'XXX' ):
self.log_buffer.insert_with_tags_by_name(end_iterator, "\n" + full_line, "error" )
- end_iterator = self.log_buffer.get_end_iter()
- mark = self.log_buffer.create_mark(None, end_iterator, True)
+ end_iterator = self.log_buffer.get_end_iter()
+ mark = self.log_buffer.create_mark(None, end_iterator, True)
self.log_view.scroll_mark_onscreen(mark)
-
-#BEGIN LPCHANGE
-
+
def protocol_generated_calcs(self, calculations, change):
- print("DEBUG: in display.protocol_generated_calcs")
+ #print("DEBUG: in display.protocol_generated_calcs")
end_iterator = self.log_buffer.get_end_iter()
- self.log_buffer.insert_with_tags_by_name(end_iterator, "\n---------- " + change + " ----------")
+ self.log_buffer.insert_with_tags_by_name(end_iterator, "\n---------- " + change + " ----------" , "fixxxme!" )
for c in calculations:
end_iterator = self.log_buffer.get_end_iter()
@@ -324,64 +406,10 @@ class Display:
to_format[2] + " " + \
to_format[3] + " " + \
to_format[4]
- self.log_buffer.insert_with_tags_by_name(end_iterator, "\n" + printable_calc)
+ self.log_buffer.insert_with_tags_by_name(end_iterator, "\n" + printable_calc, "fixxxme!" )
- end_iterator = self.log_buffer.get_end_iter()
- mark = self.log_buffer.create_mark(None, end_iterator, False)
+ mark = self.log_buffer.create_mark(None, end_iterator, True)
self.log_view.scroll_mark_onscreen(mark)
- #self.log_view.scroll_to_iter(end_iterator, 0)
- #self.log_view.set_justification(gtk.JUSTIFY_CENTER)
-
-
- def protocol_settings_string(self):
- """
- This method writes the settings of the exercise to the protocol.
- """
- settings_string = self._ex.get_settings_string()
- end_iterator = self.log_buffer.get_end_iter()
- self.log_buffer.insert_with_tags_by_name(end_iterator, "\n---------- SETTINGS ----------")
- end_iterator = self.log_buffer.get_end_iter()
- self.log_buffer.insert_with_tags_by_name(end_iterator, "\n" + settings_string)
- for i in range(1,21):
- end_iterator = self.log_buffer.get_end_iter()
- self.log_buffer.insert(end_iterator, "\n")
-
- mark = self.log_buffer.create_mark(None, end_iterator, False)
- self.log_view.scroll_mark_onscreen(mark)
- #self.log_view.scroll_to_iter(end_iterator, 0)
- #self.log_view.set_justification(gtk.JUSTIFY_CENTER)
-
- def write_protocol_to_journal(self):
- """
- This method writes the whole protocol to the journal.
- """
- #open file
- logfile = open('data/protocol.txt', 'w')
- #get string from textbuffer
- log_string = self.log_buffer.get_text(self.log_buffer.get_start_iter(), self.log_buffer.get_end_iter(), True)
- #remove empty lines
- stripped_string = ''
- for line in log_string.split('\n'):
- if line.strip():
- stripped_string += line + '\n'
- #write to file
- print stripped_string
- logfile.write(stripped_string)
- logfile.write('\n')
- logfile.close()
- print '------------------------------------------------------------------'
- print file('data/protocol.txt').read()
- #make journal entry
- journal_object = datastore.create()
- journal_object.metadata['title'] = 'ReckonPrimer Protocol'
- journal_object.metadata['mime_type'] = 'text/plain'
- journal_object.file_path = os.getcwd() + '/data/protocol.txt'
- #journal_object.file_path = 'data/protocol.txt'
- datastore.write(journal_object)
- journal_object.destroy()
-
-
-#END LPCHANGE
def input_digit(self, widget, dig, proterr, protok):
"""callback: input a digit and give feedback.
@@ -402,16 +430,17 @@ class Display:
self.errors = self.errors + 1
widget.set_text("")
self.protocol(proterr, self.errors, 'XXX')
- self._learner.calculation_error()
-
+
#WN090518
def display_calc(self, lines):
-
- self.calc_table = gtk.Table(5, 1, True)
- self.table.attach(self.calc_table, 0, 1, 0, 5)
+
+ self.calc_table = gtk.Table(5, 1, True)
+ self.calc_table.set_row_spacings(2)
+ self.calc_table.set_col_spacings(2)
+ self.table.attach(self.calc_table, 0, 1, 0, 5)
self.calc_table.show()
-
+
"""display the lines of a calc with _ at all input positions"""
lino = 0
for li in lines:
@@ -419,7 +448,7 @@ class Display:
self.create_entryline((lino, -1, 'dummy-dig', 'dummy-proterr', 'dummy-protok', li))
lino = lino + 1
-
+
def create_entryline(self, (lineno, linepos, dig, proterr, protok, line)):
"""create gtk.Entry in line at linepos and set callback_input_digit"""
#print('in Display.create_entryline: lineno=', lineno, ', linepos=',
@@ -429,197 +458,279 @@ class Display:
calc_pos = 0
self.calc_table.attach(self.calculation_box, 0, 1, 3 + lineno, 4 + lineno)
for i in calculation:
- if (calc_pos != cursor):
- self.label = gtk.Label(i)
+ if (calc_pos != cursor):
+ self.label = gtk.Label(i)
self.label.modify_font(pango.FontDescription("sans 24"))
self.calculation_box.pack_start(self.label)
- self.label.show()
+ self.label.show()
else: # prepare for input
self.text_entry = gtk.Entry(max = 1)
self.text_entry.modify_font(pango.FontDescription("sans 24"))
self.text_entry.connect("changed", self.input_digit, dig, proterr, protok)
self.calculation_box.pack_start(self.text_entry)
- self.text_entry.show()
- calc_pos = calc_pos + 1
+ self.text_entry.show()
+ calc_pos = calc_pos + 1
#?kann m.die calculation_box ZUERST aufbauen und DANN self.table.attach
self.calculation_box.show()
-
+
if(cursor != -1):
self.text_entry.grab_focus()
#just add lineno to table.attach
#TODO rename calculation, cursor below ...
#TODO remove hack on callback:
#self.input_digit('widget', dig, protline)
-
-
+
+
def finish_calc(self):
self.stopwatch.stop()
-
+
def show_progress(self):
- self.progressbar.set_fraction(self.progressbar.get_fraction()+(float(1)/float(self.total_calcs)))
+ progress = self.progressbar.get_fraction()+(float(1)/float(self.total_calcs))
+ #avoid error due to set_fraction(>1.0)
+ if(progress > float(1.0)):
+ progress = float(1.0)
+ self.progressbar.set_fraction(progress)
self.correct_count = self.correct_count + 1
self.correct_counter.set_text(str(self.correct_count))
self.calc_table.destroy()
-
- def offer_coll_to_learner(self, collect):
+
+ def show_selection_properties(self, obj):
+ ''' Shows the task/collection information in the info_table'''
+ self._title_buffer.set_text(obj.get_title())
+ self._desc_buffer.set_text(obj.get_description())
+ if isinstance(obj, Collection):
+ self.ex_name_label.hide()
+ self.ex_num_label.set_label("")
+ else:
+ self.ex_name_label.show()
+ temp = self._co._exstore.get_exercise(obj)
+ self.ex_num_label.set_label(str(temp.count()))
+
+ '''
+ def hide_selection_properties(self):
+ return
+ '''
+
+ def offer_coll_to_learner(self, data):
"""Show the exstore to the learner"""
- collect.define_coll_gui() #@#
- collect.set_coll_gui(collect) #@# sets callbacks
- self.set_coll_to_learner() # set finish_learner_coll_butt + callb
+ self.gtk_tree(data) #-->self.treeview
+ #self.exstore_table.attach(self.treeview, 0, 9, 0, 13)
+
+ self.exstore_table.attach(self.tree_scrolled_window, 0, 9, 0, 13)
+ self.tree_scrolled_window.add(self.treeview)
+
+ self.treeview.show() ### see finish_learner_coll_callback
+ self.tree_scrolled_window.show()
+ self.set_coll_to_learner() # set finish_learner_coll_butt + callback
- def switch_exercise(self):
+ '''def switch_exercise(self):
""" Another exercise has been selected. """
- #WN091215 DAS IST AB JETZT FALSCH: ex<->sett + ex<->coll moeglich
+ # WN091215 DAS IST AB JETZT FALSCH: ex<->sett + ex<->coll moeglich
self.settings_table.destroy()
self.settings_table = gtk.Table(14, 9, True)
+ self.settings_table.set_row_spacings(2)
+ self.settings_table.set_col_spacings(2)
self.table.attach(self.settings_table, 1, 2, 0, 5)
self.settings_table.show()
-
- self.feedback_table.destroy()
+
+ #self.feedback_table.destroy()
self.feedback_table = gtk.Table(14, 9, True)
+ self.feedback_table.set_row_spacings(2)
+ self.feedback_table.set_col_spacings(2)
self.table.attach(self.feedback_table, 1, 2, 0, 5)
- self.feedback_table.show()
-
+ self.feedback_table_show()
+ '''
+
def set_select_exerc_semaphore(self, coll_key):
""" Sets a semaphore for finish_collect_callback. """
- print('in display.set_select_exerc_semaphore, coll_key', self._coll_key)
+ #print('in display.set_select_exerc_semaphore, coll_key', self._coll_key)
self._coll_key = coll_key
def set_coll_to_learner(self):
""" Set the permanent gui-elements for exstore_table. """
- print('in display.set_coll_to_learner')
+ #print('in display.set_coll_to_learner')
+ # button to go back to the mein menu ->exstore_table
+ self.sfb_butt = gtk.Button(None, gtk.STOCK_STOP)
+ self.sfb_butt.connect("clicked", self.release_feedb_callback)
+ self.exercise_table.attach(self.sfb_butt, 0, 9, 14, 15)
+ self.sfb_alignment = self.sfb_butt.get_children()[0]
+ self.sfb_hbox = self.sfb_alignment.get_children()[0]
+ self.sfb_image, self.sfb_label = self.sfb_hbox.get_children()
+ self.sfb_label.set_label("Back")
+ self.sfb_butt.hide() # only show() if running calcs
# button switching from collect_table to calcs
- self.flc_butt = gtk.Button(None, gtk.STOCK_GO_FORWARD)
+ self.flc_butt = gtk.Button(None, gtk.STOCK_GO_FORWARD)
self.flc_butt.connect("clicked", self.finish_learner_coll_callback)
- self.exstore_table.attach(self.flc_butt, 0, 8, 13, 14)
+ self.exstore_table.attach(self.flc_butt, 0, 7, 13, 14)
self.flc_alignment = self.flc_butt.get_children()[0]
self.flc_hbox = self.flc_alignment.get_children()[0]
self.flc_image, self.flc_label = self.flc_hbox.get_children()
- self.flc_label.set_label("to calcs")
+ self.flc_label.set_label("Start")
self.flc_butt.show()
-
+ #disabled by default: waiting for a task to be selected
+ self.flc_butt.set_sensitive(False)
# button switching from collect_table to settings_table
- self.sts_butt = gtk.Button("")
+ self.sts_butt = gtk.Button(None, gtk.STOCK_PROPERTIES) #STOCK_EXECUTE, REFERENCES
+ self.sts_alignment = self.sts_butt.get_children()[0]
+ self.sts_hbox = self.sts_alignment.get_children()[0]
+ self.sts_image, self.sts_label = self.sts_hbox.get_children()
+ self.sts_label.set_label("")
self.sts_butt.connect("clicked", self.switch_learner_to_setts)
- self.exstore_table.attach(self.sts_butt, 8, 9, 13, 14)
+ self.exstore_table.attach(self.sts_butt, 7, 9, 13, 14)
self.sts_alignment = self.sts_butt.get_children()[0]
- self.sts_butt.show()
+ self.sts_butt.show()
+ #disabled by default
+ self.sts_butt.set_sensitive(False)
def finish_learner_coll_callback(self, widget):
""" Callback on flc_butt; uses self._coll_key as semaphore
from Collection.select_exerc_callback. """
- print('in display.finish_learner_coll_callback, _coll_key=', self._coll_key)
- if not(self._coll_key is None):
- self._co.exercise_selected(self._coll_key)
- self.exstore_table.hide()
- self.feedback_table_show()
+ #print('display: finish_learner_coll_callback: btn start auf startseite')
+ self._co.exercise_selected() #self._selected)
+ self.exstore_table.hide()
+ self.exercise_table.show()
+ self.sfb_butt.show()
+ self.sfb2_butt.hide()
+ self.info_table.hide()
+ self.feedback_table_show()
def switch_learner_to_setts(self, widget):
""" Callback on sts_butt. asks the Coach if allowed. """
- self._co.switch_to_settings(self._coll_key)
+ #print('display: switch_learner_to_setts: triggered, '+self._coll_key+', ')
+ self._co.switch_to_settings() #-> calls: self.offer_setting(exercise)
+ #self.exercise_table.hide()
self.exstore_table.hide()
-
- def set_curr_exerc(self, exerc):
- """ self._ex is needed for feedback_table etc. """
- self._ex = exerc
-
- def gtk_tree(self):
- """
- Define TreeStore and TreeView
- """
+ self.settings_table.show()
+ self.info_table.hide()
+
+ '''def set_curr_exerc(self, exerc):
+ """ self.current_exercise is needed for feedback_table etc. """
+ if(self.current_exercise == exerc):
+ print('eh schon gleich')
+ self.current_exercise = exerc
+ '''
+ def gtk_tree(self, data):
+ # treeView scroll container
+ self.tree_scrolled_window = gtk.ScrolledWindow()
+ self.tree_scrolled_window.set_policy(gtk.POLICY_NEVER,
+ gtk.POLICY_ALWAYS)
+
+ """ Define TreeStore and TreeView """
self.treestore = gtk.TreeStore(gtk.gdk.Pixbuf, str)
-
self.treestore.clear()
- #self._exstore.fill_store(self.treestore, None, None)
-
+
+ #fill the TreeStore with data from Collection
+ self.fill_store(self.treestore, None, data)
self.treeview = gtk.TreeView(self.treestore)
- # create the TreeViewColumn to display the data
- self.tvcolumn = gtk.TreeViewColumn('Uebungssammlung')
+ #create the TreeViewColumn to display the data
+ self.tvcolumn = gtk.TreeViewColumn('Exercises')
self.cellpb = gtk.CellRendererPixbuf()
self.tvcolumn.pack_start(self.cellpb, True)
self.tvcolumn.add_attribute(self.cellpb, 'pixbuf', 0)
- # create a CellRendererText to render the data
+ #create a CellRendererText to render the data
self.cell = gtk.CellRendererText()
- # add the cell to the tvcolumn and allow it to expand
+ #add the cell to the tvcolumn and allow it to expand
self.tvcolumn.pack_start(self.cell, True)
- # set the cell "text" attribute to column 0 - retrieve text
- # from that column in treestore
+ #set the cell "text" attribute to column 0 - retrieve text
+ #from that column in treestore
self.tvcolumn.add_attribute(self.cell, 'text', 1)
- # add tvcolumn to treeview
+ #add tvcolumn to treeview
self.treeview.append_column(self.tvcolumn)
- # make it searchable
+ #make it searchable
self.treeview.set_search_column(0)
- # Allow sorting on the column
+ #Allow sorting on the column
self.tvcolumn.set_sort_column_id(-1)
- # ab hier teil von robert
- self.treeview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
- self.TARGETS,
- gtk.gdk.ACTION_MOVE)
- self.treeview.enable_model_drag_dest(self.TARGETS,
- gtk.gdk.ACTION_MOVE)
- self.treeview.connect("drag_data_get", self.drag_data_get_data)
- self.treeview.connect("drag_data_received",
- self.drag_data_received_data)
+ #Callback for selection
+ self.treeselection = self.treeview.get_selection()
+ self.treeselection.connect("changed", self.treeselection_callback)
+
+ if(self._drag_and_drop == True):
+ #Drag and Drop callbacks
+ #TODO: fix bug when dropping Collection into itself -> don't
+ # allow dropping into itself!
+ self.treeview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK,
+ self.TARGETS,
+ gtk.gdk.ACTION_MOVE)
+ self.treeview.enable_model_drag_dest(self.TARGETS,
+ gtk.gdk.ACTION_MOVE)
+ self.treeview.connect("drag_data_get", self.drag_data_get_data)
+ self.treeview.connect("drag_data_received",
+ self.drag_data_received_data)
+
self.treeview.expand_all()
+ def fill_store(self, ts, parent, list):
+ """ Fill the TreeStore with data """
+ #add data from file
+ if list == None:
+ print "Can't open list! - Reason: ", list
+
+ for i in range(len(list)):
+ if isinstance(list[i], Collection):
+ olditer = ts.append(parent, [gtk.gdk.pixbuf_new_from_file("./img/collection.png"), list[i].get_title()])
+ c_list = list[i].get_data()
+ self.fill_store(ts, olditer, c_list)
+ else:
+ text = list[i].get_title() # + ": " + list[i].get_description()
+ iter = ts.append(parent, [gtk.gdk.pixbuf_new_from_file("./img/exercise.png"), text])
+
def drag_data_get_data(self, treeview, context,
selection, target_id, etime):
- # selection erfassen und pixbuf in string umwandeln
+ """ Handles the drag of an item. The left-mouse has been klicked.
+ Stores position in self._from. """
+ # get iter pointing on selected item in tree
treeselection = treeview.get_selection()
model, iter = treeselection.get_selected()
-
- # Tupel der die Drag Position angibt
- path = self.treestore.get_path(iter)
-
- print "Tree-Element: ", model.get_value(iter, 1)
- print "Drag-Position: ", path
- self.__from = path
-
- iconstr = (model.get_value(iter, 0)).get_pixels()
-
- title = model.get_value(iter, 1)
- sep = "*"
- data = iconstr + sep + title
- selection.set(selection.target, 8, data)
+ # tupel that shows the drag-position
+ self._from = self.treestore.get_path(iter)
return
-
def drag_data_received_data(self, treeview, context, x, y,
selection, info, etime):
- treeselection = treeview.get_selection()
- model, from_parent = treeselection.get_selected()
- model = treeview.get_model()
- sep = "*"
- data = selection.data
- # aus pixel-string wieder pixbuf objekt erstellen
- iconpixtemp, sep, title = data.partition(sep)
- iconpix = gtk.gdk.pixbuf_new_from_data(
- iconpixtemp, gtk.gdk.COLORSPACE_RGB, True, 8, 10, 10, 40)
- data = [iconpix, title]
-
- c = Collection(None,None,None,None)
- obj = c.get_object(self.__from)
- #obj = self.get_object(self.__from)
-
+ """ Handles the drop of an item """
+ obj = self._coll.get_object(self._from)
+ # get the drop information - tupel containing another tupel with drop
+ # position and a pointer containing information on drop (before, into,
+ # after - an item)
drop_info = treeview.get_dest_row_at_pos(x, y)
+ self._to = None
+ self._to_spec = None
if drop_info:
- self.__to = drop_info[0]
+ self._to = drop_info[0]
+ self._to_spec = drop_info[1]
- c.insert_object(obj, self.__to)
- #self.insert_object(obj, self.__to)
+ self._coll.insert_object(obj, self._to, self._to_spec)
self.treestore.clear()
- self.fill_store(self.treestore, None, None)
+ self._root = self._coll.get_data_from_pickle()
+ list = self._root.get_data()
+ self.fill_store(self.treestore, None, list)
self.treeview.expand_all()
if context.action == gtk.gdk.ACTION_MOVE:
context.finish(True, True, etime)
return
+ def treeselection_callback(self, treeselection):
+ """ sets _from to the current selected item """
+ if(treeselection.get_mode() == gtk.SELECTION_SINGLE):
+ model, iter = treeselection.get_selected()
+ self._selected = self.treestore.get_path(iter)
+ #get selected object from coach
+ obj = self._co.get_selected_object(self._selected)
+ if isinstance(obj, Collection):
+ self.show_selection_properties(obj)
+ self.flc_butt.set_sensitive(False)
+ self.sts_butt.set_sensitive(False)
+ else:
+ self.show_selection_properties(obj)
+ self.flc_butt.set_sensitive(True)
+ self.sts_butt.set_sensitive(True)
+ return
diff --git a/ReckonPrimer.activity/exercises/__init__.py b/ReckonPrimer.activity/exercises/__init__.py
index 34239d3..9f198b1 100644
--- a/ReckonPrimer.activity/exercises/__init__.py
+++ b/ReckonPrimer.activity/exercises/__init__.py
@@ -3,7 +3,7 @@
from exercise import Exercise
-""" TODO naming convention for 'topic' (aka exercise name) """
+""" TODO naming convention for 'topic' """
Exercise.EXERCISES = { 'addsub_simp': "ExAddSimp", \
'exaddsub': "ExAddSub", \
diff --git a/ReckonPrimer.activity/exercises/exaddsimp.py b/ReckonPrimer.activity/exercises/exaddsimp.py
index 9219a75..af939eb 100755..100644
--- a/ReckonPrimer.activity/exercises/exaddsimp.py
+++ b/ReckonPrimer.activity/exercises/exaddsimp.py
@@ -101,12 +101,12 @@ class ExAddSimp(Exercise):
self._display.settings_table.attach(self.label_to, 1, 2, 1, 2 )
self.label_to.show()
- self.toggle_max = gtk.ToggleButton(str(self._display._sett['MAX']))
- self.toggle_label = self.toggle_max.get_child()
- self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
- self.toggle_max.connect("toggled", self.toggle_max_callback)
- self._display.settings_table.attach(self.toggle_max, 2, 3, 1, 2)
- self.toggle_max.show()
+# self.toggle_max = gtk.ToggleButton(str(self._display._sett['MAX']))
+# self.toggle_label = self.toggle_max.get_child()
+# self.toggle_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+# self.toggle_max.connect("toggled", self.toggle_max_callback)
+# self._display.settings_table.attach(self.toggle_max, 2, 3, 1, 2)
+# self.toggle_max.show()
self.toggle_shuffle = gtk.ToggleButton("@")
self.toggle_label = self.toggle_shuffle.get_child()
@@ -537,6 +537,5 @@ class ExAddSimp(Exercise):
def _display_generated_calcs(self, change):
print("DEBUG: in exaddsubsimp._display_generated_calcs()")
self._display.protocol_generated_calcs(self._generate_calcs(), change)
-
#END LPCHANGE
diff --git a/ReckonPrimer.activity/exercises/exercise.py b/ReckonPrimer.activity/exercises/exercise.py
index 37b8f5d..cbb216a 100755..100644
--- a/ReckonPrimer.activity/exercises/exercise.py
+++ b/ReckonPrimer.activity/exercises/exercise.py
@@ -3,34 +3,24 @@ from functions import contain, collect_digits, make_line, make_input
from functions import make_line_remainder, make_input_remainder
class Exercise:
-
- EXERCISES = {}
-
- _intermediate_repetitions = 0
- _intermediate_count = 0
- _delayed_repetitions = 0
- _delayed_count = 0
+ EXERCISES = {}
- _error_list = []
- _current_calc = None
- _eval = {}
-
"""This is the base class for the individual exercises.
- An exercise is characterized by a topic. A topic determines the
+ An exercise is characterized by a topic. A topic determines the
fields of the settings self._sett and public methods of Exercise.
The values of self._sett may vary between exercises within 1 topic.
"""
def __init__(self):
""" An Exercise stores data on evaluation, i.e date, duration TODO.
The preliminary format deals with errors only and is
- [(None, errors), (settings, errors)], where None indicates,
+ [(None, errors), (settings, errors)], where None indicates,
that the settings are not changed by the Learner,
and settings indicates updates done by the Learner.
The list allows to append the current errors to the previous ones,
and even to do an Exercise subsequently several times;
thus the most recent errors are at the end of the list. """
- #self._eval = {} this statement does nothing
+ self._eval = []
""" The settings determine the generation of calculations.
The fields of the settings are determined by self._sett['topic'];
the values of the settings are different for different Exercises.
@@ -43,7 +33,7 @@ class Exercise:
def get_setting(self):
return self._sett
-
+
def update_setting(self, sett):
""" Update the settings and generate calculations accordingly. """
self._sett = sett
@@ -58,46 +48,13 @@ class Exercise:
def get_next_calc(self):
""" Get the next calculation from the Exercise.
TODO.WN091123: handle exception after last exercise. """
- if self.count() == 0 and self._delayed_count > 0:
- self._delayed_count = self._delayed_count - 1
- self._calcs.extend(self._error_list)
- self._error_list = []
- self._current_calc = (self._calcs).pop()
- return self._current_calc
-
+ return (self._calcs).pop()
+
def count(self):
""" Return the number of calculations generated by
the current settings """
return len(self._calcs)
- def handle_calculation_error(self):
- if self._intermediate_count == self._intermediate_repetitions:
- self._error_list.insert(0, self._current_calc)
- try: self._eval[str(self._sett)].append(self._current_calc)
- except Exception: self._eval[str(self._sett)] = self._current_calc
- if self._intermediate_count > 0:
- self._intermediate_count = self._intermediate_count - 1
- self._calcs.append(self._current_calc)
- else:
- self._intermediate_count = self._intermediate_repetitions
-
- def reset_evaluation_data(self):
- self._eval = {}
-
- def get_evaluation_data(self):
- return self._eval
-
- def set_num_intermediate_repetitions(self, num_repetitions):
- self._intermediate_repetitions = num_repetitions
- self._intermediate_count = num_repetitions
-
-
- def set_num_delayed_repetitions(self, num_repetitions):
- self._delayed_repetitions = num_repetitions
- self._delayed_count = num_repetitions
-
- #END CHANGE
-
#===== methods of subclasses different for topic-specific settings
def format(self, calc):
""" Prepare the representation of a calculation for Display.
@@ -108,6 +65,8 @@ class Exercise:
def _generate_calcs(self):
""" Generate calculations according to topic-specific settings.
Called on each call of update_setting"""
+
+ # please have a look at self.get_calcs()
pass
def define_buttons(self):
@@ -119,17 +78,19 @@ class Exercise:
# def butt_callback(self, widget)
# if widget.get_active():
# self._display._sett['+'] = True
- """
+ To be overwritte by the internal exercise method """
pass
def set_buttons(self, sett):
- """ Display buttons according to the current setting sett. """
+ """ Display buttons according to the current setting sett.
+ To be overwritte by the internal exercise method """
pass
#===== methods is used by more than one subclass
def format_addsub_simp(self, (calc, linepos)):
""" Prepare the representation of a calculation for Display
on 1 line. Used within several subclasses. """
+ #TODO: this method is currently only used by expassten (not working) and should be removed at this postion???
#@print('in Display.format_addsub_simp: calc=', (calc, linepos))#@
_ccs = collect_digits(calc)
#print('in Exercise.format_addsub_simp: _ccs=',_ccs )
@@ -139,13 +100,3 @@ class Exercise:
return ([_l0], _ip)
#return ([[' ', '1', '0', ' ', '-', ' ', '7', ' ', '=', ' ', '_', ' ']], [(0, 10, '3', ' 10 - 7 = _ ', ' 10 - 7 = 3 ', [' ', '1', '0', ' ', '-', ' ', '7', ' ', '=', ' ', '3', ' '])])
-#BEGIN LPCHANGE
-
- def get_settings_string(self):
- """
- This method returns the settings of the exercise as string.
- \return The settings-string.
- """
- return str(self._sett)
-
-#END LPCHANGE
diff --git a/ReckonPrimer.activity/exercises/expassten.py b/ReckonPrimer.activity/exercises/expassten.py
index 6bac2f3..f5a9b8f 100755..100644
--- a/ReckonPrimer.activity/exercises/expassten.py
+++ b/ReckonPrimer.activity/exercises/expassten.py
@@ -259,10 +259,10 @@ class ExPassTen(Exercise):
self._display.settings_table.attach(self.label3, 2, 3, 11, 12 )
self.label3.show()
- self.label6 = gtk.Label(self._display._sett['MAX'])
- self.label6.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label6, 5, 6, 1, 2 )
- self.label6.show()
+# self.label6 = gtk.Label(self._display._sett['MAX'])
+# self.label6.modify_font(pango.FontDescription("sans 12"))
+# self._display.settings_table.attach(self.label6, 5, 6, 1, 2 )
+# self.label6.show()
#self.label7 = gtk.Label(self._display._sess._gen.count((self._display._key, self._display._sett)))
#self.label7.modify_font(pango.FontDescription("sans 12"))
diff --git a/ReckonPrimer.activity/exercises/extimesdiv.py b/ReckonPrimer.activity/exercises/extimesdiv.py
index d1fe8a0..36c7d3e 100755..100644
--- a/ReckonPrimer.activity/exercises/extimesdiv.py
+++ b/ReckonPrimer.activity/exercises/extimesdiv.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# (c) Martin Neppel 2009
+''' signs like: #################### are new, not really tested parts'''
+
import gtk
import pygtk
import pango
@@ -16,28 +18,35 @@ class ExTimesDiv(Exercise):
self._display = dis
self._sett = sett
self._errors = errors
-# {'topic' : 'times_div',
-# 'title' : 'template extimesdiv',
-# 'descript': 'multiplication, division and "in" \
-# from 2 to 19 and 20 to 190. ',
-# 'icon' : None, # for quick reference of the exercise
-# 'calclines' : 1, # no. of lines for calc to be input.
-# 'MAX' : 100, # maximum of calcs generated;
-# # TODO: Generate fills up by varying input.
-# 'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
-# '*' : True, # eg. 7 . 2 =_
-# '*commute' : True, # commute the operands 2 . 7 = _
-# ':' : False, # 14 : 2 = _
-# 'in' : False, # 2 in 14 = _
-# 'remainder' : False, # : | in ... with remainder
-# 'min' : 2, # +: minimum number in right *operand
-# # -: minimum result
-# 'max' : 2, # +: maximum number in right *operand
+
+#copy from settings.py
+#self._default_times_div = \
+# {'topic' : 'times_div', #for programmers only
+# 'title' : 'template extimesdiv',
+# 'descript': 'multiplication, division and "in" \
+# from 2 to 19 and 20 to 190. ',
+# 'icon' : None, # for quick reference of the exercise
+# 'calclines' : 1, # no. of lines for calc to be input.
+# 'MAX' : 50, # maximum of calcs generated;
+# # TODO: Generate fills up by varying input.
+# 'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
+# '*' : True, # eg. 7 . 2 =_
+# '*commute' : False, # commute the operands 2 . 7 = _
+# ':' : False, # 14 : 2 = _
+# 'in' : True, # 2 in 14 = _
+# 'remainder' : True, # : | in ... with remainder
+# 'vadd' : 0, # 0 or 10, for 1.11 ... 1.19
+# 'vmult' : 1, # 1 or 10, for 1.10 ... 1.90
+# 'min' : 2, # +: minimum number in right *operand
+# # -: minimum result
+# 'max' : 2, # +: maximum number in right *operand
# # -: maximum result
-# 'shuffle_all' : False, # shuffle all calcs
-# 'shuffle_inner': True, # shuffle only 1st (inner) iteration
-# 'cut-max' : True # cut set of all calcs down to MAX
+# 'factors' : [1,2,3,4,5], # Liste mit ausgewählten zahlen zur berechnung
+# 'shuffle_all' : False, # shuffle all calcs
+# 'shuffle_inner': False, # shuffle only 1st (inner) iteration
+# 'cut-max' : True # cut set of all calcs down to MAX
# }
+
self._calcs = self._generate_calcs()
def format(self, (calc, linepos)):
@@ -59,20 +68,26 @@ class ExTimesDiv(Exercise):
def _generate_calcs(self):
"""generate all calculations between min..max given in dict"""
- #print('in Generate.times_div, (min, max)=',(_dic['min'], _dic['max'], _dic['remainder']))
+ #print('in Generate.times_div, (min, max)=',(_dic['min'], _dic['max'],
+ # _dic['remainder']))
_dic = self._sett
#print('in Generate.times_div, _dic=', _dic)
_calcs = []
if _dic['*']:
- _calcs.extend(self.tim_div(_dic['min'], _dic['max'], '*', _dic['shuffle_inner'], _dic['remainder']))
+ _calcs.extend(self.tim_div(_dic['factors'], '*',
+_dic['shuffle_inner'], _dic['remainder'], _dic['vadd'], _dic['vmult']))
if _dic['*commute']:
- _calcs.extend(self.tim_div(_dic['min'], _dic['max'], '*commute', _dic['shuffle_inner'], _dic['remainder']))
+ _calcs.extend(self.tim_div(_dic['factors'], '*commute',
+_dic['shuffle_inner'], _dic['remainder'], _dic['vadd'], _dic['vmult']))
if _dic[':']:
- _calcs.extend(self.tim_div(_dic['min'], _dic['max'], ':', _dic['shuffle_inner'], _dic['remainder']))
+ _calcs.extend(self.tim_div(_dic['factors'], ':',
+_dic['shuffle_inner'], _dic['remainder'], _dic['vadd'], _dic['vmult']))
if _dic['in']:
- _calcs.extend(self.tim_div(_dic['min'], _dic['max'], 'in', _dic['shuffle_inner'], _dic['remainder']))
+ _calcs.extend(self.tim_div(_dic['factors'], 'in',
+_dic['shuffle_inner'], _dic['remainder'], _dic['vadd'], _dic['vmult']))
if _dic['shuffle_all']:
random.shuffle(_calcs)
+ _calcs = _calcs[:_dic['MAX']]
return _calcs
# def count(self):
@@ -83,198 +98,258 @@ class ExTimesDiv(Exercise):
"""buttons for this setting, which is specific for TimesDiv"""
self.label = gtk.Label("2")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 0, 1, 13, 14 )
+ self._display.settings_table.attach(self.label, 0, 1, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("in")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 1, 2, 13, 14 )
+ self._display.settings_table.attach(self.label, 1, 2, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("2")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 2, 3, 13, 14 )
+ self._display.settings_table.attach(self.label, 2, 3, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("=")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 3, 4, 13, 14 )
+ self._display.settings_table.attach(self.label, 3, 4, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("1")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 4, 5, 13, 14 )
+ self._display.settings_table.attach(self.label, 4, 5, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("|")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 5, 6, 13, 14 )
+ self._display.settings_table.attach(self.label, 5, 6, 12, 13 )
self.label.show()
-
+
self._display.settings_table.resize(15, 8)
-
+
self.label = gtk.Label("0")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 6, 7, 13, 14 )
+ self._display.settings_table.attach(self.label, 6, 7, 12, 13 )
self.label.show()
-
+
self.label = gtk.Label("2")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 0, 1, 12, 13 )
+ self._display.settings_table.attach(self.label, 0, 1, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label(":")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 1, 2, 12, 13 )
+ self._display.settings_table.attach(self.label, 1, 2, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("2")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 2, 3, 12, 13 )
+ self._display.settings_table.attach(self.label, 2, 3, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("=")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 3, 4, 12, 13 )
+ self._display.settings_table.attach(self.label, 3, 4, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("1")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 4, 5, 12, 13 )
+ self._display.settings_table.attach(self.label, 4, 5, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("|")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 5, 6, 12, 13 )
+ self._display.settings_table.attach(self.label, 5, 6, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("0")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 6, 7, 12, 13 )
+ self._display.settings_table.attach(self.label, 6, 7, 11, 12 )
self.label.show()
-
+
self.label = gtk.Label("1")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 0, 1, 9, 10 )
+ self._display.settings_table.attach(self.label, 0, 1, 8, 9 )
self.label.show()
-
+
self.label = gtk.Label("*")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 1, 2, 9, 10 )
+ self._display.settings_table.attach(self.label, 1, 2, 8, 9 )
self.label.show()
-
+
self.label = gtk.Label("=")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 3, 4, 9, 10 )
+ self._display.settings_table.attach(self.label, 5, 6, 8, 9 )
self.label.show()
-
+
self.label = gtk.Label("2")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 4, 5, 9, 10 )
+ self._display.settings_table.attach(self.label, 6, 7, 8, 9 )
self.label.show()
-
+
self.toggle_shuffle_all = gtk.ToggleButton("@")
self.toggle_shuffle_all_label = self.toggle_shuffle_all.get_child()
- self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+ self.toggle_shuffle_all_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_shuffle_all.connect("toggled", self.toggle_shuffle_all_callback)
- self._display.settings_table.attach(self.toggle_shuffle_all, 2, 3, 11, 12 )
+ self._display.settings_table.attach(self.toggle_shuffle_all, 2, 3, 10, 11 )
self.toggle_shuffle_all.show()
-
+
self.toggle_shuffle_inner = gtk.ToggleButton("@")
self.toggle_shuffle_inner_label = self.toggle_shuffle_inner.get_child()
- self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
- self.toggle_shuffle_inner.connect("toggled", self.toggle_shuffle_inner_callback)
- self._display.settings_table.attach(self.toggle_shuffle_inner, 0, 1, 11, 12 )
+ self.toggle_shuffle_inner_label.modify_font(pango.FontDescription("sans %d"
+% style.zoom(12)))
+ self.toggle_shuffle_inner.connect("toggled",
+self.toggle_shuffle_inner_callback)
+ self._display.settings_table.attach(self.toggle_shuffle_inner, 0, 1, 10, 11 )
self.toggle_shuffle_inner.show()
-
+
self.toggle_remainder = gtk.ToggleButton("V")
self.toggle_remainder_label = self.toggle_remainder.get_child()
- self.toggle_remainder_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+ self.toggle_remainder_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_remainder.connect("toggled", self.toggle_remainder_callback)
- self._display.settings_table.attach(self.toggle_remainder, 5, 7, 11, 12 )
+ self._display.settings_table.attach(self.toggle_remainder, 6, 7, 10, 11 )
self.toggle_remainder.show()
-
+
self.label = gtk.Label("< - >")
self.label.modify_font(pango.FontDescription("sans 12"))
- self._display.settings_table.attach(self.label, 0, 3, 10, 11)
+ self._display.settings_table.attach(self.label, 0, 3, 9, 10)
self.label.show()
-
+
self.toggle_times = gtk.ToggleButton("<")
self.toggle_times_label = self.toggle_times.get_child()
- self.toggle_times_label.modify_font(pango.FontDescription(
- "sans %d" % style.zoom(12)))
+ self.toggle_times_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_times.connect("toggled", self.toggle_times_callback)
- self._display.settings_table.attach(self.toggle_times, 7, 8, 9, 10 )
+ self._display.settings_table.attach(self.toggle_times, 8, 9, 8, 9 )
self.toggle_times.show()
-
+
self.toggle_commute = gtk.ToggleButton("<")
self.toggle_commute_label = self.toggle_commute.get_child()
- self.toggle_commute_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+ self.toggle_commute_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_commute.connect("toggled", self.toggle_commute_callback)
- self._display.settings_table.attach(self.toggle_commute, 7, 8, 10, 11 )
+ self._display.settings_table.attach(self.toggle_commute, 8, 9, 9, 10 )
self.toggle_commute.show()
-
+
self.toggle_div = gtk.ToggleButton("<")
self.toggle_div_label = self.toggle_div.get_child()
- self.toggle_div_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+ self.toggle_div_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_div.connect("toggled", self.toggle_div_callback)
- self._display.settings_table.attach(self.toggle_div, 7, 8, 12, 13 )
+ self._display.settings_table.attach(self.toggle_div, 8, 9, 11, 12 )
self.toggle_div.show()
-
+
self.toggle_in = gtk.ToggleButton("<")
self.toggle_in_label = self.toggle_in.get_child()
- self.toggle_in_label.modify_font(pango.FontDescription("sans %d" % style.zoom(12)))
+ self.toggle_in_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
self.toggle_in.connect("toggled", self.toggle_in_callback)
- self._display.settings_table.attach(self.toggle_in, 7, 8, 13, 14 )
+ self._display.settings_table.attach(self.toggle_in, 8, 9, 12, 13 )
self.toggle_in.show()
-
+
+ self.toggle_vadd = gtk.ToggleButton("1")
+ self.toggle_vadd_label = self.toggle_vadd.get_child()
+ self.toggle_vadd_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
+ self.toggle_vadd.connect("toggled", self.toggle_vadd_callback)
+ self._display.settings_table.attach(self.toggle_vadd, 2, 3, 0, 9 )
+ self.toggle_vadd.show()
+
+ self.toggle_vmult = gtk.ToggleButton("0")
+ self.toggle_vmult_label = self.toggle_vmult.get_child()
+ self.toggle_vmult_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
+ self.toggle_vmult.connect("toggled", self.toggle_vmult_callback)
+ self._display.settings_table.attach(self.toggle_vmult, 4, 5, 0, 9 )
+ self.toggle_vmult.show()
+
self.number_butts = []
- for i in range(2 ,9 + 1):
+ for i in range(1 ,9 + 1):
self.toggle = gtk.ToggleButton(str(i))
self.toggle_label = self.toggle.get_child()
- self.toggle_label.modify_font(pango.FontDescription(
- "sans %d" % style.zoom(12)))
- self.toggle.connect("toggled", self.toggle_number_callback, i)
- self._display.settings_table.attach(self.toggle, 2, 3, 11-i, 12-i)
+ self.toggle_label.modify_font(pango.FontDescription("sans %d" %
+style.zoom(12)))
+ self.toggle.connect("toggled", self.toggle_number_callback, i)
+ self._display.settings_table.attach(self.toggle, 3, 4, 9-i, 10-i)
self.toggle.show()
self.number_butts.append(self.toggle)
-
+
def set_buttons(self, sett):
"""buttons for setting specific to 'topic' 'times_div'"""
- for i in range(sett['min'],sett['max']+1):
- self.number_butts[i-2].set_active(True)
-
+ print('### in extimesdiv. set_buttons sett=',sett)
+ for i in range(0, 8+1):
+ print('### inaktiv werden:',i)
+ self.number_butts[i].set_active(False)
+
+ print('### vor der aktivierungsschleife:',sett['factors'])
+ #_xxx = [1,2,3] #sett['factors']
+ #print('### in extimesdiv. set_buttons _xxx=',_xxx)
+ #for i in _xxx:
+ for i in sett['factors']:
+ print('### in extimesdiv, i=',i-1)
+ print('### in der schleife sind die factors:', sett['factors'])
+ self.number_butts[i-1].set_active(True)
+ print('### in extimesdiv. set_buttons after set_active(True)')
+ print('### nach der schleife sind die factors:', sett['factors'])
+
+#('### in extimesdiv. set_buttons _xxx=', [1, 2, 3])
+#('### in extimesdiv, i=', 0)
+#Traceback (most recent call last):
+# File "/netshares/staffhomes/wneuper/Activities/ReckonPrimer.activity/extimesdiv.py", line 381, in toggle_number_callback
+# del_ord(self._display._sett['factors'], i)
+# File "/netshares/staffhomes/wneuper/Activities/ReckonPrimer.activity/functions.py", line 367, in del_ord
+# ls.remove(n)
+#ValueError: list.remove(x): x not in list
+#('### in extimesdiv, i=', 1)
+#Traceback (most recent call last):
+# File "/netshares/staffhomes/wneuper/Activities/ReckonPrimer.activity/extimesdiv.py", line 386, in toggle_number_callback
+# ins_ord(self._display._sett['factors'], i)
+#RuntimeError: maximum recursion depth exceeded
+#('### in extimesdiv, i=', 2)
+#Traceback (most recent call last):
+# File "/netshares/staffhomes/wneuper/Activities/ReckonPrimer.activity/extimesdiv.py", line 381, in toggle_number_callback
+# del_ord(self._display._sett['factors'], i)
+# File "/netshares/staffhomes/wneuper/Activities/ReckonPrimer.activity/functions.py", line 367, in del_ord
+# ls.remove(n)
+#ValueError: list.remove(x): x not in list
+#1265902075.138594 WARNING root: No gtk.AccelGroup in the top level window.
+#1265902075.141243 WARNING root: No gtk.AccelGroup in the top level window.
+### in extimesdiv. set_buttons after set_active(True)
+
if (sett['shuffle_all'] == True):
self.toggle_shuffle_all.set_active(True)
else:
self.toggle_shuffle_all.set_active(False)
-
+
if (sett['shuffle_inner'] == True):
self.toggle_shuffle_inner.set_active(True)
else:
self.toggle_shuffle_inner.set_active(False)
-
+
if (sett['*'] == True):
self.toggle_times.set_active(True)
else:
self.toggle_times.set_active(False)
-
+
if (sett['*commute'] == True):
self.toggle_commute.set_active(True)
else:
self.toggle_commute.set_active(False)
-
+
if (sett[':'] == True):
self.toggle_div.set_active(True)
else:
self.toggle_div.set_active(False)
-
+
if (sett['in'] == True):
self.toggle_in.set_active(True)
else:
self.toggle_in.set_active(False)
-
+
if (sett['remainder'] == True):
self.toggle_remainder.set_active(True)
else:
@@ -282,133 +357,174 @@ class ExTimesDiv(Exercise):
#**** callbacks ********************************************************
+ def toggle_vadd_callback(self, widget):
+ if widget.get_active():
+ self._display._sett['vadd'] = 10
+ self.toggle_vadd.set_active(True)
+ self._display._sett['vmult'] = 1
+ self.toggle_vmult.set_active(False)
+ self._display._sett['remainder'] = False ####################
+ self.toggle_remainder.set_active(False) ####################
+ else:
+ self._display._sett['vadd'] = 0
+
+ def toggle_vmult_callback(self, widget):
+ if widget.get_active():
+ self._display._sett['vmult'] = 10
+ self.toggle_vmult.set_active(True)
+ self._display._sett['vadd'] = 0
+ self.toggle_vadd.set_active(False)
+ self._display._sett['remainder'] = False ####################
+ self.toggle_remainder.set_active(False) ####################
+ else:
+ self._display._sett['vmult'] = 1
+
def toggle_shuffle_all_callback(self, widget):
if widget.get_active():
self._display._sett['shuffle_all'] = True
self.toggle_shuffle_inner.set_active(True)
else:
self._display._sett['shuffle_all'] = False
-
+
def toggle_shuffle_inner_callback(self, widget):
if widget.get_active():
self._display._sett['shuffle_inner'] = True
else:
- if(self.toggle_shuffle_all.get_active()):
+ if(self.toggle_shuffle_all.get_active()):
widget.set_active(True)
else:
self._display._sett['shuffle_inner'] = False
-
+
+ def count_active_butts(self):
+ act = 0
+ for butt in self.number_butts:
+ if butt.get_active():
+ act = act + 1
+ return act
+
def toggle_number_callback(self, widget, i):
+ """Callback for the numberbuttons 1..9.
+ Any button can be activated or deactivated,
+ but one button must remain active.
+ REMARK: last button is redrawn from settings (i.e. last stmt)."""
if widget.get_active():
- pass
-# if(i < self._display._sett['min']):
-# self._display._sett['min'] = i
-# self.set_buttons(self._display._sett)
-#
-# elif( i > self._display._sett['max'] ):
-# self._display._sett['max'] = i
-# self.set_buttons(self._display._sett)
+ if(i in self._display._sett['factors']):
+ #print('passed cause i=', i)
+ pass
+ else:
+ #print('number to add=', i)
+ #print('list bevore adding:', self._display._sett['factors'])
+ ins_ord(self._display._sett['factors'], i)
+ #print('list after adding', self._display._sett['factors'])
else:
- if( i == self._display._sett['min'] ):
- if( self._display._sett['min'] == self._display._sett['max'] ):
- widget.set_active(True)
-# else:
-# self._display._sett['min'] = i+1
-# self.set_buttons(self._display._sett)
- elif( i == self._display._sett['max'] ):
- if( self._display._sett['min'] == self._display._sett['max'] ):
- widget.set_active(True)
-# else:
-# self._display._sett['max'] = i-1
+ if(len(self._display._sett['factors']) > 1):
+ #print('number to remove=', i)
+ #print('list bevore removeing:', self._display._sett['factors'])
+ self._display._sett['factors'].remove(i)
+ #print('list after removeing:', self._display._sett['factors'])
+ else: # gtk deactivates button anyway; thus get values from setting
+ #print('list will stay, because list is:', self._display._sett['factors'])
self.set_buttons(self._display._sett)
- else:
- widget.set_active(True)
-
def toggle_times_callback(self, widget):
if widget.get_active():
self._display._sett['*'] = True
+ self._display._sett['remainder'] = False ####################
+ self.toggle_remainder.set_active(False) ####################
else:
- if( self.toggle_commute.get_active() or self.toggle_in.get_active() or self.toggle_div.get_active() ):
+ if( self.toggle_commute.get_active() or
+ self.toggle_in.get_active() or
+ self.toggle_div.get_active() ):
self._display._sett['*'] = False
else:
widget.set_active(True)
-
+
def toggle_commute_callback(self, widget):
if widget.get_active():
self._display._sett['*commute'] = True
else:
- if( self.toggle_times.get_active() or self.toggle_in.get_active() or self.toggle_div.get_active() ):
+ if( self.toggle_times.get_active() or self.toggle_in.get_active() or
+self.toggle_div.get_active() ):
self._display._sett['*commute'] = False
else:
widget.set_active(True)
-
+
def toggle_div_callback(self, widget):
if widget.get_active():
self._display._sett[':'] = True
else:
- if( self.toggle_times.get_active() or self.toggle_in.get_active() or self.toggle_commute.get_active() ):
+ if( self.toggle_times.get_active() or self.toggle_in.get_active() or
+self.toggle_commute.get_active() ):
self._display._sett[':'] = False
else:
widget.set_active(True)
-
+
def toggle_in_callback(self, widget):
if widget.get_active():
self._display._sett['in'] = True
else:
- if( self.toggle_times.get_active() or self.toggle_commute.get_active() or self.toggle_div.get_active() ):
+ if( self.toggle_times.get_active() or self.toggle_commute.get_active()
+or self.toggle_div.get_active() ):
self._display._sett['in'] = False
else:
widget.set_active(True)
-
+
def toggle_remainder_callback(self, widget):
if widget.get_active():
self._display._sett['remainder'] = True
+ self._display._sett['*'] = False ####################
+ self.toggle_times.set_active(False) ####################
+ self._display._sett['vadd'] = 0 ####################
+ self.toggle_vadd.set_active(False) ####################
+ self._display._sett['vmult'] = 1 ####################
+ self.toggle_vmult.set_active(False) ####################
else:
self._display._sett['remainder'] = False
-
+
##### end of public methods ############################################
- def tim_div(self, min, maxx, dic, shuffle_inner, remainder):
+ def tim_div(self, factors, dic, shuffle_inner, remainder, vadd, vmult):
"""generate all multiplications between min..max given for * : in;
to be called such that all *, all : etc are together"""
- _calcs = []
- for _j in range(min, maxx +1):
+ _calcs = []
+
+ for _j in factors:
+ _jj = (_j+vadd)*vmult
if remainder:
for _i in range(0,10*_j +1):
#print('in Generate.tim_div, (j,i,dm)=',(_j, _i),
# divmod(_i, _j))
- _res, _rem = divmod(_i, _j)
+ _res, _rem = divmod(_i, _jj)
if dic == '*': #this should be excluded by settings
- _c = [str(_i),'*',str(_j),'=',to_str_99(_i*_j)]
+ _c = [str(_i),'*',str(_jj),'=',to_str_99(_i*_jj)]
elif dic == '*commute': #this should be excluded ..
- _c = [str(_j),'*',str(_i),'=',to_str_99(_i*_j)]
+ _c = [str(_jj),'*',str(_i),'=',to_str_99(_i*_jj)]
elif dic == ':':
- _c = [to_str_99(_i),':',str(_j),'=',to_str_99(_res),
+ _c = [to_str_99(_i),':',str(_jj),'=',to_str_99(_res),
'|', str(_rem)]
elif dic == 'in':
- _c = [str(_j),'in',to_str_99(_i),'=',to_str_99(_res),
+ _c = [str(_jj),'in',to_str_99(_i),'=',to_str_99(_res),
'|', str(_rem)]
- _c = flatten(_c)
- _c = strip(_c, '#') # to_str_99 returns leading 0 as #
+ _c = flatten(_c)
+ _c = strip(_c, '#') # to_str_99 returns leading 0 as #
_calcs.append((_c, 5))
else:
for _i in range(1,11):
#print('in Generate.tim_div, (j,i)=',(_j, _i))
if dic == '*':
- #_c = [to_str_99(_i),'*',str(_j*10),'=',to_str_99(_i*_j*10)]
- _c = [to_str_99(_i),'*',str(_j),'=',to_str_99(_i*_j)]
+ _c = [to_str_99(_i),'*',str(_jj),'=',to_str_99(_i*_jj)]
elif dic == '*commute':
- _c = [str(_j),'*',to_str_99(_i),'=',to_str_99(_i*_j)]
+ _c = [str(_jj),'*',to_str_99(_i),'=',to_str_99(_i*_jj)]
elif dic == ':':
- _c = [to_str_99(_i*_j),':',str(_j),'=',to_str_99(_i)]
+ _c = [to_str_99(_i*_jj),':',str(_jj),'=',to_str_99(_i)]
elif dic == 'in':
- _c = [str(_j),'in',to_str_99(_i*_j),'=',to_str_99(_i)]
- _c = flatten(_c)
- _c = strip(_c, '#') # to_str_99 returns leading 0 as #
+ _c = [str(_jj),'in',to_str_99(_i*_jj),'=',to_str_99(_i)]
+ _c = flatten(_c)
+ _c = strip(_c, '#') # to_str_99 returns leading 0 as #
_calcs.append((_c, 5))
if shuffle_inner:
random.shuffle(_calcs)
return _calcs
-
+
+
diff --git a/ReckonPrimer.activity/exstore.py b/ReckonPrimer.activity/exstore.py
index 412c9d3..a12a77c 100644
--- a/ReckonPrimer.activity/exstore.py
+++ b/ReckonPrimer.activity/exstore.py
@@ -6,132 +6,179 @@ import pango
import random
import copy
from sugar.graphics import style
-
-from settings import Settings #WN.100112 remove with "treeView-Kollektion"
-from coach import Coach
+#from settings import Settings #WN.100112 remove with "treeView-Kollektion"
+#from coach import Coach
from collection import Collection
from task import Task
-
from exercises.exaddsimp import ExAddSimp
from exercises import *
from exercises.exercise import Exercise
-
class ExStore:
""" Holds all exercises avaiable in RP in a tree and stores them on disk.
The tree ist presented looking like a filebrowser, see Display.treeview.
The Learner starts an Exercise by selecting an item of the tree.
- The Author creates new Exercises copying certain Exercises by
- drag-and-drop and then editing the title, the description and the settings.
-
+ The Author creates new Exercises copying certain Exercises by
+ drag-and-drop andself.imagecollection = gtk.gdk.pixbuf_new_from_file(
+ "./img/collection.png")
+ self.imageexercise = gtk.gdk.pixbuf_new_from_file(
+ "./img/exercise.png") then editing the title, the description and the settings.
+
"""
- _data = None #hold the tree with root of Collection and leafs of Task
+ _root = None #hold the tree with root of Collection and leafs of Task
+
def __init__(self, display, coach):
- self._sett = Settings()
+ self._display = display
+ self._coach = coach
+ self._active_exerc = None
+ #self._sett = Settings()
#Provisorium für die "3-Button-Version" vvvvvvvvvvvvvvvvvvvvvvvvv
- self._data = [(self._sett.get_setting('addsub_simp'), []),
- (self._sett.get_setting('passten'), []),
- (self._sett.get_setting('times_div'), [])]
+ #self._data = [(self._sett.get_setting('addsub_simp'), []),
+ # (self._sett.get_setting('passten'), []),
+ # (self._sett.get_setting('times_div'), [])]
#Provisorium für die "3-Button-Version" ^^^^^^^^^^^^^^^^^^^^^^^^^
#Provisorium für impl. "treeView-Kollektion" vvvvvvvvvvvvvvvvvvvv
- _ex000 = Task({'topic' : 'times_div', #for programmers only
- 'title' : 'template extimesdiv',
- 'descript': 'multiplication, division and "in" \
- from 2 to 19 and 20 to 190. ',
+ _ex010 = Task({'topic' : 'addsub_simp',
+ 'title' : 'template exaddsimp',
+ 'descript': 'addition and subtraction without carry, \
+ i.e. without passing the 10 barrier. ',
'icon' : None, # for quick reference of the exercise
- 'calclines' : 1, # no. of lines for calc to be input.
- 'MAX' : 100, # maximum of calcs generated;
- # TODO: Generate fills up by varying input.
- 'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
- '*' : True, # eg. 7 . 2 =_
- '*commute' : True, # commute the operands 2 . 7 = _
- ':' : False, # 14 : 2 = _
- 'in' : True, # 2 in 14 = _
- 'remainder' : False, # : | in ... with remainder
- 'min' : 2, # +: minimum number in right *operand
- # -: minimum result
- 'max' : 2, # +: maximum number in right *operand
- # -: maximum result
- 'shuffle_all' : False, # shuffle all calcs
- 'shuffle_inner': True, # shuffle only 1st (inner) iteration
- 'cut-max' : True # cut set of all calcs down to MAX
+ 'calclines': 1, # no. of lines for calc to be input.
+ 'MAX' : 30, # maximum of calcs generated.
+ # Generate fills up by varying input.
+ 'MIN' : 20, # minimum of calcs generated UNUSED
+ 'min' : 0, # minimum in size of a number in a calc
+ 'max' : 1, # maximum in size of a number in a calc
+ # 0 <= min <= max <= 10
+ '+' : True, # make all additions min..max
+ '-' : True, # make all subtactions min..max
+ '_+_=_' : True, # = is _right_ from operator, e.g. 1+2=3
+ 'input=' : [1,3,5],# list of positions in calc: 1 | 3 | 5
+ # where input is possible;
+ # actual positions chosen by Generate.
+ '_=_+_' : False, # = is _left_ from operator, e.g. 3=1+2
+ '=input' : [1,3,5],# analogous to '_+_=_'
+ 'shuffle': True, # shuffle _all_ the calcs
+ 'cut-max': True # cut set of all calcs down to MAX
}, [])
- _ex001 = Task({'topic' : 'times_div', #for programmers only
- 'title' : 'template extimesdiv',
- 'descript': 'multiplication, division and "in" \
- from 2 to 19 and 20 to 190. ',
+ _ex011 = Task({'topic' : 'passten',
+ 'title' : 'template expassten',
+ 'descript': 'addition and subtraction with carry, \
+ i.e. with passing the 10 barrier. ',
'icon' : None, # for quick reference of the exercise
- 'calclines' : 1, # no. of lines for calc to be input.
- 'MAX' : 100, # maximum of calcs generated;
+ 'calclines' : 1, # or 2 iff 'newline' : True.
+ 'MAX' : 150, # maximum of calcs generated;
# TODO: Generate fills up by varying input.
'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
- '*' : True, # eg. 7 . 2 =_
- '*commute' : True, # commute the operands 2 . 7 = _
- ':' : False, # 14 : 2 = _
- 'in' : True, # 2 in 14 = _
- 'remainder' : False, # : | in ... with remainder
- 'min' : 3, # +: minimum number in right *operand
- # -: minimum result
- 'max' : 3, # +: maximum number in right *operand
- # -: maximum result
+ '+' :True, # + crossing the ten barrier!!
+ '-' :False, # - goes below the ten barrier!!!
+ # (i.e. iteration on left arg. is "outer" loop)
+ 'min' : 2, # +: minimum in size of number in left argument
+ #'min' : 5, # +: minimum in size of number in left argument
+ # -: minimum in size of result
+ 'max' : 2, # +: maximum in size of number in left argument
+ # -: maximum in size of result
+ #'max' : 9, # +: maximum in size of number in left argument
+ 'input' :[3], # list of positions in calc 3 | 5
+ # where input is possible;
+ # actual positions chosen by Generate.
+ 'newline' : True, # display 2nd line for intermediate results
'shuffle_all' : False, # shuffle all calcs
- 'shuffle_inner': True, # shuffle only 1st (inner) iteration
+ 'shuffle_inner': False, # shuffle only 1st (inner) iteration
'cut-max' : True # cut set of all calcs down to MAX
}, [])
- _coll00 = Collection("einzeln * in",
+ _ex012 = Task({'topic' : 'times_div', #for programmers only
+ 'title' : 'template extimesdiv',
+ 'descript': 'multiplication, division and "in" \
+ from 2 to 19 and 20 to 190. ',
+ 'icon' : None, # for quick reference of the exercise
+ 'calclines' : 1, # no. of lines for calc to be input.
+ 'MAX' : 50, # maximum of calcs generated;
+ # TODO: Generate fills up by varying input.
+ 'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
+ '*' : False, # eg. 7 . 2 =_
+ '*commute' : False, # commute the operands 2 . 7 = _
+ ':' : True, # 14 : 2 = _
+ 'in' : False, # 2 in 14 = _
+ 'remainder' : False, # : | in ... with remainder
+ 'vadd' : 0, # 0 or 10, for 1.11 ... 1.19
+ 'vmult' : 1, # 1 or 10, for 1.10 ... 1.90
+ 'min' : 2, # +: minimum number in right *operand
+ # -: minimum result
+ 'max' : 2, # +: maximum number in right *operand
+ # -: maximum result
+ 'factors' : [2,4], # Liste mit ausgewählten zahlen zur berechnung
+ 'shuffle_all' : False, # shuffle all calcs
+ 'shuffle_inner': False, # shuffle only 1st (inner) iteration
+ 'cut-max' : True # cut set of all calcs down to MAX
+ }, [])
+
+ _coll00 = Collection("Add Sub: + & -",
"hier sind alle 1x1-Reihen mit 'in'",
- None, [_ex000, _ex001])
- _coll0 = Collection("'*' und 'in' Reihen",
+ None, [])
+
+ _coll01 = Collection("Times Division: x & in",
"hier sind alle 1x1-Reihen mit 'in'",
- None, [_coll00])
- _coll0.set_data_in_pickle(_coll0) #WN.100112 remove asap
- #self._data = _coll0
+ None, [_ex010, _ex011, _ex012])
+
+ _coll02 = Collection("Pass Ten: ->10",
+ "hier sind alle 1x1-Reihen mit 'in'",
+ None, [])
+
+ _coll0 = Collection("Templates",
+ "Hier finden Sie alle verfügbaren Templates",
+ None, [_coll00, _coll01, _coll02])
+
+ #constructor of collections root
+ self._root = Collection("root = invisible node",
+ "aber benötigt zum richtigen speichern/lesen",
+ None, [_coll0])
+
+
+ # comment to save changes (order of the items) till the next start
+ self._root.set_data_in_pickle(self._root)
+
#Provisorium für impl. "treeView-Kollektion" ^^^^^^^^^^^^^^^^^^^^
-
- self._display = display
- self._coach = coach
- self._active_exerc = None
- #self.__data = []
- #self.__title = "Collection"
- #self.__description = "Description"
- self.imagecollection = gtk.gdk.pixbuf_new_from_file(
- "./img/collection.png")
- self.imageexercise = gtk.gdk.pixbuf_new_from_file(
- "./img/exercise.png")
- def select(self, key):
- """ Select an exercise by key. return instance of an exercise.
- Errors are retrieved for (future) use by Coach. """
- #WN.LV Code ersetzen: key ist dann fuer Listen von Listen !!
- (_sett, _errors) = self._data[key]
- exercise_label = _sett['topic']
+ def reload(self):
+ self._root = self._root.get_data_from_pickle()
+
+ def offer_coll_to_learner(self):
+ """Show Collection to Learner and hand over control to Display (gtk)"""
+ data = self._root.get_data()
+ self._display.offer_coll_to_learner(data)
+ def get_exercise(self, obj):
+ """ Loads the proper exercise class for the given object and returns it
+ as a new exercise object """
+ exercise_label = obj.get_object_name()
if not Exercise.EXERCISES.has_key(exercise_label):
- raise Exception('Collection#select: Wrong key. To register an exercise see exercises/__init__.py')
-
- klass = Exercise.EXERCISES[exercise_label]
- package = __import__("exercises." + klass.lower())
- module = getattr(package, klass.lower())
- return getattr(module, klass)(self._display, (_sett, _errors))
+ raise Exception('Collection#select: Wrong pos. To register an exercise see exercises/__init__.py')
+ class_name = Exercise.EXERCISES[exercise_label]
+ package = __import__("exercises." + class_name.lower())
+ module = getattr(package, class_name.lower())
+ return getattr(module, class_name)(self._display, (obj.get_settings(), obj.get_eval()))
+ """
#@# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+
def define_coll_gui(self):
- """ Define gui-elements for presenting the collection.
- TODO: define once at startup of RP ?"""
+ #Define gui-elements for presenting the collection.
+ #TODO: define once at startup of RP ?
#WN.LV diesen Code ersetzen: exstore_table.attach(self.colldata,...
self.topic_box = gtk.HBox(True, 0)
#self._display.exstore_table.attach(self.topic_box, 0, 6, 0, 1)
self._display.exstore_table.attach(self.topic_box, 0, 9, 5, 6)
def set_coll_gui(self, coll_data):
- """ Set gui-elements according to Collection.data. """
+ #Set gui-elements according to Collection.data.
#WN.LV diesen Code ersetzen !!!!!
_i = 0
for _t in ['addsub_simp','passten','times_div']:
self.button = gtk.Button()
self.image = gtk.Image()
-
+
if(_t == 'addsub_simp'):
self.image.set_from_file("img/addsub_simp.jpg")
elif(_t == 'passten'):
@@ -146,9 +193,9 @@ class ExStore:
_i = _i + 1
self.topic_box.show()
#@# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
+
def select_exerc_callback(self, widget, coll_key):
- """ Callback telling the item from the collection selected. """
+ #Callback telling the item from the collection selected.
#WN.LV diesen Code ersetzen> statt 1..n fuer Listen kommt coll_key
print('in Collection.select_exerc_callback')
if(self._active_exerc == None):
@@ -164,6 +211,5 @@ class ExStore:
self._active_exerc = coll_key
self._display.switch_exercise() # TODO rename
self._display.set_select_exerc_semaphore(coll_key)
- #self._coach.notify(('exerc-selected', coll_key))
-
-
+ #self._coach.notify(('exerc-selected', coll_key))
+ """
diff --git a/ReckonPrimer.activity/functions.py b/ReckonPrimer.activity/functions.py
index 0c8f646..4743b16 100755..100644
--- a/ReckonPrimer.activity/functions.py
+++ b/ReckonPrimer.activity/functions.py
@@ -225,10 +225,13 @@ def make_input(coll_calc, linepos):
def make_input_remainder(strs, res, rem):
- """make the 2 lines for input result and remainder with ':' and 'in'"""
- #print('in make_input_remainder: len(strs)=', len(strs))
- #print('in make_input_remainder: strs=', strs)
- #print('in make_input_remainder: res=', res, ', rem=', rem)
+ """make the line for input result and remainder with ':' and 'in'.
+ res: , rem:
+ returns:
+ """
+ print('in functions.make_input_remainder: len(strs)=', len(strs))
+ print('in functions.make_input_remainder: strs=', strs)
+ print('in functions.make_input_remainder: res=', res, ', rem=', rem)
_strs = copy.deepcopy(strs)
if len(_strs) == 13: # 9 : 2 = 4|1
_line1 = copy.deepcopy(_strs)
@@ -236,10 +239,11 @@ def make_input_remainder(strs, res, rem):
_line2 = copy.deepcopy(_strs)
_strs[11] = rem[0]
_line3 = copy.deepcopy(_strs)
- #print('in make_input_remainder: line1,2,3=', _line1, _line2, _line3)
+ print('in make_input_remainder: line1,2,3=', _line1, _line2, _line3)
_ins = [(0, 9, res[0], "".join(_line1), "".join(_line2), _line2),\
(0, 11, rem[0], "".join(_line2), "".join(_line3), _line3)]
elif len(_strs) == 14: # 17 : 2 = 8|1
+ print('in functions.make_input_remainder: len(_strs) == 14')
_line1 = copy.deepcopy(_strs)
_strs[10] = res[0]
_line2 = copy.deepcopy(_strs)
@@ -248,8 +252,10 @@ def make_input_remainder(strs, res, rem):
_ins = [(0, 10, res[0], "".join(_line1), "".join(_line2), _line2),\
(0, 12, rem[0], "".join(_line2), "".join(_line3), _line3)]
elif len(_strs) == 15: # 20 : 2 = 10|0
+ print('in functions.make_input_remainder: len(_strs) == 15')
_line1 = copy.deepcopy(_strs)
_strs[10] = res[0]
+ print('', _strs[10])
_line2 = copy.deepcopy(_strs)
_strs[11] = res[1]
_line3 = copy.deepcopy(_strs)
@@ -322,3 +328,43 @@ def flatten(ls):
#['1', '2', '+', '3', '4', '=', '4', '6']
#print(flatten([['2'], 'in', ['2', '0'], '=', ['1', '0'], '|', ['0']]))
#['2', 'in', '2', '0', '=', '1', '0', '|', '0']
+
+
+def ins_ord(ls, n):
+ """Insert n into the ordered list ls. Beware of creating doubles. """
+ pos = 0
+ #print("in functions.ins_ord: ls,n=",ls,n)
+ for i in ls:
+ #print("in functions.ins_ord: i=",i)
+ if n > i:
+ pos = pos + 1
+ #print("in functions.ins_ord: pos=",pos)
+ ls.insert(pos, n)
+ return ls
+
+
+#xx = ins_ord([], 2)
+#print("result=",xx)
+
+#xx = ins_ord([2], 8)
+#print("result=",xx)
+
+#xx = ins_ord([2,8], 4)
+#print("result=",xx)
+
+#xx = ins_ord([2,4,8], 1)
+#print("result=",xx)
+
+#xx = ins_ord([2,4,8], 9)
+#print("result=",xx)
+
+#xx = ins_ord([2,4,8], 4)
+#print("result=",xx)
+
+
+#if (len(xxx) < 2):
+# print('xxx < 2')
+#if (len(xxx) > 2):
+# print('xxx > 2')
+#else:
+# print('xxx = 2')
diff --git a/ReckonPrimer.activity/img/addsub_simp.jpg b/ReckonPrimer.activity/img/addsub_simp.jpg
index c0c9874..c0c9874 100755..100644
--- a/ReckonPrimer.activity/img/addsub_simp.jpg
+++ b/ReckonPrimer.activity/img/addsub_simp.jpg
Binary files differ
diff --git a/ReckonPrimer.activity/img/collection.png b/ReckonPrimer.activity/img/collection.png
index 23a7de8..da69a62 100644
--- a/ReckonPrimer.activity/img/collection.png
+++ b/ReckonPrimer.activity/img/collection.png
Binary files differ
diff --git a/ReckonPrimer.activity/img/exercise.png b/ReckonPrimer.activity/img/exercise.png
index 51c52b7..21e20e2 100644
--- a/ReckonPrimer.activity/img/exercise.png
+++ b/ReckonPrimer.activity/img/exercise.png
Binary files differ
diff --git a/ReckonPrimer.activity/img/passten.jpg b/ReckonPrimer.activity/img/passten.jpg
index d9b8313..d9b8313 100755..100644
--- a/ReckonPrimer.activity/img/passten.jpg
+++ b/ReckonPrimer.activity/img/passten.jpg
Binary files differ
diff --git a/ReckonPrimer.activity/img/times_div.jpg b/ReckonPrimer.activity/img/times_div.jpg
index aa36438..aa36438 100755..100644
--- a/ReckonPrimer.activity/img/times_div.jpg
+++ b/ReckonPrimer.activity/img/times_div.jpg
Binary files differ
diff --git a/ReckonPrimer.activity/learner.py b/ReckonPrimer.activity/learner.py
index 4c12e29..d49ca8b 100644
--- a/ReckonPrimer.activity/learner.py
+++ b/ReckonPrimer.activity/learner.py
@@ -3,39 +3,25 @@
class Learner:
""" All functionality within the learners rights. """
- _learnmode = None
-
def __init__(self, display, coach):
self._display = display
self._coach = coach
- self._learnmode = self._coach.get_learnmode()
self._ex = None
self._curr_in = None
- pass
def run(self):
- """ As long as user does exercises.
- Doing Exercises is terminated by another choice in the menu
- or by the user going bach to the OS.
- """
+ # Initializing the learners tree view: loading exercises
self._coach.request_exercise()
- self._display.init_calc() #TODOWN091101 take Exercise as argument
-
+
def start_calcs(self, exercise):
self._ex = exercise
-
- try: self._ex.set_num_intermediate_repetitions(self._learnmode['intermediate_repetitions'])
- except Exception: self._ex.set_num_intermediate_repetitions(0)
- try: self._ex.set_num_delayed_repetitions(self._learnmode['delayed_repetitions'])
- except Exception: self._ex.set_num_delayed_repetitions(0)
-
- self._display.set_curr_exerc(exercise)
+ #print('start calcs: ') #+str(self._ex.get_setting()[min]))
_calc = self._ex.get_next_calc()
_lines, self._input = exercise.format(_calc)
self._display.display_calc(_lines)
- self._curr_in = self._input.pop() #need _curr_in in notify
+ self._curr_in = self._input.pop()
self._display.create_entryline(self._curr_in)
-
+
def digit_done(self):
(lino, pos, dig, proterr, protok, li) = self._curr_in
self._display.create_entryline((lino, -1, dig, proterr, protok, li))
@@ -55,20 +41,3 @@ class Learner:
except IndexError:
self._display.finish_calc()
- def calculation_error(self):
- self._ex.handle_calculation_error()
- #print('in learner.notify, digit-done: _input=', self._input)
- (lino, pos, dig, proterr, protok, li) = self._curr_in
- self._display.create_entryline((lino, -1, dig, proterr, protok, li))
- self._display.show_progress()
- try: # get_next_calc
- _calc = self._ex.get_next_calc()
- print('in learner.notify: calc=', _calc)
- _lines, self._input = self._ex.format(_calc)
- self._display.display_calc(_lines)
- self._curr_in = self._input.pop() #need _curr_in in notify
- self._display.create_entryline(self._curr_in)
- # create_entryline sets the callback from gtk to Display
- except IndexError:
- self._display.finish_calc()
-
diff --git a/ReckonPrimer.activity/session.py b/ReckonPrimer.activity/session.py
index 83e0d0d..1b05408 100755..100644
--- a/ReckonPrimer.activity/session.py
+++ b/ReckonPrimer.activity/session.py
@@ -11,8 +11,8 @@ class Session:
for stand-alone usage by the ox-user.
?for collaborative sessions see CoSession
"""
- print("in session.py, after class Session")
-
+ #print("in session.py, after class Session")
+
def __init__(self, name, window):
self._name = name
self._dis = Display(window)
@@ -21,7 +21,7 @@ class Session:
self._author = Author()
self._exstore = ExStore(self._dis, self._co)
self._co.register(self, self._dis, self._exstore, self._learner)
- print("in session, before _dis.register")
+ #print("in session, before _dis.register")
self._dis.register(self, self._co, self._learner, self._exstore)
#self._co.create_exercises() #TODO.WN091101 replace by storing Exerc.s
self._calcs = None #pop !
@@ -39,12 +39,6 @@ class Session:
#self._co.request_exercise()
#self._dis.init_calc() #TODOWN091101 take Exercise as argument
- #BEGIN LPCHANGE
- def close(self):
- """ Closes the session"""
- self._dis.write_protocol_to_journal()
- #END LPCHANGE
-
# def notify(self, (msg, data)):
# '''called by the observed objects'''
# #print('in Session.notify: msg=,data=', msg, data)
diff --git a/ReckonPrimer.activity/setup.py b/ReckonPrimer.activity/setup.py
index ec0f64e..ec0f64e 100755..100644
--- a/ReckonPrimer.activity/setup.py
+++ b/ReckonPrimer.activity/setup.py
diff --git a/ReckonPrimer.activity/task.py b/ReckonPrimer.activity/task.py
index 740f81b..fb30b3a 100644
--- a/ReckonPrimer.activity/task.py
+++ b/ReckonPrimer.activity/task.py
@@ -9,10 +9,13 @@ description: test class "task" to test our new idea for saving all tasks
class Task:
""" The leaf-type of the ExStore._data. The root and the non-leaf nodes
are of type Collection.
- """
+ """
_sett = None
_eval = None
+ def get_data(self):
+ return self
+
def __init__(self, sett, eval):
self._sett = sett
self._eval = eval
@@ -29,8 +32,20 @@ class Task:
def set_description(self, description):
self._sett['descript'] = description
- def getSettings(self):
+ def get_settings(self):
return self._sett
- def setSettings(self, settings):
+ def set_settings(self, settings):
self._sett = settings
+
+ def get_eval(self):
+ return self._eval
+
+ def set_eval(self, eval):
+ self._eval = eval
+
+ def get_object_name(self):
+ return self._sett['topic']
+
+
+
diff --git a/ReckonPrimer.activity/timer.py b/ReckonPrimer.activity/timer.py
index 5043452..41ffb41 100755..100644
--- a/ReckonPrimer.activity/timer.py
+++ b/ReckonPrimer.activity/timer.py
@@ -30,7 +30,7 @@ Decorator exists for printing out execution times:
>>> print mult(2, 6)
mult in 1.38282775879e-05 sec
6
-
+
"""
__version__ = '0.3.1'
@@ -40,7 +40,7 @@ class Timer(object):
def __init__(self):
self.__stopped = None
self.__start = self.__time()
-
+
def stop(self):
"""Stops the clock permanently for the instance of the Timer.
Returns the time at which the instance was stopped.
@@ -55,20 +55,24 @@ class Timer(object):
"""
return self.__last_time() - self.__start
elapsed = property(elapsed)
-
+
+ def reset(self):
+ self.__start = time.time()
+ self.__stopped = None
+
def start_time(self):
"""The time at which the Timer instance was created.
"""
return self.__start
start_time = property(start_time)
-
+
def stop_time(self):
- """The time at which stop() was called, or None if stop was
+ """The time at which stop() was called, or None if stop was
never called.
"""
- return self.__stopped
- stop_time = property(stop_time)
-
+ return self.__stopped
+ stop_time = property(stop_time)
+
def __last_time(self):
"""Return the current time or the time at which stop() was call,
if called at all.
@@ -76,12 +80,12 @@ class Timer(object):
if self.__stopped is not None:
return self.__stopped
return self.__time()
-
+
def __time(self):
"""Wrapper for time.time() to allow unit testing.
"""
return time.time()
-
+
def __str__(self):
"""Nicely format the elapsed time
"""