diff --git a/poc_hugo.py b/poc_hugo.py index 4dc2cc3..d89302c 100644 --- a/poc_hugo.py +++ b/poc_hugo.py @@ -9,18 +9,57 @@ from collections import Counter from rich.console import Console from rich.markdown import Markdown -def _create_dictionnary(): + +# Open the CSV file and create a dictionary with all the questions +def _create_dictionary(): with open(path) as file: reader = csv.DictReader(file) data = list(reader) + return data - question = random.choice(data) - return question + +# Count the number of questions and generate a list of IDs +def _count_questions(dictionary): + questions_id = [0] + questions_counter = 0 + for questions in dictionary: + questions_counter += 1 + questions_id.append(questions_counter) + questions_id.pop() + return questions_id + + +def _get_question(dictionary, questions_id): + questions_numbers = questions_id + + print(questions_numbers) + + +def _print_question(question_asked): + os.system("clear") + c = Console() + actual_question = "# {}".format(question_asked["QUESTION"]) + actual_question = Markdown(actual_question) + c.print(actual_question) + answers = [] + for i in question_asked.keys(): + if i.isnumeric(): + answers.append(question_asked[i]) + answer = "" + for i in answers: + answer += "1. {} \n".format(i) + answer = Markdown(answer) + c.print(answer) + +def _test_question(question_asked) if __name__ == "__main__": path = "./data/list_book1.csv" - _create_dictionnary() - print(get_random_question()) + dictionary = _create_dictionary() + questions_id = _count_questions(dictionary) + random.shuffle(dictionary) + for question in dictionary: + _print_question(question) + result = _test_question(question) - - print() \ No newline at end of file + #_get_question(dictionary, questions_id) \ No newline at end of file