Compare commits
No commits in common. "ec4135035def6c817a323689ac8bd0936b822d42" and "ba9d85def158b593828b2f60337f5ac57bb7cbcf" have entirely different histories.
ec4135035d
...
ba9d85def1
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,3 @@
|
|||||||
.idea
|
|
||||||
csvmarp
|
|
||||||
|
|
||||||
# ---> Python
|
# ---> Python
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
10
README.md
10
README.md
@ -1,11 +1,3 @@
|
|||||||
# csv-to-marp-converter
|
# csv-to-marp-converter
|
||||||
|
|
||||||
multiple-choice-quiz-csv-to-marp-markdown-slides-converter
|
multiple-choice-quiz-csv-to-marp-markdown-slides-converter
|
||||||
|
|
||||||
|
|
||||||
docker run --rm --init -v $PWD:/home/marp/app/ -e LANG=$LANG marpteam/marp-cli slide-deck.md --pdf
|
|
||||||
|
|
||||||
Script to run:
|
|
||||||
1. csv -> marp markdown converter
|
|
||||||
2. md -> pdf conversion using mark cli docker image
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
# from md_tagebuch import __version__
|
|
||||||
import converter
|
|
||||||
|
|
||||||
def get_parser():
|
|
||||||
parser = argparse.ArgumentParser(description='Generate marp markdown slides from csv')
|
|
||||||
# required arg
|
|
||||||
parser.add_argument("inputFile", help="name of the csv file to used as input, e.g. quiz.csv",
|
|
||||||
type=str)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
|
|
||||||
def command_line_runner():
|
|
||||||
parser = get_parser()
|
|
||||||
args = parser.parse_args()
|
|
||||||
converter.write_markdown_file(args.inputFile)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
command_line_runner()
|
|
71
converter.py
71
converter.py
@ -1,71 +0,0 @@
|
|||||||
import calendar
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
# def file_exists(filename):
|
|
||||||
# if os.path.exists(filename):
|
|
||||||
# print('Note: Diary \'' + filename + '\' already exists. Will not be modified.')
|
|
||||||
# return True
|
|
||||||
# return False
|
|
||||||
NUMBER_OF_ANSWERS = 5
|
|
||||||
|
|
||||||
|
|
||||||
class QuestionAndAnswers:
|
|
||||||
def __init__(self, question, answerArray):
|
|
||||||
self.question = question
|
|
||||||
self.answerArray = answerArray
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "QuestionAndAnswers: Question: {}, Answers: {}".format(self.question, self.answerArray)
|
|
||||||
|
|
||||||
|
|
||||||
def write_markdown_file(csv_path):
|
|
||||||
# csv_path = "quiz-example.csv"
|
|
||||||
markdown_path = "slide-deck.md"
|
|
||||||
# read CSV
|
|
||||||
list_of_q_and_as = []
|
|
||||||
|
|
||||||
with open(csv_path, 'r', encoding='UTF-8') as csv_file:
|
|
||||||
data = csv_file.readlines()
|
|
||||||
for line in data:
|
|
||||||
column_data = line.split(',')
|
|
||||||
print(column_data)
|
|
||||||
#check size of array
|
|
||||||
print(len(column_data))
|
|
||||||
if len(column_data) is NUMBER_OF_ANSWERS:
|
|
||||||
question = column_data[0]
|
|
||||||
answers = column_data[1:] # select all elements from list except first
|
|
||||||
# answers = column_data[-3:]
|
|
||||||
q_and_a = QuestionAndAnswers(question, answers)
|
|
||||||
list_of_q_and_as.append(q_and_a)
|
|
||||||
print(q_and_a)
|
|
||||||
# break
|
|
||||||
|
|
||||||
# static_part = ""
|
|
||||||
# copy template
|
|
||||||
template_name = "quiz-slides-template.md"
|
|
||||||
shutil.copyfile(template_name, markdown_path)
|
|
||||||
|
|
||||||
# with open(markdown_path, 'w', encoding='UTF-8') as markdown_file:
|
|
||||||
# append questions and answers to copy of template
|
|
||||||
with open(markdown_path, 'a', encoding='UTF-8') as markdown_file:
|
|
||||||
# write month headline
|
|
||||||
# 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('---')
|
|
||||||
|
|
||||||
markdown_file.close()
|
|
||||||
# return filename
|
|
@ -1,10 +0,0 @@
|
|||||||
(1) Probleme sind nur Dorninge Chancen,Jan Böhmermann,Christian Lindner,Elon Musk,Pable Escobar
|
|
||||||
(2) Niemand hat die Absicht eine Mauer zu errichten,Erich Honecker,Lothar de Maizière,Walter Ulbricht,Donald Trump
|
|
||||||
(3) Auf den Alkohol – den Ursprung und die Lösung sämtlicher Lebensprobleme,Boris Jelzin,Homer Simpson,Prinz Harry,Charlie Sheen
|
|
||||||
"(4) Ich so zu mein homie: ich komme später, ich steck noch im Verkehr Er: mit dem Auto? Ich: nein in 1 bitch. Geschlechtsverkehr!",Moneyboy,Oliver Pocher,Manny Marc,Dieter Bohlen
|
|
||||||
(5) Aus großer Macht folgt große Verantwortung.,Neil Armstrong,Jesus Christus,Chuck Norris,Ben Parker aus Spiderman
|
|
||||||
"(6) Wenn ich über steuer- und erbrechtliche Anerkennung von homosexuellen Paaren diskutiere, dann kann ich gleich über Teufelsanbetung diskutieren.",Rainer Maria Woelki,Papst Benedikt XVI,Friedrich Merz,Edmund Stoiber
|
|
||||||
"(7) Mir hat auch niemand gesagt, wie man Kapitalist wird.",Dagobert Duck,Christian Lindner,Jeff Bezos,Queen Elisabeth II.
|
|
||||||
"(8) Geh dein Weg, leb dein Leben, sei du selbst, Fick deine Mutter",Money Boy,Farid Bang,KIZ (wer von denen?),Immanuel Kant
|
|
||||||
(9) Man muss Gesetze kompliziert machen. Dann fällt es nicht so auf.,Horst Seehofer,Wladimir Putin,Erich Honecker,Boris Johnson
|
|
||||||
"(10) Chef sein ist wie ein Wecker. Keiner will ihn, jeder hasst ihn, aber wenn er nicht da ist, dann machen alle Schnarch.",Paul Ditter,Bernd Stromberg,Markus Stockschläder,Jürgen Klopp
|
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
marp: true
|
|
||||||
theme: gaia
|
|
||||||
# class:
|
|
||||||
# - lead
|
|
||||||
# - invert
|
|
||||||
---
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Styling the Theme:
|
|
||||||
https://github.com/marp-team/marp-core/tree/main/themes -->
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--color-background: #ddd !important;
|
|
||||||
--color-foreground: #333 !important;
|
|
||||||
--color-highlight: #f96 !important;
|
|
||||||
--color-dimmed: #888 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
# Quiz
|
|
||||||
<!-- INSERT NAME OF QUIZ HERE -->
|
|
||||||
|
|
||||||
---
|
|
42
tests.py
42
tests.py
@ -1,42 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
import converter
|
|
||||||
|
|
||||||
class TestDiary(unittest.TestCase):
|
|
||||||
|
|
||||||
# BASE_FODLER = "test_data"
|
|
||||||
|
|
||||||
def test_create_month_file_january(self):
|
|
||||||
# python command_line 2021-01
|
|
||||||
BASE_FODLER = "test_data"
|
|
||||||
converter.write_markdown_file('quiz-example.csv')
|
|
||||||
# assert file was created
|
|
||||||
assert(os.path.exists(os.path.join(BASE_FODLER, "slide-deck.md")))
|
|
||||||
|
|
||||||
# def test_create_month_file_january(self):
|
|
||||||
# # python command_line 2021-01
|
|
||||||
# BASE_FODLER = "test_data"
|
|
||||||
# diary.parse_input('2021-01', BASE_FODLER)
|
|
||||||
# # assert file was created
|
|
||||||
# assert(os.path.exists(os.path.join(BASE_FODLER, "01_2021.md")))
|
|
||||||
|
|
||||||
|
|
||||||
# def setUp(self):
|
|
||||||
# print("test started...")
|
|
||||||
# BASE_FODLER = "test_data"
|
|
||||||
# # bla = os.path.join(BASE_FODLER, "12_2020.md")
|
|
||||||
# if not os.path.exists(BASE_FODLER):
|
|
||||||
# os.makedirs(BASE_FODLER)
|
|
||||||
|
|
||||||
# def tearDown(self):
|
|
||||||
# # pass
|
|
||||||
# BASE_FODLER = "test_data"
|
|
||||||
# if os.path.exists(BASE_FODLER):
|
|
||||||
# shutil.rmtree(BASE_FODLER) # remove testing garbage folder
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
Loading…
x
Reference in New Issue
Block a user