Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/coach.py
blob: ceae232586275abd67e9bb5d96f96245081d40cf (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
# -*- coding: utf-8 -*-

import os
import pprint
import pickle
from display import Display

class Coach:
    """ The coach supervises the selection of exercises. """
    print('in coach, class definition')

    def __init__(self):
        #print("in coach.__init__")
        self._ex = None # the learner can change the settings of _this_ exerc

    def register(self, sess, dis, collect, learner):
        self._sess = sess
        self._dis = dis
        self._collect = collect
        self._learner = learner
#        print('in coach.register, exaddsimp =', self._collect.select(0))
#        print('in coach.register, exaddsimp._display =', self._collect.select(0)._display)
#        print('in coach.register, expassten =', self._collect.select(1))
#        print('in coach.register, extimesdiv=', self._collect.select(2))
#        print('in coach.register, =')
#        print('in coach.register, =')
#        print('in coach.register, =')

    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 notify(self, (msg, data)):
        """called by the observed objects"""
        print("in coach.notify: msg=, data=", (msg, data))
        if msg == 'setting-done':      # from display
            self._ex.update_setting(data)
            self._learner.notify(('start-calcs', self._ex))
        elif msg == 'exerc-selected':  # from collection
            self._ex = self._collect.select(data)
            print('in coach.notify(exerc-selected), _sett=',self._ex._sett)
            self._learner.notify(('start-calcs', self._ex))
        elif msg == 'switch-to-setts':  # from display
            self._ex = self._collect.select(data)
            self._dis.offer_setting(self._ex)
        else:
            raise Error()