ENCOA-311
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from .handle_exception import handle_exception
|
||||
from .logger import suppress_loggers
|
||||
from .pick_difficulty import pick_difficulty
|
||||
|
||||
__all__ = [
|
||||
"handle_exception",
|
||||
"suppress_loggers"
|
||||
"suppress_loggers",
|
||||
"pick_difficulty"
|
||||
]
|
||||
|
||||
14
ielts_be/utils/pick_difficulty.py
Normal file
14
ielts_be/utils/pick_difficulty.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import random
|
||||
from typing import Optional, List
|
||||
|
||||
from ielts_be.configs.constants import EducationalContent
|
||||
|
||||
|
||||
def pick_difficulty(difficulty: Optional[str], difficulties: Optional[List[str]]) -> str:
|
||||
if difficulty:
|
||||
return difficulty
|
||||
|
||||
if difficulties:
|
||||
return random.choice(difficulties)
|
||||
|
||||
return random.choice(EducationalContent.DIFFICULTIES)
|
||||
Reference in New Issue
Block a user