From 46ddf063cf7247e284bf2f7cc46549f3f902b8b0 Mon Sep 17 00:00:00 2001
From: LM <2609891867@qq.com>
Date: Fri, 10 Jun 2022 21:18:16 +0800
Subject: [PATCH] =?UTF-8?q?[REFACTOR]=20=E5=B0=86Artical.py=E6=96=87?=
 =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E7=9A=84=E5=89=8D=E7=AB=AF=E4=BB=A3=E7=A0=81?=
 =?UTF-8?q?=E5=88=86=E7=A6=BB=E5=87=BA=E6=9D=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 app/Article.py                  | 40 +++++++--------------------------
 app/templates/userpage_get.html | 40 ++++++++++++++++++++++++++++++++-
 app/user_service.py             | 11 +++++++--
 3 files changed, 56 insertions(+), 35 deletions(-)
diff --git a/app/Article.py b/app/Article.py
index 774d25a..7d3aad5 100644
--- a/app/Article.py
+++ b/app/Article.py
@@ -61,22 +61,14 @@ def get_today_article(user_word_list, articleID):
             if within_range(text_level, user_level, (8.0 - user_level) * factor):
                 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 += 'Article added on: %s
' % (d['date'])
-    s += ''
+            
+    article_date = d['date']
     article_title = get_article_title(d['text'])
     article_body = get_article_body(d['text'])
-    s += '
%s
' % (article_title)
-    s += '
%s 
' % (article_body)
-    s += '
%s 
' % (d['source'])
-    s += '
%s 
' % (get_question_part(d['question']))
-    s = s.replace('\n', '
')
-    s += '%s' % (get_answer_part(d['question']))
-    s += '
ANSWER \n'
-    html_code += '%s
\n' % ('\n'.join(result))
-    return html_code
\ No newline at end of file
+    return result
\ No newline at end of file
diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html
index d7cd982..da8a351 100644
--- a/app/templates/userpage_get.html
+++ b/app/templates/userpage_get.html
@@ -31,7 +31,45 @@
      下一篇 Next Article  
     阅读文章并回答问题 
 
-    {{ today_article|safe }}
+
+
+    
+        According to your word list, your level is 
+        {{ user_level }}   
+        and we have chosen an article with a difficulty level of 
+        {{ text_level }}  
+        for you.
+    
+    
Article added on: {{ article_date }}
+    
+    
{{ article_title }}
+    
{{ article_body }} 
+    
+        {% for x in question_part %}
+            {{ x }}
+    
+        {% endfor %}
+     
+    
+    
+    
ANSWER 
+    
+        {% for x in answer_part %}
+            {{ x }}
+    
+        {% endfor %}
+    
+    
+
     /mark", methods=['GET', 'POST'])
 def user_mark_word(username):
     '''