Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalther Neuper <neuper@neuper.(none)>2010-01-12 15:45:43 (GMT)
committer Walther Neuper <neuper@neuper.(none)>2010-01-12 15:45:43 (GMT)
commit47fc436d53c96ca1978c424deaf7fc91d8fb0f4b (patch)
tree560a39f29611ef99ca8b42e1ca54c4843df46f77
parent0adfc88056214a70f019b5ae63a9cb2fba94ecf7 (diff)
exstore --> pickle, exstore_table old
-rw-r--r--ReckonPrimer.activity/collection.py208
-rwxr-xr-xReckonPrimer.activity/display.py2
-rw-r--r--ReckonPrimer.activity/exstore.py172
-rw-r--r--ReckonPrimer.activity/task.py32
4 files changed, 179 insertions, 235 deletions
diff --git a/ReckonPrimer.activity/collection.py b/ReckonPrimer.activity/collection.py
index a90d82d..b94ca3a 100644
--- a/ReckonPrimer.activity/collection.py
+++ b/ReckonPrimer.activity/collection.py
@@ -9,115 +9,115 @@ import gtk
import pickle
import os
-class CollectionTest:
-# __data = None
-# __title = None
-# __description = None
- #__pic = None
- def __init__(self):
- self.__data = []
- self.__title = "Collection"
- self.__description = "Description"
- #self.__pic = gtk.gdk.pixbuf_new_from_file("collection.png")
+class Collection:
+ __data = None
+ __title = None
+ __description = None
+ __pic = None
- '''
- def __init__(self, title, description, pic):
+ 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
+ def getPic(self):
+ return self.__pic
+
+ def setPic(self, pic):
+ self.__pic = pic
'''
-# 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
-# def getPic(self):
-# return self.__pic
-#
-# def setPic(self, pic):
-# self.__pic = pic
-# '''
-#
-# def get_data_from_pickle(self):
-# path = os.path.join(os.getcwd(), "data/Collection.data")
-# f = open(path, "rb")
-# root = pickle.load(f)
-# f.close()
-# return root
-#
-# def set_data_in_pickle(self, root):
-# path = os.path.join(os.getcwd(), "data/Collection.data")
-# f = open(path, "wb")
-# pickle.dump(root, f)
-# f.close()
-#
-#
-# def insert_object(self, obj, pos):
-# root = self.get_data_from_pickle()
-# list = root.getData()
-#
-# if (pos == None):
-# list.append(obj) # sonderfall ganz hinten einfügen
-# else:
-# max = len(pos)
-# for i in range(len(pos)):
-# try:
-# if isinstance(list[pos[i]], CollectionTest):
-# list = list[pos[i]].getData()
-# if (i == (max - 1)):
-# list.append(obj)
-# else:
-# list.insert(pos[i], obj)
-# except IndexError:
-# list.append(obj) # wenn in eigener collection verschoben wird, wurde ja element schon gelöscht daher passt index nicht mehr
-#
-# self.set_data_in_pickle(root)
-#
-#
-# def get_object(self, pos):
-# root = self.get_data_from_pickle()
-#
-# list = root.getData()
-#
-# # find object and return it to insert it in collection
-# for i in range(len(pos)):
-# if isinstance(list[pos[i]], CollectionTest):
-# obj = list[pos[i]]
-# list = list[pos[i]].getData()
-# 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]], CollectionTest):
-# 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)
-#
-# self.set_data_in_pickle(root)
-# return obj
+ def insert_object(self, obj, pos):
+ root = self.get_data_from_pickle()
+ list = root.getData()
+
+ if (pos == None):
+ list.append(obj) # sonderfall ganz hinten einfügen
+ 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)):
+ list.append(obj)
+ else:
+ list.insert(pos[i], obj)
+ except IndexError:
+ list.append(obj) # wenn in eigener collection verschoben wird, wurde ja element schon gelöscht daher passt index nicht mehr
+
+ self.set_data_in_pickle(root)
+
+
+ def get_object(self, pos):
+ root = self.get_data_from_pickle()
+
+ list = root.getData()
+
+ # 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()
+ 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)
+
+ self.set_data_in_pickle(root)
+ return obj
+
+ def get_data_from_pickle(self):
+ path = os.path.join(os.getcwd(), "data/Collection.data")
+ f = open(path, "rb")
+ root = pickle.load(f)
+ f.close()
+ return root
+
+ def set_data_in_pickle(self, root):
+ path = os.path.join(os.getcwd(), "data/Collection.data")
+ f = open(path, "wb")
+ pickle.dump(root, f)
+ f.close()
diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py
index 0f9a6d9..05173ed 100755
--- a/ReckonPrimer.activity/display.py
+++ b/ReckonPrimer.activity/display.py
@@ -535,7 +535,7 @@ class Display:
iconpix = gtk.gdk.pixbuf_new_from_data(iconpixtemp, gtk.gdk.COLORSPACE_RGB, True, 8, 10, 10, 40)
data = [iconpix, title]
- c = CollectionTest()
+ c = Collection(None,None,None,None)
obj = c.get_object(self.__from)
#obj = self.get_object(self.__from)
diff --git a/ReckonPrimer.activity/exstore.py b/ReckonPrimer.activity/exstore.py
index 48da7f7..562ce65 100644
--- a/ReckonPrimer.activity/exstore.py
+++ b/ReckonPrimer.activity/exstore.py
@@ -9,6 +9,8 @@ from sugar.graphics import style
from settings import Settings
from coach import Coach
+from collection import Collection
+from task import Task
from exercises.exaddsimp import ExAddSimp
from exercises import *
@@ -24,12 +26,65 @@ class ExStore:
(self._sett.get_setting('passten'), []),
(self._sett.get_setting('times_div'), [])]
#WN.LV [] ist die vorlaeufige Liste der errors ###########
+ _ex000 = 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' : 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
+ }, [])
+ _ex001 = 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' : 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' : 3, # +: minimum number in right *operand
+ # -: minimum result
+ 'max' : 3, # +: 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
+ }, [])
+ _coll00 = Collection("einzeln * in",
+ "hier sind alle 1x1-Reihen mit 'in'",
+ None, [_ex000, _ex001])
+ _coll0 = Collection("'*' und 'in' Reihen",
+ "hier sind alle 1x1-Reihen mit 'in'",
+ None, [_coll00])
+ _coll0.set_data_in_pickle(_coll0)
+
+ #xxxxxxxxxxxxxxxxxxxxxxxx
self._display = display
self._coach = coach
self._active_exerc = None
- self.__data = []
- self.__title = "Collection"
- self.__description = "Description"
+ #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(
@@ -100,115 +155,6 @@ 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))
-
-
- def fill_store(self, ts, parent, list):
- """ Fill treestore with data from disk. """
- #c = CollectionTest()
- root = self.get_data_from_pickle()
-
- if list == None:
- list = root.getData()
-
- for i in range(len(list)):
- if isinstance(list[i], CollectionTest):
- olditer = ts.append(parent, [self.imagecollection, list[i].getTitle()])
- c_list = list[i].getData()
- self.fill_store(ts, olditer, c_list)
- else:
- text = list[i].getTitle() + ": " + list[i].getDescription()
- iter = ts.append(parent, [self.imageexercise, text])
-
- 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
- def getPic(self):
- return self.__pic
-
- def setPic(self, pic):
- self.__pic = pic
- '''
-
- def get_data_from_pickle(self):
- path = os.path.join(os.getcwd(), "data/Collection.data")
- f = open(path, "rb")
- root = pickle.load(f)
- f.close()
- return root
-
- def set_data_in_pickle(self, root):
- path = os.path.join(os.getcwd(), "data/Collection.data")
- f = open(path, "wb")
- pickle.dump(root, f)
- f.close()
-
-
- def insert_object(self, obj, pos):
- root = self.get_data_from_pickle()
- list = root.getData()
-
- if (pos == None):
- list.append(obj) # sonderfall ganz hinten einfügen
- else:
- max = len(pos)
- for i in range(len(pos)):
- try:
- if isinstance(list[pos[i]], CollectionTest):
- list = list[pos[i]].getData()
- if (i == (max - 1)):
- list.append(obj)
- else:
- list.insert(pos[i], obj)
- except IndexError:
- list.append(obj) # wenn in eigener collection verschoben wird, wurde ja element schon gelöscht daher passt index nicht mehr
-
- self.set_data_in_pickle(root)
-
-
- def get_object(self, pos):
- root = self.get_data_from_pickle()
-
- list = root.getData()
-
- # find object and return it to insert it in collection
- for i in range(len(pos)):
- if isinstance(list[pos[i]], CollectionTest):
- obj = list[pos[i]]
- list = list[pos[i]].getData()
- else:
- obj = list[pos[i]]
-
- list = root.getData()
- max = len(pos)
+ #self._coach.notify(('exerc-selected', coll_key))
- # find object and delete it in current collection
- for i in range(len(pos)):
- if isinstance(list[pos[i]], CollectionTest):
- 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)
- self.set_data_in_pickle(root)
- return obj
diff --git a/ReckonPrimer.activity/task.py b/ReckonPrimer.activity/task.py
index ddb64ee..c704be9 100644
--- a/ReckonPrimer.activity/task.py
+++ b/ReckonPrimer.activity/task.py
@@ -5,29 +5,27 @@ description: test class "task" to test our new idea for saving all tasks
'''
class Task:
- __title = None
- __description = None
- __settings = None
+ _sett = None
+ _eval = None
- def __init__(self):
- self.__title = "title"
- self.__description = "description"
- self.__settings = "settings"
+ def __init__(self, sett, eval):
+ self._sett = sett
+ self._eval = eval
- def getTitle(self):
- return self.__title
+ def get_title(self):
+ return self._sett['title']
- def setTitle(self, title):
- self.__title = title
+ def set_title(self, title):
+ self._sett['title'] = title
- def getDescription(self):
- return self.__description
+ def get_description(self):
+ return self._sett['descript']
- def setDescription(self, description):
- self.__description = description
+ def set_description(self, description):
+ self._sett['descript'] = description
def getSettings(self):
- return self.__settings
+ return self._sett
def setSettings(self, settings):
- self.__settings = settings
+ self._sett = settings