From 878468fe34c65fc02959e267bc66f81718366662 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Thu, 11 Feb 2021 18:47:34 +0800 Subject: app/main.py: choose an article only when articleID is None. --- app/main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'app/main.py') diff --git a/app/main.py b/app/main.py index 3556d83..2bd903a 100644 --- a/app/main.py +++ b/app/main.py @@ -94,14 +94,15 @@ def get_today_article(user_word_list, articleID): user_level = user_difficulty_level(d_user, d3) # more consideration as user's behaviour is dynamic. Time factor should be considered. random.shuffle(result) # shuffle list d = random.choice(result) - text_level = text_difficulty_level(d['text'], d3) - for reading in result: - text_level = text_difficulty_level(reading['text'], d3) - #print('TEXT_LEVEL %4.2f' % (text_level)) - if within_range(text_level, user_level, 0.1): - d = reading - break - + if articleID == None: + text_level = text_difficulty_level(d['text'], d3) + for reading in result: + text_level = text_difficulty_level(reading['text'], d3) + #print('TEXT_LEVEL %4.2f' % (text_level)) + if within_range(text_level, user_level, 0.1): + d = reading + break + s = '

According to your word list, your level is %4.2f and we have chosen an article with a difficulty level of %4.2f for you.

' % (user_level, text_level) s += '

%s

' % (d['date']) s += '

%s

' % (d['text']) -- cgit v1.2.1