Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
def end_section(learn, score):
    if int(score) == score:
        score_str = "%d" % int(score)
    else:
        score_str = "%.1f" % score
    result = learn.SetReadingResponseInformation(score_str, '1')
    status = result['SetReadingResponseInformationResult']
    if status == '1':
        library.success('ended section ' + learn.SectionID +
                        ' successfully: score ' + score_str)
    else:
        library.fail('ended section ' + learn.SectionID + ' failed')
        # Retry login
        status = login(learn)
        # Retry set response
        result = learn.SetReadingResponseInformation(score_str, '1')
        status = result['SetReadingResponseInformationResult']
        if status == '1':
            library.success('ended section ' + learn.SectionID +
                            ' successfully: score ' + score_str)
        else:
            library.fail('ended section ' + learn.SectionID + ' failed twice')
            exit()
    return status
Beispiel #7
0
if args.activation == False:
    status = login(learn)

# Get Progress
status = get_progress(learn)
if status == '1':
    fetch = library.fetch(var['type'], learn.level, learn.SectionID)
    if fetch['next']['unit'] != learn.UnitID:
        update_unit(learn)
        learn.UnitID = fetch['next']['unit']
        learn.SectionID = fetch['next']['section']

# Learn English
while True:
    learn.GetServerTime()
    library.success('learning ' + var['type'] + ': unit ' + learn.UnitID +
                    ', section ' + learn.SectionID)
    library.timer(random.randint(var['min-time'], var['max-time']))
    library.success('finished ' + var['type'] + ': unit ' + learn.UnitID +
                    ', section ' + learn.SectionID)

    fetch = library.fetch(var['type'], learn.level, learn.SectionID)
    if fetch['problem'] == 0:
        score = 0
    else:
        # Get int in next two var
        min_problem = int(var['min-mark'] * fetch['problem'] / 100) + 1
        max_problem = int(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']