# -*- 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 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'... 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) #WN091215 self._dis.offer_setting(self._ex) self._learner.notify(('start-calcs', self._ex))