# -*- 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()