Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/settings.py
blob: b91e92735de175ba3f05bdffd60ec0ab43e2946b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# -*- coding: utf-8 -*-
# (c) Patrick Loder 2009

import pickle
import os
class Settings:
    """ A setting is a dictionary, the settings are a dict of dicts. """
    print('in settings, class definition')

    def __init__(self):
        #print("in settings.__init__")
        #+ and - between min and max, max <= 10
        self._default_addsub_simp = \
        {'topic'  : 'addsub_simp', #for programmers only
         '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'    : 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
        }

        self._default_passten = \
        {'topic'        : 'passten', #for programmers only
         '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,      # 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,   # + 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': False,   # shuffle only 1st (inner) iteration
         'cut-max'      : True   # cut set of all calcs down to MAX
        }

        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'          : 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
                                  # -: 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
        }
        #!!!extend here with additional topic!!!
                          
        self._setts = {'addsub_simp' : self._default_addsub_simp,
                       'passten'     : self._default_passten,
                       'times_div'   : self._default_times_div
                       #!!!extend here with additional topic!!!
        }

    def get_setting(self, key):
        #print("in settings.get_setting, key=" + key)
        return self._setts[key]
    
#    def load_last_sett(self, key):
#        _dict = None
#        _path = 'coach/'
#        _path_name = _path + 'LAST_' + key + '.data'
#        print('in Setting.load_last_sett: _path_name=', _path_name)
#        if os.path.exists(_path_name):
#            _addr = open(_path_name, 'rb')
#            _dict =  pickle.load(_addr)
#            _addr.close()
#        return _dict
#                
#    def save_last_sett(self, key, sett):
#        print('in Settings.save_last_sett')
#        _path = 'coach/'
#        _path_name = _path + 'LAST_' + key + '.data'
#        print('in Setting.save_last_sett: _path_name=', _path_name)
#        _addr = open(_path_name, 'wb')
#        pickle.dump(sett, _addr)
#        _addr.close()
#
#    def load_setting(self, key):
#        """a variant of this will be used for authoring"""
#        dat_name = 'C:/rpa8/coach/latest-topic.txt'
#        if os.path.exists(dat_name):
#            txt_file = open(dat_name, 'rb')
#            if key == 'default_addsub_simp':
#                self._default_addsub_simp = pickle.load(txt_file)
#            elif key == 'default_passten':
#                self._default_passten = pickle.load(txt_file)
#                
#    def save_setting(self, key):
#        """a variant of this will be used for authoring"""
#        dat_name = 'C:/rpa8/coach/latest-topic.txt'
#        txt_file = open(dat_name, 'wb')
#        if key == 'default_addsub_simp':
#            pickle.dump(self._default_addsub_simp, txt_file)
#        elif key == 'default_passten':
#            pickle.dump(self._default_passten, txt_file)