muhh-b commited on
Commit
698e07f
1 Parent(s): d4145ba

Update quiz_generation.py

Browse files
Files changed (1) hide show
  1. quiz_generation.py +1 -38
quiz_generation.py CHANGED
@@ -110,41 +110,6 @@ def generate_quiz_url(prompt_text, form_service):
110
  return form_url
111
  '''
112
 
113
- def explain_quiz_answers(questions_list):
114
- explanations = []
115
-
116
- for question in questions_list:
117
- context = question["question"]
118
- choices = question["choices"]
119
- correct_answer = question["correct_answer"]
120
-
121
- explanation = f"Question: {context}\n"
122
-
123
- for choice in choices:
124
- # Construct a query with each choice as a question
125
- query = f"What is the reason for choosing '{choice}' in {context}?"
126
-
127
- # Tokenize the query and context
128
- inputs = tokenizer.encode_plus(query, context, return_tensors="pt", truncation=True, padding="max_length", max_length=512)
129
-
130
- # Generate the explanation using the T5 model
131
- outputs = model.generate(input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"], max_length=256)
132
-
133
- # Decode the explanation
134
- explanation_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
135
-
136
- # Add the explanation to the overall explanation
137
- explanation += f"\nChoice: {choice}\nExplanation: {explanation_text}"
138
-
139
- # Add an indicator if the choice is the correct answer
140
- if choice == correct_answer:
141
- explanation += " (Correct Answer)"
142
-
143
- explanation += "\n"
144
-
145
- explanations.append(explanation)
146
-
147
- return explanations
148
 
149
 
150
  def generate_quiz_url(prompt_text, form_service):
@@ -220,8 +185,6 @@ def generate_quiz_url(prompt_text, form_service):
220
  # Construct the quiz link using the form ID
221
  form_url = result["responderUri"]
222
 
223
- # Get the explanations for the quiz
224
- explanations = explain_quiz_answers(questions_list)
225
 
226
- return form_url, explanations
227
 
 
110
  return form_url
111
  '''
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
 
115
  def generate_quiz_url(prompt_text, form_service):
 
185
  # Construct the quiz link using the form ID
186
  form_url = result["responderUri"]
187
 
 
 
188
 
189
+ return form_url
190