def start_section(learn): result = learn.SetListeningResponseInformation('0', '0') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('started section ' + learn.SectionID + ' successfully') else: library.fail('started section ' + learn.SectionID + ' failed') exit() return status
def update_unit(learn): result = learn.SetListeningUnitLearnStaus('1') status = result['SetListeningUnitLearnStausResult'] if status == '1': library.success('update unit learn status success: unit ' + learn.UnitID) else: library.fail('update unit learn status fail: unit ' + learn.UnitID) exit() return status
def login(learn): result = learn.LoginListening() status = result['LoginListeningResult'] if status == '1': library.warning('user ' + learn.username + ' need activation') exit() elif status != '2': library.fail('user ' + learn.username + ' login failed: ' + result['ReturnMessage']) exit() else: library.success('user ' + learn.username + ' login successfully') return status
def end_section(learn, score): result = learn.SetListeningResponseInformation("%.1f" % score, '1') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('ended section ' + learn.SectionID + ' successfully: score ' + "%.1f" % score) else: library.fail('ended section ' + learn.SectionID + ' failed') # Retry login status = login(learn) # Retry set response result = learn.SetListeningResponseInformation("%.1f" % score, '1') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('ended section ' + learn.SectionID + ' successfully: score ' + "%.1f" % score) else: library.fail('ended section ' + learn.SectionID + ' failed twice') exit() return status
def active(learn, SerialNumber, LicenseNumber, ActivationCode): result = learn.LoginListening() status = result['LoginListeningResult'] if status == '2': library.warning('user ' + learn.username + ' have been actived') return '1' elif status != '1': if result['ReturnMessage'].find('Activation') == -1: library.fail('user ' + learn.username + ' login failed: ' + result['ReturnMessage']) exit() result = learn.SetListeningUserActiveInfo(SerialNumber, LicenseNumber, ActivationCode) status = result['SetListeningUserActiveInfoResult'] if status == '1': library.success('user ' + learn.username + ' active successfully') else: library.fail('user ' + learn.username + ' active failed: ' + result['ReturnMessage']) exit() return status
if args.activation == False: status = login(learn) # Get Progress status = get_progress(learn) if status == '1': fetch = library.fetch(learn.level, learn.SectionID) if fetch['next']['unit'] != learn.UnitID: update_unit(learn, fetch) learn.UnitID = fetch['next']['unit'] learn.SectionID = fetch['next']['section'] # Learn English while True: learn.GetServerTime() library.success('learning english: unit ' + learn.UnitID + ', section ' + learn.SectionID) library.timer(random.randint(var['min-time'], var['max-time'])) library.success('finished learning: unit ' + learn.UnitID + ', section ' + learn.SectionID) fetch = library.fetch(learn.level, learn.SectionID) if fetch['problem'] == 0: score = 0 else: # Get int in next two var min_problem = var['min-mark'] * fetch['problem'] / 100 + 1 max_problem = var['max-mark'] * fetch['problem'] / 100 if min_problem > max_problem: min_problem = max_problem score = random.randint(min_problem, max_problem) * 100.0 / fetch['problem']