refactor writing of q and a into separate method
This commit is contained in:
parent
ccced3a981
commit
fe37165a23
@ -3,6 +3,14 @@
|
||||
multiple-choice-quiz-csv-to-marp-markdown-slides-converter
|
||||
|
||||
|
||||
csv needs to have the following format
|
||||
````
|
||||
Kategorie 1: Zitate ( Wer hat's gesagt?),,,,
|
||||
(1) Probleme sind nur Dorninge Chancen,Jan Böhmermann,Christian Lindner,Elon Musk,Pable Escobar
|
||||
````
|
||||
Strings surrounded with quotation marks
|
||||
|
||||
|
||||
docker run --rm --init -v $PWD:/home/marp/app/ -e LANG=$LANG marpteam/marp-cli slide-deck.md --pdf
|
||||
|
||||
Script to run:
|
||||
|
35
converter.py
35
converter.py
@ -52,23 +52,27 @@ def write_markdown_file(csv_path):
|
||||
# markdown_file.writelines(static_part)
|
||||
for q_and_a in list_of_q_and_as:
|
||||
print(q_and_a)
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines('# {}'.format(q_and_a.question))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines(' - {}'.format(q_and_a.answerArray[0]))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines(' - {}'.format(q_and_a.answerArray[1]))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines(' - {}'.format(q_and_a.answerArray[2]))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines(' - {}'.format(q_and_a.answerArray[3]))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines('---')
|
||||
write_q_and_a_to_markdown_file(markdown_file, q_and_a)
|
||||
|
||||
markdown_file.close()
|
||||
# return filename
|
||||
|
||||
|
||||
def write_q_and_a_to_markdown_file(markdown_file, q_and_a):
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines('# {}'.format(q_and_a.category))
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines('## {}'.format(q_and_a.question))
|
||||
|
||||
# for i, obj in q_and_a.answerArray:
|
||||
for i, obj in enumerate(q_and_a.answerArray):
|
||||
markdown_file.writelines('\n')
|
||||
markdown_file.writelines(' - {}'.format(q_and_a.answerArray[i]))
|
||||
|
||||
markdown_file.writelines('---')
|
||||
return markdown_file
|
||||
|
||||
|
||||
def handle_q_and_a_row(line, list_of_q_and_as, category):
|
||||
column_data = line.split(',')
|
||||
print(column_data)
|
||||
@ -81,4 +85,9 @@ def handle_q_and_a_row(line, list_of_q_and_as, category):
|
||||
q_and_a = QuestionAndAnswers(question, answers, category)
|
||||
list_of_q_and_as.append(q_and_a)
|
||||
print(q_and_a)
|
||||
return list_of_q_and_as
|
||||
return list_of_q_and_as
|
||||
|
||||
|
||||
# def to_pdf(filename):
|
||||
# import docker
|
||||
# client = docker.from_env()
|
||||
|
Loading…
x
Reference in New Issue
Block a user