Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -72,141 +72,6 @@ def start_quiz():
|
|
| 72 |
st.session_state.generated_questions = []
|
| 73 |
logger.info("Quiz started")
|
| 74 |
|
| 75 |
-
# def generate_similar_question(wrong_q, misconception_id, generator):
|
| 76 |
-
# """์ ์ฌ ๋ฌธ์ ์์ฑ"""
|
| 77 |
-
# if not isinstance(wrong_q, dict):
|
| 78 |
-
# logger.error(f"Invalid wrong_q type: {type(wrong_q)}")
|
| 79 |
-
# st.error("์ ์ฌ ๋ฌธ์ ์์ฑ์ ํ์ํ ๋ฐ์ดํฐ ํ์์ด ์๋ชป๋์์ต๋๋ค.")
|
| 80 |
-
# return None
|
| 81 |
-
|
| 82 |
-
# try:
|
| 83 |
-
# generated_q, _ = generator.generate_similar_question_with_text(
|
| 84 |
-
# construct_name=wrong_q['ConstructName'],
|
| 85 |
-
# subject_name=wrong_q['SubjectName'],
|
| 86 |
-
# question_text=wrong_q['QuestionText'],
|
| 87 |
-
# correct_answer_text=wrong_q[f'Answer{wrong_q["CorrectAnswer"]}Text'],
|
| 88 |
-
# wrong_answer_text=wrong_q[f'Answer{st.session_state.selected_wrong_answer}Text'],
|
| 89 |
-
# misconception_id=misconception_id
|
| 90 |
-
# )
|
| 91 |
-
|
| 92 |
-
# if generated_q:
|
| 93 |
-
# return {
|
| 94 |
-
# 'question': generated_q.question,
|
| 95 |
-
# 'choices': generated_q.choices,
|
| 96 |
-
# 'correct': generated_q.correct_answer,
|
| 97 |
-
# 'explanation': generated_q.explanation
|
| 98 |
-
# }
|
| 99 |
-
# except Exception as e:
|
| 100 |
-
# logger.error(f"Error generating similar question: {e}")
|
| 101 |
-
# st.error(f"๋ฌธ์ ์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.")
|
| 102 |
-
# return None
|
| 103 |
-
|
| 104 |
-
# def generate_similar_question(wrong_q, misconception_id, generator):
|
| 105 |
-
# """์ ์ฌ ๋ฌธ์ ์์ฑ"""
|
| 106 |
-
# # ์
๋ ฅ ๋ฐ์ดํฐ ํ์ธ
|
| 107 |
-
# logger.info(f"Generating similar question for misconception_id: {misconception_id}")
|
| 108 |
-
# logger.info(f"Wrong question data type: {type(wrong_q)}")
|
| 109 |
-
# logger.info(f"Wrong question data: {wrong_q}")
|
| 110 |
-
|
| 111 |
-
# # wrong_q๊ฐ ๋์
๋๋ฆฌ๊ฐ ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
|
| 112 |
-
# if not isinstance(wrong_q, dict):
|
| 113 |
-
# logger.error(f"Invalid wrong_q type: {type(wrong_q)}")
|
| 114 |
-
# st.error("์ ์ฌ ๋ฌธ์ ์์ฑ์ ํ์ํ ๋ฐ์ดํฐ ํ์์ด ์๋ชป๋์์ต๋๋ค.")
|
| 115 |
-
# return None
|
| 116 |
-
|
| 117 |
-
# # misconception_id NaN ์ฒดํฌ
|
| 118 |
-
# if pd.isna(misconception_id):
|
| 119 |
-
# logger.warning("misconception_id ๊ฐ์ด NaN์
๋๋ค. ๊ธฐ๋ณธ ๋ฌธ์ ๋ฅผ ๋ฐํํฉ๋๋ค.")
|
| 120 |
-
# return {
|
| 121 |
-
# 'question': f"[์ ์ฌ ๋ฌธ์ ] {wrong_q.get('QuestionText', '๋ฌธ์ ๊ฐ ์ ๊ณต๋์ง ์์์ต๋๋ค.')}",
|
| 122 |
-
# 'choices': {
|
| 123 |
-
# 'A': "๋ณด๊ธฐ A",
|
| 124 |
-
# 'B': "๋ณด๊ธฐ B",
|
| 125 |
-
# 'C': "๋ณด๊ธฐ C",
|
| 126 |
-
# 'D': "๋ณด๊ธฐ D"
|
| 127 |
-
# },
|
| 128 |
-
# 'correct': 'A',
|
| 129 |
-
# 'explanation': "Misconception ID๊ฐ ์ ๊ณต๋์ง ์์ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฅผ ๋ฐํํฉ๋๋ค."
|
| 130 |
-
# }
|
| 131 |
-
|
| 132 |
-
# try:
|
| 133 |
-
# # ์ ์ฌ ๋ฌธ์ ์์ฑ
|
| 134 |
-
# #logger.info(f"At least I'm in")
|
| 135 |
-
|
| 136 |
-
# #logger.info(f"Type of wrong_q: {type(wrong_q)}")
|
| 137 |
-
# #logger.info(f"Content of wrong_q: {wrong_q}")
|
| 138 |
-
# #logger.info(f"Type of misconception_id: {type(misconception_id)}")
|
| 139 |
-
# #logger.info(f"Value of misconception_id: {misconception_id}")
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
# # input ์ ๋ฆฌ
|
| 143 |
-
# construct_name=wrong_q['ConstructName'],
|
| 144 |
-
# subject_name=wrong_q['SubjectName'],
|
| 145 |
-
# question_text=wrong_q['QuestionText'],
|
| 146 |
-
# correct_answer_text=wrong_q[f'Answer{wrong_q["CorrectAnswer"]}Text'],
|
| 147 |
-
# wrong_answer_text=wrong_q[f'Answer{st.session_state.selected_wrong_answer}Text'],
|
| 148 |
-
# misconception_id=int(misconception_id)
|
| 149 |
-
# #logger.info(f"Input Arguments: construct_name={construct_name}, subject_name={subject_name}, question_text={question_text}, correct_answer_text={correct_answer_text}, wrong_answer_text={wrong_answer_text}, misconception_id={misconception_id}")
|
| 150 |
-
|
| 151 |
-
# construct_name = construct_name[0] if isinstance(construct_name, tuple) else construct_name
|
| 152 |
-
# subject_name = subject_name[0] if isinstance(subject_name, tuple) else subject_name
|
| 153 |
-
# question_text = question_text[0] if isinstance(question_text, tuple) else question_text
|
| 154 |
-
# correct_answer_text = correct_answer_text[0] if isinstance(correct_answer_text, tuple) else correct_answer_text
|
| 155 |
-
# wrong_answer_text = wrong_answer_text[0] if isinstance(wrong_answer_text, tuple) else wrong_answer_text
|
| 156 |
-
# #logger.info(f"construct_name={construct_name}, Type={type(construct_name)}, subject_name={subject_name}, Type={type(subject_name)}")
|
| 157 |
-
# #logger.info(f"question_text={question_text}, Type={type(question_text)}, correct_answer_text={correct_answer_text}, Type={type(correct_answer_text)}")
|
| 158 |
-
# #logger.info(f"wrong_answer_text={wrong_answer_text}, Type={type(wrong_answer_text)}")
|
| 159 |
-
# print("Debugging log block reached")
|
| 160 |
-
|
| 161 |
-
# #logger.info(f"Cleaned Input Arguments: construct_name={construct_name}, subject_name={subject_name}, question_text={question_text}, correct_answer_text={correct_answer_text}, wrong_answer_text={wrong_answer_text}, misconception_id={misconception_id}")
|
| 162 |
-
# #logger.debug(f"Cleaned arguments: {construct_name}, {subject_name}, {question_text}, {correct_answer_text}, {wrong_answer_text}, {misconception_id}")
|
| 163 |
-
|
| 164 |
-
# # generated_q, _ = generator.generate_similar_question_with_text(
|
| 165 |
-
# # construct_name=wrong_q['ConstructName'],
|
| 166 |
-
# # subject_name=wrong_q['SubjectName'],
|
| 167 |
-
# # question_text=wrong_q['QuestionText'],
|
| 168 |
-
# # correct_answer_text=wrong_q[f'Answer{wrong_q["CorrectAnswer"]}Text'],
|
| 169 |
-
# # wrong_answer_text=wrong_q[f'Answer{st.session_state.selected_wrong_answer}Text'],
|
| 170 |
-
# # misconception_id=int(misconception_id)
|
| 171 |
-
# # )
|
| 172 |
-
# logger.info(f"Inputs: construct_name={construct_name}, subject_name={subject_name}, question_text={question_text}, correct_answer_text={correct_answer_text}, wrong_answer_text={wrong_answer_text}, misconception_id={misconception_id}")
|
| 173 |
-
|
| 174 |
-
# generated_q, _ = generator.generate_similar_question_with_text(
|
| 175 |
-
# construct_name,
|
| 176 |
-
# subject_name,
|
| 177 |
-
# question_text,
|
| 178 |
-
# correct_answer_text,
|
| 179 |
-
# wrong_answer_text,
|
| 180 |
-
# misconception_id
|
| 181 |
-
# )
|
| 182 |
-
# logger.info(f"Generated question type: {type(generated_q)}")
|
| 183 |
-
|
| 184 |
-
# if generated_q:
|
| 185 |
-
# logger.info(f"At least there is something generated")
|
| 186 |
-
# return {
|
| 187 |
-
# 'question': generated_q.question,
|
| 188 |
-
# 'choices': generated_q.choices,
|
| 189 |
-
# 'correct': generated_q.correct_answer,
|
| 190 |
-
# 'explanation': generated_q.explanation
|
| 191 |
-
# }
|
| 192 |
-
# except Exception as e:
|
| 193 |
-
# # ๋๋ฒ๊น
์ ์ํ ์์ธ ์ค๋ฅ ์ถ๋ ฅ
|
| 194 |
-
# logger.error(f"Error generating similar question: {e}")
|
| 195 |
-
# st.error(f"๋ฌธ์ ์์ฑ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. {e}")
|
| 196 |
-
# return None
|
| 197 |
-
|
| 198 |
-
# # ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐํ
|
| 199 |
-
# return {
|
| 200 |
-
# 'question': f"[์ ์ฌ ๋ฌธ์ ] {wrong_q.get('QuestionText', '๋ฌธ์ ๊ฐ ์ ๊ณต๋์ง ์์์ต๋๋ค.')}",
|
| 201 |
-
# 'choices': {
|
| 202 |
-
# 'A': "์๋ก์ด ๋ณด๊ธฐ A",
|
| 203 |
-
# 'B': "์๋ก์ด ๋ณด๊ธฐ B",
|
| 204 |
-
# 'C': "์๋ก์ด ๋ณด๊ธฐ C",
|
| 205 |
-
# 'D': "์๋ก์ด ๋ณด๊ธฐ D"
|
| 206 |
-
# },
|
| 207 |
-
# 'correct': 'A',
|
| 208 |
-
# 'explanation': f"์ด ๋ฌธ์ ๋ Misconception ID {misconception_id}์ ๊ด๋ จ๋์ด ์์ต๋๋ค."
|
| 209 |
-
# }
|
| 210 |
|
| 211 |
def generate_similar_question(wrong_q, misconception_id, generator):
|
| 212 |
"""์ ์ฌ ๋ฌธ์ ์์ฑ"""
|
|
|
|
| 72 |
st.session_state.generated_questions = []
|
| 73 |
logger.info("Quiz started")
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
def generate_similar_question(wrong_q, misconception_id, generator):
|
| 77 |
"""์ ์ฌ ๋ฌธ์ ์์ฑ"""
|