Spaces:
Sleeping
Sleeping
Update quiz_generator.py
Browse files- quiz_generator.py +2 -35
quiz_generator.py
CHANGED
@@ -2,6 +2,7 @@ import aiohttp
|
|
2 |
import asyncio
|
3 |
import json
|
4 |
import logging
|
|
|
5 |
from typing import List, Dict, Any
|
6 |
from fallback_questions import FallbackQuestions
|
7 |
|
@@ -139,38 +140,4 @@ A) [alternativ 1]
|
|
139 |
B) [alternativ 2]
|
140 |
C) [alternativ 3]
|
141 |
D) [alternativ 4]
|
142 |
-
KORREKT: [A, B, C eller D]
|
143 |
-
FORKLARING: [kort forklaring]
|
144 |
-
|
145 |
-
---
|
146 |
-
|
147 |
-
Tema: {request.tema}
|
148 |
-
Type: {request.type}
|
149 |
-
Vanskelighetsgrad: {request.vanskelighetsgrad}/5
|
150 |
-
|
151 |
-
Start generering:"""
|
152 |
-
else:
|
153 |
-
return f"""Generate {request.antall_spørsmål} quiz questions in English about "{request.tema}".
|
154 |
-
|
155 |
-
Format each question exactly like this:
|
156 |
-
QUESTION: [question text]
|
157 |
-
A) [option 1]
|
158 |
-
B) [option 2]
|
159 |
-
C) [option 3]
|
160 |
-
D) [option 4]
|
161 |
-
CORRECT: [A, B, C, or D]
|
162 |
-
EXPLANATION: [brief explanation]
|
163 |
-
|
164 |
-
---
|
165 |
-
|
166 |
-
Topic: {request.tema}
|
167 |
-
Type: {request.type}
|
168 |
-
Difficulty: {request.vanskelighetsgrad}/5
|
169 |
-
|
170 |
-
Start generating:"""
|
171 |
-
|
172 |
-
def _parse_quiz_response(self, response: str, expected_count: int) -> List[Dict[str, Any]]:
|
173 |
-
"""Parse AI-respons til quiz-spørsmål"""
|
174 |
-
questions = []
|
175 |
-
|
176 |
-
# Spli
|
|
|
2 |
import asyncio
|
3 |
import json
|
4 |
import logging
|
5 |
+
import re
|
6 |
from typing import List, Dict, Any
|
7 |
from fallback_questions import FallbackQuestions
|
8 |
|
|
|
140 |
B) [alternativ 2]
|
141 |
C) [alternativ 3]
|
142 |
D) [alternativ 4]
|
143 |
+
KORREKT: [A, B, C eller D]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|